EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairRunAna.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairRunAna.cxx
1 // -------------------------------------------------------------------------
2 // ----- FairRunAna source file -----
3 // ----- Created 06/01/04 by M. Al-Turany -----
4 // -------------------------------------------------------------------------
5 
6 #include "FairRunAna.h"
7 
8 #include "FairRootManager.h"
9 #include "FairTask.h"
10 #include "FairBaseParSet.h"
11 #include "FairEventHeader.h"
12 #include "FairFieldFactory.h"
13 #include "FairRuntimeDb.h"
14 #include "FairTrajFilter.h"
15 #include "FairRunIdGenerator.h"
16 #include "FairLogger.h"
17 #include "FairFileHeader.h"
18 #include "FairMCEventHeader.h"
19 #include "FairParIo.h"
20 #include "FairAnaSelector.h"
21 
22 #include "TROOT.h"
23 #include "TTree.h"
24 #include "TSeqCollection.h"
25 #include "TGeoManager.h"
26 #include "TKey.h"
27 #include "TF1.h"
28 #include "TSystem.h"
29 #include "TProof.h"
30 #include "TProofOutputFile.h"
31 
32 #include <iostream>
33 #include <list>
34 
35 using std::cout;
36 using std::endl;
37 using std::list;
38 
39 
40 //_____________________________________________________________________________
42 //_____________________________________________________________________________
44 {
45 
46  return fgRinstance;
47 }
48 //_____________________________________________________________________________
50  :FairRun(),
51  fRunInfo(),
52  fIsInitialized(kFALSE),
53  fInputGeoFile(0),
54  fLoadGeo( kFALSE),
55  fEvtHeader(0),
56  fMCHeader(0),
57  fStatic(kFALSE),
58  fField(0),
59  fTimeStamps(kFALSE),
60  fInFileIsOpen(kFALSE),
61  fMixedInput(kFALSE),
62  fEventTimeMin(0),
63  fEventTimeMax(0),
64  fEventTime(0),
65  fEventMeanTime(0),
66  fTimeProb(0),
67  fProof(NULL),
68  fProofAnalysis(kFALSE),
69  fRunOnProofWorker(kFALSE),
70  fProofServerName(""),
71  fProofParName("$VMCWORKDIR/gconfig/libFairRoot.par"),
72  fOutputDirectory(""),
73  fProofOutputStatus("copy"),
74  fFinishProcessingLMDFile(kFALSE)
75 {
76 
77  fgRinstance=this;
78  fAna=kTRUE;
79 }
80 //_____________________________________________________________________________
81 
82 //_____________________________________________________________________________
83 FairRunAna::FairRunAna(const char* type, const char* proofName)
84  :FairRun(),
85  fRunInfo(),
86  fIsInitialized(kFALSE),
87  // fInputFile(0),
88  fInputGeoFile(0),
89  fLoadGeo( kFALSE),
90  fEvtHeader(0),
91  fMCHeader(0),
92  fStatic(kFALSE),
93  fField(0),
94  fTimeStamps(kFALSE),
95  fInFileIsOpen(kFALSE),
96  fMixedInput(kFALSE),
97  fEventTimeMin(0),
98  fEventTimeMax(0),
99  fEventTime(0),
100  fEventMeanTime(0),
101  fTimeProb(0),
102  fProof(NULL),
103  fProofAnalysis(kFALSE),
104  fRunOnProofWorker(kFALSE),
105  fProofServerName(proofName),
106  fProofParName("$VMCWORKDIR/gconfig/libFairRoot.par"),
107  fOutputDirectory(""),
108  fProofOutputStatus("copy"),
109  fFinishProcessingLMDFile(kFALSE)
110 {
111  TString anaType = type;
112  anaType.ToLower();
113 
114  fProof = NULL;
115  fProofAnalysis = kFALSE;
116  fProofServerName = proofName;
117 
118  if ( anaType.Contains("proof") ) {
119  fProofAnalysis = kTRUE;
120  fProofServerName = proofName;
121 
122  cout << "+++++++ T P R O O F +++++++++++++++++++++++++++++++++" << endl;
123  cout << "creating TProof* proof = TProof::Open(\"" << fProofServerName.Data()
124  << "\");" << endl;
125  TProof::AddEnvVar("LOCALDATASERVER","file://");
126  // TProof* proof = TProof::Open("lite:///?workers=1");
127  fProof = TProof::Open(fProofServerName.Data());
128  cout << "+++++++ C R E A T E D +++++++++++++++++++++++++++++++" << endl;
129  // fStatic = kTRUE;
130  }
131 
132  fgRinstance=this;
133  fAna=kTRUE;
134 }
135 //_____________________________________________________________________________
136 
137 //_____________________________________________________________________________
139 {
140  // delete fFriendFileList;
141  if (fField) {
142  delete fField;
143  }
144  if (gGeoManager) {
145  delete gGeoManager;
146  }
147 }
148 
149 //_____________________________________________________________________________
150 
151 void FairRunAna::SetGeomFile(const char* GeoFileName)
152 {
153  if (fIsInitialized) {
154  fLogger->Fatal(MESSAGE_ORIGIN, "Geometry file has to be set before Run::Init !") ;
155  exit(-1);
156  } else {
157 
158  TFile* CurrentFile=gFile;
159  fInputGeoFile= new TFile(GeoFileName);
160  if (fInputGeoFile->IsZombie()) {
161  fLogger->Error(MESSAGE_ORIGIN, "Error opening Geometry Input file");
162  fInputGeoFile=0;
163  }
164  fLogger->Info(MESSAGE_ORIGIN, " Opening Geometry input file: %s ", GeoFileName);
165  fLoadGeo=kTRUE;
166  gFile=CurrentFile;
167  }
168 }
169 
170 //_____________________________________________________________________________
171 
173 {
174 
175  if (fIsInitialized) {
176  fLogger->Fatal(MESSAGE_ORIGIN,"Error Init is already called before!");
177  exit(-1);
178  } else {
179  fIsInitialized=kTRUE;
180  }
181 
182  if ( fRunOnProofWorker ) {
184  } else {
185  // Open the input file and add other input files added by AddFile to the
186  // input chain. Do a check if the added files are of the same type
187  // as the the input file. Same type means check if they contain the
188  // same branch.
189  if (!fMixedInput) {
191  } else {
192  Bool_t openBKChain = fRootManager->OpenBackgroundChain();
193  if (!openBKChain) {
194  fLogger->Fatal(MESSAGE_ORIGIN, "Could not open background Chain!");
195  }
197  }
198  }
199  //Load Geometry from user file
200 
201  if (fLoadGeo) {
202  if (fInputGeoFile!=0) { //First check if the user has a separate Geo file!
203  TIter next(fInputGeoFile->GetListOfKeys());
204  TKey* key;
205  while ((key = (TKey*)next())) {
206  if (strcmp(key->GetClassName(),"TGeoManager") != 0) {
207  continue;
208  }
209  gGeoManager = (TGeoManager*)key->ReadObj();
210  break;
211  }
212  }
213  }
214  if (fInFileIsOpen) {
215  if ( fRunOnProofWorker ) {
216  if (fLoadGeo && gGeoManager==0) {
217  fRootManager->GetInFile()->Get("FAIRGeom");
218  }
219  if (fLoadGeo && gGeoManager==0) {
220  }
221  } else {
222 
223  // Add all friend files defined by AddFriend to the correct chain
225  if (fLoadGeo && gGeoManager==0) {
226  // Check if the geometry in the first file of the Chain
227  fRootManager->GetInChain()->GetFile()->Get("FAIRGeom");
228  }
229  //check that the geometry was loaded if not try all connected files!
230  if (fLoadGeo && gGeoManager==0) {
231  fLogger->Info(MESSAGE_ORIGIN, "Geometry was not found in the input file we will look in the friends if any!" );
232  TFile* currentfile= gFile;
233  TFile* nextfile=0;
234  TSeqCollection* fileList=gROOT->GetListOfFiles();
235  for (Int_t k=0; k<fileList->GetEntries(); k++) {
236  nextfile=(TFile*)fileList->At(k);
237  if (nextfile) {
238  nextfile->Get("FAIRGeom");
239  }
240  if (gGeoManager) {
241  break;
242  }
243  }
244  gFile=currentfile;
245  }
246  }
247  } else if (fMixedInput) {
248 
249 
250 
251  } else { // if(fInputFile )
252  // NO input file but there is a geometry file
253  if (fLoadGeo) {
254  if (fInputGeoFile!=0) { //First check if the user has a separate Geo file!
255  TIter next(fInputGeoFile->GetListOfKeys());
256  TKey* key;
257  while ((key = (TKey*)next())) {
258  if (strcmp(key->GetClassName(),"TGeoManager") != 0) {
259  continue;
260  }
261  gGeoManager = (TGeoManager*)key->ReadObj();
262  break;
263  }
264  }
265  }
266  }
267  //Init the Chain ptr
268  // fcurrent = fChainList.begin();
269 // fOutFile = fRootManager->OpenOutFile(fOutname);
270 
271  if ( fProofAnalysis ) {
272  return;
273  }
274 
275  gROOT->GetListOfBrowsables()->Add(fTask);
276 
277  // Init the RTDB containers
278  fRtdb= GetRuntimeDb();
280  (fRtdb->getContainer("FairBaseParSet"));
281 
283  if (fTimeStamps) {
285  }
286 
287 
288 
289  // Assure that basic info is there for the run
290  // if(par && fInputFile) {
291  if (par && fInFileIsOpen) {
292 
293  fLogger->Info(MESSAGE_ORIGIN,"Parameter and input file are available, Assure that basic info is there for the run!");
295 
296  fEvtHeader = (FairEventHeader*)fRootManager->GetObject("EventHeader.");
297  fMCHeader = (FairMCEventHeader*)fRootManager->GetObject("MCEventHeader.");
298  if (fEvtHeader ==0) {
303  } else {
305  }
306 
307  //Copy the Event Header Info to Output
308  fEvtHeader->Register();
309 
310  // Init the containers in Tasks
311 
313  fTask->SetParTask();
314 
316  if (gGeoManager==0) {
317  par->GetGeometry();
318  }
319  // fRootManager->SetBranchNameList(par->GetBranchNameList());
320 
321  } else if (fMixedInput) {
322  fLogger->Info(MESSAGE_ORIGIN,"Initializing for Mixed input");
323 
324  //For mixed input we have to set containers to static becauser of the different run ids
325  //fRtdb->setContainersStatic(kTRUE);
326 
327  fEvtHeader = (FairEventHeader*) fRootManager->GetObject("EventHeader.");
328 
329 
330  fMCHeader = (FairMCEventHeader*)fRootManager->GetObject("MCEventHeader.");
331  if (fEvtHeader ==0) {
336  }
337 
338 
340 
341  //Copy the Event Header Info to Output
342  fEvtHeader->Register();
343 
345  // Init the containers in Tasks
347 
348  if (gGeoManager==0) {
349  fLogger->Info(MESSAGE_ORIGIN,"Read the Geometry from Parameter file");
350  par->GetGeometry();
351 
352  }
353  if (gGeoManager==0) {
354  fLogger->Fatal(MESSAGE_ORIGIN,"Could not Read the Geometry from Parameter file");
355  }
356  fTask->SetParTask();
358 
359  } else {
360  fLogger->Info(MESSAGE_ORIGIN,"Initializing without input file or Mixed input");
362  evt->Register();
363  FairRunIdGenerator genid;
364  fRunId = genid.generateId();
365  fRtdb->addRun(fRunId);
366  evt->SetRunId( fRunId);
367  fTask->SetParTask();
369 
370  }
372  if (fieldfact) {
373  fieldfact->SetParm();
374  }
375 
378 
379  // create a field
380  // <DB>
381  // Add test for external FairField settings
382  if (fieldfact && !fField) {
383  fField= fieldfact->createFairField();
384  }
385  // Now call the User initialize for Tasks
386  fTask->InitTask();
387  // if the vis manager is available then initialize it!
388  FairTrajFilter* fTrajFilter = FairTrajFilter::Instance();
389  if (fTrajFilter) {
390  fTrajFilter->Init();
391  }
392 
393  // create the output tree after tasks initialisation
394  fOutFile->cd();
395  TTree* outTree =new TTree("cbmsim", "/cbmout", 99);
396  fRootManager->TruncateBranchNames(outTree, "cbmout");
397  fRootManager->SetOutTree(outTree);
400 }
401 //_____________________________________________________________________________
402 
403 //_____________________________________________________________________________
405 {
406  fRtdb= GetRuntimeDb();
408  (fRtdb->getContainer("FairBaseParSet"));
409 
410  if (par && fInFileIsOpen) {
412 
415 
416  if ( fMCHeader != 0 ) {
418  fEvtHeader->SetRunId(fRunId); // should i do it?
420  } else {
422  }
423 
424  //Copy the Event Header Info to Output
425  fEvtHeader->Register();
426 
427  // Init the containers in Tasks
429  fTask->ReInitTask();
430  // fTask->SetParTask();
432  if (gGeoManager==0) {
433  par->GetGeometry();
434  }
435  }
436 }
437 //_____________________________________________________________________________
438 
439 //_____________________________________________________________________________
440 void FairRunAna::RunMixed(Int_t Ev_start, Int_t Ev_end)
441 {
442 
443  fLogger->Debug(MESSAGE_ORIGIN,"Running in mixed mode");
444  Int_t MaxAllowed=fRootManager->CheckMaxEventNo(Ev_end);
445  if (Ev_end==0) {
446  if (Ev_start==0) {
447  Ev_end=MaxAllowed;
448  } else {
449  Ev_end = Ev_start;
450  if ( Ev_end > MaxAllowed ) {
451  Ev_end = MaxAllowed;
452  }
453  Ev_start=0;
454  }
455  } else {
456  if (Ev_end > MaxAllowed) {
457  Ev_end=MaxAllowed;
458  }
459  }
460 
461  for (int i=Ev_start; i< Ev_end; i++) {
464  fLogger->Debug(MESSAGE_ORIGIN,"------Event is read , now execute the tasks--------");
465  fTask->ExecuteTask("");
466  fLogger->Debug(MESSAGE_ORIGIN,"------ Tasks executed, now fill the tree --------");
467  fRootManager->Fill();
469  fTask->FinishEvent();
470  if (NULL != FairTrajFilter::Instance()) {
472  }
473  }
474  fTask->FinishTask();
477  fRootManager->Write();
478 
479 }
480 //_____________________________________________________________________________
481 
482 //_____________________________________________________________________________
483 void FairRunAna::Run(Int_t Ev_start, Int_t Ev_end)
484 {
485  if ( fProofAnalysis ) {
486  RunOnProof(Ev_start,Ev_end);
487  return;
488  }
489 
490  if (fTimeStamps) {
491  RunTSBuffers();
492  } else if (fMixedInput) {
493  RunMixed(Ev_start,Ev_end);
494  } else {
495  UInt_t tmpId =0;
496  // if (fInputFile==0) {
497  if (!fInFileIsOpen) {
498  DummyRun(Ev_start,Ev_end);
499  return;
500  }
501  if (Ev_end==0) {
502  if (Ev_start==0) {
503  Ev_end=Int_t((fRootManager->GetInChain())->GetEntries());
504  } else {
505  Ev_end = Ev_start;
506  if ( Ev_end > ((fRootManager->GetInChain())->GetEntries()) ) {
507  Ev_end = (Int_t) (fRootManager->GetInChain())->GetEntries();
508  }
509  Ev_start=0;
510  }
511  } else {
512  Int_t fileEnd=(fRootManager->GetInChain())->GetEntries();
513  if (Ev_end > fileEnd) {
514  cout << "-------------------Warning---------------------------" << endl;
515  cout << " -W FairRunAna : File has less events than requested!!" << endl;
516  cout << " File contains : " << fileEnd << " Events" << endl;
517  cout << " Requested number of events = " << Ev_end << " Events"<< endl;
518  cout << " The number of events is set to " << fileEnd << " Events"<< endl;
519  cout << "-----------------------------------------------------" << endl;
520  Ev_end = fileEnd;
521  }
522 
523  }
524 
525  fRunInfo.Reset();
526 
527 
528  for (int i=Ev_start; i< Ev_end; i++) {
534  if (fRootManager->IsEvtHeaderNew()) {
535  tmpId = fMCHeader->GetRunID();
536  } else {
537  tmpId = fEvtHeader->GetRunId();
538  }
539  if ( tmpId != fRunId ) {
540  fRunId = tmpId;
541  if ( !fStatic ) {
542  Reinit( fRunId );
543  fTask->ReInitTask();
544  }
545  }
546  //FairMCEventHeader* header = (FairMCEventHeader*)fRootManager->GetObject("MCEventHeader.");
547  //std::cout << "WriteoutBufferData with time: " << fRootManager->GetEventTime();
549  fTask->ExecuteTask("");
550  fRootManager->Fill();
552  fTask->FinishEvent();
553 
555  if (NULL != FairTrajFilter::Instance()) {
557  }
558 
559  }
560 
562  fTask->FinishTask();
563  if (fWriteRunInfo) {
565  }
567  fRootManager->Write();
568  }
569 }
570 //_____________________________________________________________________________
571 
572 //_____________________________________________________________________________
573 void FairRunAna::Run(Double_t delta_t)
574 {
575  while (fRootManager->ReadNextEvent(delta_t)==kTRUE) {
576  fTask->ExecuteTask("");
577  fRootManager->Fill();
579  fTask->FinishEvent();
580  if (NULL != FairTrajFilter::Instance()) {
582  }
583  }
584 
586  fTask->FinishTask();
588  fRootManager->Write();
589 
590 }
591 //_____________________________________________________________________________
592 
593 //_____________________________________________________________________________
594 void FairRunAna::Run(Long64_t entry)
595 {
596 // if (fTimeStamps) {
597 // RunTSBuffers();
598 // } else {
599  UInt_t tmpId =0;
600  fRootManager->ReadEvent(entry);
601  tmpId = fEvtHeader->GetRunId();
602  if ( tmpId != fRunId ) {
603  fRunId = tmpId;
604  if ( !fStatic ) {
605  Reinit( fRunId );
606  fTask->ReInitTask();
607  }
608  }
609  fTask->ExecuteTask("");
610  fTask->FinishTask();
611  fRootManager->Fill();
614  fRootManager->Write();
615 // }
616 }
617 //_____________________________________________________________________________
618 
619 //_____________________________________________________________________________
620 void FairRunAna::RunOneEvent(Long64_t entry)
621 {
622  if (fTimeStamps) {
623  RunTSBuffers();
624  } else {
625  UInt_t tmpId =0;
626  fRootManager->ReadEvent(entry);
627  tmpId = fEvtHeader->GetRunId();
628  if ( tmpId != fRunId ) {
629  fRunId = tmpId;
630  if ( !fStatic ) {
631  Reinit( fRunId );
632  fTask->ReInitTask();
633  }
634  }
636 
637  fTask->ExecuteTask("");
638  fRootManager->Fill();
640  fTask->FinishEvent();
641  }
642 }
643 //_____________________________________________________________________________
644 
645 //_____________________________________________________________________________
647 {
648  Int_t globalEvent = 0;
649 
650  bool firstRun = true;
651  while (firstRun || fRootManager->AllDataProcessed() == kFALSE) {
652  firstRun = false;
653  if (globalEvent < fRootManager->GetInTree()->GetEntriesFast()) { //this step is necessary to load in all data which is not read in via TSBuffers
654  fRootManager->ReadEvent(globalEvent++);
655  }
656  fTask->ExecuteTask("");
657  fRootManager->Fill();
659  fTask->FinishEvent();
660  if (NULL != FairTrajFilter::Instance()) {
662  }
663  }
665  fTask->FinishTask();
667  fRootManager->Write();
668 }
669 //_____________________________________________________________________________
670 //_____________________________________________________________________________
671 
672 void FairRunAna::RunOnLmdFiles(UInt_t NStart, UInt_t NStop)
673 {
674  if(NStart==0 && NStop==0) {
675  NStart=0;
676  NStop=1000000000;
677  fLogger->Info(MESSAGE_ORIGIN," Maximum number of event is set to 1E9");
678  }
679  for (UInt_t i=NStart; i< NStop; i++) {
680  if ( fFinishProcessingLMDFile ) {
681  i = NStop;
682 
683  }
684 
685  fTask->ExecuteTask("");
686  fRootManager->Fill();
687  }
688 
689  fTask->FinishTask();
690  fRootManager->Write();
691 
692 }
693 //_____________________________________________________________________________
694 
695 //_____________________________________________________________________________
696 void FairRunAna::DummyRun(Int_t Ev_start, Int_t Ev_end)
697 {
698 
700  for (int i=Ev_start; i< Ev_end; i++) {
701  fTask->ExecuteTask("");
702  fRootManager->Fill();
703  }
704  fTask->FinishTask();
705  fRootManager->Write();
706 
707 }
708 //_____________________________________________________________________________
709 
710 //_____________________________________________________________________________
711 void FairRunAna::RunOnProof(Int_t NStart,Int_t NStop)
712 {
713  cout << "FairRunAna::RunOnProof(" << NStart << "," << NStop << "): "
714  << "running FairAnaSelector on proof server: \"" << fProofServerName.Data() << "\" "
715  << "with PAR file name = \"" << fProofParName.Data() << "\"." << endl;
716 
717  FairAnaSelector* proofSelector = new FairAnaSelector();
718 
719 
720  TChain* inChain = (TChain*)fRootManager->GetInChain();
721  TString par1File = "";
722  TString par2File = "";
723  if ( fRtdb->getFirstInput () ) {
724  par1File = fRtdb->getFirstInput ()->getFilename();
725  }
726  if ( fRtdb->getSecondInput() ) {
727  par2File = fRtdb->getSecondInput()->getFilename();
728  }
729 
730  TString outDir = (fOutputDirectory.Length()>1?fOutputDirectory.Data():gSystem->WorkingDirectory());
731 
732 // cout << "+++++++ T P R O O F +++++++++++++++++++++++++++++++++" << endl;
733 // cout << "creating TProof* proof = TProof::Open(\"" << fProofServerName.Data()
734 // << "\");" << endl;
735 // TProof::AddEnvVar("LOCALDATASERVER","file://");
736 // // TProof* proof = TProof::Open("lite:///?workers=1");
737 // TProof* proof = TProof::Open(fProofServerName.Data());
738 // cout << "+++++++ C R E A T E D +++++++++++++++++++++++++++++++" << endl;
739 
740  TString outFile = fRootManager->GetOutFile()->GetName();
742 
743  fProof->AddInput(fTask);
744 
745  fProof->AddInput(new TNamed("FAIRRUNANA_fContainerStatic",(fStatic?"kTRUE":"kFALSE")));
746  fProof->AddInput(new TNamed("FAIRRUNANA_fProofOutputStatus",fProofOutputStatus.Data()));
747  fProof->AddInput(new TNamed("FAIRRUNANA_fOutputDirectory",outDir.Data()));
748  fProof->AddInput(new TNamed("FAIRRUNANA_fOutputFileName",outFile.Data()));
749  fProof->AddInput(new TNamed("FAIRRUNANA_fParInput1FName",par1File.Data()));
750  fProof->AddInput(new TNamed("FAIRRUNANA_fParInput2FName",par2File.Data()));
751 
752  cout << "0309: ClearPackages" << endl;
753  fProof->ClearPackages();
754  cout << "0309: UploadPackages" << endl;
755  fProof->UploadPackage(fProofParName.Data());
756  cout << "0309: EnablePackages" << endl;
757  fProof->EnablePackage(fProofParName.Data());
758  cout << "0309: ShowPackages" << endl;
759  fProof->ShowPackages();
760  cout << "0309: Done" << endl;
761 
762  Int_t nofChainEntries = inChain->GetEntries();
763  cout << "FairRunAna::RunOnProof(): The chain seems to have " << nofChainEntries << " entries." << endl;
764 
765  TObjArray* listOfFiles = inChain->GetListOfFiles();
766  cout << "FairRunAna::RunOnProof(): There are " << listOfFiles->GetEntries() << " files in the chain." << endl;
767 
768  inChain->SetProof();
769 
770  Int_t nofEventsToAnalyze = NStop-NStart;
771 
772  if ( nofEventsToAnalyze <= 0 ) {
773  cout << "You requested to analyze events from " << NStart << " to " << NStop << " that is " << nofEventsToAnalyze << " events!!!" << endl;
774  nofEventsToAnalyze = nofChainEntries-NStart;
775  cout << "It will be changed to analyze all events from " << NStart << " to the end of chain (" << nofChainEntries << "), that is to analyze " << nofEventsToAnalyze << " events." << endl;
776  }
777 
778  cout << "FairRunAna::RunOnProof(): Starting inChain->Process(\"FairAnaSelector\",\"\","
779  << nofEventsToAnalyze << "," << NStart << ")" << endl;
780  inChain->Process("FairAnaSelector","",nofEventsToAnalyze,NStart);
781  cout << "FairRunAna::RunOnProof(): inChain->Process DONE" << endl;
782 
783  return;
784 }
785 //_____________________________________________________________________________
786 
787 //_____________________________________________________________________________
789 {
791  fTask->FinishTask();
792  gDirectory->SetName(fRootManager->GetOutFile()->GetName());
793  // fRunInfo.WriteInfo(); // CRASHES due to file ownership i guess...
794  // cout << ">>> SlaveTerminate fRootManager->GetInChain()->Print()" << endl;
795  // fRootManager->GetInChain()->Print();
796  // cout << ">>>------------------------------------------------<<<" << endl;
798  fRootManager->Write();
800 }
801 //_____________________________________________________________________________
802 
803 //_____________________________________________________________________________
805 {
806  if (!fMixedInput) {
807  fRootManager->SetInputFile(name);
808  }
809 }
810 //_____________________________________________________________________________
811 void FairRunAna::SetSignalFile(TString name, UInt_t identifier )
812 {
813  fMixedInput=kTRUE;
814  if (identifier==0) {
815  fLogger->Fatal(MESSAGE_ORIGIN," ----- Identifier 0 is reserved for background files! please use other value ------ ");
816  }
817  fRootManager->AddSignalFile(name, identifier);
818  fLogger->Info(MESSAGE_ORIGIN," ----- Mixed input mode will be used ------ ");
819 }
820 //_____________________________________________________________________________
822 {
823  fMixedInput=kTRUE;
825  fLogger->Info(MESSAGE_ORIGIN," ----- Mixed input mode will be used ------ ");
826 
827 }//_____________________________________________________________________________
829 {
830  if (fMixedInput) {
832  } else {
833  fLogger->Fatal(MESSAGE_ORIGIN," Background can be added only if mixed mode is used");
834  }
835 }
836 //_____________________________________________________________________________
837 void FairRunAna::AddSignalFile(TString name, UInt_t identifier )
838 {
839  if (fMixedInput) {
840  if (identifier==0) {
841  fLogger->Fatal(MESSAGE_ORIGIN," ----- Identifier 0 is reserved for background files! please use other value ------ ");
842  }
843  fRootManager->AddSignalFile(name, identifier);
844  } else {
845  fLogger->Fatal(MESSAGE_ORIGIN," Signal can be added only if mixed mode is used");
846  }
847 }
848 //_____________________________________________________________________________
850 {
851  if (fIsInitialized) {
852  fLogger->Fatal(MESSAGE_ORIGIN, "AddFriend has to be set before Run::Init !");
853  } else {
854  fRootManager->AddFriend(Name);
855  }
856 }
857 //_____________________________________________________________________________
858 
859 void FairRunAna::Reinit(UInt_t runId)
860 {
861  // reinit procedure
862  fRtdb->initContainers( runId );
863 }
864 //_____________________________________________________________________________
865 
867 {
868  fRootManager->AddFile(name);
869 }
870 //_____________________________________________________________________________
871 
873 {
874  if (ROOT_VERSION_CODE >= ROOT_VERSION(5,29,1)) {
875  if (fIsInitialized) {
876  fLogger->Warning(MESSAGE_ORIGIN, "RunWithTimeStamps has to be set before Run::Init !");
877  exit(-1);
878  } else {
879  fTimeStamps=kTRUE;
881  }
882  } else {
883  fLogger->Fatal(MESSAGE_ORIGIN, "RunWithTimeStamps need at least ROOT version 5.29.1") ;
884  }
885 }
886 //_____________________________________________________________________________
887 
889 {
891 }
892 //_____________________________________________________________________________
893 void FairRunAna::SetEventTimeInterval(Double_t min, Double_t max)
894 {
896 }
897 //_____________________________________________________________________________
898 void FairRunAna::SetEventMeanTime(Double_t mean)
899 {
901 }
902 //_____________________________________________________________________________
903 void FairRunAna::SetContainerStatic(Bool_t tempBool)
904 {
905  fStatic=tempBool;
906  if ( fStatic ) {
907  fLogger->Info(MESSAGE_ORIGIN, "Parameter Cont. initialisation is static");
908  } else {
909  fLogger->Info(MESSAGE_ORIGIN, "Parameter Cont. initialisation is NOT static");
910  }
911 }
912 //_____________________________________________________________________________
913 void FairRunAna::BGWindowWidthNo(UInt_t background, UInt_t Signalid)
914 {
915  fRootManager->BGWindowWidthNo(background, Signalid);
916 }
917 //_____________________________________________________________________________
918 void FairRunAna::BGWindowWidthTime(Double_t background, UInt_t Signalid)
919 {
920  fRootManager->BGWindowWidthTime(background, Signalid);
921 }
922 //_____________________________________________________________________________
923 
925 
926