-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathFairFileSource.h
More file actions
181 lines (155 loc) · 6.65 KB
/
FairFileSource.h
File metadata and controls
181 lines (155 loc) · 6.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/********************************************************************************
* Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence (LGPL) version 3, *
* copied verbatim in the file "LICENSE" *
********************************************************************************/
//
// FairFileSource.h
// FAIRROOT
//
// Created by Mohammad Al-Turany on 08/02/14.
//
//
#ifndef __FAIRROOT__FairFileSource__
#define __FAIRROOT__FairFileSource__
#include "FairFileSourceBase.h"
#include <TArrayI.h>
#include <TChain.h>
#include <TF1.h>
#include <TFile.h>
#include <TFolder.h>
#include <TString.h>
#include <TTree.h>
#include <list>
#include <map>
#include <memory>
class FairEventHeader;
class FairFileHeader;
class FairMCEventHeader;
class FairFileSource : public FairFileSourceBase
{
public:
FairFileSource(TFile* f, const char* Title = "InputRootFile", UInt_t identifier = 0);
FairFileSource(const TString* RootFileName, const char* Title = "InputRootFile", UInt_t identifier = 0);
FairFileSource(const TString RootFileName, const char* Title = "InputRootFile", UInt_t identifier = 0);
// FairFileSource(const FairFileSource& file);
~FairFileSource() override = default;
Bool_t Init() override;
Int_t ReadEvent(UInt_t i = 0) override;
/**Check the maximum event number we can run to*/
Int_t CheckMaxEventNo(Int_t EvtEnd = 0) override;
/**Read the tree entry on one branch**/
void ReadBranchEvent(const char* BrName) override;
/**Read specific tree entry on one branch**/
void ReadBranchEvent(const char* BrName, Int_t Entry) override;
void FillEventHeader(FairEventHeader* feh) override;
/** Add a friend file (input) by name)*/
void AddFriend(TString FileName);
/**Add ROOT file to input, the file will be chained to already added files*/
void AddFile(TString FileName);
void AddFriendsToChain();
void PrintFriendList();
void CheckFriendChains();
void CreateNewFriendChain(TString inputFile, TString inputLevel);
TTree* GetInTree() { return fInChain->GetTree(); }
TChain* GetInChain() { return fInChain; }
[[deprecated("Use Close() function")]] void CloseInFile()
{
if (fRootFile != nullptr) {
fRootFile->Close();
}
}
void SetInTree(TTree* tempTree);
TFolder* GetBranchDescriptionFolder() { return fCbmroot; }
UInt_t GetEntries() { return fNoOfEntries; }
// TList* GetBranchNameList() {return fBranchNameList;}
void SetInputFile(TString name);
/** Set the repetition time of the beam when it can interact (beamTime) and when no interaction happen (gapTime).
* The total repetition time is beamTime + gapTime */
void SetBeamTime(Double_t beamTime, Double_t gapTime);
/** Set the min and max limit for event time in ns */
void SetEventTimeInterval(Double_t min, Double_t max);
/** Set the mean time for the event in ns */
void SetEventMeanTime(Double_t mean);
void SetEventTime();
Double_t GetDeltaEventTime();
void SetFileHeader(FairFileHeader* f) { fFileHeader = f; }
Double_t GetEventTime();
Bool_t ActivateObject(TObject** obj, const char* BrName) override;
Bool_t ActivateObjectAny(void**, const std::type_info&, const char*) override;
/**Set the status of the EvtHeader
*@param Status: True: The header was creatged in this session and has to be filled
FALSE: We use an existing header from previous data level
*/
void SetEvtHeaderNew(Bool_t Status) { fEvtHeaderIsNew = Status; }
Bool_t IsEvtHeaderNew() { return fEvtHeaderIsNew; }
/** Allow to disable the testing the file layout when adding files to a chain.
*/
void SetCheckFileLayout(Bool_t enable) { fCheckFileLayout = enable; }
/**Read one event from source to find out which RunId to use*/
Bool_t SpecifyRunId() override;
private:
/** Title of input source, could be input, background or signal*/
TString fInputTitle;
/** List of all files added with AddFriend */
std::list<TString> fFriendFileList; //!
std::list<TString> fInputChainList; //!
std::map<TString, TChain*> fFriendTypeList; //!
std::list<TString> fInputLevel; //!
std::map<TString, std::multimap<TString, TArrayI>> fRunIdInfoAll; //!
/**Input Chain */
TChain* fInChain;
/**Input Tree */
TTree* fInTree;
/**folder structure of output*/
TFolder* fCbmout;
/**folder structure of input*/
TFolder* fCbmroot;
/***/
UInt_t fSourceIdentifier;
/**No of Entries in this source*/
UInt_t fNoOfEntries;
/**Initialization flag, true if initialized*/
Bool_t IsInitialized;
FairFileSource(const FairFileSource&);
FairFileSource operator=(const FairFileSource&);
/** MC Event header */
FairMCEventHeader* fMCHeader; //!
/**Event Header*/
FairEventHeader* fEvtHeader; //!
/**File Header*/
FairFileHeader* fFileHeader; //!
/** This is true if the event time used, came from simulation*/
Bool_t fEventTimeInMCHeader; //!
/**This flag is true if the event header was created in this session
* otherwise it is false which means the header was created in a previous data
* level and used here (e.g. in the digi)
*/
Bool_t fEvtHeaderIsNew; //!
/** for internal use, to return the same event time for the same entry*/
UInt_t fCurrentEntryNo; //!
/** for internal use, to return the same event time for the same entry*/
UInt_t fTimeforEntryNo; //!
/** min time for one event (ns) */
Double_t fEventTimeMin; //!
/** max time for one Event (ns) */
Double_t fEventTimeMax; //!
/** Time of event since th start (ns) */
Double_t fEventTime; //!
/** Time of particles in beam (ns) */
Double_t fBeamTime; //!
/** Time without particles in beam (gap) (ns) */
Double_t fGapTime; //!
/** EventMean time used (P(t)=1/fEventMeanTime*Exp(-t/fEventMeanTime) */
Double_t fEventMeanTime; //!
/** used to generate random numbers for event time; */
std::unique_ptr<TF1> fTimeProb; //!
/** True if the file layout should be checked when adding files to a chain.
* Default value is true.
*/
Bool_t fCheckFileLayout; //!
ClassDefOverride(FairFileSource, 3);
};
#endif /* defined(__FAIRROOT__FairFileSource__) */