1 // ALICE event generator based on the THERMINATOR model
2 // It reads the test output of the model and puts it onto
4 // It has an option to use the Lhyquid3D input freeze-out
6 // Author: Adam.Kisiel@cern.ch
11 #include <TClonesArray.h>
12 #include <TMCProcess.h>
13 #include <TDatabasePDG.h>
14 #include <TParticle.h>
17 #include "AliDecayer.h"
18 #include "AliGenEventHeader.h"
19 #include "AliGenHijingEventHeader.h"
20 #include "AliGenTherminator.h"
24 ClassImp(AliGenTherminator)
28 AliGenTherminator::AliGenTherminator():
46 // Default constructor
47 fParticles = new TClonesArray("TParticle",20000);
49 AliGenTherminator::AliGenTherminator(Int_t npart):
67 // Constructor specifying the size of the particle table
68 fParticles = new TClonesArray("TParticle",20000);
72 AliGenTherminator::~AliGenTherminator()
74 // AliGenMC::~AliGenMC();
75 // if (fTherminator) delete fTherminator;
78 void AliGenTherminator::Generate()
80 // Run single event generation with the Therminator model
81 AliWarning("Generating event from AliGenTherminator");
83 Float_t polar[3] = {0,0,0};
84 Float_t origin[3] = {0,0,0};
85 Float_t origin0[3] = {0,0,0};
94 for (j=0; j < 3; j++) origin0[j] = fVertex[j];
98 ((TTherminator *) fMCEvGen)->GenerateEvent();
99 AliWarning("Generated");
100 ((TTherminator *) fMCEvGen)->ImportParticles(fParticles);
102 Int_t np = fParticles->GetEntriesFast();
103 AliWarning(Form("Imported %d particles", np));
105 TParticle *iparticle;
106 Double_t evrot = gRandom->Rndm()*TMath::Pi();
108 for (int i = 0; i < np; i++) {
109 iparticle = (TParticle *) fParticles->At(i);
110 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
111 Bool_t hasDaughter = (iparticle->GetFirstDaughter() >=0);
113 kf = iparticle->GetPdgCode();
114 ks = iparticle->GetStatusCode();
115 Double_t aphi = TMath::ATan2(iparticle->Py(), iparticle->Px());
116 Double_t arho = TMath::Hypot(iparticle->Px(), iparticle->Py());
117 p[0] = arho*TMath::Cos(aphi + evrot);
118 p[1] = arho*TMath::Sin(aphi + evrot);
119 // p[0] = iparticle->Px();
120 // p[1] = iparticle->Py();
121 p[2] = iparticle->Pz();
122 mass = TDatabasePDG::Instance()->GetParticle(kf)->Mass();
123 energy = sqrt(mass*mass + p[0]*p[0] + p[1]*p[1] + p[2]*p[2]);
124 origin[0] = origin0[0]+iparticle->Vx();
125 origin[1] = origin0[1]+iparticle->Vy();
126 origin[2] = origin0[2]+iparticle->Vz();
129 TParticle* mother = 0;
131 imo = iparticle->GetFirstMother();
132 mother = (TParticle *) fParticles->At(imo);
134 Bool_t tFlag = (!hasDaughter);
136 printf("Pushing Track %d with status %d mother %d\n", kf, tFlag, imo);
137 PushTrack(tFlag,imo,kf,
138 p[0],p[1],p[2],energy,
139 origin[0],origin[1],origin[2],iparticle->T()*0.197327*1e-13/300000000,
140 polar[0],polar[1],polar[2],
141 hasMother ? kPDecay:kPNoProcess,nt);
147 SetHighWaterMark(fNprimaries);
151 eventVertex[0] = origin0[0];
152 eventVertex[1] = origin0[1];
153 eventVertex[2] = origin0[2];
155 // Builds the event header, to be called after each event
156 AliGenEventHeader* header = new AliGenHijingEventHeader("Therminator");
159 // AliGenEventHeader* header = new AliGenEventHeader("Therminator");
161 // header->SetPrimaryVertex(eventVertex);
162 // header->SetNProduced(fNprimaries);
164 ((AliGenHijingEventHeader*) header)->SetNProduced(fNprimaries);
165 ((AliGenHijingEventHeader*) header)->SetPrimaryVertex(eventVertex);
166 ((AliGenHijingEventHeader*) header)->SetImpactParameter(0.0);
167 ((AliGenHijingEventHeader*) header)->SetTotalEnergy(0.0);
168 ((AliGenHijingEventHeader*) header)->SetHardScatters(0);
169 ((AliGenHijingEventHeader*) header)->SetParticipants(0, 0);
170 ((AliGenHijingEventHeader*) header)->SetCollisions(0, 0, 0, 0);
171 ((AliGenHijingEventHeader*) header)->SetSpectators(0, 0, 0, 0);
172 ((AliGenHijingEventHeader*) header)->SetReactionPlaneAngle(evrot);
175 // 4-momentum vectors of the triggered jets.
177 // Before final state gluon radiation.
178 // TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(21),
179 // fHijing->GetHINT1(22),
180 // fHijing->GetHINT1(23),
181 // fHijing->GetHINT1(24));
183 // TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(31),
184 // fHijing->GetHINT1(32),
185 // fHijing->GetHINT1(33),
186 // fHijing->GetHINT1(34));
187 // // After final state gluon radiation.
188 // TLorentzVector* jet3 = new TLorentzVector(fHijing->GetHINT1(26),
189 // fHijing->GetHINT1(27),
190 // fHijing->GetHINT1(28),
191 // fHijing->GetHINT1(29));
193 // TLorentzVector* jet4 = new TLorentzVector(fHijing->GetHINT1(36),
194 // fHijing->GetHINT1(37),
195 // fHijing->GetHINT1(38),
196 // fHijing->GetHINT1(39));
197 // ((AliGenHijingEventHeader*) header)->SetJets(jet1, jet2, jet3, jet4);
198 // Bookkeeping for kinematic bias
199 // ((AliGenHijingEventHeader*) header)->SetTrials(fTrials);
201 header->SetPrimaryVertex(fVertex);
203 fCollisionGeometry = (AliGenHijingEventHeader*) header;
205 gAlice->SetGenEventHeader(header);
208 void AliGenTherminator::Init()
210 // Initialize global variables and
211 // particle and decay tables
212 if (fFileName.Length() == 0)
213 fFileName = "event.out";
214 ReadShareParticleTable();
216 SetMC(new TTherminator());
219 ((TTherminator *) fMCEvGen)->Initialize();
221 void AliGenTherminator::SetFileName(const char *infilename)
223 // Set parameter filename
224 fFileName = infilename;
226 void AliGenTherminator::SetEventNumberInFile(int evnum)
228 // Set number of events to generate - default: 1
229 fEventNumber = evnum;
232 void AliGenTherminator::ReadShareParticleTable()
234 // Read in particle table from share
235 // and add missing particle type to TDatabasePDG
240 TDatabasePDG *tInstance = TDatabasePDG::Instance();
241 TParticlePDG *tParticleType;
243 AliWarning(Form("Reading particle types from particles.data"));
245 TString aroot = gSystem->Getenv("ALICE_ROOT");
246 ifstream in((aroot+"/TTherminator/data/SHARE/particles.data").Data());
247 // ifstream in("particles.data");
252 if ((in) && (in.is_open()))
262 if (/*(*str == '#')||*/(*str<65)||(*str>122))
264 in.getline(str1,200);
267 double mass, gamma, spin, tI3, tI, q, s, aq, as, c, ac, mc;
269 in>>mass>>gamma>>spin>>tI>>tI3>>q>>s>>aq>>as>>c>>ac>>mc;
271 tParticleType = tInstance->GetParticle((int) mc);
272 if (!tParticleType) {
274 if (strstr(str, "plu")) charge = 1;
275 if (strstr(str, "min")) charge = -1;
276 if (strstr(str, "plb")) charge = -1;
277 if (strstr(str, "mnb")) charge = 1;
278 if (strstr(str, "plp")) charge = 2;
279 if (strstr(str, "ppb")) charge = -2;
280 tInstance->AddParticle(str, str, mass, gamma == 0.0 ? 1:0, gamma, charge , "meson", (int) mc);
281 AliWarning(Form("Added particle %s with PDG PID %d charge %d", str, (int) mc, charge));
282 // AliWarning(Form("Quantum numbers q s c aq as ac tI3 %lf %lf %lf %lf %lf %lf %lf", q, s, c, aq, as, ac, tI3));
288 CreateTherminatorInputFile();
291 void AliGenTherminator::CreateTherminatorInputFile()
293 // Create Therminator input file
294 const char *aroot = gSystem->Getenv("ALICE_ROOT");
295 ofstream *ostr = new ofstream("therminator.in");
296 (*ostr) << "NumberOfEvents = 1" << endl;
297 (*ostr) << "Randomize = 1" << endl;
298 (*ostr) << "TableType = SHARE" << endl;
299 (*ostr) << "InputDirSHARE = "<< aroot << "/TTherminator/data/SHARE" << endl;
300 (*ostr) << "EventOutputFile = " << fFileName.Data() << endl;
301 (*ostr) << "FOHSLocation = " << fFOHSlocation.Data() << endl;
302 (*ostr) << "FreezeOutModel = " << fFreezeOutModel.Data() << endl;
303 (*ostr) << "BWVt = " << fBWVt << endl;
304 (*ostr) << "Tau = " << fTau << endl;
305 (*ostr) << "RhoMax = " << fRhoMax << endl;
306 (*ostr) << "Temperature = " << fTemperature << endl;
307 (*ostr) << "MiuI = " << fMiuI << endl;
308 (*ostr) << "MiuS = " << fMiuS << endl;
309 (*ostr) << "MiuB = " << fMiuB << endl;
310 (*ostr) << "AlphaRange = " << fAlfaRange << endl;
311 (*ostr) << "RapidityRange = " << fRapRange << endl;
312 (*ostr) << "NumberOfIntegrateSamples = 1000000" << endl;
315 void AliGenTherminator::SetModel(const char *model)
317 // Set the freeze-out model to use
318 fFreezeOutModel = model;
321 void AliGenTherminator::SetLhyquidSet(const char *set)
323 // Select one of pregenerated Lhyquid hypersurfaces
324 const char *aroot = gSystem->Getenv("ALICE_ROOT");
325 if (strstr(set, "LHC500C0005")) {
326 AliWarning(Form("AliGenTherminator: Selected default Lhyquid hypersurface"));
327 AliWarning(Form(" Pb-Pb collisions, centrality 0-5%"));
328 AliWarning(Form(" initial temperature at tau=1 fm in the center Ti=500 MeV"));
329 AliWarning(Form(" freeze-out criteria Tf=145 MeV"));
330 AliWarning(Form(" for details see $(ALICE_ROOT)/TTherminator/data/LHC500C0005/FO.txt"));
331 fFOHSlocation = aroot;
332 fFOHSlocation += "/TTherminator/data/LHC500C0005";
334 else if (strstr(set, "LHC500C2030")) {
335 AliWarning(Form("AliGenTherminator: Selected default Lhyquid hypersurface"));
336 AliWarning(Form(" Pb-Pb collisions, centrality 20-30%"));
337 AliWarning(Form(" initial temperature at tau=1 fm in the center Ti=500 MeV"));
338 AliWarning(Form(" freeze-out criteria Tf=145 MeV"));
339 AliWarning(Form(" for details see $(ALICE_ROOT)/TTherminator/data/LHC500C2030/FO.txt"));
340 fFOHSlocation = aroot;
341 fFOHSlocation += "/TTherminator/data/LHC500C2030";
344 AliWarning(Form("Did not find Lhyquid set %s", set));
345 AliWarning(Form("Reverting to default: current directory"));
350 void AliGenTherminator::SetLhyquidInputDir(const char *inputdir)
352 // Select Your own Lhyquid hypersurface
353 fFOHSlocation = inputdir;