KaliVeda
Toolkit for HIC analysis
KVSimReader_ELIE2023.cpp
1 #include "KVSimReader_ELIE2023.h"
2 
3 
4 
5 
24 
26 {
27  // File header no longer contains all info on simulation, this can be found in accompanying '.input' file
28  //
29  // File header now looks like:
30  //~~~~
31  //zproj aproj zcibl acibl ebeam number_of_events run_number
32  //~~~~
33  //
34  // while '.input' file contains
35  //~~~~
36  //alevel=7.87
37  //entropy_max=1.25
38  //g_al=1.
39  //thermal=1
40  //fermi_gas=1
41  //geometry=1
42  // ...
43  //~~~~
44 
45  auto res = ReadLineAndCheck(7, " ");
46  switch (res) {
48  Info("ReadHeader", "Can't read file header infos");
49  return kFALSE;
51  AddInfo("Aproj", GetReadPar(1));
52  AddInfo("Zproj", GetReadPar(0));
53  AddInfo("Atarg", GetReadPar(3));
54  AddInfo("Ztarg", GetReadPar(2));
55  AddInfo("Ebeam", GetReadPar(4));
56  AddInfo("Nevents", GetReadPar(5));
57  AddInfo("RunNumber", GetReadPar(6));
62  break;
63  default:
64  Info("ReadHeader", "res=%d", (int)res);
65  return kFALSE;
66  }
67 
68  // derive '.input' file name from name of file being read
69  auto input_file = GetFileName();
70  auto suff_ind = input_file.Index("_primary.output");
71  if (suff_ind < 0) suff_ind = input_file.Index("_secondary.output");
72  if (suff_ind < 0) {
73  Warning("ReadHeader", "Cannot deduce name of '.input' file from filename:%s", input_file.Data());
74  Warning("ReadHeader", "Informations on input parameters of calculation will not be read/kept");
75  return kFALSE;
76  }
77  input_file.Remove(suff_ind);
78  input_file.Append(".input");
79 
80  // open '.input' file and read infos
81  KVFileReader input_file_reader("#");// comments start with '#' in file
82  if (!input_file_reader.OpenFileToRead(input_file)) {
83  Warning("ReadHeader", "Failed to open file %s", input_file.Data());
84  Warning("ReadHeader", "Informations on input parameters of calculation will not be read/kept");
85  return kFALSE;
86  }
87 
88  read_elie_params(input_file_reader);
89 
90  return kTRUE;
91 }
92 
93 
94 
102 
104 {
105  // New event header structure is:
106  //~~~~
107  //event_number multiplicity b_reduit reduced_density tempe_part tempe_qp tempe_qt sigma* pauli_factor
108  //~~~~
109  //
110  // These are the names used for the event parameters
111 
112  evt->Clear();
113 
114  auto res = ReadLineAndCheck(9, " ");
115  Int_t mult = 0;
116  switch (res) {
119  return kFALSE;
122  mult = GetIntReadPar(1);
123  evt->GetParameters()->SetValue("bred", GetDoubleReadPar(2));
124  evt->GetParameters()->SetValue("mult", mult);
125  evt->GetParameters()->SetValue("reduced_density", GetDoubleReadPar(3));
126  evt->GetParameters()->SetValue("tempe_part", GetDoubleReadPar(4));
127  evt->GetParameters()->SetValue("tempe_qp", GetDoubleReadPar(5));
128  evt->GetParameters()->SetValue("tempe_qt", GetDoubleReadPar(6));
129  evt->GetParameters()->SetValue("sigma*", GetDoubleReadPar(7));
130  evt->GetParameters()->SetValue("pauli_factor", GetDoubleReadPar(8));
131  break;
132 
133  default:
134  return kFALSE;
135  }
136  for (Int_t mm = 0; mm < mult; mm++) {
138  if (!ReadNucleus()) return kFALSE;
139  }
140  nevt++;
141 
142  // if in lab, transform to CM frame
143  if (elie_params->GetIntValue("lab_frame") > 0) transform_to_cm();
144  else evt->SetFrameName("CM");
145 
146  return kTRUE;
147 }
148 
149 
150 
160 
162 {
163  // New particle structure is:
164  //~~~~
165  //particule_number z_part a_part teta_part phi_part e_part exci_part origine_part
166  //~~~~
167  //
168  //
169  // The origin of secondary decay particles is stored in a parameter named "ORIGIN"
170  // As particles in a KVEvent are numbered 1,2,... we add 1 to the value read in
171 
172  auto res = ReadLineAndCheck(8, " ");
173  switch (res) {
175  Info("ReadNucleus", "premature end of file?");
176  return kFALSE;
178  Info("ReadNucleus", "case 0 line est vide");
179  return kFALSE;
180 
182  nuc->SetZ(GetIntReadPar(1));
183  nuc->SetA(GetIntReadPar(2));
188  nuc->SetParameter("ORIGIN", GetIntReadPar(7) + 1);
189  return kTRUE;
190  break;
191 
192  default:
193  return kFALSE;
194  }
195 
196  return kFALSE;
197 }
198 
199 
201 
202 
203 
int Int_t
bool Bool_t
constexpr Bool_t kFALSE
constexpr Bool_t kTRUE
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
KVString GetFileName()
Definition: KVFileReader.h:189
@ 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
Double_t GetDoubleReadPar(Int_t pos) const
Definition: KVFileReader.h:333
Int_t GetIntReadPar(Int_t pos) const
Definition: KVFileReader.h:337
KVString GetReadPar(Int_t pos) const
Definition: KVFileReader.h:341
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)
void SetExcitEnergy(Double_t e)
Definition: KVNucleus.cpp:868
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 SetParameter(const Char_t *name, ValType value) const
Definition: KVParticle.h:819
void SetEnergy(Double_t e)
Definition: KVParticle.h:599
Nucleus in a simulated event.
Definition: KVSimNucleus.h:32
Read ASCII files generated by ELIE (new format 2022)
void read_elie_params(KVFileReader &input_file_reader)
KVNameValueList * elie_params
void transform_to_cm()
transform all particle kinematics to CM frame from lab
Int_t nevt
Definition: KVSimReader.h:62
KVSimNucleus * nuc
Definition: KVSimReader.h:60
KVSimEvent * evt
Definition: KVSimReader.h:59
void AddInfo(const Char_t *name, const Char_t *val)
void SetFrameName(const KVString &name)
Particle * AddParticle()
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual void Info(const char *method, const char *msgfmt,...) const
ClassImp(TPyArg)