7 #include "TClonesArray.h"
27 : TObject(), fBuffer(new TObjArray(nEvents)) {
28 if (!
FillBuffer(fileName, branchName, nEvents))
29 Fatal(
"CbmMvdPileupManager",
"Error in filling buffer");
45 if (!
fBuffer) Fatal(
"CbmMvdPileupManager::GetEvent",
"No event buffer!");
47 if (iEvent >
fBuffer->GetEntriesFast()) {
48 cout <<
"-W- CbmMvdPileupManager::GetEvent: Event " << iEvent
49 <<
" not present in buffer! " << endl;
50 cout <<
" Returning NULL pointer! "
55 TClonesArray* pArray = (TClonesArray*)
fBuffer->At(iEvent);
58 cout <<
"-W CbmMvdPileupManager::GetEvent: Returning NULL pointer!" << endl;
72 if (!
fBuffer) Fatal(
"Fill Buffer",
"No event buffer!");
76 TClonesArray* pointArray = NULL;
77 TFile* saveGFile = gFile;
79 TFile* bgfile =
new TFile(fileName);
81 cout <<
"-W- CbmMvdPileupManager::FillBuffer: Background file " << fileName
82 <<
" could noy be opened! " << endl;
85 cout <<
"-I- CbmMvdPileupManager::FillBuffer: Opening file " << endl;
86 cout << fileName << endl;
88 TTree* bgtree = (TTree*) bgfile->Get(
"cbmsim");
90 cout <<
"-W- CbmMvdPileupManager::FillBuffer: "
91 <<
"Could not find cbmsim tree in background file " << endl;
95 Int_t nEventsInFile = bgtree->GetEntries();
96 cout <<
"-I- CbmMvdPileupManager::FillBuffer: " << nEventsInFile
97 <<
" events in file" << endl;
98 Int_t nBuffer = TMath::Min(nEvents, nEventsInFile);
99 cout <<
"-I- CbmMvdPileupManager::FillBuffer: Buffering " << nBuffer
100 <<
" events" << endl;
102 cout <<
"-W- CbmMvdPileupManager::FillBuffer: "
103 <<
"Number of events may not be sufficient for appropriate "
104 <<
"presentation of background pattern!" << endl;
106 bgtree->SetBranchAddress(branchName, &pointArray);
108 for (Int_t iEvent = 0; iEvent < nBuffer; iEvent++) {
109 bgtree->GetEntry(iEvent);
110 fBuffer->AddAt(pointArray->Clone(), iEvent);