GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EvapLMOF.h
Go to the documentation of this file.
1 #ifndef GW_EVAPLMOF_H
2 #define GW_EVAPLMOF_H
3 
4 #ifndef ROOT_Rtypes
5 #include "Rtypes.h"
6 #endif
7 #ifndef GWS_BUFFER_H
8 #include "Buffer.h"
9 #endif
10 
11 #include <iostream>
12 #include <fstream>
13 #include <string>
14 #include <sstream>
15 #include <vector>
16 
17 class TLeaf;
18 
19 namespace Gw {
20 
90 class EvapLMOF
91 {
92 public:
94  enum Status { kEmpty, kGood, kEoE, kFail };
95 
97  static Short_t VERBOSE;
98 
99 public:
100  static const Short_t MAXCASCADE = 200;
101  static const Short_t MAXPARTICLES = 12; // because arrays start from 0 in C++ while 1 in fortran
102 
103 private:
104  // structure corresponding to the GLOB common
105  struct GLOBAL {
106  Int_t AC;
107  Int_t ZC;
108  Int_t NCASC;
109  Int_t MDIR;
110  Int_t JCASC;
111  Float_t ENER;
112  Float_t SIGMA;
113  Float_t VRC;
114  Int_t MAX_P;
115  };
116  // structure corresponding to the ID common
117  struct ID {
118  Short_t MG;
119  Float_t EE;
120  Float_t JE;
121  Float_t L;
122  Short_t Z;
123  Short_t N;
124  Short_t NUM;
125  Float_t WT;
126 
127  Bool_t FIS;
128  };
129  // structure corresponding to the DATA common
130  struct DATA {
131  Short_t MODE[MAXCASCADE];
132  Float_t EI[MAXCASCADE];
133  Float_t EP[MAXCASCADE];
134  Short_t JI[MAXCASCADE];
135  Short_t LP[MAXCASCADE];
136  Short_t MP[MAXCASCADE];
137  Short_t MUL[MAXPARTICLES];
138  Float_t ES[MAXPARTICLES];
139  Float_t DJ[MAXPARTICLES];
140  };
141  // structure corresponding to the KINMAT common (always filled unless idonly is set)
142  struct KINMAT {
143  Float_t V0[3];
144  Float_t VE[MAXCASCADE][3];
145  Float_t THETA[MAXCASCADE];
146  Float_t PHI[MAXCASCADE];
147  Short_t ZB;
148  Short_t AB;
149  Float_t ER;
150  Float_t EEJ[MAXCASCADE];
151  Float_t JF[MAXCASCADE];
152  };
153 
154 public:
155  friend EvapLMOF &idonly(EvapLMOF &reader) ;
156  friend EvapLMOF &full(EvapLMOF &reader) ;
157 
158 private:
159  Gws::Buffer *fHeader; // to identify the next record (Global or Id)
160 
161  Gws::Buffer *fGlobalRecord; // global record (one per run)
162  Gws::Buffer *fIdRecord; // id record (one per cascade)
163  Gws::Buffer *fDataRecord; // full cascade
164 
165 private:
166  struct GLOBAL fGlobal;
167  struct ID fId;
168  struct DATA fData;
169  struct KINMAT fKin;
170 
171 private:
172  Bool_t fIdOnly;
173 
174  TString fError;
175  TString fWarning;
176 
177 private:
178  void SetRecord(Gws::Memory::EEndian);
179 
180  Bool_t ReadGlobal();
181  Bool_t ReadId();
182  Bool_t ReadData();
183  void ReadHeader();
184 
185 private:
186  FILE *fInfile; // input stream
187 
188  Int_t fCurrent, fMaxFiles, fStatus; // current file number, max file number and current status
189 
190  std::vector<Double_t> fEventsRead; // total number of events read for each files
191  std::vector<std::string> fFileName; // name of each file
192 
193  std::string fPath; // path to reach input files
194 
195 public:
196  EvapLMOF();
197  ~EvapLMOF();
198 
200 
208  EvapLMOF &operator<< (EvapLMOF &(*pf)(EvapLMOF &)) { return (*pf)(*this); }
209 
211 
219  void AddFile(const char *fname) { std::string s = fname; fFileName.push_back(s); Double_t zero = 0.0; fEventsRead.push_back(zero); fMaxFiles++; }
220 
222  void SetPath(const char *path ="./") { fPath = path; }
223 
225  const std::vector<Double_t> &GetEventsRead() { return fEventsRead; }
226 
228 
232  void NextFile();
233 
235 
239  Bool_t NextEvent(UInt_t next = 0);
240 
242 
245  void Rewind();
246 
248 
251  void Scan(UInt_t start = 0, UInt_t end = 10);
252 
254  const GLOBAL &GetGlobal() { return fGlobal;}
256  const ID &GetId() { return fId; }
258  const DATA &GetData() { return fData; }
260  const KINMAT &GetKin() { return fKin; }
261 
263 
276  TLeaf *GetLeaf(const char *leafname = "no");
277 
279  void ShowCurrentEvent(std::ostream &out = std::cout);
280 
282 
286  void ShowCurrentConditions(std::ostream &out = std::cout);
287 
289  TString &GetError() { return fError; }
290 
292  TString &GetWarning() { return fWarning; }
293 };
294 inline EvapLMOF &idonly(EvapLMOF &reader) { reader.fIdOnly = true ; return reader; }
295 inline EvapLMOF &full(EvapLMOF &reader) { reader.fIdOnly = false ; return reader; }
296 }
297 #endif
298 
EEndian
The adjectives big-endian and little-endian refer to which bytes are most significant in multi-byte d...
Definition: Memory.h:59
void AddFile(const char *fname)
to add an input (pax) file
Definition: EvapLMOF.h:219
friend EvapLMOF & full(EvapLMOF &reader)
Definition: EvapLMOF.h:295
Status
Reading status.
Definition: EvapLMOF.h:94
void ShowCurrentEvent(std::ostream &out=std::cout)
The show the content of the current event on the standard ouput.
Definition: EvapLMOF.cpp:256
Interface to read/decode EvapOR List Mode Output Files (so-called .pax files)
Definition: EvapLMOF.h:90
#define AC
void Rewind()
To restart the data stream from the beginning.
Definition: EvapLMOF.cpp:555
EvapLMOF & full(EvapLMOF &reader)
Definition: EvapLMOF.h:295
void ShowCurrentConditions(std::ostream &out=std::cout)
The current status is shown on the standard ouptut.
Definition: EvapLMOF.cpp:242
TLeaf * GetLeaf(const char *leafname="no")
To get a ROOT leaf corresponding to one of the variable.
Definition: EvapLMOF.cpp:633
friend EvapLMOF & idonly(EvapLMOF &reader)
Definition: EvapLMOF.h:294
void SetPath(const char *path="./")
set the directory where to find the input files
Definition: EvapLMOF.h:222
void Scan(UInt_t start=0, UInt_t end=10)
To scan events and show them on the standard output.
Definition: EvapLMOF.cpp:615
A buffer is used to read/write raw data buffers from/on files.
Definition: Buffer.h:43
#define MP
const DATA & GetData()
To get the current data structure.
Definition: EvapLMOF.h:258
TString & GetError()
To get the last error.
Definition: EvapLMOF.h:289
Int_t Z[3000]
const GLOBAL & GetGlobal()
To get the current global structure.
Definition: EvapLMOF.h:254
const std::vector< Double_t > & GetEventsRead()
it returns an array with the number of events read from all the input files
Definition: EvapLMOF.h:225
void NextFile()
switch to next file.
Definition: EvapLMOF.cpp:343
const ID & GetId()
To get the current id structure.
Definition: EvapLMOF.h:256
static const Short_t MAXPARTICLES
Definition: EvapLMOF.h:101
static Short_t VERBOSE
Set verbosity level.
Definition: EvapLMOF.h:97
EvapLMOF & operator<<(EvapLMOF &(*pf)(EvapLMOF &))
to modified the reading
Definition: EvapLMOF.h:208
const KINMAT & GetKin()
To get the current kinematic structure.
Definition: EvapLMOF.h:260
EvapLMOF & idonly(EvapLMOF &reader)
Definition: EvapLMOF.h:294
Bool_t NextEvent(UInt_t next=0)
To load the next event.
Definition: EvapLMOF.cpp:572
header file for Buffer.cpp
TString & GetWarning()
To get the last warning.
Definition: EvapLMOF.h:292
static const Short_t MAXCASCADE
Definition: EvapLMOF.h:100