KaliVeda
Toolkit for HIC analysis
KVSimReader_HaC.cpp
1 #include "KVSimReader_HaC.h"
2 
3 
5 
7 {
8  SetTreeName("HaC");
9  SetTreeTitle("Hybrid alpha-Cluster model");
10  SetROOTFileName("HaC_events");
11 }
12 
13 
14 
16 
17 KVSimReader_HaC::KVSimReader_HaC(const TString& filename)
18  : KVSimReader_HaC()
19 {
21 }
22 
23 
24 
28 
30 {
31  // Format of events:
32  // 1 1001.0000 0 7 -32.98796701 1.90742430 => event number,simulation time,l-value (entrance channel),number of fragments,?,?
33 
34  auto res = ReadLineAndCheck(6," ");
35  switch (res) {
38  return kTRUE;
39 
41  evt->SetNumber(GetIntReadPar(0));
42  evt->GetParameters()->SetValue("SimulationTime",GetDoubleReadPar(1));
43  evt->GetParameters()->SetValue("AngularMomentum", GetIntReadPar(2));
44  evt->GetParameters()->SetValue("nfra", GetIntReadPar(3));
45  break;
46 
48  KVError::Info(this,"ReadEvent","End of file reached after event %d", GetEventNumber());
49  return kFALSE;
50 
51  default:
52  KVError::Error(this,"ReadEvent","ReadLineAndCheck status = %s",GetReadStatus(res).Data());
53  return kFALSE;
54  }
55 
56  return kTRUE;
57 }
58 
59 
60 
80 
82 {
83  // Format of events:
84  //1 -21.80360935 37.17158811 77.88473322 -0.46023991 0.78299889 1.66679455 -28.30000000 18.65061322 0.00000000
85  //nalpha,xcm,ycm,zcm,kxcm,kycm,kzcm,total internal energy,kinetic cm energy,internal kinetic energy
86  //1 => id of each alpha in cluster
87  //2 -32.98385616 18.06693460 32.40992559 -0.71499466 0.36699478 0.70946383 -58.66470598 11.91719999 0.20506607
88  //2 7 => id of each alpha in cluster
89  //3 8.23280728 -52.40935312 51.83598017 0.17541902 -1.11296131 1.12388664 -86.46620999 39.34742042 1.90408960
90  //3 4 6 => id of each alpha in cluster
91  //1 0.08819134 105.14792154 49.71340857 -0.01218202 2.29301067 1.10528160 -28.30000000 33.47455814 0.00000000
92  //5
93  //1 82.12723574 -37.59507061 -129.88880017 1.75078647 -0.83889006 -2.81229792 -28.30000000 60.11693332 0.00000000
94  //8
95  //1 -84.28224914 -0.48406407 -130.11314158 -1.80061962 -0.00914512 -2.82881943 -28.30000000 57.90240833 0.00000000
96  //9
97  //1 65.13972189 16.85381518 -87.92399172 1.42598734 0.37691999 -1.92154637 -28.30000000 30.32639124 0.00000000
98  //10
99  //
100  // 2 1001.0000 0 8 -32.98597627 2.21586178 ==> next event
101 
102  auto nfra = evt->GetParameters()->GetIntValue("nfra");
103  if(nfra)
104  {
105  for(int i=0; i<nfra; ++i)
106  {
107  auto nuc = evt->AddParticle();
108  if(!ReadNucleus(nuc))
109  return kFALSE;
110  }
111  }
112  return kTRUE;
113 }
114 
115 
116 
137 
139 {
140  // Format of events:
141  // 1 1001.0000 0 7 -32.98796701 1.90742430 => event number,simulation time,l-value (entrance channel),number of fragments,?,?
142  //1 -21.80360935 37.17158811 77.88473322 -0.46023991 0.78299889 1.66679455 -28.30000000 18.65061322 0.00000000
143  //nalpha,xcm,ycm,zcm,kxcm,kycm,kzcm,total internal energy,kinetic cm energy,internal kinetic energy
144  //1 => id of each alpha in cluster
145  //2 -32.98385616 18.06693460 32.40992559 -0.71499466 0.36699478 0.70946383 -58.66470598 11.91719999 0.20506607
146  //2 7 => id of each alpha in cluster
147  //3 8.23280728 -52.40935312 51.83598017 0.17541902 -1.11296131 1.12388664 -86.46620999 39.34742042 1.90408960
148  //3 4 6 => id of each alpha in cluster
149  //1 0.08819134 105.14792154 49.71340857 -0.01218202 2.29301067 1.10528160 -28.30000000 33.47455814 0.00000000
150  //5
151  //1 82.12723574 -37.59507061 -129.88880017 1.75078647 -0.83889006 -2.81229792 -28.30000000 60.11693332 0.00000000
152  //8
153  //1 -84.28224914 -0.48406407 -130.11314158 -1.80061962 -0.00914512 -2.82881943 -28.30000000 57.90240833 0.00000000
154  //9
155  //1 65.13972189 16.85381518 -87.92399172 1.42598734 0.37691999 -1.92154637 -28.30000000 30.32639124 0.00000000
156  //10
157  //
158  // 2 1001.0000 0 8 -32.98597627 2.21586178 ==> next event
159  auto res = ReadLineAndCheck(10, " ");
160  switch (res) {
162  {
163  int nalpha = GetIntReadPar(0);
164  nuc->SetZ(nalpha*2);
165  nuc->SetA(nalpha*4);
168  nuc->GetParameters()->SetValue("Total internal energy [MeV]", GetDoubleReadPar(7));
169  nuc->GetParameters()->SetValue("Kinetic CM energy [MeV]", GetDoubleReadPar(8));
170  nuc->GetParameters()->SetValue("Internal kinetic energy [MeV/alpha]", GetDoubleReadPar(9));
171  auto reres = ReadLineAndCheck(1,"|");//not used as delimiter: KVString::Begin() just returns the full string
173  {
174  KVError::Error(this,"ReadNucleus","ReadLineAndCheck(1) status = %s",GetReadStatus(reres).Data());
175  return kFALSE;
176  }
177  KVNumberList idlist(GetReadPar(0));
178  nuc->GetParameters()->SetValue("Alpha id list", idlist.AsString());
179  break;
180  }
181  default:
182  KVError::Error(this,"ReadNucleus","ReadLineAndCheck(10) status = %s",GetReadStatus(res).Data());
183  return kFALSE;
184  }
185  return kTRUE;
186 }
187 
188 
189 ClassImp(KVSimReader_HaC)
190 
virtual void SetNumber(UInt_t num)
Definition: KVBase.h:224
KVNameValueList * GetParameters() const
Definition: KVEvent.h:180
@ CommentLine
last line read was a comment line
@ 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 GetReadStatus(ReadStatus s)
Definition: KVFileReader.h:167
KVString GetReadPar(Int_t pos) const
Definition: KVFileReader.h:342
Int_t GetIntValue(const Char_t *name) const
void SetValue(const Char_t *name, value_type value)
static Double_t hbar
hbar*c in MeV.fm
Definition: KVNucleus.h:153
void SetA(Int_t a)
Definition: KVNucleus.cpp:658
void SetZ(Int_t z, Char_t mt=-1)
Definition: KVNucleus.cpp:709
Strings used to represent a set of ranges of values.
Definition: KVNumberList.h:86
const Char_t * AsString(Int_t maxchars=0) const
KVNameValueList * GetParameters() const
Definition: KVParticle.h:818
void SetMomentum(const TVector3 &v)
Definition: KVParticle.h:581
Container class for simulated nuclei, KVSimNucleus.
Definition: KVSimEvent.h:22
Nucleus in a simulated event.
Definition: KVSimNucleus.h:32
void SetPosition(Double_t rx, Double_t ry, Double_t rz)
set the position of the nucleus in position space
Convert events generated by the HaC (Hybrid alpha-Cluster) model.
Bool_t ReadNucleus(KVSimNucleus *nuc) override
Bool_t ReadEventHeader(KVSimEvent *evt) override
Bool_t ReadEvent(KVSimEvent *evt) override
void SetROOTFileName(KVString name)
Definition: KVSimReader.h:247
void SetTreeTitle(KVString n)
Definition: KVSimReader.h:237
int GetEventNumber() const
Definition: KVSimReader.h:190
void ConvertAndSaveEventsInFile(KVString filename)
Read events, convert and save in ROOT file(s)
void SetTreeName(KVString n)
Definition: KVSimReader.h:232
Particle * AddParticle()
void Error(UserClass p, const char *location, const char *va_(fmt),...)
Definition: KVError.h:116
void Info(UserClass p, const char *location, const char *va_(fmt),...)
Definition: KVError.h:134