KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
KVSimReader_ELIE.cpp
Go to the documentation of this file.
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 
15 void KVSimReader_ELIE::define_output_filename()
16 {
17  // ROOT file called: ELIE_[PROJ]_[TARG]_[EBEAM]AMeV_PRIM.root
18  // Call after reading file header
19  SetROOTFileName(Form("ELIE_%s_%s_%.1fAMeV_PRIM.root",
20  proj.GetSymbol(), targ.GetSymbol(), ebeam));
21  tree_title.Form("ELIE primary events %s + %s %.1f MeV/nuc.",
22  proj.GetSymbol(), targ.GetSymbol(), ebeam);
23 }
24 
25 
26 
29 
31 {
32  // transform all particle kinematics to CM frame from lab
33 
35  evt->ChangeFrame(compound.GetV(), "CM");
36 }
37 
38 
39 
42 
44 {
45  // Default constructor
46  init();
47 }
48 
49 
50 
51 
54 
56 {
57  // Read file
58  init();
59  ConvertEventsInFile(filename);
60 }
61 
62 
63 
65 
67 {
68  if (!OpenFileToRead(filename)) return;
69  if (!ReadHeader()) return;
71  Run();
72  CloseFile();
73 }
74 
75 
76 
77 
79 
81 {
82  Info("ReadFile", "begins");
83  while (IsOK()) {
84  while (ReadEvent()) {
85  if (nevt && nevt % 1000 == 0) Info("ReadFile", "%d evts lus", nevt);
86  if (HasToFill()) FillTree();
87  }
88  }
89 }
90 
91 
92 
111 
113 {
114  // File header contains info on simulation
115  //
116  // 54 129 50 119 32
117  // 20000
118  // ievt=50
119  // projectile=Ni
120  // target=Au
121  // a_proj=58
122  // z_proj=28
123  // a_targ=197
124  // z_targ=79
125  // [...]
126  // geometry=0
127  // free_nucleon=0
128  // lambda_ex=1.3
129  //
130  // The simulation parameters are stored in a KVNameValueList
131 
132  auto res = ReadLineAndCheck(5, " ");
133  switch (res) {
135  Info("ReadHeader", "Can't read system");
136  return kFALSE;
138  AddInfo("Aproj", GetReadPar(1));
139  AddInfo("Zproj", GetReadPar(0));
140  AddInfo("Atarg", GetReadPar(3));
141  AddInfo("Ztarg", GetReadPar(2));
142  AddInfo("Ebeam", GetReadPar(4));
145  ebeam = GetDoubleReadPar(4);
146  break;
147  default:
148  return kFALSE;
149  }
150 
151  res = ReadLineAndCheck(1, " ");
152  switch (res) {
154  Info("ReadHeader", "Can't read events");
155  return kFALSE;
157  AddInfo("Nevents", GetReadPar(0));
158  break;
159 
160  default:
161  return kFALSE;
162  }
163  read_elie_params(*this);
164 
165  return kTRUE;
166 }
167 
168 
169 
171 
173 {
174  elie_params->Clear();
175  elie_params->SetName("ELIE Parameters");
176  auto res = input_file_reader.ReadLineAndCheck(2, "=");
177  while (res != KVFileReader::ReadStatus::EndOfFile) {
178  if (res == KVFileReader::ReadStatus::OK) {
179  if (input_file_reader.GetReadPar(1).IsDigit()) elie_params->SetValue(input_file_reader.GetReadPar(0), input_file_reader.GetIntReadPar(1));
180  else if (input_file_reader.GetReadPar(1).IsFloat()) elie_params->SetValue(input_file_reader.GetReadPar(0), input_file_reader.GetDoubleReadPar(1));
181  else elie_params->SetValue(input_file_reader.GetReadPar(0), input_file_reader.GetReadPar(1));
182  }
183  res = input_file_reader.ReadLineAndCheck(2, "=");
184  }
186 }
187 
188 
189 
203 
205 {
206  // Event structure: (primary events) -> OLD WAY, see bellow for recent ELIE calculations
207  // nevt multiplicite b reduit
208  // 0 2 0.998654688551
209  // particules dans l'evt
210  // indice_particule charge_particule masse_particule teta_particule(degres) phi_particule(degres) indice_particule energie d'excitation totale (MeV)
211  // 0 27 57 3.27897003986 230.52425244 1109.37002505 0 0.00499304975261
212  // 1 80 198 176.726338776 129.481056376 319.364098122 1 0.017344278088
213 
214  // nevt multiplicite b reduit
215  //1 11 0.665404278608
216  // indice_particule charge_particule masse_particule teta_particule(degres) phi_particule(degres) E(MeV) E*(MeV) L(hbar)
217  //0 21 45 2.49354294869 78.2453656442 2180.55536792 91.0936851491 1.0
218  //1 20 46 5.25547324063 79.8035650615 7.5872385507 93.1179892635 1.0
219 
220 
221  evt->Clear();
222 
223  // first line of first event will have been read already by ReadHeader,
224  // therefore we do not read a new line in this case (when nevt=0)
225  auto res = (nevt ? ReadLineAndCheck(3, " ") : ReuseLineAndCheck(3, " "));
226  Int_t mult = 0;
227  switch (res) {
230  return kFALSE;
233  mult = GetIntReadPar(1);
234  evt->GetParameters()->SetValue("bred", GetDoubleReadPar(2));
235  evt->GetParameters()->SetValue("mult", mult);
236  break;
237  default:
238  return kFALSE;
239  }
240  for (Int_t mm = 0; mm < mult; mm++) {
242  if (!ReadNucleus()) return kFALSE;
243  }
244  nevt++;
245 
246  // if in lab, transform to CM frame
247  if (elie_params->GetIntValue("lab_frame") > 0) transform_to_cm();
248  else evt->SetFrameName("CM");
249 
250  return kTRUE;
251 }
252 
253 
254 
268 
270 {
271  // Event structure: (primary events) -> OLD WAY, see bellow for recent ELIE calculations
272  // nevt multiplicite b reduit
273  // 0 2 0.998654688551
274  // particules dans l'evt
275  // indice_particule charge_particule masse_particule teta_particule(degres) phi_particule(degres) indice_particule energie d'excitation totale (MeV)
276  // 0 27 57 3.27897003986 230.52425244 1109.37002505 0 0.00499304975261
277  // 1 80 198 176.726338776 129.481056376 319.364098122 1 0.017344278088
278 
279  // nevt multiplicite b reduit
280  //1 11 0.665404278608
281  // indice_particule charge_particule masse_particule teta_particule(degres) phi_particule(degres) E(MeV) E*(MeV) L(hbar)
282  //0 21 45 2.49354294869 78.2453656442 2180.55536792 91.0936851491 1.0
283  //1 20 46 5.25547324063 79.8035650615 7.5872385507 93.1179892635 1.0
284 
285 
286 
287  auto res = ReadLineAndCheck(8, " ");
288  switch (res) {
290  Info("ReadNucleus", "case 0 line est vide");
291  return kFALSE;
292 
294  nuc->SetZ(GetIntReadPar(1));
295  nuc->SetA(GetIntReadPar(2));
300  if (nuc->GetExcitEnergy() > 0.) nuc->SetAngMom(GetDoubleReadPar(7), 0, 0);
301 
302  return kTRUE;
303  break;
304 
305  default:
306  return kFALSE;
307  }
308 
309  return kFALSE;
310 }
311 
312 
int Int_t
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
const Bool_t kFALSE
bool Bool_t
const Bool_t kTRUE
char * Form(const char *fmt,...)
virtual void SetNumber(UInt_t num)
Definition: KVBase.h:215
KVNameValueList * GetParameters() const
Definition: KVEvent.h:203
void Clear(Option_t *opt="")
Clear object properties : name, type/title, number, label.
Definition: KVEvent.h:262
Handle reading columns of numeric data in text files.
Definition: KVFileReader.h:119
@ 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:125
void SetExcitEnergy(Double_t e)
Definition: KVNucleus.cpp:865
Double_t GetExcitEnergy() const
Definition: KVNucleus.h:282
void SetA(Int_t a)
Definition: KVNucleus.cpp:655
void SetZ(Int_t z, Char_t mt=-1)
Definition: KVNucleus.cpp:704
void SetZandA(Int_t z, Int_t a)
Set atomic number and mass number.
Definition: KVNucleus.cpp:721
void SetZAandE(Int_t z, Int_t a, Double_t ekin)
Set atomic number, mass number, and kinetic energy in MeV.
Definition: KVNucleus.cpp:733
void SetTheta(Double_t theta)
Definition: KVParticle.h:695
void SetPhi(Double_t phi)
Definition: KVParticle.h:699
void SetEnergy(Double_t e)
Definition: KVParticle.h:601
Nucleus in a simulated event.
Definition: KVSimNucleus.h:31
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)
Method called by constructors with KVString filename argument.
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:57
Int_t nevt
Definition: KVSimReader.h:68
void Run(Option_t *option="recreate")
KVSimNucleus * nuc
Definition: KVSimReader.h:66
virtual Bool_t HasToFill()
Definition: KVSimReader.h:133
virtual void FillTree()
Definition: KVSimReader.h:129
void AddObject(TObject *obj)
KVSimEvent * evt
Definition: KVSimReader.h:65
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:72
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()
const long double mm
Definition: KVUnits.h:69