FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairFileSource.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 //
9 // FairFileSource.h
10 // FAIRROOT
11 //
12 // Created by Mohammad Al-Turany on 08/02/14.
13 //
14 //
15 
16 #ifndef __FAIRROOT__FairFileSource__
17 #define __FAIRROOT__FairFileSource__
18 
19 #include "FairSource.h"
20 
21 #include <TArrayI.h>
22 #include <TChain.h>
23 #include <TFile.h>
24 #include <TFolder.h>
25 #include <TString.h>
26 #include <list>
27 #include <map>
28 
29 class FairEventHeader;
30 class FairFileHeader;
31 class FairMCEventHeader;
32 class FairRuntimeDb;
33 class TF1;
34 class TTree;
35 
36 class FairFileSource : public FairSource
37 {
38  public:
39  FairFileSource(TFile* f, const char* Title = "InputRootFile", UInt_t identifier = 0);
40  FairFileSource(const TString* RootFileName, const char* Title = "InputRootFile", UInt_t identifier = 0);
41  FairFileSource(const TString RootFileName, const char* Title = "InputRootFile", UInt_t identifier = 0);
42  // FairFileSource(const FairFileSource& file);
43  virtual ~FairFileSource();
44 
45  Bool_t Init();
46  Int_t ReadEvent(UInt_t i = 0);
47  void Close();
48  void Reset();
49 
50  virtual Source_Type GetSourceType() { return kFILE; }
51 
52  virtual void SetParUnpackers() {}
53 
54  virtual Bool_t InitUnpackers() { return kTRUE; }
55 
56  virtual Bool_t ReInitUnpackers() { return kTRUE; }
57 
59  virtual Int_t CheckMaxEventNo(Int_t EvtEnd = 0);
61  virtual void ReadBranchEvent(const char* BrName);
63  virtual void ReadBranchEvent(const char* BrName, Int_t Entry);
64  virtual void FillEventHeader(FairEventHeader* feh);
65 
66  const TFile* GetRootFile() { return fRootFile; }
68  void AddFriend(TString FileName);
70  void AddFile(TString FileName);
71  void AddFriendsToChain();
72  void PrintFriendList();
73  Bool_t CompareBranchList(TFile* fileHandle, TString inputLevel);
74  void CheckFriendChains();
75  void CreateNewFriendChain(TString inputFile, TString inputLevel);
76  TTree* GetInTree() { return fInChain->GetTree(); }
77  TChain* GetInChain() { return fInChain; }
78  TFile* GetInFile() { return fRootFile; }
79  void CloseInFile()
80  {
81  if (fRootFile) {
82  fRootFile->Close();
83  }
84  }
86  void SetInTree(TTree* tempTree);
87  TObjArray* GetListOfFolders() { return fListFolder; }
88  TFolder* GetBranchDescriptionFolder() { return fCbmroot; }
89  UInt_t GetEntries() { return fNoOfEntries; }
90 
91  // TList* GetBranchNameList() {return fBranchNameList;}
92 
93  void SetInputFile(TString name);
94 
97  void SetBeamTime(Double_t beamTime, Double_t gapTime);
99  void SetEventTimeInterval(Double_t min, Double_t max);
101  void SetEventMeanTime(Double_t mean);
102  void SetEventTime();
103  Double_t GetDeltaEventTime();
104  void SetFileHeader(FairFileHeader* f) { fFileHeader = f; }
105  Double_t GetEventTime();
106 
107  virtual Bool_t ActivateObject(TObject** obj, const char* BrName);
108  virtual Bool_t ActivateObjectAny(void**, const std::type_info&, const char*);
109 
114  void SetEvtHeaderNew(Bool_t Status) { fEvtHeaderIsNew = Status; }
115  Bool_t IsEvtHeaderNew() { return fEvtHeaderIsNew; }
116 
119  void SetCheckFileLayout(Bool_t enable) { fCheckFileLayout = enable; }
120 
122  Bool_t SpecifyRunId();
123 
124  private:
126  TString fInputTitle;
128  TFile* fRootFile;
130  Int_t fCurrentEntryNr;
131 
132  std::list<TString> fFriendFileList;
133  std::list<TString> fInputChainList;
134  std::map<TString, TChain*> fFriendTypeList;
135  std::map<TString, std::list<TString>*> fCheckInputBranches;
136  std::list<TString> fInputLevel;
137  std::map<TString, std::multimap<TString, TArrayI>> fRunIdInfoAll;
138 
139  TChain* fInChain;
141  TTree* fInTree;
143  TObjArray* fListFolder;
144 
145  FairRuntimeDb* fRtdb;
147  TFolder* fCbmout;
149  TFolder* fCbmroot;
150  /***/
151  UInt_t fSourceIdentifier;
153  UInt_t fNoOfEntries;
155  Bool_t IsInitialized;
156 
158  FairFileSource operator=(const FairFileSource&);
159 
161  FairMCEventHeader* fMCHeader;
162 
164  FairEventHeader* fEvtHeader;
165 
167  FairFileHeader* fFileHeader;
168 
170  Bool_t fEventTimeInMCHeader;
171 
175  Bool_t fEvtHeaderIsNew;
176 
178  UInt_t fCurrentEntryNo;
179 
180  UInt_t fTimeforEntryNo;
181 
183  Double_t fEventTimeMin;
184 
185  Double_t fEventTimeMax;
186 
187  Double_t fEventTime;
188 
189  Double_t fBeamTime;
190 
191  Double_t fGapTime;
192 
193  Double_t fEventMeanTime;
194 
195  TF1* fTimeProb;
196 
199  Bool_t fCheckFileLayout;
200 
201  ClassDef(FairFileSource, 3);
202 };
203 
204 #endif /* defined(__FAIRROOT__FairFileSource__) */
virtual Source_Type GetSourceType()
void SetBeamTime(Double_t beamTime, Double_t gapTime)
void AddFile(TString FileName)
virtual Int_t CheckMaxEventNo(Int_t EvtEnd=0)
list of container factories
Definition: FairRuntimeDb.h:24
Bool_t IsEvtHeaderNew()
void SetInTree(TTree *tempTree)
TFile * GetInFile()
TFolder * GetBranchDescriptionFolder()
Int_t ReadEvent(UInt_t i=0)
UInt_t GetEntries()
Double_t GetEventTime()
virtual void SetParUnpackers()
const TString FileName
virtual void FillEventHeader(FairEventHeader *feh)
virtual Bool_t ActivateObjectAny(void **, const std::type_info &, const char *)
void SetFileHeader(FairFileHeader *f)
void SetInputFile(TString name)
Source_Type
Definition: FairSource.h:26
virtual Bool_t InitUnpackers()
virtual Bool_t ActivateObject(TObject **obj, const char *BrName)
virtual void ReadBranchEvent(const char *BrName)
FairFileSource(TFile *f, const char *Title="InputRootFile", UInt_t identifier=0)
TObjArray * GetListOfFolders()
void SetCheckFileLayout(Bool_t enable)
virtual ~FairFileSource()
Double_t GetDeltaEventTime()
void CreateNewFriendChain(TString inputFile, TString inputLevel)
void AddFriend(TString FileName)
Bool_t CompareBranchList(TFile *fileHandle, TString inputLevel)
void SetEvtHeaderNew(Bool_t Status)
TChain * GetInChain()
virtual Bool_t ReInitUnpackers()
TTree * GetInTree()
void SetEventMeanTime(Double_t mean)
void SetEventTimeInterval(Double_t min, Double_t max)
const TFile * GetRootFile()