20 if ( !
FillBuffer(fileName, branchName, nEvents, nMerged) )
21 cout <<
"-E- PndMvdEventMerger: Error in filling buffer";
35 if ((
unsigned int)iEvent >
fBuffer.size())
37 cout <<
"-W- CbmMvdPileupManager::GetEvent: Event " << iEvent
38 <<
" not present in buffer! " << endl;
39 cout <<
" Returning NULL pointer! "
44 TClonesArray* pArray = (TClonesArray*)
fBuffer[iEvent];
48 cout <<
"-W CbmMvdPileupManager::GetEvent: Returning NULL pointer!"
64 TClonesArray* pointArray= NULL;
65 TClonesArray* mergedPointsArray = NULL;
68 TFile* bgfile =
new TFile(fileName);
71 cout <<
"-W- CbmMvdPileupManager::FillBuffer: Background file "
72 << fileName <<
" could noy be opened! " << endl;
75 cout <<
"-I- CbmMvdPileupManager::FillBuffer: Opening file " << endl;
76 cout << fileName << endl;
78 TTree* bgtree = (TTree*) bgfile->Get(
"pndsim");
81 cout <<
"-W- CbmMvdPileupManager::FillBuffer: "
82 <<
"Could not find pndsim tree in background file " << endl;
86 Int_t nEventsInFile = bgtree->GetEntries();
87 cout <<
"-I- CbmMvdPileupManager::FillBuffer: " << nEventsInFile
88 <<
" events in file" << endl;
89 Int_t nBuffer =
TMath::Min(nEvents, nEventsInFile);
90 cout <<
"-I- CbmMvdPileupManager::FillBuffer: Buffering " << nBuffer
93 Int_t nMergedBuffer =
TMath::Min(nMerged, nEventsInFile);
96 bgtree->SetBranchAddress(branchName, &pointArray);
98 for (Int_t iEvent=0; iEvent<nMergedBuffer; iEvent++)
100 bgtree->GetEntry(iEvent);
102 mergedPointsArray = (TClonesArray*)pointArray->Clone();
104 std::cout <<
"New size of mergedPointsArray: " <<
AddTClonesArray(mergedPointsArray, pointArray) << std::endl;
110 for (Int_t iEvent=0; iEvent<nBuffer; iEvent++)
112 std::cout <<
"Adding Event: " << iEvent <<
" to buffer!" << std::endl;
113 std::cout <<
"Merged PointsArray Size: " << mergedPointsArray->GetEntriesFast() << std::endl;
115 fBuffer.push_back((TClonesArray*)mergedPointsArray);
128 Int_t origSize = target->GetEntriesFast();
129 for (
int i = 0;
i < source->GetEntriesFast();
i++){
130 std::cout << source->GetClass()->GetName() << std::endl;
131 TString myClassName(source->GetClass()->GetName());
132 if(myClassName.Contains(
"PndSdsMCPoint"))
134 else if (myClassName.Contains(
"PndSdsDigiPixel"))
136 else if (myClassName.Contains(
"PndSdsDigiStrip"))
142 else std::cout <<
"The Class: " << myClassName <<
" is unknown!" << std::endl;
145 return target->GetEntriesFast();
Int_t FillBuffer(TString fileName, TString branchName, Int_t nEvents, Int_t nMerged)
ClassImp(PndMvdEventMerger)
TClonesArray * GetEvent(Int_t iEvent)
Class for digitised strip hits.
static T Min(const T &x, const T &y)
virtual ~PndMvdEventMerger()
Data class to store the digi output of a pixel module.
Int_t AddTClonesArray(TClonesArray *target, TClonesArray *source)
std::vector< TClonesArray * > fBuffer