Get a TList from a THashList

Hello experts,

Could someone help to resolve how to read the TList object from a THashList structure?
I try to:

 TDirectory* dir_se_pairing = proData->GetDirectory("analysis-same-event-pairing");
 THashList*  hash_output = (THashList*)dir_se_pairing->FindObject("output");
 TList* pairbarrelSEPM = (TList*)hash_output->FindObject("PairsBarrelSEPM_jpsiO2MCdebugCuts");

And the response:

warning: null passed to a callee that requires a non-null argument [-Wnonnull]
TList* pairbarrelSEPM = (TList*)hash_output->FindObject("PairsBarrelSEPM_jpsiO2MCdebugCuts");

Thanks in advance.

Best
Liuyao

Try the following:

TDirectory* dir_se_pairing = proData->GetDirectory("analysis-same-event-pairing");
THashList*  hash_output = dir_se_pairing->Get<THashList>("output");
if (hash_output == nullptr) {
    cerr << "Could not get the THashList output from the directory\n";
    return;
}
TList* pairbarrelSEPM = (TList*)hash_output->FindObject("PairsBarrelSEPM_jpsiO2MCdebugCuts");

Thanks very much. It works for me perfectly.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.