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 
22 void KVSimReader_ELIE::define_output_filename()
23 {
24  // ROOT file called either
25  //
26  // ELIE_[PROJ]_[TARG]_[EBEAM]AMeV_PRIM.root
27  //
28  // or
29  //
30  // ELIE_[PROJ]_[TARG]_[EBEAM]AMeV_Run[xx...]_PRIM.root
31  //
32  // if run_number is defined
33  //
34  // Call after reading file header
35 
36  if (run_number >= 0)
37  SetROOTFileName(Form("ELIE_%s_%s_%.1fAMeV_Run%d_PRIM",
38  proj.GetSymbol(), targ.GetSymbol(), ebeam, run_number));
39  else
40  SetROOTFileName(Form("ELIE_%s_%s_%.1fAMeV_PRIM",
41  proj.GetSymbol(), targ.GetSymbol(), ebeam));
42  SetTreeTitle(Form("ELIE primary events %s + %s %.1f MeV/nuc.",
43  proj.GetSymbol(), targ.GetSymbol(), ebeam));
44 }
45 
46 
47 
50 
51 void KVSimReader_ELIE::transform_to_cm(KVSimEvent* evt)
52 {
53  // transform all particle kinematics to CM frame from lab
54 
55  KVNucleus compound = proj + targ;
56  evt->ChangeFrame(compound.GetV(), "CM");
57 }
58 
59 
60 
63 
65 {
66  // Default constructor
67  init();
68 }
69 
70 
71 
74 
76 {
77  // Read file
78  init();
80 }
81 
82 
83 
102 
104 {
105  // File header contains info on simulation
106  //
107  // 54 129 50 119 32
108  // 20000
109  // ievt=50
110  // projectile=Ni
111  // target=Au
112  // a_proj=58
113  // z_proj=28
114  // a_targ=197
115  // z_targ=79
116  // [...]
117  // geometry=0
118  // free_nucleon=0
119  // lambda_ex=1.3
120  //
121  // The simulation parameters are stored in a KVNameValueList
122 
123  auto res = ReadLineAndCheck(5, " ");
124  switch (res) {
126  Info("ReadHeader", "Can't read system");
127  return kFALSE;
129  AddInfo({"Aproj", GetIntReadPar(1)});
130  AddInfo({"Zproj", GetIntReadPar(0)});
131  AddInfo({"Atarg", GetIntReadPar(3)});
132  AddInfo({"Ztarg", GetIntReadPar(2)});
133  AddInfo({"Ebeam", GetDoubleReadPar(4)});
135  targ.SetZandA(GetIntReadPar(2), GetIntReadPar(3));
136  ebeam = GetDoubleReadPar(4);
137  break;
138  default:
139  return kFALSE;
140  }
141 
142  res = ReadLineAndCheck(1, " ");
143  switch (res) {
145  Info("ReadHeader", "Can't read events");
146  return kFALSE;
148  AddInfo({"Nevents", GetIntReadPar(0)});
149  break;
150 
151  default:
152  return kFALSE;
153  }
154  read_elie_params(*this);
155 
156  define_output_filename();
157 
158  return kTRUE;
159 }
160 
161 
162 
164 
165 void KVSimReader_ELIE::read_elie_params(KVFileReader& input_file_reader)
166 {
167  reuse_last_line=true;
168  elie_params->Clear();
169  elie_params->SetName("ELIE Parameters");
170  auto res = input_file_reader.ReadLineAndCheck(2, "=");
171  while (res != KVFileReader::ReadStatus::EndOfFile) {
172  if (res == KVFileReader::ReadStatus::OK) {
173  if (input_file_reader.GetReadPar(1).IsDigit()) elie_params->SetValue(input_file_reader.GetReadPar(0), input_file_reader.GetIntReadPar(1));
174  else if (input_file_reader.GetReadPar(1).IsFloat()) elie_params->SetValue(input_file_reader.GetReadPar(0), input_file_reader.GetDoubleReadPar(1));
175  else elie_params->SetValue(input_file_reader.GetReadPar(0), input_file_reader.GetReadPar(1));
176  }
177  res = input_file_reader.ReadLineAndCheck(2, "=");
178  }
179  if (elie_params->GetEntries()) AddObject(elie_params);
180 }
181 
182 
183 
199 
201 {
202  // Event structure: (primary events) -> OLD WAY, see bellow for recent ELIE calculations
203  // nevt multiplicite b reduit
204  // 0 2 0.998654688551
205  // particules dans l'evt
206  // indice_particule charge_particule masse_particule teta_particule(degres) phi_particule(degres) indice_particule energie d'excitation totale (MeV)
207  // 0 27 57 3.27897003986 230.52425244 1109.37002505 0 0.00499304975261
208  // 1 80 198 176.726338776 129.481056376 319.364098122 1 0.017344278088
209 
210  // nevt multiplicite b reduit
211  //1 11 0.665404278608
212  // indice_particule charge_particule masse_particule teta_particule(degres) phi_particule(degres) E(MeV) E*(MeV) L(hbar)
213  //0 21 45 2.49354294869 78.2453656442 2180.55536792 91.0936851491 1.0
214  //1 20 46 5.25547324063 79.8035650615 7.5872385507 93.1179892635 1.0
215 
216  // first line of first event will have been read already by ReadFileHeader,
217  // therefore we do not read a new line in this case
218  auto res = (reuse_last_line ? ReuseLineAndCheck(3, " ") : ReadLineAndCheck(3, " "));
219  reuse_last_line=false;
220  mult = 0;
221  switch (res) {
224  return kFALSE;
226  evt->SetNumber(GetIntReadPar(0));
227  mult = GetIntReadPar(1);
228  evt->GetParameters()->SetValue("bred", GetDoubleReadPar(2));
229  evt->GetParameters()->SetValue("mult", mult);
230  return kTRUE;
231  default:
232  return kFALSE;
233  }
234  return kFALSE;
235 }
236 
237 
238 
240 
242 {
243  for (Int_t mm = 0; mm < mult; mm++) {
244  auto nuc = evt->AddParticle();
245  if (!ReadNucleus(nuc)) return kFALSE;
246  }
247 
248  // if in lab, transform to CM frame
249  if (elie_params->GetIntValue("lab_frame") > 0) transform_to_cm(evt);
250  else evt->SetFrameName("CM");
251 
252  return kTRUE;
253 }
254 
255 
256 
270 
272 {
273  // Event structure: (primary events) -> OLD WAY, see bellow for recent ELIE calculations
274  // nevt multiplicite b reduit
275  // 0 2 0.998654688551
276  // particules dans l'evt
277  // indice_particule charge_particule masse_particule teta_particule(degres) phi_particule(degres) indice_particule energie d'excitation totale (MeV)
278  // 0 27 57 3.27897003986 230.52425244 1109.37002505 0 0.00499304975261
279  // 1 80 198 176.726338776 129.481056376 319.364098122 1 0.017344278088
280 
281  // nevt multiplicite b reduit
282  //1 11 0.665404278608
283  // indice_particule charge_particule masse_particule teta_particule(degres) phi_particule(degres) E(MeV) E*(MeV) L(hbar)
284  //0 21 45 2.49354294869 78.2453656442 2180.55536792 91.0936851491 1.0
285  //1 20 46 5.25547324063 79.8035650615 7.5872385507 93.1179892635 1.0
286 
287 
288 
289  auto res = ReadLineAndCheck(8, " ");
290  switch (res) {
292  Info("ReadNucleus", "case 0 line est vide");
293  return kFALSE;
294 
296  nuc->SetZ(GetIntReadPar(1));
297  nuc->SetA(GetIntReadPar(2));
298  if (GetDoubleReadPar(6) >= 0.) nuc->SetExcitEnergy(GetDoubleReadPar(6));
299  nuc->SetEnergy(GetDoubleReadPar(5));
300  nuc->SetTheta(GetDoubleReadPar(3));
301  nuc->SetPhi(GetDoubleReadPar(4));
302  if (nuc->GetExcitEnergy() > 0.) nuc->SetAngMom(GetDoubleReadPar(7), 0, 0);
303 
304  return kTRUE;
305  break;
306 
307  default:
308  return kFALSE;
309  }
310 
311  return kFALSE;
312 }
313 
314 
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:224
KVNameValueList * GetParameters() const
Definition: KVEvent.h:180
Handle reading columns of numeric data in text files.
Definition: KVFileReader.h:121
@ 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:279
Double_t GetDoubleReadPar(Int_t pos) const
Definition: KVFileReader.h:334
Int_t GetIntReadPar(Int_t pos) const
Definition: KVFileReader.h:338
KVString GetReadPar(Int_t pos) const
Definition: KVFileReader.h:342
ReadStatus ReuseLineAndCheck(Int_t nexpect, const KVString &pattern)
Definition: KVFileReader.h:304
Int_t GetIntValue(const Char_t *name) const
void SetValue(const Char_t *name, value_type value)
Int_t GetEntries() const
void Clear(Option_t *opt="") override
Description of properties and kinematics of atomic nuclei.
Definition: KVNucleus.h:108
const Char_t * GetSymbol(Option_t *opt="") const
Definition: KVNucleus.cpp:43
void SetExcitEnergy(Double_t e)
Definition: KVNucleus.cpp:867
Double_t GetExcitEnergy() const
Definition: KVNucleus.h:257
void SetA(Int_t a)
Definition: KVNucleus.cpp:658
void SetZ(Int_t z, Char_t mt=-1)
Definition: KVNucleus.cpp:709
void SetZAandE(Int_t z, Int_t a, Double_t ekin)
Set atomic number, mass number, and kinetic energy in MeV.
Definition: KVNucleus.cpp:738
void SetTheta(Double_t theta)
Definition: KVParticle.h:696
void SetPhi(Double_t phi)
Definition: KVParticle.h:700
void SetEnergy(Double_t e)
Definition: KVParticle.h:602
Container class for simulated nuclei, KVSimNucleus.
Definition: KVSimEvent.h:22
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.
Bool_t ReadNucleus(KVSimNucleus *) override
Bool_t ReadEventHeader(KVSimEvent *) override
Bool_t ReadEvent(KVSimEvent *) override
Bool_t ReadFileHeader() override
KVSimReader_ELIE()
Default constructor.
Base class to convert output from different simulation codes into TTrees containing KVSimEvent event ...
Definition: KVSimReader.h:117
void SetROOTFileName(KVString name)
Definition: KVSimReader.h:247
void SetTreeTitle(KVString n)
Definition: KVSimReader.h:237
void ConvertEventsInFile(KVString filename)
Definition: KVSimReader.cpp:24
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)