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
48 AliGenTherminator::AliGenTherminator(Int_t npart):
66 // Constructor specifying the size of the particle table
70 AliGenTherminator::~AliGenTherminator()
72 // AliGenMC::~AliGenMC();
73 // if (fTherminator) delete fTherminator;
76 void AliGenTherminator::Generate()
78 // Run single event generation with the Therminator model
79 AliWarning("Generating event from AliGenTherminator");
81 Float_t polar[3] = {0,0,0};
82 Float_t origin[3] = {0,0,0};
83 Float_t origin0[3] = {0,0,0};
92 for (j=0; j < 3; j++) origin0[j] = fVertex[j];
96 ((TTherminator *) fMCEvGen)->GenerateEvent();
97 AliWarning("Generated");
98 ((TTherminator *) fMCEvGen)->ImportParticles(&fParticles);
100 Int_t np = fParticles.GetEntriesFast();
101 AliWarning(Form("Imported %d particles", np));
103 TParticle *iparticle;
104 Double_t evrot = gRandom->Rndm()*TMath::Pi();
106 for (int i = 0; i < np; i++) {
107 iparticle = (TParticle *) fParticles.At(i);
108 Bool_t hasMother = (iparticle->GetFirstMother() >=0);
109 Bool_t hasDaughter = (iparticle->GetFirstDaughter() >=0);
111 kf = iparticle->GetPdgCode();
112 ks = iparticle->GetStatusCode();
113 Double_t aphi = TMath::ATan2(iparticle->Py(), iparticle->Px());
114 Double_t arho = TMath::Hypot(iparticle->Px(), iparticle->Py());
115 p[0] = arho*TMath::Cos(aphi + evrot);
116 p[1] = arho*TMath::Sin(aphi + evrot);
117 // p[0] = iparticle->Px();
118 // p[1] = iparticle->Py();
119 p[2] = iparticle->Pz();
120 mass = TDatabasePDG::Instance()->GetParticle(kf)->Mass();
121 energy = sqrt(mass*mass + p[0]*p[0] + p[1]*p[1] + p[2]*p[2]);
123 Double_t vphi = TMath::ATan2(iparticle->Vy(), iparticle->Vx());
124 Double_t vrho = TMath::Hypot(iparticle->Vx(), iparticle->Vy());
125 origin[0] = origin0[0]+vrho*TMath::Cos(vphi + evrot);
126 origin[1] = origin0[1]+vrho*TMath::Sin(vphi + evrot);
127 origin[2] = origin0[2]+iparticle->Vz();
130 TParticle* mother = 0;
132 imo = iparticle->GetFirstMother();
133 mother = (TParticle *) fParticles.At(imo);
135 Bool_t tFlag = (!hasDaughter);
137 printf("Pushing Track %d with status %d mother %d\n", kf, tFlag, imo);
138 PushTrack(tFlag,imo,kf,
139 p[0],p[1],p[2],energy,
140 origin[0],origin[1],origin[2],iparticle->T()*0.197327*1e-13/300000000,
141 polar[0],polar[1],polar[2],
142 hasMother ? kPDecay:kPNoProcess,nt);
148 SetHighWaterMark(fNprimaries);
152 eventVertex[0] = origin0[0];
153 eventVertex[1] = origin0[1];
154 eventVertex[2] = origin0[2];
156 // Builds the event header, to be called after each event
157 AliGenEventHeader* header = new AliGenHijingEventHeader("Therminator");
160 // AliGenEventHeader* header = new AliGenEventHeader("Therminator");
162 // header->SetPrimaryVertex(eventVertex);
163 // header->SetNProduced(fNprimaries);
165 ((AliGenHijingEventHeader*) header)->SetNProduced(fNprimaries);
166 ((AliGenHijingEventHeader*) header)->SetPrimaryVertex(eventVertex);
167 ((AliGenHijingEventHeader*) header)->SetImpactParameter(0.0);
168 ((AliGenHijingEventHeader*) header)->SetTotalEnergy(0.0);
169 ((AliGenHijingEventHeader*) header)->SetHardScatters(0);
170 ((AliGenHijingEventHeader*) header)->SetParticipants(0, 0);
171 ((AliGenHijingEventHeader*) header)->SetCollisions(0, 0, 0, 0);
172 ((AliGenHijingEventHeader*) header)->SetSpectators(0, 0, 0, 0);
173 ((AliGenHijingEventHeader*) header)->SetReactionPlaneAngle(evrot);
176 // 4-momentum vectors of the triggered jets.
178 // Before final state gluon radiation.
179 // TLorentzVector* jet1 = new TLorentzVector(fHijing->GetHINT1(21),
180 // fHijing->GetHINT1(22),
181 // fHijing->GetHINT1(23),
182 // fHijing->GetHINT1(24));
184 // TLorentzVector* jet2 = new TLorentzVector(fHijing->GetHINT1(31),
185 // fHijing->GetHINT1(32),
186 // fHijing->GetHINT1(33),
187 // fHijing->GetHINT1(34));
188 // // After final state gluon radiation.
189 // TLorentzVector* jet3 = new TLorentzVector(fHijing->GetHINT1(26),
190 // fHijing->GetHINT1(27),
191 // fHijing->GetHINT1(28),
192 // fHijing->GetHINT1(29));
194 // TLorentzVector* jet4 = new TLorentzVector(fHijing->GetHINT1(36),
195 // fHijing->GetHINT1(37),
196 // fHijing->GetHINT1(38),
197 // fHijing->GetHINT1(39));
198 // ((AliGenHijingEventHeader*) header)->SetJets(jet1, jet2, jet3, jet4);
199 // Bookkeeping for kinematic bias
200 // ((AliGenHijingEventHeader*) header)->SetTrials(fTrials);
202 header->SetPrimaryVertex(fVertex);
204 fCollisionGeometry = (AliGenHijingEventHeader*) header;
206 gAlice->SetGenEventHeader(header);
209 void AliGenTherminator::Init()
211 // Initialize global variables and
212 // particle and decay tables
213 if (fFileName.Length() == 0)
214 fFileName = "event.out";
215 ReadShareParticleTable();
217 SetMC(new TTherminator());
220 ((TTherminator *) fMCEvGen)->Initialize();
222 void AliGenTherminator::SetFileName(const char *infilename)
224 // Set parameter filename
225 fFileName = infilename;
227 void AliGenTherminator::SetEventNumberInFile(int evnum)
229 // Set number of events to generate - default: 1
230 fEventNumber = evnum;
233 void AliGenTherminator::ReadShareParticleTable()
235 // Read in particle table from share
236 // and add missing particle type to TDatabasePDG
241 TDatabasePDG *tInstance = TDatabasePDG::Instance();
242 TParticlePDG *tParticleType;
244 AliWarning(Form("Reading particle types from particles.data"));
246 TString aroot = gSystem->Getenv("ALICE_ROOT");
247 ifstream in((aroot+"/TTherminator/data/SHARE/particles.data").Data());
248 // ifstream in("particles.data");
253 if ((in) && (in.is_open()))
263 if (/*(*str == '#')||*/(*str<65)||(*str>122))
265 in.getline(str1,200);
268 double mass, gamma, spin, tI3, tI, q, s, aq, as, c, ac, mc;
270 in>>mass>>gamma>>spin>>tI>>tI3>>q>>s>>aq>>as>>c>>ac>>mc;
272 tParticleType = tInstance->GetParticle((int) mc);
273 if (!tParticleType) {
275 if (strstr(str, "plu")) charge = 1;
276 if (strstr(str, "min")) charge = -1;
277 if (strstr(str, "plb")) charge = -1;
278 if (strstr(str, "mnb")) charge = 1;
279 if (strstr(str, "plp")) charge = 2;
280 if (strstr(str, "ppb")) charge = -2;
281 tInstance->AddParticle(str, str, mass, gamma == 0.0 ? 1:0, gamma, charge , "meson", (int) mc);
282 AliWarning(Form("Added particle %s with PDG PID %d charge %d", str, (int) mc, charge));
283 // 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));
289 CreateTherminatorInputFile();
292 void AliGenTherminator::CreateTherminatorInputFile()
294 // Create Therminator input file
295 const char *aroot = gSystem->Getenv("ALICE_ROOT");
296 ofstream *ostr = new ofstream("therminator.in");
297 (*ostr) << "NumberOfEvents = 1" << endl;
298 (*ostr) << "Randomize = 1" << endl;
299 (*ostr) << "TableType = SHARE" << endl;
300 (*ostr) << "InputDirSHARE = "<< aroot << "/TTherminator/data/SHARE" << endl;
301 (*ostr) << "EventOutputFile = " << fFileName.Data() << endl;
302 (*ostr) << "FOHSLocation = " << fFOHSlocation.Data() << endl;
303 (*ostr) << "FreezeOutModel = " << fFreezeOutModel.Data() << endl;
304 (*ostr) << "BWVt = " << fBWVt << endl;
305 (*ostr) << "Tau = " << fTau << endl;
306 (*ostr) << "RhoMax = " << fRhoMax << endl;
307 (*ostr) << "Temperature = " << fTemperature << endl;
308 (*ostr) << "MiuI = " << fMiuI << endl;
309 (*ostr) << "MiuS = " << fMiuS << endl;
310 (*ostr) << "MiuB = " << fMiuB << endl;
311 (*ostr) << "AlphaRange = " << fAlfaRange << endl;
312 (*ostr) << "RapidityRange = " << fRapRange << endl;
313 (*ostr) << "NumberOfIntegrateSamples = 1000000" << endl;
316 void AliGenTherminator::SetModel(const char *model)
318 // Set the freeze-out model to use
319 fFreezeOutModel = model;
322 void AliGenTherminator::SetLhyquidSet(const char *set)
324 // Select one of pregenerated Lhyquid hypersurfaces
325 const char *aroot = gSystem->Getenv("ALICE_ROOT");
326 if (strstr(set, "LHC500C0005")) {
327 AliWarning(Form("AliGenTherminator: Selected default Lhyquid hypersurface"));
328 AliWarning(Form(" Pb-Pb collisions, centrality 0-5%"));
329 AliWarning(Form(" initial temperature at tau=1 fm in the center Ti=500 MeV"));
330 AliWarning(Form(" freeze-out criteria Tf=145 MeV"));
331 AliWarning(Form(" for details see $(ALICE_ROOT)/TTherminator/data/LHC500C0005/FO.txt"));
332 fFOHSlocation = aroot;
333 fFOHSlocation += "/TTherminator/data/LHC500C0005";
335 else if (strstr(set, "LHC500C2030")) {
336 AliWarning(Form("AliGenTherminator: Selected default Lhyquid hypersurface"));
337 AliWarning(Form(" Pb-Pb collisions, centrality 20-30%"));
338 AliWarning(Form(" initial temperature at tau=1 fm in the center Ti=500 MeV"));
339 AliWarning(Form(" freeze-out criteria Tf=145 MeV"));
340 AliWarning(Form(" for details see $(ALICE_ROOT)/TTherminator/data/LHC500C2030/FO.txt"));
341 fFOHSlocation = aroot;
342 fFOHSlocation += "/TTherminator/data/LHC500C2030";
345 AliWarning(Form("Did not find Lhyquid set %s", set));
346 AliWarning(Form("Reverting to default: current directory"));
351 void AliGenTherminator::SetLhyquidInputDir(const char *inputdir)
353 // Select Your own Lhyquid hypersurface
354 fFOHSlocation = inputdir;