KaliVeda
Toolkit for HIC analysis
KVSimReader_HaC.cpp
1 #include "KVSimReader_HaC.h"
2 
3 
5 
7 {
8  tree_name = "HaC";
9  tree_title = "Hybrid alpha-Cluster model";
10  root_file_name = "HaC_events.root";
11 }
12 
13 
14 
16 
18  : KVSimReader_HaC()
19 {
21 }
22 
23 
24 
26 
28 {
29  while (IsOK()) {
30  while (ReadEvent()) {
31  if (nevt % 1000 == 0) Info("ReadFile", "%d evts lus", nevt);
32  if (HasToFill()) FillTree();
33  }
34  }
35 }
36 
37 
38 
59 
61 {
62  // Format of events:
63  // 1 1001.0000 0 7 -32.98796701 1.90742430 => event number,simulation time,l-value (entrance channel),number of fragments,?,?
64  //1 -21.80360935 37.17158811 77.88473322 -0.46023991 0.78299889 1.66679455 -28.30000000 18.65061322 0.00000000
65  //nalpha,xcm,ycm,zcm,kxcm,kycm,kzcm,total internal energy,kinetic cm energy,internal kinetic energy
66  //1 => id of each alpha in cluster
67  //2 -32.98385616 18.06693460 32.40992559 -0.71499466 0.36699478 0.70946383 -58.66470598 11.91719999 0.20506607
68  //2 7 => id of each alpha in cluster
69  //3 8.23280728 -52.40935312 51.83598017 0.17541902 -1.11296131 1.12388664 -86.46620999 39.34742042 1.90408960
70  //3 4 6 => id of each alpha in cluster
71  //1 0.08819134 105.14792154 49.71340857 -0.01218202 2.29301067 1.10528160 -28.30000000 33.47455814 0.00000000
72  //5
73  //1 82.12723574 -37.59507061 -129.88880017 1.75078647 -0.83889006 -2.81229792 -28.30000000 60.11693332 0.00000000
74  //8
75  //1 -84.28224914 -0.48406407 -130.11314158 -1.80061962 -0.00914512 -2.82881943 -28.30000000 57.90240833 0.00000000
76  //9
77  //1 65.13972189 16.85381518 -87.92399172 1.42598734 0.37691999 -1.92154637 -28.30000000 30.32639124 0.00000000
78  //10
79  //
80  // 2 1001.0000 0 8 -32.98597627 2.21586178 ==> next event
81 
82  evt->Clear();
83  auto res = ReadLineAndCheck(6," ");
84  int nfra = 0;
85  switch (res) {
88  return kTRUE;
89 
91  nevt = GetIntReadPar(0);
92  evt->GetParameters()->SetValue("SimulationTime",GetDoubleReadPar(1));
93  evt->GetParameters()->SetValue("AngularMomentum", GetIntReadPar(2));
94  nfra = GetIntReadPar(3);
95  evt->SetNumber(nevt);
96  evt->GetParameters()->SetValue("nfra", nfra);
97  break;
98 
100  KVError::Info(this,"ReadEvent","End of file reached after %d events",nevt);
101  return kFALSE;
102 
103  default:
104  KVError::Error(this,"ReadEvent","ReadLineAndCheck status = %s",GetReadStatus(res).Data());
105  return kFALSE;
106  }
107  if(nfra)
108  {
109  for(int i=0; i<nfra; ++i)
110  {
111  nuc = (KVSimNucleus*)evt->AddParticle();
112  if(!ReadNucleus())
113  return kFALSE;
114  }
115  }
116  return kTRUE;
117 }
118 
119 
120 
141 
143 {
144  // Format of events:
145  // 1 1001.0000 0 7 -32.98796701 1.90742430 => event number,simulation time,l-value (entrance channel),number of fragments,?,?
146  //1 -21.80360935 37.17158811 77.88473322 -0.46023991 0.78299889 1.66679455 -28.30000000 18.65061322 0.00000000
147  //nalpha,xcm,ycm,zcm,kxcm,kycm,kzcm,total internal energy,kinetic cm energy,internal kinetic energy
148  //1 => id of each alpha in cluster
149  //2 -32.98385616 18.06693460 32.40992559 -0.71499466 0.36699478 0.70946383 -58.66470598 11.91719999 0.20506607
150  //2 7 => id of each alpha in cluster
151  //3 8.23280728 -52.40935312 51.83598017 0.17541902 -1.11296131 1.12388664 -86.46620999 39.34742042 1.90408960
152  //3 4 6 => id of each alpha in cluster
153  //1 0.08819134 105.14792154 49.71340857 -0.01218202 2.29301067 1.10528160 -28.30000000 33.47455814 0.00000000
154  //5
155  //1 82.12723574 -37.59507061 -129.88880017 1.75078647 -0.83889006 -2.81229792 -28.30000000 60.11693332 0.00000000
156  //8
157  //1 -84.28224914 -0.48406407 -130.11314158 -1.80061962 -0.00914512 -2.82881943 -28.30000000 57.90240833 0.00000000
158  //9
159  //1 65.13972189 16.85381518 -87.92399172 1.42598734 0.37691999 -1.92154637 -28.30000000 30.32639124 0.00000000
160  //10
161  //
162  // 2 1001.0000 0 8 -32.98597627 2.21586178 ==> next event
163  auto res = ReadLineAndCheck(10, " ");
164  switch (res) {
166  {
167  int nalpha = GetIntReadPar(0);
168  nuc->SetZ(nalpha*2);
169  nuc->SetA(nalpha*4);
170  nuc->SetPosition(GetDoubleReadPar(1),GetDoubleReadPar(2),GetDoubleReadPar(3));
172  nuc->GetParameters()->SetValue("Total internal energy [MeV]", GetDoubleReadPar(7));
173  nuc->GetParameters()->SetValue("Kinetic CM energy [MeV]", GetDoubleReadPar(8));
174  nuc->GetParameters()->SetValue("Internal kinetic energy [MeV/alpha]", GetDoubleReadPar(9));
175  auto reres = ReadLineAndCheck(1,"|");//not used as delimiter: KVString::Begin() just returns the full string
177  {
178  KVError::Error(this,"ReadNucleus","ReadLineAndCheck(1) status = %s",GetReadStatus(reres).Data());
179  return kFALSE;
180  }
181  KVNumberList idlist(GetReadPar(0));
182  nuc->GetParameters()->SetValue("Alpha id list", idlist.AsString());
183  break;
184  }
185  default:
186  KVError::Error(this,"ReadNucleus","ReadLineAndCheck(10) status = %s",GetReadStatus(res).Data());
187  return kFALSE;
188  }
189  return kTRUE;
190 }
191 
192 
194 
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
@ 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
Bool_t IsOK()
Definition: KVFileReader.h:231
KVString GetReadStatus(ReadStatus s)
Definition: KVFileReader.h:167
KVString GetReadPar(Int_t pos) const
Definition: KVFileReader.h:342
static Double_t hbar
hbar*c in MeV.fm
Definition: KVNucleus.h:153
Strings used to represent a set of ranges of values.
Definition: KVNumberList.h:86
const Char_t * AsString(Int_t maxchars=0) const
Nucleus in a simulated event.
Definition: KVSimNucleus.h:32
Convert events generated by the HaC (Hybrid alpha-Cluster) model.
Bool_t ReadEvent() override
Bool_t ReadNucleus() override
void ReadFile() override
Bool_t HasToFill()
Definition: KVSimReader.h:122
virtual void FillTree()
Definition: KVSimReader.h:118
virtual void ConvertAndSaveEventsInFile(KVString filename)
Read events, convert and save in ROOT file.
virtual void Info(const char *method, const char *msgfmt,...) const
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
str tree_name
ClassImp(TPyArg)