2 #include "ERRootSource.h" 4 #include "FairRootManager.h" 7 #include "ERHe8EventHeader.h" 12 ERRootSource::ERRootSource():
25 ERRootSource::~ERRootSource(){
29 Bool_t ERRootSource::Init(){
31 if (fPath.size() == 0)
32 Fatal(
"ERRootSource",
"No files for source ERRootSource");
33 if (fRawEvents.size() == 0)
34 Fatal(
"ERRootSource",
"ERRootSource without regiistered events");
38 FairRun* run = FairRun::Instance();
40 header->Register(fTree, fBranchName);
42 for (Int_t iREvent = 0; iREvent < fRawEvents.size(); iREvent++)
43 fRawEvents[iREvent]->Register(fTree, fBranchName);
47 Int_t ERRootSource::ReadEvent(UInt_t
id){
48 FairRootManager* ioman = FairRootManager::Instance();
49 if ( ! ioman ) Fatal(
"Init",
"No FairRootManager");
52 if (fTree->GetEntriesFast() == ioman->GetEntryNr()-fOldEvents){
53 fOldEvents += ioman->GetEntryNr();
58 fTree->GetEntry(ioman->GetEntryNr()-fOldEvents);
60 for (Int_t iREvent = 0; iREvent < fRawEvents.size(); iREvent++)
61 fRawEvents[iREvent]->Process();
65 void ERRootSource::Close(){
72 void ERRootSource::Reset(){
75 void ERRootSource::SetFile(TString path, TString treeName, TString branchName){
76 fPath.push_back(path);
78 fBranchName = branchName;
79 cout <<
"Input file " << path <<
" with tree name " << fTreeName <<
" and branch name " <<
80 fBranchName <<
" added to source ERRootSource" << endl;
84 Int_t ERRootSource::OpenNextFile(){
85 if (fCurFile == fPath.size())
87 fFile =
new TFile(fPath[fCurFile++]);
89 Fatal(
"ERRootSource",
"Can`t open file for source ERRootSource");
91 cout << fPath[fCurFile-1] <<
" opened for source ERRootSource" << endl;
92 fTree = (TTree*)fFile->Get(fTreeName);
94 Fatal(
"ERRootSource",
"Can`t find tree in input file for source ERRootSource");