Diana Software
QGFileHandler.hh
Go to the documentation of this file.
1 #ifndef _QG_FILE_HANDLER_HH_
2 #define _QG_FILE_HANDLER_HH_
3 
11 #include <map>
12 #include <set>
13 #include <string>
14 
15 #ifndef WIN32
16  #include <time.h>
17 #endif
18 
19 #include <vector>
20 #include "QSampleInfo.hh"
21 #include "QVector.hh"
22 #include <TCut.h>
23 #include <TEventList.h>
24 
25 class QChain;
26 class QChannelRunData;
27 class QRunData;
28 class TFile;
29 class QHeader;
30 class QPulseInfo;
31 namespace Diana {class QGlobalDataManager;}
32 
33 
34 class QGFileHandler {
35 public:
37  QGFileHandler();
38 
40  virtual ~QGFileHandler();
41 
43  bool CheckForModifiedFiles();
44 
46  void CloseFiles();
47 
49  void GetEvent(const Long64_t eventNumber, const std::string& samplesName = "");
50 
52  TEventList GetEventList(TCut cuts);
53 
55  std::vector<std::string> GetFilenames() {return fFilenames;}
56 
58  const QSampleInfo& GetMasterSample(const Long64_t eventNumber);
59 
61  const Diana::QVector& GetPulse(const Long64_t eventNumber, const std::string& samplesName);
62 
63  TObject* GetGenericObject(const Long64_t eventNumber, const std::string& samplesName);
64 
66  const QChannelRunData* GetChannelRunData(const Long64_t eventNumber);
67 
69  const QRunData* GetRunData(const Long64_t eventNumber);
70 
72  QChain *GetQChain() {return fQChain;}
73 
75  std::set<std::string> GetSetOfAliases();
76 
78  std::set<std::string> GetSetOfQVectorAliases();
79 
81  std::set<std::string> GetSetOfLeaves();
82 
84  std::set<std::string> GetSetOfQVectorLeaves();
85 
87  std::string GetDefaultPulseLabel() const { return fDefaultPulseLabel; }
88 
90  const std::vector<QSampleInfo>& GetSignificantSamples(const Long64_t eventNumber);
91 
93  std::string GetTreeClass() {return fTreeClass;}
94 
96  bool IsFileOpen() {return fFileOpen;}
97 
99  void ListOpenFiles();
100 
102  void OpenFile();
103 
105  void OpenFile(std::string filename);
106 
108  void OpenFiles(const std::vector<std::string>& files);
109 
111  void ParseFileList(const std::string& filename);
112 
113 protected:
114 
115 #ifndef WIN32
117  time_t ModificationTime(const std::string& filename);
118 #else
119  int ModificationTime(const std::string& filename)
120  {return 0;}
121 #endif
122 
124  void ReopenFiles();
125 
127  void SetLowestStartTimeUnix(const std::string& treeName);
128 
130  void SetUpChain();
131 
133  void SetUpNumericTypes();
134 
136  std::string fDataDirectory;
137 
139  TEventList fEventList;
140 
142  TFile *fFile;
143 
145  std::vector<std::string> fFilenames;
146 
148  bool fFileOpen;
149 
152 
153 #ifndef WIN32
155  std::map<std::string, time_t> fModificationTime;
156 #else
157  std::map<std::string, int> fModificationTime;
158 #endif
159 
161  std::set<std::string> fNumericTypes;
162 
164  Diana::QVector fDefaultPulse;
165 
169 
172 
174  std::string fTreeClass;
175 
177  Diana::QVector fSamples;
178  TObject* fGenericObject;
179 
180  Diana::QGlobalDataManager* fDataManager;
181 
183  std::string fDefaultPulseLabel;
184 
185 
186  ClassDef(QGFileHandler, 0)
187 };
188 
189 #endif
TChain used in diana.
Definition: QChain.hh:23
basic channel and run based info. Used in the QRunData object.
Class to handle ROOT files.
time_t ModificationTime(const std::string &filename)
Return modification time of file.
Diana::QGlobalDataManager * fDataManager
std::set< std::string > GetSetOfQVectorAliases()
Get the aliases defined in the tree.
double fLowestStartTimeUnix
Lowest StartTimeUnix of open files.
std::set< std::string > GetSetOfLeaves()
Get the names of the leaves of the tree.
bool fFileOpen
File open flag.
Diana::QVector fSamples
samples (QVector or QVectorI or QPulse) to load
void OpenFile(std::string filename)
Open a new file, add it to the chain.
std::set< std::string > GetSetOfAliases()
Get the aliases defined in the tree.
const QRunData * GetRunData(const Long64_t eventNumber)
Get the run data for an event.
std::string fDataDirectory
Directory containing data files.
const QChannelRunData * GetChannelRunData(const Long64_t eventNumber)
Get the run data for an event.
const Diana::QVector & GetPulse(const Long64_t eventNumber, const std::string &samplesName)
Get the pulse of an event.
bool CheckForModifiedFiles()
Check whether any open file has been modified.
TEventList GetEventList(TCut cuts)
Get an event list containing the events passing a cut.
std::set< std::string > fNumericTypes
Collection of numeric data types.
void SetUpChain()
Set up the chain.
std::vector< std::string > fFilenames
Filenames.
QHeader * fHeader
QBaseEvent.
std::string fTreeClass
Name of tree's class.
bool IsFileOpen()
Check whether a file is open.
void OpenFile()
Pop up a file open dialog.
TObject * GetGenericObject(const Long64_t eventNumber, const std::string &samplesName)
QPulseInfo * fPulseInfo
void ParseFileList(const std::string &filename)
Parse file list.
std::string GetDefaultPulseLabel() const
Get the names of the leaves of the tree.
void ReopenFiles()
Reopen files.
void SetUpNumericTypes()
Specify the numeric data types.
Diana::QVector fDefaultPulse
Default (empty) pulse, for use when opening a non-Diana file.
QChain * fQChain
QChain.
std::set< std::string > GetSetOfQVectorLeaves()
Get the names of the leaves of the tree.
std::vector< std::string > GetFilenames()
Get a vector containing the names of the open files.
const std::vector< QSampleInfo > & GetSignificantSamples(const Long64_t eventNumber)
Get significant samples of an event.
std::string fDefaultPulseLabel
defalt label of samples to load
TObject * fGenericObject
const QSampleInfo & GetMasterSample(const Long64_t eventNumber)
Get master sample of an event.
void SetLowestStartTimeUnix(const std::string &treeName)
Set LowestStartTimeUnix alias.
void GetEvent(const Long64_t eventNumber, const std::string &samplesName="")
Get an event.
void ListOpenFiles()
Print a list of open files to the console.
virtual ~QGFileHandler()
Destructor.
std::map< std::string, time_t > fModificationTime
Modification times of every open file.
QGFileHandler()
Constructor.
QChain * GetQChain()
Get a pointer to the chian.
void CloseFiles()
Close all open files, empty the chain.
TEventList fEventList
Event list.
void OpenFiles(const std::vector< std::string > &files)
Open files, add them to the chain.
TFile * fFile
ROOT file.
std::string GetTreeClass()
Get the class name of the tree.
Object to manage I/O (DB, file, or memory) of diana global quantities.
Raw event: basic information like run number and time.
Definition: QHeader.hh:16
Raw event: bolometer channel, trigger positions and types.
Definition: QPulseInfo.hh:18
Basic run based info.
Definition: QRunData.hh:20
contains information on flagged samples
Definition: QSampleInfo.hh:24
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...