Dear all,
I cannot seem to figure out how to loop over a TList that contains TTrees.
On
https://root.cern.ch/doc/master/classTList.html
there are five ways provided to loop over a TList, but none seem to help me.
The code I use
TString input_path_hits_FCT = "MyFCTPath";
TFile *inputFCT_hits = new TFile(input_path_hits_FCT, "read");
TTree *hitTreeFCT = (TTree*)inputFCT_hits->Get("o2sim");
TString input_path_hits_FT3 = "MyFT3Path";
TFile *inputFT3_hits = new TFile(input_path_hits_FT3, "read");
TTree *hitTreeFT3 = (TTree*)inputFT3_hits->Get("o2sim");
// Set branch addresses - hits files
std::vector<Hit>* hitFCT = nullptr;
hitTreeFCT->SetBranchAddress("FCTHit", &hitFCT);
Int_t nFCTEvents = hitTreeFCT->GetEntries();
// FT3
std::vector<Hit>* hitFT3 = nullptr;
hitTreeFT3->SetBranchAddress("FCTHit", &hitFT3);
Int_t nFT3Events = hitTreeFT3->GetEntries();
// List for TTrees of detectors hit files
TList *detectorTrees = new TList;
detectorTrees->Add(hitTreeFCT);
detectorTrees->Add(hitTreeFT3);
How do I then loop over this TList?
If I take the first example from the TList documentation page
for(const auto&& obj: *GetListOfPrimitives())
obj->Write();
How does this piece of code understand about which TList we are talking about?
An example of how to loop over a TList would help a lot!
Thanks in advance.
Cas
_Platform: C++