KaliVeda
Toolkit for HIC analysis
KVSimReader_ELIE.cpp
1 //Created by KVClassFactory on Sun Jan 20 13:31:10 2013
2 //Author: John Frankland,,,
3 
4 #include "KVSimReader_ELIE.h"
5 
7 
8 
9 
10 
11 
24 void KVSimReader_ELIE::define_output_filename()
25 {
26  // ROOT file called either
27  //
28  // ELIE_[PROJ]_[TARG]_[EBEAM]AMeV_PRIM.root
29  //
30  // or
31  //
32  // ELIE_[PROJ]_[TARG]_[EBEAM]AMeV_Run[xx...]_PRIM.root
33  //
34  // if run_number is defined
35  //
36  // Call after reading file header
37 
38  if (run_number >= 0)
39  SetROOTFileName(Form("ELIE_%s_%s_%.1fAMeV_Run%d_PRIM.root",
40  proj.GetSymbol(), targ.GetSymbol(), ebeam, run_number));
41  else
42  SetROOTFileName(Form("ELIE_%s_%s_%.1fAMeV_PRIM.root",
43  proj.GetSymbol(), targ.GetSymbol(), ebeam));
44  tree_title.Form("ELIE primary events %s + %s %.1f MeV/nuc.",
45  proj.GetSymbol(), targ.GetSymbol(), ebeam);
46 }
47 
48 
49 
52 
54 {
55  // transform all particle kinematics to CM frame from lab
56 
58  evt->ChangeFrame(compound.GetV(), "CM");
59 }
60 
61 
62 
65 
67 {
68  // Default constructor
69  init();
70 }
71 
72 
73 
74 
77 
79 {
80  // Read file
81  init();
83 }
84 
85 
86 
88 
90 {
91  if (!OpenFileToRead(filename)) return;
92  if (!ReadHeader()) return;
94  Run();
95  CloseFile();
96 }
97 
98 
99 
100 
102 
104 {
105  Info("ReadFile", "begins");
106  while (IsOK()) {
107  while (ReadEvent()) {
108  if (nevt && nevt % 1000 == 0) Info("ReadFile", "%d evts lus", nevt);
109  if (HasToFill()) FillTree();
110  }
111  }
112 }
113 
114 
115 
134 
136 {
137  // File header contains info on simulation
138  //
139  // 54 129 50 119 32
140  // 20000
141  // ievt=50
142  // projectile=Ni
143  // target=Au
144  // a_proj=58
145  // z_proj=28
146  // a_targ=197
147  // z_targ=79
148  // [...]
149  // geometry=0
150  // free_nucleon=0
151  // lambda_ex=1.3
152  //
153  // The simulation parameters are stored in a KVNameValueList
154 
155  auto res = ReadLineAndCheck(5, " ");
156  switch (res) {
158  Info("ReadHeader", "Can't read system");
159  return kFALSE;
161  AddInfo("Aproj", GetReadPar(1));
162  AddInfo("Zproj", GetReadPar(0));
163  AddInfo("Atarg", GetReadPar(3));
164  AddInfo("Ztarg", GetReadPar(2));
165  AddInfo("Ebeam", GetReadPar(4));
168  ebeam = GetDoubleReadPar(4);
169  break;
170  default:
171  return kFALSE;
172  }
173 
174  res = ReadLineAndCheck(1, " ");
175  switch (res) {
177  Info("ReadHeader", "Can't read events");
178  return kFALSE;
180  AddInfo("Nevents", GetReadPar(0));
181  break;
182 
183  default:
184  return kFALSE;
185  }
186  read_elie_params(*this);
187 
188  return kTRUE;
189 }
190 
191 
192 
194 
196 {
197  elie_params->Clear();
198  elie_params->SetName("ELIE Parameters");
199  auto res = input_file_reader.ReadLineAndCheck(2, "=");
200  while (res != KVFileReader::ReadStatus::EndOfFile) {
201  if (res == KVFileReader::ReadStatus::OK) {
202  if (input_file_reader.GetReadPar(1).IsDigit()) elie_params->SetValue(input_file_reader.GetReadPar(0), input_file_reader.GetIntReadPar(1));
203  else if (input_file_reader.GetReadPar(1).IsFloat()) elie_params->SetValue(input_file_reader.GetReadPar(0), input_file_reader.GetDoubleReadPar(1));
204  else elie_params->SetValue(input_file_reader.GetReadPar(0), input_file_reader.GetReadPar(1));
205  }
206  res = input_file_reader.ReadLineAndCheck(2, "=");
207  }
209 }
210 
211 
212 
226 
228 {
229  // Event structure: (primary events) -> OLD WAY, see bellow for recent ELIE calculations
230  // nevt multiplicite b reduit
231  // 0 2 0.998654688551
232  // particules dans l'evt
233  // indice_particule charge_particule masse_particule teta_particule(degres) phi_particule(degres) indice_particule energie d'excitation totale (MeV)
234  // 0 27 57 3.27897003986 230.52425244 1109.37002505 0 0.00499304975261
235  // 1 80 198 176.726338776 129.481056376 319.364098122 1 0.017344278088
236 
237  // nevt multiplicite b reduit
238  //1 11 0.665404278608
239  // indice_particule charge_particule masse_particule teta_particule(degres) phi_particule(degres) E(MeV) E*(MeV) L(hbar)
240  //0 21 45 2.49354294869 78.2453656442 2180.55536792 91.0936851491 1.0
241  //1 20 46 5.25547324063 79.8035650615 7.5872385507 93.1179892635 1.0
242 
243 
244  evt->Clear();
245 
246  // first line of first event will have been read already by ReadHeader,
247  // therefore we do not read a new line in this case (when nevt=0)
248  auto res = (nevt ? ReadLineAndCheck(3, " ") : ReuseLineAndCheck(3, " "));
249  Int_t mult = 0;
250  switch (res) {
253  return kFALSE;
256  mult = GetIntReadPar(1);
257  evt->GetParameters()->SetValue("bred", GetDoubleReadPar(2));
258  evt->GetParameters()->SetValue("mult", mult);
259  break;
260  default:
261  return kFALSE;
262  }
263  for (Int_t mm = 0; mm < mult; mm++) {
265  if (!ReadNucleus()) return kFALSE;
266  }
267  nevt++;
268 
269  // if in lab, transform to CM frame
270  if (elie_params->GetIntValue("lab_frame") > 0) transform_to_cm();
271  else evt->SetFrameName("CM");
272 
273  return kTRUE;
274 }
275 
276 
277 
291 
293 {
294  // Event structure: (primary events) -> OLD WAY, see bellow for recent ELIE calculations
295  // nevt multiplicite b reduit
296  // 0 2 0.998654688551
297  // particules dans l'evt
298  // indice_particule charge_particule masse_particule teta_particule(degres) phi_particule(degres) indice_particule energie d'excitation totale (MeV)
299  // 0 27 57 3.27897003986 230.52425244 1109.37002505 0 0.00499304975261
300  // 1 80 198 176.726338776 129.481056376 319.364098122 1 0.017344278088
301 
302  // nevt multiplicite b reduit
303  //1 11 0.665404278608
304  // indice_particule charge_particule masse_particule teta_particule(degres) phi_particule(degres) E(MeV) E*(MeV) L(hbar)
305  //0 21 45 2.49354294869 78.2453656442 2180.55536792 91.0936851491 1.0
306  //1 20 46 5.25547324063 79.8035650615 7.5872385507 93.1179892635 1.0
307 
308 
309 
310  auto res = ReadLineAndCheck(8, " ");
311  switch (res) {
313  Info("ReadNucleus", "case 0 line est vide");
314  return kFALSE;
315 
317  nuc->SetZ(GetIntReadPar(1));
318  nuc->SetA(GetIntReadPar(2));
323  if (nuc->GetExcitEnergy() > 0.) nuc->SetAngMom(GetDoubleReadPar(7), 0, 0);
324 
325  return kTRUE;
326  break;
327 
328  default:
329  return kFALSE;
330  }
331 
332  return kFALSE;
333 }
334 
335 
int Int_t
bool Bool_t
constexpr Bool_t kFALSE
constexpr Bool_t kTRUE
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
char * Form(const char *fmt,...)
virtual void SetNumber(UInt_t num)
Definition: KVBase.h:216
KVNameValueList * GetParameters() const
Definition: KVEvent.h:179
void Clear(Option_t *opt="")
Definition: KVEvent.h:238
Handle reading columns of numeric data in text files.
Definition: KVFileReader.h:120
@ EndOfFile
end of file reached
@ EmptyLine
last line read was empty (only whitespace)
@ OK
successful read and import of parameters from line
ReadStatus ReadLineAndCheck(Int_t nexpect, const KVString &pattern)
Definition: KVFileReader.h:278
void CloseFile()
Definition: KVFileReader.h:236
Double_t GetDoubleReadPar(Int_t pos) const
Definition: KVFileReader.h:333
Int_t GetIntReadPar(Int_t pos) const
Definition: KVFileReader.h:337
Bool_t IsOK()
Definition: KVFileReader.h:230
KVString GetReadPar(Int_t pos) const
Definition: KVFileReader.h:341
ReadStatus ReuseLineAndCheck(Int_t nexpect, const KVString &pattern)
Definition: KVFileReader.h:303
Bool_t OpenFileToRead(const KVString &filename)
Definition: KVFileReader.h:209
Int_t GetIntValue(const Char_t *name) const
void SetValue(const Char_t *name, value_type value)
virtual void Clear(Option_t *opt="")
Int_t GetEntries() const
Description of properties and kinematics of atomic nuclei.
Definition: KVNucleus.h:126
void SetExcitEnergy(Double_t e)
Definition: KVNucleus.cpp:868
Double_t GetExcitEnergy() const
Definition: KVNucleus.h:283
void SetA(Int_t a)
Definition: KVNucleus.cpp:658
void SetZ(Int_t z, Char_t mt=-1)
Definition: KVNucleus.cpp:707
void SetZandA(Int_t z, Int_t a)
Set atomic number and mass number.
Definition: KVNucleus.cpp:724
void SetZAandE(Int_t z, Int_t a, Double_t ekin)
Set atomic number, mass number, and kinetic energy in MeV.
Definition: KVNucleus.cpp:736
void SetTheta(Double_t theta)
Definition: KVParticle.h:693
void SetPhi(Double_t phi)
Definition: KVParticle.h:697
void SetEnergy(Double_t e)
Definition: KVParticle.h:599
Nucleus in a simulated event.
Definition: KVSimNucleus.h:32
void SetAngMom(Double_t lx, Double_t ly, Double_t lz)
set the angular momentum of the nucleus
Read ascii files containing events generated by Elie.
void read_elie_params(KVFileReader &input_file_reader)
virtual void define_output_filename()
void ConvertEventsInFile(KVString filename)
KVNameValueList * elie_params
void transform_to_cm()
transform all particle kinematics to CM frame from lab
KVSimReader_ELIE()
Default constructor.
Base class to read output files for simulation and create tree using KVSimEvent class.
Definition: KVSimReader.h:51
Int_t nevt
Definition: KVSimReader.h:62
void Run(Option_t *option="recreate")
KVSimNucleus * nuc
Definition: KVSimReader.h:60
virtual Bool_t HasToFill()
Definition: KVSimReader.h:127
virtual void FillTree()
Definition: KVSimReader.h:123
void AddObject(TObject *obj)
KVSimEvent * evt
Definition: KVSimReader.h:59
void AddInfo(const Char_t *name, const Char_t *val)
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:73
void ChangeFrame(const KVFrameTransform &ft, const KVString &name="")
void SetFrameName(const KVString &name)
Particle * AddParticle()
virtual void SetName(const char *name)
virtual void Info(const char *method, const char *msgfmt,...) const
Bool_t IsFloat() const
Bool_t IsDigit() const
void compound()
ClassImp(TPyArg)