KaliVeda  1.12/06
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 }
22 
23 
24 
27 
29 {
30  // transform all particle kinematics to CM frame from lab
31 
33  evt->ChangeFrame(compound.GetV(), "CM");
34 }
35 
36 
37 
40 
42 {
43  // Default constructor
44  init();
45 }
46 
47 
48 
49 
52 
54 {
55  // Read file
56  init();
57  ConvertEventsInFile(filename);
58 }
59 
60 
61 
64 
66 {
67  // Destructor
68 }
69 
70 
71 
73 
75 {
76  if (!OpenFileToRead(filename)) return;
77  if (!ReadHeader()) return;
79  tree_title.Form("ELIE primary events %s + %s %.1f MeV/nuc.",
81  Run();
82  CloseFile();
83 }
84 
85 
86 
87 
89 
91 {
92  Info("ReadFile", "begins");
93  while (IsOK()) {
94  while (ReadEvent()) {
95  if (nevt && nevt % 1000 == 0) Info("ReadFile", "%d evts lus", nevt);
96  if (HasToFill()) FillTree();
97  }
98  }
99 }
100 
101 
102 
121 
123 {
124  // File header contains info on simulation
125  //
126  // 54 129 50 119 32
127  // 20000
128  // ievt=50
129  // projectile=Ni
130  // target=Au
131  // a_proj=58
132  // z_proj=28
133  // a_targ=197
134  // z_targ=79
135  // [...]
136  // geometry=0
137  // free_nucleon=0
138  // lambda_ex=1.3
139  //
140  // The simulation parameters are stored in a KVNameValueList
141 
142  Int_t res = ReadLineAndCheck(5, " ");
143  switch (res) {
144  case 0:
145  Info("ReadHeader", "Can't read system");
146  return kFALSE;
147  case 1:
148  AddInfo("Aproj", GetReadPar(1));
149  AddInfo("Zproj", GetReadPar(0));
150  AddInfo("Atarg", GetReadPar(3));
151  AddInfo("Ztarg", GetReadPar(2));
152  AddInfo("Ebeam", GetReadPar(4));
155  ebeam = GetDoubleReadPar(4);
156  break;
157  default:
158  return kFALSE;
159  }
160 
161  res = ReadLineAndCheck(1, " ");
162  switch (res) {
163  case 0:
164  Info("ReadHeader", "Can't read events");
165  return kFALSE;
166  case 1:
167  AddInfo("Nevents", GetReadPar(0));
168  break;
169 
170  default:
171  return kFALSE;
172  }
173  elie_params->Clear();
174  elie_params->SetName("ELIE Parameters");
175  res = ReadLineAndCheck(2, "=");
176  while (res < 2) {
177  if (res > 0) {
178  if (GetReadPar(1).IsDigit()) elie_params->SetValue(GetReadPar(0), GetIntReadPar(1));
179  else if (GetReadPar(1).IsFloat()) elie_params->SetValue(GetReadPar(0), GetDoubleReadPar(1));
181  }
182  res = ReadLineAndCheck(2, "=");
183  }
185 
186  return kTRUE;
187 }
188 
189 
190 
204 
206 {
207  // Event structure: (primary events) -> OLD WAY, see bellow for recent ELIE calculations
208  // nevt multiplicite b reduit
209  // 0 2 0.998654688551
210  // particules dans l'evt
211  // indice_particule charge_particule masse_particule teta_particule(degres) phi_particule(degres) indice_particule energie d'excitation totale (MeV)
212  // 0 27 57 3.27897003986 230.52425244 1109.37002505 0 0.00499304975261
213  // 1 80 198 176.726338776 129.481056376 319.364098122 1 0.017344278088
214 
215  // nevt multiplicite b reduit
216  //1 11 0.665404278608
217  // indice_particule charge_particule masse_particule teta_particule(degres) phi_particule(degres) E(MeV) E*(MeV) L(hbar)
218  //0 21 45 2.49354294869 78.2453656442 2180.55536792 91.0936851491 1.0
219  //1 20 46 5.25547324063 79.8035650615 7.5872385507 93.1179892635 1.0
220 
221 
222  evt->Clear();
223 
224  // first line of first event will have been read already by ReadHeader,
225  // therefore we do not read a new line in this case (when nevt=0)
226  Int_t res = (nevt ? ReadLineAndCheck(3, " ") : ReuseLineAndCheck(3, " "));
227  Int_t mult = 0;
228  switch (res) {
229  case 0:
230  return kFALSE;
231  case 1:
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  Int_t res = ReadLineAndCheck(8, " ");
288  switch (res) {
289  case 0:
290  Info("ReadNucleus", "case 0 line est vide");
291  return kFALSE;
292 
293  case 1:
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:209
KVNameValueList * GetParameters() const
Definition: KVEvent.h:391
void SetFrameName(const KVString &)
Definition: KVEvent.cpp:1215
virtual void Clear(Option_t *opt="")
Definition: KVEvent.cpp:200
KVNucleus * AddParticle()
Definition: KVEvent.cpp:166
void ChangeFrame(const KVFrameTransform &, const KVString &="")
Definition: KVEvent.cpp:815
Int_t ReadLineAndCheck(Int_t nexpect, const Char_t *pattern)
Definition: KVFileReader.h:100
Int_t ReuseLineAndCheck(Int_t nexpect, const Char_t *pattern)
Definition: KVFileReader.h:117
TString GetReadPar(Int_t pos)
Definition: KVFileReader.h:167
void CloseFile()
Definition: KVFileReader.h:79
Bool_t OpenFileToRead(KVString filename)
Definition: KVFileReader.h:59
Double_t GetDoubleReadPar(Int_t pos)
Definition: KVFileReader.h:159
Bool_t IsOK()
Definition: KVFileReader.h:74
Int_t GetIntReadPar(Int_t pos)
Definition: KVFileReader.h:163
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
const Char_t * GetSymbol(Option_t *opt="") const
Definition: KVNucleus.cpp:81
void SetExcitEnergy(Double_t e)
Definition: KVNucleus.cpp:865
Double_t GetExcitEnergy() const
Definition: KVNucleus.h:285
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:654
void SetPhi(Double_t phi)
Definition: KVParticle.h:658
void SetEnergy(Double_t e)
Definition: KVParticle.h:560
Nucleus in a simulated event.
Definition: KVSimNucleus.h:20
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.
virtual void define_output_filename()
virtual ~KVSimReader_ELIE()
Destructor.
virtual 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
KVString tree_title
Definition: KVSimReader.h:69
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
virtual void SetName(const char *name)
virtual void Info(const char *method, const char *msgfmt,...) const
void Form(const char *fmt,...)
void compound()
const long double mm
Definition: KVUnits.h:69