13 #include "TObjArray.h" 14 #include "TG4RunConfiguration.h" 17 #include "FairGeoLoader.h" 18 #include "FairGeoInterface.h" 19 #include "FairLogger.h" 20 #include "FairEventHeader.h" 22 #include "FairTrajFilter.h" 24 #include "ERRecoMCApplication.h" 28 ERRunAna* ERRunAna::fInstance = NULL;
29 TCut ERRunAna::fUserCut =
"";
30 TH1I* ERRunAna::fEventsForProcessing = NULL;
31 Bool_t gFRAIsInterrupted;
42 fHoldEventsCount(kFALSE)
44 LOG(DEBUG) <<
"ERRunAna constructor" << FairLogger::endl;
47 void ERRunAna::Init(){
49 FairGeoLoader* loader=
new FairGeoLoader(
"TGeo",
"Geo Loader");
50 FairGeoInterface* GeoInterFace=loader->getGeoInterface();
51 GeoInterFace->SetNoOfSets(0);
52 TString erPath = gSystem->Getenv(
"VMCWORKDIR");
53 GeoInterFace->setMediaFile(erPath+
"/geometry/media.geo");
54 GeoInterFace->readMedia();
59 FairRootManager* ioman = FairRootManager::Instance();
60 if ( ! ioman ) Fatal(
"Init",
"No FairRootManager");
62 LOG(INFO) <<
"User cut " << fUserCut <<
" implementation" << FairLogger::endl;
63 TTree* tree = ioman->GetInTree();
64 fEventsForProcessing =
new TH1I (
"hist",
"Events for processing", tree->GetEntries(), 1, tree->GetEntries());
65 tree->Draw(
"Entry$>>hist",fUserCut,
"goff");
66 if (!fEventsForProcessing->GetEntries()) {
67 LOG(FATAL) <<
"ERRunAna: No data for analysis with defined user cut: " 68 << fUserCut << FairLogger::endl;
74 TG4RunConfiguration* runConfiguration
75 =
new TG4RunConfiguration(
"geomRoot",
"emStandard",
"specialCuts+stackPopper");
77 TGeant4* geant4 =
new TGeant4(
"TGeant4",
"The Geant4 Monte Carlo", runConfiguration);
79 geant4->ProcessGeantMacro(erPath+
"/gconfig/g4config.in");
81 geant4->ProcessRun(0);
86 void FRA_handler_ctrlc(
int)
88 LOG(INFO) <<
"*********** CTRL C PRESSED *************";
89 gFRAIsInterrupted = kTRUE;
95 gFRAIsInterrupted = kFALSE;
102 if (!fInFileIsOpen) {
103 DummyRun(Ev_start,Ev_end);
107 Int_t MaxAllowed=fRootManager->CheckMaxEventNo(Ev_end);
108 if ( MaxAllowed != -1 ) {
114 if ( Ev_end > MaxAllowed ) {
120 if (Ev_end > MaxAllowed) {
121 cout <<
"-------------------Warning---------------------------" << endl;
122 cout <<
" -W FairRunAna : File has less events than requested!!" << endl;
123 cout <<
" File contains : " << MaxAllowed <<
" Events" << endl;
124 cout <<
" Requested number of events = " << Ev_end <<
" Events"<< endl;
125 cout <<
" The number of events is set to " << MaxAllowed <<
" Events"<< endl;
126 cout <<
"-----------------------------------------------------" << endl;
130 LOG(INFO) <<
"FairRunAna::Run() After checking, the run will run from event " << Ev_start <<
" to " << Ev_end <<
".";
133 LOG(INFO) <<
"FairRunAna::Run() continue running without stop";
136 Int_t readEventReturn = 0;
138 for (
int i=Ev_start; i< Ev_end || MaxAllowed==-1 ; i++) {
140 if (!ContentForAnalysis(i)) {
144 gSystem->IgnoreInterrupt();
146 signal(SIGINT, FRA_handler_ctrlc);
148 if ( gFRAIsInterrupted ) {
149 LOG(WARNING) <<
"FairRunAna::Run() Event loop was interrupted by the user!";
153 readEventReturn = fRootManager->ReadEvent(i);
155 if ( readEventReturn != 0 ) {
156 LOG(WARNING) <<
"FairRunAna::Run() fRootManager->ReadEvent(" << i <<
") returned " << readEventReturn <<
". Breaking the event loop";
160 fRootManager->FillEventHeader(fEvtHeader);
162 tmpId = fEvtHeader->GetRunId();
163 if ( tmpId != fRunId ) {
171 fRootManager->StoreWriteoutBufferData(fRootManager->GetEventTime());
172 fTask->ExecuteTask(
"");
174 fRootManager->DeleteOldWriteoutBufferData();
175 fTask->FinishEvent();
177 if (NULL != FairTrajFilter::Instance()) {
178 FairTrajFilter::Instance()->Reset();
183 fRootManager->StoreAllWriteoutBufferData();
185 fRootManager->LastFill();
186 fRootManager->Write();
190 bool ERRunAna::ContentForAnalysis(Int_t iEvent) {
191 if (fUserCut !=
"") {
192 if (!fEventsForProcessing->GetBinContent(iEvent)){
193 LOG(INFO) <<
" Skip event with user cut"<< FairLogger::endl;
200 void ERRunAna::MarkFill(Bool_t flag){
201 if (!fHoldEventsCount)
void Run(Int_t NStart=0, Int_t NStop=0)