EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairRun.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairRun.cxx
1 // -------------------------------------------------------------------------
2 // ----- FairRun source file -----
3 // ----- Created 06/01/04 by M. Al-Turany -----
4 // -------------------------------------------------------------------------
5 
6 
7 #include "FairRun.h"
8 #include "FairTask.h"
9 #include "FairRootManager.h"
10 #include "FairRuntimeDb.h"
11 #include "FairEventHeader.h"
12 #include "FairFileHeader.h"
13 #include <iostream>
14 
15 bool FairRun::mJanaPluginMode = false;
16 
17 //_____________________________________________________________________________
19 //_____________________________________________________________________________
21 {
22  return fRunInstance;
23 }
24 //_____________________________________________________________________________
26  :TNamed(),
27  fNTasks(0),
28  fLogger(FairLogger::GetLogger()),
29  fRtdb(FairRuntimeDb::instance()),
30  fTask(new FairTask("FairTaskList")),
31  fOutname(""),
32  fRootManager(new FairRootManager()),
33  fOutFile(0),
34  fRunId(0),
35  fAna(kFALSE),
36  fEvHead(NULL),
37  fFileHeader(new FairFileHeader()),
38  fWriteRunInfo(kTRUE),
39  mEvCurrent(-1)
40 {
41  if (fRunInstance) {
42  Fatal("FairRun", "Singleton instance already exists.");
43  return;
44  }
45  fRunInstance=this;
47 }
48 //_____________________________________________________________________________
50 {
51  fLogger->Debug(MESSAGE_ORIGIN," Enter Destructor of FairRun ");
52  if (fTask) {
53  delete fTask; // There is another tasklist in MCApplication,
54  }
55  // but this should be independent
56  if (fRtdb) {
57  delete fRtdb; // who is responsible for the RuntimeDataBase
58  }
59  if (fRootManager) {
60  delete fRootManager; // who is responsible
61  fRootManager=0;
62  }
63  if (fEvHead) {
64  delete fEvHead;
65  }
66 }
67 //_____________________________________________________________________________
68 
69 //_____________________________________________________________________________
70 void FairRun::SetOutputFile(const char* fname)
71 {
72  fOutname=fname;
74 
75 }
76 //_____________________________________________________________________________
77 
78 //_____________________________________________________________________________
79 void FairRun::SetOutputFile(TFile* f)
80 {
81  fOutname=f->GetName();
83  fOutFile = f;
84 
85 }
86 //_____________________________________________________________________________
87 
88 //_____________________________________________________________________________
90 {
91  fTask->Add(t);
92  fNTasks++;
93  fFileHeader->AddTaskClassName(t->ClassName());
94 }
95 //_____________________________________________________________________________
97 {
98  if ( fTask ) { delete fTask; }
99  fTask = t;
100  fFileHeader->AddTaskClassName(t->ClassName());
101 }
102 //_____________________________________________________________________________
103 void FairRun::CreateGeometryFile(const char* geofile)
104 {
106 }
107 //_____________________________________________________________________________
108 FairTask* FairRun::GetTask(const char* taskName)
109 {
110  TList* taskList = fTask->GetListOfTasks();
111  TObject* task = taskList->FindObject(taskName);
112  return dynamic_cast<FairTask*>(task);
113 }
114 //_____________________________________________________________________________
116 {
117  if ( NULL == fEvHead ) {
118  fEvHead = new FairEventHeader();
119  }
120  return fEvHead;
121 }
122 //_____________________________________________________________________________
124 
125