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()) {
219 mParticles.insert(tPLIter, *aParticle);
222 mParticles.push_back(*aParticle);
226 Event::ReadMultiplicities()
234 ifstream *fin = NULL;
236 tHash = mInteg->ParameterHash();
237 multsize = strlen(mFOHSlocation.Data()) + 25 + strlen(tHash);
238 tMultName = (char *) malloc(sizeof(char) * multsize);
241 printf("Cannot allocate memory!\n");
245 if (mFOHSlocation != "") {
246 strcpy(tMultName, mFOHSlocation.Data());
247 strcat(tMultName, "/");
248 strcat(tMultName, "fmultiplicity_");
249 strcat(tMultName, tHash);
250 strcat(tMultName, ".txt");
251 fin = new ifstream(tMultName);
253 else if (!((fin) && (fin->is_open()))) {
254 strcpy(tMultName, "fmultiplicity_");
255 strcat(tMultName, tHash);
256 strcat(tMultName, ".txt");
257 fin = new ifstream(tMultName);
260 // strcpy(tMultName, "fmultiplicity_");
261 // strcat(tMultName, tHash);
262 // strcat(tMultName, ".txt");
264 // fin = new ifstream(tMultName);
265 if ((fin) && (fin->is_open())) {
266 PRINT_MESSAGE("Reading Multiplicities from " << tMultName);
270 (*fin) >> tName >> tMult;
271 PRINT_DEBUG_2(tName << " " << mDB->GetParticleTypeIndex(strdup(tName)) << " " << tMult);
272 mAverageMultiplicities[mDB->GetParticleTypeIndex(strdup(tName))] = tMult;
281 Event::GenerateMultiplicities()
283 for (unsigned int tIter=0; tIter<mAverageMultiplicities.size(); tIter++)
284 mMultiplicities[tIter] = mRandom->Poisson(mAverageMultiplicities[tIter]);
288 Event::DecayParticles()
290 Particle *tPart1, *tPart2, *tPart3, *tFather;
291 ParticleDecayer* tDecayer;
294 tDecayer = new ParticleDecayer(mDB);
295 tDecayer->SeedSet(mRandom->Integer(100000000));
297 // InitParticleScan();
298 while ((tFather = GetParticleOfCount(tCount)))
300 if (tFather->GetParticleType()->GetGamma() >= 0.0) {
301 if ((tFather->GetParticleType()->GetTable()) && (((DecayTable *) tFather->GetParticleType()->GetTable())->GetChannelCount()+1 > 0))
303 tDecayer->DecayParticle(tFather, &tPart1, &tPart2, &tPart3);
304 #ifndef _RESCALE_CHANNELS_
310 #ifdef _NO_THREE_BODY_DECAYS_
316 #ifdef _OMIT_TWO_BODY_
317 if (tPart1 && tPart2 && !tPart3){
323 tPart1->SetFather(tCount);
324 tPart2->SetFather(tCount);
326 tPart3->SetFather(tCount);
355 mRandom->SetSeed2(dat.Get() / 2 * 3, dat.Get() / 11 * 9);
357 mRandom->SetSeed(dat.Get() / 2 * 3);
362 Event::ReadParameters()
365 STR tUseNegativeBinomial;
368 tEvFile = sRPInstance->getPar("EventOutputFile");
371 PRINT_DEBUG_1("Event::ReadParameters - Caught exception " << e);
372 PRINT_MESSAGE("Did not find one of the neccessary parameters in the parameters file.");
376 tUseNegativeBinomial = sRPInstance->getPar("MultiplicityDistribution");
377 if (tUseNegativeBinomial.Contains("NegativeBinomial"))
383 PRINT_MESSAGE("Using default multiplicty distribution: Poissonian");
387 mFOHSlocation = sRPInstance->getPar("FOHSLocation");