BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnFileSource.h
Go to the documentation of this file.
1// -------------------------------------------------------------------------
2// ----- BmnFileSource header file -----
3// -------------------------------------------------------------------------
4/** BmnFileSource.h
5 *@author Created by Mohammad Al-Turany. Modified by Konstantin Gertsenberger <gertsen@jinr.ru>
6 **
7 ** Class presents a source inherited from FairFileSourceBase to work with BmnRoot data in ROOT files
8 **/
9
10#ifndef BMNFILESOURCE_H
11#define BMNFILESOURCE_H
12
13#include "FairEventHeader.h"
14#include "FairFileHeader.h"
15#include "FairFileSourceBase.h"
16#include "FairMCEventHeader.h"
17
18#include <TArrayI.h>
19#include <TChain.h>
20#include <TF1.h>
21#include <TFile.h>
22#include <TFolder.h>
23#include <TString.h>
24#include <TTree.h>
25#include <list> // for _List_iterator, list, etc
26#include <map> // multimap
27#include <memory>
28
30{
31 public:
32 BmnFileSource(TFile* f, const char* Title = "InputRootFile", UInt_t identifier = 0);
33 BmnFileSource(const TString* RootFileName, const char* Title = "InputRootFile", UInt_t identifier = 0);
34 BmnFileSource(const TString RootFileName, const char* Title = "InputRootFile", UInt_t identifier = 0);
35 BmnFileSource(const TString RootFileName, int& period_number, int& run_number);
36 // BmnFileSource(const BmnFileSource& file);
37 ~BmnFileSource() override;
38
39 Bool_t Init() override;
40 Int_t ReadEvent(UInt_t i = 0) override;
41 void Close() override;
42
43 /**Check the maximum event number we can run to*/
44 Int_t CheckMaxEventNo(Int_t EvtEnd = 0) override;
45 /**Read the tree entry on one branch**/
46 void ReadBranchEvent(const char* BrName) override;
47 /**Read specific tree entry on one branch**/
48 void ReadBranchEvent(const char* BrName, Int_t Entry) override;
49 void FillEventHeader(FairEventHeader* feh) override;
50
51 const TFile* GetRootFile() { return fRootFile; }
52 /** Add a friend file (input) by name)*/
53 void AddFriend(TString FileName);
54 /**Add ROOT file to input, the file will be chained to already added files*/
55 void AddFile(TString FileName);
56 void AddFriendsToChain();
57 void PrintFriendList();
58 void CheckFriendChains();
59 void CreateNewFriendChain(TString inputFile, TString inputLevel);
60 TTree* GetInTree() { return fInChain->GetTree(); }
61 TChain* GetInChain() { return fInChain; }
62 TFile* GetInFile() { return fRootFile; }
64 {
65 if (fRootFile) {
66 fRootFile->Close();
67 }
68 }
69 void SetInTree(TTree* tempTree);
73
74 // TList* GetBranchNameList() {return fBranchNameList;}
75
76 void SetInputFile(TString name);
77
78 /** Set the repetition time of the beam when it can interact (beamTime) and when no interaction happen (gapTime).
79 * The total repetition time is beamTime + gapTime */
80 void SetBeamTime(Double_t beamTime, Double_t gapTime);
81 /** Set the min and max limit for event time in ns */
83 /** Set the mean time for the event in ns */
84 void SetEventMeanTime(Double_t mean);
85 void SetEventTime();
87 void SetFileHeader(FairFileHeader* f) { fFileHeader = f; }
89
90 Bool_t ActivateObject(TObject** obj, const char* BrName) override;
91 Bool_t ActivateObjectAny(void**, const std::type_info&, const char*) override;
92
93 /**Set the status of the EvtHeader
94 *@param Status: True: The header was creatged in this session and has to be filled
95 FALSE: We use an existing header from previous data level
96 */
97 void SetEvtHeaderNew(Bool_t Status) { fEvtHeaderIsNew = Status; }
99
100 /** Allow to disable the testing the file layout when adding files to a chain.
101 */
102 void SetCheckFileLayout(Bool_t enable) { fCheckFileLayout = enable; }
103
104 /**Read one event from source to find out which RunId to use*/
105 Bool_t SpecifyRunId() override;
106
107 /** Get period and run numbers extracted while the class construction if exist */
108 void GetRunNumber(int& period_number, int& run_number);
109 /** Get input file type (data level): 0 - EXP DIGI, 1 - EXP DST, 10 - SIM DIGI, 11 - SIM DST, <0 - errors */
111
112 private:
113 /** Title of input source, could be input, background or signal*/
115 /**ROOT file*/
117 /** List of all files added with AddFriend */
118 std::list<TString> fFriendFileList; //!
119 std::list<TString> fInputChainList; //!
120 std::map<TString, TChain*> fFriendTypeList; //!
121 std::list<TString> fInputLevel; //!
122 std::map<TString, std::multimap<TString, TArrayI>> fRunIdInfoAll; //!
123 /**Input Chain */
125 /**Input Tree */
127 /** list of folders from all input (and friends) files*/
129 /**folder structure of output*/
131 /**folder structure of input*/
133 /***/
135 /**No of Entries in this source*/
137 /**Initialization flag, true if initialized*/
139
142
143 /** MC Event header */
145
146 /**Event Header*/
148
149 /**File Header*/
150 FairFileHeader* fFileHeader; //!
151
152 /** This is true if the event time used, came from simulation*/
154 /**This flag is true if the event header was created in this session
155 * otherwise it is false which means the header was created in a previous data
156 * level and used here (e.g. in the digi)
157 */
159
160 /** for internal use, to return the same event time for the same entry*/
162 /** for internal use, to return the same event time for the same entry*/
164
165 /** min time for one event (ns) */
167 /** max time for one Event (ns) */
169 /** Time of event since th start (ns) */
171 /** Time of particles in beam (ns) */
173 /** Time without particles in beam (gap) (ns) */
175 /** EventMean time used (P(t)=1/fEventMeanTime*Exp(-t/fEventMeanTime) */
177 /** used to generate random numbers for event time; */
178 std::unique_ptr<TF1> fTimeProb; //!
179 /** True if the file layout should be checked when adding files to a chain.
180 * Default value is true.
181 */
183
184 /** function to extract period and run numbers in the class constructor if exist */
185 int ExtractRunNumber();
186 /** period number extracted in the class constructor if exists */
188 /** run number extracted in the class constructor if exists */
190 /** input file type (data level): 0 - EXP DIGI, 1 - EXP DST, 10 - SIM DIGI, 11 - SIM DST, <0 - errors */
192
194};
195
196#endif /* defined(BMNFILESOURCE_H) */
int i
Definition P4_F32vec4.h:22
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
Definition P4_F32vec4.h:30
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition P4_F32vec4.h:31
bool Bool_t
int Int_t
unsigned int UInt_t
double Double_t
#define ClassDefOverride(name, id)
void SetEvtHeaderNew(Bool_t Status)
Set the status of the EvtHeader.
std::map< TString, TChain * > fFriendTypeList
TChain * fInChain
Input Chain.
UInt_t fNoOfEntries
No of Entries in this source.
void SetBeamTime(Double_t beamTime, Double_t gapTime)
Set the repetition time of the beam when it can interact (beamTime) and when no interaction happen (g...
TFolder * fCbmout
folder structure of output
BmnFileSource(const BmnFileSource &)
BmnFileSource(TFile *f, const char *Title="InputRootFile", UInt_t identifier=0)
TTree * fInTree
Input Tree.
UInt_t fCurrentEntryNo
for internal use, to return the same event time for the same entry
Int_t CheckMaxEventNo(Int_t EvtEnd=0) override
Check the maximum event number we can run to.
Double_t fGapTime
Time without particles in beam (gap) (ns).
TObjArray * GetListOfFoldersBmn()
TFile * fRootFile
ROOT file.
void SetCheckFileLayout(Bool_t enable)
Allow to disable the testing the file layout when adding files to a chain.
void GetRunNumber(int &period_number, int &run_number)
Get period and run numbers extracted while the class construction if exist.
Bool_t SpecifyRunId() override
Read one event from source to find out which RunId to use.
std::list< TString > fFriendFileList
List of all files added with AddFriend.
void SetInputFile(TString name)
Bool_t ActivateObject(TObject **obj, const char *BrName) override
Double_t GetEventTime()
Bool_t fEvtHeaderIsNew
This flag is true if the event header was created in this session otherwise it is false which means t...
void SetEventTimeInterval(Double_t min, Double_t max)
Set the min and max limit for event time in ns.
void CreateNewFriendChain(TString inputFile, TString inputLevel)
int ExtractRunNumber()
function to extract period and run numbers in the class constructor if exist
Int_t fFileType
input file type (data level): 0 - EXP DIGI, 1 - EXP DST, 10 - SIM DIGI, 11 - SIM DST,...
TFolder * GetBranchDescriptionFolder()
TString fInputTitle
Title of input source, could be input, background or signal.
void SetInTree(TTree *tempTree)
std::map< TString, std::multimap< TString, TArrayI > > fRunIdInfoAll
FairEventHeader * fEvtHeader
Event Header.
TTree * GetInTree()
TFile * GetInFile()
Int_t GetFileType()
Get input file type (data level): 0 - EXP DIGI, 1 - EXP DST, 10 - SIM DIGI, 11 - SIM DST,...
BmnFileSource operator=(const BmnFileSource &)
void SetEventMeanTime(Double_t mean)
Set the mean time for the event in ns.
void SetFileHeader(FairFileHeader *f)
Bool_t Init() override
Double_t fEventTimeMax
max time for one Event (ns)
Double_t fEventMeanTime
EventMean time used (P(t)=1/fEventMeanTime*Exp(-t/fEventMeanTime).
std::unique_ptr< TF1 > fTimeProb
used to generate random numbers for event time;
UInt_t GetEntries()
TChain * GetInChain()
Double_t fEventTime
Time of event since th start (ns).
FairMCEventHeader * fMCHeader
MC Event header.
Int_t fPeriodNumber
period number extracted in the class constructor if exists
Bool_t fEventTimeInMCHeader
This is true if the event time used, came from simulation.
~BmnFileSource() override
Bool_t IsInitialized
Initialization flag, true if initialized.
void AddFriend(TString FileName)
Add a friend file (input) by name).
Bool_t IsEvtHeaderNew()
Int_t ReadEvent(UInt_t i=0) override
Bool_t ActivateObjectAny(void **, const std::type_info &, const char *) override
void Close() override
Bool_t fCheckFileLayout
True if the file layout should be checked when adding files to a chain.
std::list< TString > fInputLevel
const TFile * GetRootFile()
Double_t fBeamTime
Time of particles in beam (ns).
Int_t fRunNumber
run number extracted in the class constructor if exists
UInt_t fSourceIdentifier
void FillEventHeader(FairEventHeader *feh) override
Double_t fEventTimeMin
min time for one event (ns)
Double_t GetDeltaEventTime()
TFolder * fCbmroot
folder structure of input
void AddFile(TString FileName)
Add ROOT file to input, the file will be chained to already added files.
FairFileHeader * fFileHeader
File Header.
std::list< TString > fInputChainList
UInt_t fTimeforEntryNo
for internal use, to return the same event time for the same entry
void ReadBranchEvent(const char *BrName) override
Read the tree entry on one branch.
TObjArray fListFolderBmn
list of folders from all input (and friends) files