10#include <FairRootManager.h>
14#include <TClonesArray.h>
25 , fLegacyArray(nullptr)
26 , fBranchName(branchname)
33 list<TString>::const_iterator p;
35 Int_t s = fileList.size();
42 for (i = 0; i < s; i++) {
46 if (fileList[i].
size() == 0)
continue;
47 fChains[i] =
new TChain(
"cbmsim");
48 for (p = fileList[i].begin(); p != fileList[i].end(); ++p)
55 for (i = 0; i < s; i++)
63 LOG(error) <<
"AddFriend method should not be called in legacy mode";
66 if (chainNum1 < 0 || chainNum1 >=
static_cast<Int_t
>(
fChains.size()) ||
fChains[chainNum1] ==
nullptr) {
67 LOG(error) <<
"chainNum1=" << chainNum1 <<
" is not a correct chain number.";
70 if (chainNum2 < 0 || chainNum2 >=
static_cast<Int_t
>(
fChains.size()) ||
fChains[chainNum2] ==
nullptr) {
71 LOG(error) <<
"chainNum2=" << chainNum2 <<
" is not a correct chain number.";
80 , fLegacyArray(nullptr)
81 , fBranchName(branchname)
88 FairRootManager* fManager = FairRootManager::Instance();
90 LOG(fatal) <<
"CbmMCDataArray(): Can't find a Root Manager.";
93 fLegacyArray = (TClonesArray*) fManager->GetObject(branchname);
95 LOG(fatal) <<
"CbmMCDataArray(): Can't find " <<
fBranchName <<
" in the system.";
103 if (fileNumber >= 0 || eventNumber >= 0)
104 LOG(debug1) <<
"LegacyGet: Trying to get object with fileNum=" << fileNumber <<
", entryNum=" << eventNumber
105 <<
" in legacy mode.";
106 if (index < 0)
return 0;
115 if (fileNumber < 0 || fileNumber >=
fSize)
return nullptr;
116 if (eventNumber < 0 || eventNumber >=
fN[fileNumber])
return nullptr;
117 if (index < 0)
return nullptr;
120 map<Int_t, TClonesArray*>& arr =
fArrays[fileNumber];
123 if (arr.find(eventNumber) != arr.end())
return arr[eventNumber]->At(index);
126 TChain* ch =
fChains[fileNumber];
127 ch->GetEntry(eventNumber);
129 if (!
fTArr[fileNumber])
return nullptr;
131 arr[eventNumber] = (TClonesArray*) (
fTArr[fileNumber]->Clone());
133 return arr[eventNumber]->At(index);
140 if (fileNumber < 0 || fileNumber >=
fSize)
return -1111;
141 if (eventNumber < 0 || eventNumber >=
fN[fileNumber])
return -1111;
144 map<Int_t, TClonesArray*>& arr =
fArrays[fileNumber];
147 if (arr.find(eventNumber) != arr.end())
return arr[eventNumber]->GetEntriesFast();
150 TChain* ch =
fChains[fileNumber];
151 ch->GetEntry(eventNumber);
153 return (
fTArr[fileNumber]) ?
fTArr[fileNumber]->GetEntriesFast() : -1111;
163 map<Int_t, TClonesArray*>::const_iterator p;
165 for (i = 0; i <
fSize; i++) {
180 for (i = 0; i <
fSize; i++)
ClassImp(CbmConverterManager)
static constexpr size_t size()
Access to a MC data branch for time-based analysis.
TObject * Get(const CbmLink *lnk)
TObject * LegacyGet(Int_t fileNumber, Int_t eventNumber, Int_t index)
std::vector< std::map< Int_t, TClonesArray * > > fArrays
Number of entries in chains.
Int_t fSize
Name of the data branch.
TString fBranchName
Pointer to TClonesArray for legacy mode.
std::vector< TChain * > fChains
Number of input file lists (one per source)
Int_t Size(Int_t fileNumber, Int_t eventNumber)
std::vector< Long64_t > fN
Data arrays from chains (one per input source)
void AddFriend(Int_t chainNum1, Int_t chainNum2)
std::vector< TClonesArray * > fTArr
Arrays of chains (one per input source)
TClonesArray * fLegacyArray
If true, run in legacy mode.