1 /******************************************************************************
2 * T H E R M I N A T O R *
3 * THERMal heavy-IoN generATOR *
6 * Authors of the model: Wojciech Broniowski, Wojciech.Broniowski@ifj.edu.pl, *
7 * Wojciech Florkowski, Wojciech.Florkowski@ifj.edu.pl *
8 * Authors of the code: Adam Kisiel, kisiel@if.pw.edu.pl *
9 * Tomasz Taluc, ttaluc@if.pw.edu.pl *
10 * Code designers: Adam Kisiel, Tomasz Taluc, Wojciech Broniowski, *
11 * Wojciech Florkowski *
13 * For the detailed description of the program and furhter references *
14 * to the description of the model plesase refer to: nucl-th/0504047, *
15 * accessibile at: http://www.arxiv.org/nucl-th/0504047 *
17 * Homepage: http://hirg.if.pw.edu.pl/en/therminator/ *
19 * This code can be freely used and redistributed. However if you decide to *
20 * make modifications to the code, please contact the authors, especially *
21 * if you plan to publish the results obtained with such modified code. *
22 * Any publication of results obtained using this code must include the *
23 * reference to nucl-th/0504047 and the published version of it, when *
26 *****************************************************************************/
32 #include "Integrator.h"
33 #include "ParticleDecayer.h"
34 #include "DecayTable.h"
37 extern ReadPar* sRPInstance;
39 Event::Event(ParticleDB *aDB, Integrator* aInteg) :
45 mRandom = new TRandom2();
47 mRandom->SetSeed2(31851, 14327);
49 mRandom->SetSeed(31851);
51 mAverageMultiplicities.resize(mDB->GetParticleTypeCount());
52 mMultiplicities.resize(mDB->GetParticleTypeCount());
67 Event::GenerateEvent(int aSeed)
73 if (aSeed) mRandom->SetSeed2(aSeed, (aSeed*2) % (7*11*23*31));
75 if (aSeed) mRandom->SetSeed(aSeed);
77 GenerateMultiplicities();
78 for (unsigned int tIter=0; tIter<mAverageMultiplicities.size(); tIter++) {
79 mInteg->Generate(mDB->GetParticleType(tIter), mMultiplicities[tIter], &tPartBuf);
80 for (int tBufIter=0; tBufIter<mMultiplicities[tIter]; tBufIter++) {
81 AddParticle(tPartBuf[tBufIter]);
82 delete tPartBuf[tBufIter];
89 Event::GetParticleCount()
91 return mParticles.size();
95 Event::GetNextParticle()
99 if (mCurIter == mParticles.end())
110 Event::InitParticleScan()
112 mCurIter = mParticles.begin();
117 Event::GetParticleOfCount(int aCount)
122 else if (aCount == 1) {
132 if (mCurIter == mParticles.end())
141 Event::WriteEvent(int nEvent)
143 ParticleListIter tPLIter;
144 tPLIter = mParticles.begin();
150 os.open(sRPInstance->getPar("EventOutputFile").Data());
153 PRINT_MESSAGE("Very strange: No event output filename ???");
159 os.open(sRPInstance->getPar("EventOutputFile").Data(), ios::app);
162 PRINT_MESSAGE("Very strange: No event output filename ???");
171 os << "Therminator text output\nall_particles_p_x\nTherminator " << endl;
173 os << nEvent+1 << " " << GetParticleCount() << " " << "0.000" << " " << "0.000" << endl;
175 while (tPLIter != mParticles.end())
177 os.flags(ios::right);
181 (*tPLIter).WriteParticle(&os);
191 Event::AddParticle(Particle* aParticle)
194 ParticleListIter tPLIter;
195 tPLIter = mParticles.begin();
196 while (tPLIter != mParticles.end())
198 if (((*tPLIter).GetMass() == aParticle->GetMass()) &&
199 ((*tPLIter).GetI3() == aParticle->GetI3()) &&
200 ((*tPLIter).GetBarionN() == aParticle->GetBarionN()) &&
201 ((*tPLIter).GetStrangeness() == aParticle->GetStrangeness()))
203 if ((*tPLIter).GetMass() < aParticle->GetMass())
205 else if ((*tPLIter).GetMass() == aParticle->GetMass())
206 if ((*tPLIter).GetI3() < aParticle->GetI3())
208 else if ((*tPLIter).GetI3() == aParticle->GetI3())
209 if ((*tPLIter).GetBarionN() < aParticle->GetBarionN())
211 else if ((*tPLIter).GetBarionN() == aParticle->GetBarionN())
212 if ((*tPLIter).GetStrangeness() < aParticle->GetStrangeness())
216 mParticles.insert(tPLIter, *aParticle);
219 mParticles.push_back(*aParticle);
223 Event::ReadMultiplicities()
230 ifstream *fin = NULL;
232 tHash = mInteg->ParameterHash();
234 strcpy(tMultName, "fmultiplicity_");
235 strcat(tMultName, tHash);
236 strcat(tMultName, ".txt");
238 fin = new ifstream(tMultName);
239 if ((fin) && (fin->is_open())) {
240 PRINT_MESSAGE("Reading Multiplicities from " << tMultName);
244 (*fin) >> tName >> tMult;
245 PRINT_DEBUG_2(tName << " " << mDB->GetParticleTypeIndex(strdup(tName)) << " " << tMult);
246 mAverageMultiplicities[mDB->GetParticleTypeIndex(strdup(tName))] = tMult;
253 Event::GenerateMultiplicities()
255 for (unsigned int tIter=0; tIter<mAverageMultiplicities.size(); tIter++)
256 mMultiplicities[tIter] = mRandom->Poisson(mAverageMultiplicities[tIter]);
260 Event::DecayParticles()
262 Particle *tPart1, *tPart2, *tPart3, *tFather;
263 ParticleDecayer* tDecayer;
266 tDecayer = new ParticleDecayer(mDB);
267 tDecayer->SeedSet(mRandom->Integer(100000000));
269 // InitParticleScan();
270 while ((tFather = GetParticleOfCount(tCount)))
272 if (tFather->GetParticleType()->GetGamma() >= 0.0)
273 if ((tFather->GetParticleType()->GetTable()) && (((DecayTable *) tFather->GetParticleType()->GetTable())->GetChannelCount()+1 > 0))
275 tDecayer->DecayParticle(tFather, &tPart1, &tPart2, &tPart3);
276 #ifndef _RESCALE_CHANNELS_
282 #ifdef _NO_THREE_BODY_DECAYS_
288 #ifdef _OMIT_TWO_BODY_
289 if (tPart1 && tPart2 && !tPart3){
295 tPart1->SetFather(tCount);
296 tPart2->SetFather(tCount);
298 tPart3->SetFather(tCount);
326 mRandom->SetSeed2(dat.Get() / 2 * 3, dat.Get() / 11 * 9);
328 mRandom->SetSeed(dat.Get() / 2 * 3);
333 Event::ReadParameters()
336 STR tUseNegativeBinomial;
339 tEvFile = sRPInstance->getPar("EventOutputFile");
342 PRINT_DEBUG_1("Event::ReadParameters - Caught exception " << e);
343 PRINT_MESSAGE("Did not find one of the neccessary parameters in the parameters file.");
347 tUseNegativeBinomial = sRPInstance->getPar("MultiplicityDistribution");
348 if (tUseNegativeBinomial.Contains("NegativeBinomial"))
354 PRINT_MESSAGE("Using default multiplicty distribution: Poissonian");