[Halld-offline] [EXTERNAL] Re: GetSingle() issue to get associated object.

Sean Dobbs seandobbs at gmail.com
Wed Aug 13 10:07:28 EDT 2025


For what it's worth, the old-style (non-templated) syntax still works
for me, e.g.:

https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_JeffersonLab_halld-5Frecon_blob_c8e35ce03de7ffdbb7ec529ea62ddaf16e1cd7b8_src_plugins_Utilities_evio-5Fwriter_DEVIOBufferWriter.cc-23L515&d=DwIFaQ&c=CJqEzB1piLOyyvZjb8YUQw&r=Te_hCR4EUlJ6iCDYLJ8Viv2aDOR7D9ZZMoBAvf2H0M4&m=LEPFSRA4MtXZ0Cs3RggZDRNVWJW8vAWzY-UsTdaVvcCOiLCbAnkX1eA32ZQQKnyv&s=9Ru1E3P8OX9KFqQV2kFX_-o-qrLQp0MYu2AnawGvMxs&e= 

           for(auto hitPtr : obj_taghhits) {
                const DTAGHDigiHit* the_digihit = nullptr;
                hitPtr->GetSingle(the_digihit);
                if(the_digihit != nullptr)
                obj_taghdigihits.push_back(the_digihit);
                const DTAGHTDCDigiHit* the_tdcdigihit = nullptr;
                hitPtr->GetSingle(the_tdcdigihit);
                if(the_tdcdigihit != nullptr)
                obj_taghtdcdigihits.push_back(the_tdcdigihit);
         }

On Wed, Aug 13, 2025 at 9:59 AM zihlmann via Halld-offline
<halld-offline at jlab.org> wrote:
>
> issue:
> while looping over DTAGMHit ojects I want to get the associated object DTAGMDigiHit since
> a DTAGMHit object is made as a match between DTAGMDigiHit and DTAGMTDCDigiHit.
> However, when using the GetSingle() method it returns at times NULL. This should
> not be possible.
> Any idea why that can be?
>
> here the code I use:
>   vector <const DTAGMHit*> TagMHits = event->Get<DTAGMHit>();
>   for (unsigned int k=0; k<TagMHits.size(); k++){
>
>     const DTAGMHit *hit = TagMHits[k];
>     const DTAGMDigiHit *dh = hit->GetSingle<DTAGMDigiHit>();
>     if (!dh){
>       //cout<<"Error no associated object DTAGMDigiHit found!" << endl;
>       continue;
>     }
>     tagmAMPmatched->Fill((double)dh->column, (double)dh->pulse_peak);
>     tagmADCtimeMatched->Fill((double)dh->column, (double)dh->pulse_time*0.0625);
>   }
>
> _______________________________________________
> Halld-offline mailing list
> Halld-offline at jlab.org
> https://mailman.jlab.org/mailman/listinfo/halld-offline 


More information about the Halld-offline mailing list