EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairRootManager.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairRootManager.h
1 #ifndef FAIR_ROOT_MANAGER_H
2 #define FAIR_ROOT_MANAGER_H
3 
4 #include "TObject.h"
5 #include "TString.h"
6 #include "TArrayI.h"
7 #include "TObjArray.h"
8 #include "TFile.h"
9 #include "TChain.h"
10 #include <map>
11 #include <list>
12 #include <queue>
13 
14 class FairGeoNode;
15 class FairFileHeader;
16 class FairMCEventHeader;
17 class FairEventHeader;
18 class FairFileHeader;
19 class FairLogger;
21 class BinaryFunctor;
22 class FairWriteoutBuffer;
23 class FairLink;
24 class TCollection;
25 class TClonesarray;
26 class TFolder;
27 class TTree;
28 class TNamed;
29 class TBranch;
30 class TList;
31 class TF1;
32 
33 
41 //_____________________________________________________________________
42 
43 class FairRootManager : public TObject
44 {
45  public:
49  virtual ~FairRootManager();
50  void AddSignalFile(TString name, UInt_t identifier );
52  void AddBackgroundFile(TString name);
53  void AddFile(TString name);
54  void AddFriend(TString Name);
55  void AddFriendsToChain();
56 
57  Bool_t AllDataProcessed();
58 
65  Int_t CheckBranch(const char* BrName);
66 
67  void CloseInFile() { if(fInFile) { fInFile->Close(); }}
68 
69  void CloseOutFile() { if(fOutFile) { fOutFile->Close(); }}
71  void CreateGeometryFile(const char* geofile);
72  Bool_t DataContainersEmpty();
73  Bool_t DataContainersFilled();
74  void Fill();
75  void ForceFill();
76  void LastFill();
77  TClonesArray* ForceGetDataContainer(TString branchName);
78  TClonesArray* GetEmptyTClonesArray(TString branchName);
79  TClonesArray* GetTClonesArray(TString branchName);
80  TClonesArray* GetDataContainer(TString branchName);
82  TString GetBranchName(Int_t id);
84  Int_t GetBranchId(TString BrName);
87 
88  TTree* GetInTree() {return fInChain->GetTree();}
89  TChain* GetInChain() {return fInChain;}
90  TChain* GetBGChain() { return fBackgroundChain;}
91  TChain* GetSignalChainNo(UInt_t i);
92  TTree* GetOutTree() {return fOutTree;}
93  TFile* GetInFile() {return fInFile;}
94  TFile* GetOutFile() {return fOutFile;}
100  FairGeoNode* GetGeoParameter(const char* detname, const char* gname);
102  TObject* GetObject(const char* BrName);
104  TObject* GetObjectFromInTree(const char* BrName);
105  Double_t GetEventTime();
107  TObject* GetCloneOfLinkData(const FairLink link);
114  TClonesArray* GetCloneOfTClonesArray(const FairLink link);
115 
116  TClonesArray* GetData(TString branchName, BinaryFunctor* function, Double_t parameter);
117  TClonesArray* GetData(TString branchName, BinaryFunctor* startFunction, Double_t startParameter, BinaryFunctor* stopFunction, Double_t stopParameter);
118  void RegisterTSBuffer(TString branchName, FairTSBufferFunctional* functionalBuffer) {fTSBufferMap[branchName] = functionalBuffer;}
119  FairTSBufferFunctional* GetTSBuffer(TString branchName) {return fTSBufferMap[branchName];}
120 
122  static FairRootManager* Instance();
123 
124  Bool_t OpenInChain();
125 
127  Bool_t OpenInTree();
128 
129  Bool_t OpenBackgroundChain();
130  Bool_t OpenSignalChain();
131  TFile* OpenOutFile(const char* fname="cbmsim.root");
132  TFile* OpenOutFile(TFile* f);
134  void ReadBKEvent(Int_t i);
135  void ReadEvent(Int_t i);
137  Bool_t ReadNextEvent(Double_t dt);
143  void Register(const char* name, const char* Foldername, TNamed* obj, Bool_t toFile);
149  void Register(const char* name,const char* Foldername ,TCollection* obj, Bool_t toFile);
150 
151  TClonesArray* Register(TString branchName, TString className, TString folderName, Bool_t toFile);
155  void RunWithTimeStamps() {fTimeStamps = kTRUE;}
156 
161  void SetSignalFile(TString name, UInt_t identifier );
163  void SetBackgroundFile(TString name);
173  void SetEvtHeaderNew(Bool_t Status) {fEvtHeaderIsNew = Status;}
174  Bool_t IsEvtHeaderNew() {return fEvtHeaderIsNew;}
175 
177  void SetBranchNameList(TList* list);
178  void SetCompressData(Bool_t val) {fCompressData = val;}
180  void SetInputFile(TString name);
181 
183  void SetInTree (TTree* tempTree) {fInTree = NULL; fInTree = tempTree;}
184 
186  void SetOutTree(TTree* fTree) { fOutTree=fTree;}
187 
189  void SetLastFill(Bool_t val = kTRUE) { fFillLastData=val;}
193  void TruncateBranchNames(TBranch* b, TString ffn);
197  void TruncateBranchNames(TTree* fTree, const char* folderName);
198 
199  void Write();
201  void WriteGeometry();
205  void WriteFolder() ;
207  void SetEventTimeInterval(Double_t min, Double_t max);
209  void SetEventMeanTime(Double_t mean);
210  void SetEventTime();
212 
217  void BGWindowWidthNo(UInt_t background, UInt_t Signalid);
222  void BGWindowWidthTime(Double_t background, UInt_t Signalid);
223 
225  Int_t CheckMaxEventNo(Int_t EvtEnd=0);
226 
227 
228  void StoreWriteoutBufferData(Double_t eventTime);
231 
232  Int_t GetEntryNr() {return fEntryNr;}
233  void SetEntryNr(Int_t val) {fEntryNr = val;}
234 
235  void AddMoCaLookupEntry(unsigned id, TClonesArray *ptr) { mMoCaLookup[id] = ptr; };
236  void AddDigiLookupEntry(unsigned id, TClonesArray *ptr) { mDigiLookup[id] = ptr; };
237  TClonesArray *GetMoCaLookup(unsigned id) {
238  if (mMoCaLookup.find(id) == mMoCaLookup.end()) return 0;
239  return mMoCaLookup[id];
240  };
241  TClonesArray *GetDigiLookup(unsigned id) {
242  if (mDigiLookup.find(id) == mDigiLookup.end()) return 0;
243  return mDigiLookup[id];
244  };
245 
246  private:
252  TObject* ActivateBranch(const char* BrName);
253  TObject* ActivateBranchInInTree(const char* BrName);
254  void AddFriends( );
256  void AddMemoryBranch(const char*, TObject* );
257  void AssignTClonesArrays();
258  void AssignTClonesArray(TString branchName);
265  Int_t CheckBranchSt(const char* BrName);
266  void CheckFriendChains();
267  Bool_t CompareBranchList(TFile* fileHandle, TString inputLevel);
268  void CreateNewFriendChain(TString inputFile, TString inputLevel);
270  void CreatePerMap();
271  TObject* GetMemoryBranch( const char* );
272  void GetRunIdInfo(TString fileName, TString inputLevel);
273  void PrintFriendList();
274  void SaveAllContainers();
276  void ReadMixedEvent(Int_t i);
277  FairWriteoutBuffer* GetWriteoutBuffer(TString branchName);
278  Int_t fOldEntryNr;
279 //_____________________________________________________________________
282  TFolder* fCbmout;
284  TFolder* fCbmroot;
286  Double_t fCurrentTime;
288  TFile* fInFile;
290  TChain* fInChain;
292  TTree* fInTree;
294  TFile* fOutFile;
296  TTree* fOutTree;
298  TObjArray fListFolder;
300  Int_t fNObj;
301  std::map < TString , TObject* > fMap;
302  TTree* fPtrTree;
304 
310 
311  std::map<TString, std::queue<TClonesArray*> > fDataContainer;
313  std::map<TString, TClonesArray*> fActiveContainer;
315  std::map<TString, FairTSBufferFunctional*> fTSBufferMap;
316  std::map<TString, FairWriteoutBuffer* > fWriteoutBufferMap;
317  std::map<Int_t, TBranch*> fInputBranchMap;
318 
322  Bool_t fTimeStamps;
326  std::map < TString , Int_t > fBrPerMap;
327 
328  std::map < TString, Int_t>::iterator fBrPerMapIter;
330  std::list<TString> fFriendFileList;
331 
332  TString fInputFileName;
333  std::list<TString> fInputChainList;
334  std::map<TString, TChain*> fFriendTypeList;
335 
336  std::map<TString, std::list<TString>* > fCheckInputBranches;
337  std::list<TString> fInputLevel;
338  std::map<TString, std::multimap<TString, TArrayI> > fRunIdInfoAll;
339 
341 
342  Bool_t fMixedInput;
343 
345 
346  UInt_t fNoOfSignals;
347 
348  std::list<TString>* fSignalChainList;
349 
352  std::map<UInt_t, TChain*> fSignalTypeList;
353 
355  Double_t fEventTimeMin;
356 
357  Double_t fEventTimeMax;
358 
359  Double_t fEventTime;
360 
361  Double_t fEventMeanTime;
362 
363  TF1* fTimeProb;
364 
366 
369 
372 
374  std::map<UInt_t, Double_t> fSignalBGN;
375 
377 
378  Bool_t fSBRatiobyN;
379 
380  Bool_t fSBRatiobyT;
381 
383 
385 
386  UInt_t fNoOfBGEntries;
387 
388  std::map<UInt_t, UInt_t> fCurrentEntry;
389 
394  Bool_t fFillLastData;
395  Int_t fEntryNr;
396 
397  // Lookup tables, which allow one to access MC point and digi hit arrays
398  // by using digitized hits branch ID;
399  std::map<unsigned, TClonesArray*> mMoCaLookup, mDigiLookup;
400 
401  ClassDef(FairRootManager,7) // Root IO manager
402 };
403 
404 
405 
406 #endif //FAIR_ROOT_MANAGER_H
407 
408