FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairRun.h
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 #ifndef FAIRRUN_H
9 #define FAIRRUN_H
10 
11 #include "FairAlignmentHandler.h"
12 #include "FairRootManager.h"
13 
14 #include <Rtypes.h> // for Int_t, Bool_t, etc
15 #include <TMCtls.h> // for multi-threading
16 #include <TNamed.h> // for TNamed
17 #include <TString.h>
18 #include <map>
19 #include <string>
20 
21 class FairEventHeader;
22 class FairFileHeader;
23 class FairRuntimeDb;
24 class FairSink;
25 class FairTask;
26 class TFile;
27 class FairField;
28 class TGeoHMatrix;
29 
37 class FairRun : public TNamed
38 {
39  friend class FairMCApplication;
40 
41  public:
45  FairRun(Bool_t isMaster = kTRUE);
49  virtual ~FairRun();
53  static FairRun* Instance();
57  virtual void AddTask(FairTask* t);
58  virtual void StoreTaskNames(const FairTask* t);
59  virtual void SetTask(FairTask* t);
63  virtual void Init() = 0;
64  /*
65  * Get the magnetic field *
66  */
67  virtual FairField* GetField() = 0;
71  virtual void Run(Int_t NStart = 0, Int_t NStop = 0) = 0;
76  void SetEventHeader(FairEventHeader* EvHeader) { fEvtHeader = EvHeader; }
80  FairRuntimeDb* GetRuntimeDb(void) { return fRtdb; }
84  void SetSink(FairSink* tempSink)
85  {
86  fSink = tempSink;
87  fRootManager->SetSink(tempSink);
89  }
93  FairSink* GetSink() { return fSink; }
97  Int_t GetRunId() { return (static_cast<Int_t>(fRunId)); }
98 
102  void SetRunId(UInt_t runId) { fRunId = runId; }
103 
109  Bool_t IsAna() { return fAna; }
114  FairTask* GetTask(const char* taskName);
118  FairTask* GetMainTask() { return fTask; }
122  Int_t GetNTasks() { return fNTasks; }
123 
125  void CreateGeometryFile(const char* geofile);
126 
127  //** Set if RunInfo file should be written */
128  void SetWriteRunInfoFile(Bool_t write);
129 
130  //** Set if RunInfo should be generated */
131  void SetGenerateRunInfo(Bool_t write) { fGenerateRunInfo = write; }
132 
133  //** Get info if RunInfo file is written */
134  Bool_t GetWriteRunInfoFile();
135 
136  //** Get info if RunInfo file is written */
138 
139  //** Switches the use of FairLinks */
140  void SetUseFairLinks(Bool_t val);
141 
142  //** Get info if run on master */
143  Bool_t GetIsMaster() const { return fIsMaster; }
144 
145  //** Mark/Unmark event to be filled into output. Default is TRUE. */
146  void MarkFill(Bool_t flag) { fMarkFill = flag; }
147 
148  //** Get option string */
149  TString GetOptions() { return fOptions; };
150 
151  //** Set option string */
152  void SetOptions(const TString& s) { fOptions = s; };
153 
154  // vvvvvvvvvv depracted functions, replaced by FairSink vvvvvvvvvv
158  virtual void SetOutputFile(const char* fname);
162  virtual void SetOutputFile(TFile* f);
166  void SetOutputFileName(const TString& name);
167  TFile* GetOutputFile();
168  // ^^^^^^^^^^ depracted functions, replaced by FairSink ^^^^^^^^^^
169 
174  void SetUserOutputFileName(const TString& name);
175  TString GetUserOutputFileName() const;
176 
177  void AddAlignmentMatrices(const std::map<std::string, TGeoHMatrix>& alignmentMatrices, bool invertMatrices = false);
178 
179  private:
180  FairRun(const FairRun& M);
181  FairRun& operator=(const FairRun&) { return *this; }
183  Int_t fNTasks;
184 
185  protected:
187  static TMCThreadLocal FairRun* fRunInstance;
199  TString fOptions;
201  UInt_t fRunId;
202 
203  Bool_t fAna;
204 
206 
210 
211  Bool_t fIsMaster;
212 
213  Bool_t fMarkFill;
214 
216 
217  void AlignGeometry() const;
218 
219  ClassDef(FairRun, 5);
220 };
221 #endif // FAIRRUN_H
void AlignGeometry() const
Definition: FairRun.cxx:181
void CreateGeometryFile(const char *geofile)
Definition: FairRun.cxx:103
list of container factories
Definition: FairRuntimeDb.h:24
virtual void SetOutputFile(const char *fname)
Definition: FairRun.cxx:140
FairAlignmentHandler fAlignmentHandler
Definition: FairRun.h:215
Bool_t fAna
Definition: FairRun.h:203
TFile * GetOutputFile()
Definition: FairRun.cxx:168
TString GetUserOutputFileName() const
Definition: FairRun.cxx:179
void SetEventHeader(FairEventHeader *EvHeader)
Definition: FairRun.h:76
FairTask * GetTask(const char *taskName)
Definition: FairRun.cxx:105
FairRun(Bool_t isMaster=kTRUE)
Definition: FairRun.cxx:33
Bool_t GetWriteRunInfoFile()
Definition: FairRun.cxx:131
FairRootManager * fRootManager
Definition: FairRun.h:193
Bool_t GetIsMaster() const
Definition: FairRun.h:143
static FairRun * Instance()
Definition: FairRun.cxx:31
FairTask * fTask
Definition: FairRun.h:191
void SetWriteRunInfoFile(Bool_t write)
Definition: FairRun.cxx:122
FairEventHeader * GetEventHeader()
Definition: FairRun.cxx:112
FairSink * GetSink()
Definition: FairRun.h:93
void SetRunId(UInt_t runId)
Definition: FairRun.h:102
FairEventHeader * fEvtHeader
Definition: FairRun.h:205
void SetSink(FairSink *tempSink)
void SetOutputFileName(const TString &name)
Definition: FairRun.cxx:159
void SetGenerateRunInfo(Bool_t write)
Definition: FairRun.h:131
void SetSink(FairSink *tempSink)
Definition: FairRun.h:84
virtual void Init()=0
Bool_t fIsMaster
Definition: FairRun.h:211
virtual FairField * GetField()=0
void SetUseFairLinks(Bool_t val)
Definition: FairRun.cxx:120
static TMCThreadLocal FairRun * fRunInstance
Definition: FairRun.h:187
void SetOptions(const TString &s)
Definition: FairRun.h:152
virtual ~FairRun()
Definition: FairRun.cxx:60
void AddAlignmentMatrices(const std::map< std::string, TGeoHMatrix > &alignmentMatrices, bool invertMatrices=false)
Definition: FairRun.cxx:183
ClassDef(FairRun, 5)
virtual void Run(Int_t NStart=0, Int_t NStop=0)=0
FairFileHeader * fFileHeader
Definition: FairRun.h:207
Int_t GetNTasks()
Definition: FairRun.h:122
virtual void StoreTaskNames(const FairTask *t)
Definition: FairRun.cxx:76
Bool_t IsRunInfoGenerated()
Definition: FairRun.h:137
TString GetOptions()
Definition: FairRun.h:149
void MarkFill(Bool_t flag)
Definition: FairRun.h:146
TString fOptions
Definition: FairRun.h:199
FairSink * fSink
Definition: FairRun.h:195
FairRuntimeDb * GetRuntimeDb(void)
Definition: FairRun.h:80
Bool_t fMarkFill
Definition: FairRun.h:213
Bool_t fGenerateRunInfo
Definition: FairRun.h:209
virtual void AddTask(FairTask *t)
Definition: FairRun.cxx:70
TString fUserOutputFileName
Definition: FairRun.h:197
void SetUserOutputFileName(const TString &name)
Definition: FairRun.cxx:177
UInt_t fRunId
Definition: FairRun.h:201
FairRuntimeDb * fRtdb
Definition: FairRun.h:189
Bool_t IsAna()
Definition: FairRun.h:109
virtual void SetTask(FairTask *t)
Definition: FairRun.cxx:91
FairTask * GetMainTask()
Definition: FairRun.h:118
virtual TString GetFileName()
Definition: FairSink.h:47
Int_t GetRunId()
Definition: FairRun.h:97