Added PDG db. updater, complete information in the header plus minor fixes
[u/mrichter/AliRoot.git] / EPOS / TEpos.cxx
CommitLineData
9ef1c2d9 1/*
2 *###################################################################
3 *# EPOS 1.67 K. WERNER, T. PIEROG, S. PORTEBOEUF. #
4 *# Contact: werner@subatech.in2p3.fr #
5 *###################################################################
6 *
7 * TEpos.cxx
8 *
9 * Wraper class for interfacing EPOS model, derived from ROOT's TGenerator.
10 * It generates temporary input file for the model, providing user with
11 * ability to add his/hers own lines to the input.
12 * Output is read directly from common blocks.
13 *
14 * Author: Piotr Ostrowski, postrow@if.pw.edu.pl
15 */
16
17
18#include <TClonesArray.h>
6a0522a4 19#include <TDatabasePDG.h>
9ef1c2d9 20#include <TObjArray.h>
21#include <TParticle.h>
22#include <TROOT.h>
23#include <TRandom.h>
879c2333 24#include <TMath.h>
9ef1c2d9 25#include <iostream>
26#include <fstream>
27#include <string>
28#include <vector>
29#include "eposproc.h"
30#include "EPOScommon.h"
879c2333 31#include "AliGenEposIsajetToPdgConverter.h"
9ef1c2d9 32#include "TEpos.h"
33
34using namespace std;
35
36ClassImp(TEpos)
37
38TEpos::TEpos() : TGenerator("EPOS", "Epos event generator"),
39 fLaproj(0),
40 fMaproj(0),
41 fLatarg(0),
42 fMatarg(0),
43 fBminim(0.0),
44 fBmaxim(10000.0),
45 fPhimin(0.0),
879c2333 46 fPhimax(TMath::TwoPi()),
9ef1c2d9 47 fEcms(-1),
48 fSplitting(kFALSE),
49 fNoDecays(),
879c2333 50 fExtraInputLines(),
51 fIdConverter()
9ef1c2d9 52{
879c2333 53 fIdConverter=new AliGenEposIsajetToPdgConverter();
9ef1c2d9 54}
55
879c2333 56TEpos::TEpos(const TEpos&) : TGenerator("EPOS", "Epos event generator"),
57 fLaproj(0),
58 fMaproj(0),
59 fLatarg(0),
60 fMatarg(0),
61 fBminim(0.0),
62 fBmaxim(10000.0),
63 fPhimin(0.0),
64 fPhimax(TMath::TwoPi()),
65 fEcms(-1),
66 fSplitting(kFALSE),
67 fNoDecays(),
68 fExtraInputLines(),
69 fIdConverter()
70{
71 fIdConverter = new AliGenEposIsajetToPdgConverter();
72}
73
74TEpos::~TEpos() {
75 delete fIdConverter;
76}
77
78TEpos& TEpos::operator=(const TEpos&) {
79 if (!fIdConverter) {
80 fIdConverter = new AliGenEposIsajetToPdgConverter();
81 }
82 return *this;
83}
9ef1c2d9 84
85void TEpos::Initialize() {
86 Int_t nopeno = 0;
87 GenerateInputFile();
88 aaset(0);
89 atitle();
90 xiniall();
91
92 const char *inputFileName = GetInputFileName();
93 Int_t nameLength = strlen(inputFileName);
94 setinp(inputFileName, nameLength, nameLength);
95 aread();
96 while(copen.nopen == -1) {
97 copen.nopen=nopeno;
98 prnt1.iecho=1;
99 xiniall();
100 aread();
101 }
102 Int_t ishini;
103 utpri("aamain",prnt1.ish,ishini,4,6);
104 if(appli.model != 1)
105 IniModel(appli.model);
106 ebin.nrebin = 1;
107 ainit();
108}
109
110void TEpos::GenerateEvent() {
111 cseed.seedj = gRandom->Rndm() * 1e10;
112 aseed(2);
113 Int_t n = 1;
114 evgen(n);
115}
116
117Int_t TEpos::ImportParticles(TClonesArray *particles, Option_t *) {
118 particles->Clear();
119 if (!cevt.nevt) return 0;
120 Int_t numpart = cptl.nptl;
121 printf("%d particles generated\n", numpart);
122 for (Int_t iPart=0; iPart<numpart; iPart++) {
123 Int_t tFather = cptl.iorptl[iPart] - 1;
124 tFather = tFather < -1 ? -1 : tFather;
125 if (tFather> -1) {
126 TParticle *mother = (TParticle*) (particles->UncheckedAt(tFather));
127 mother->SetLastDaughter(iPart);
128 if (mother->GetFirstDaughter()==-1)
129 mother->SetFirstDaughter(iPart);
130 }
9ef1c2d9 131 Int_t status = cptl.istptl[iPart] + 1;
879c2333 132 Int_t pdg = fIdConverter->ConvertIsajetToPdg(cptl.idptl[iPart]);
9ef1c2d9 133 new((*particles)[iPart]) TParticle(pdg, status,
134 tFather, -1, -1, -1,
135 cptl.pptl[iPart][0], cptl.pptl[iPart][1],cptl.pptl[iPart][2],cptl.pptl[iPart][3],
136 cptl.xorptl[iPart][0]*1.e-12, cptl.xorptl[iPart][1]*1.e-12, cptl.xorptl[iPart][2]*1.e-12, cptl.xorptl[iPart][3]*1e-12);
137 (*particles)[iPart]->SetUniqueID(iPart);
138 }
139
140 return numpart;
141}
142
143TObjArray* TEpos::ImportParticles(Option_t *) {
144 fParticles->Clear();
145 if (!cevt.nevt) return NULL;
146 Int_t numpart = cptl.nptl;
147 printf("%d particles generated\n", numpart);
148 for (Int_t iPart=0; iPart<numpart; iPart++) {
149 Int_t tFather = cptl.iorptl[iPart] - 1;
150 tFather = tFather < -1 ? -1 : tFather;
151 if (tFather> -1) {
152 TParticle *mother = (TParticle*) (fParticles->UncheckedAt(tFather));
153 mother->SetLastDaughter(iPart);
154 if (mother->GetFirstDaughter()==-1)
155 mother->SetFirstDaughter(iPart);
156 }
9ef1c2d9 157 Int_t status = cptl.istptl[iPart] + 1;
879c2333 158 Int_t pdg = fIdConverter->ConvertIsajetToPdg(cptl.idptl[iPart]);
9ef1c2d9 159 TParticle* p = new TParticle(pdg, status,
160 tFather, -1, -1, -1,
161 cptl.pptl[iPart][0], cptl.pptl[iPart][1],cptl.pptl[iPart][2],cptl.pptl[iPart][3],
162 cptl.xorptl[iPart][0]*1.e-12, cptl.xorptl[iPart][1]*1.e-12, cptl.xorptl[iPart][2]*1.e-12, cptl.xorptl[iPart][3]*1e-12);
163 p->SetUniqueID(iPart);
164 fParticles->Add(p);
165 }
166
167 return fParticles;
168}
169
170void TEpos::AddNoDecay(Int_t nodecay) {
171 fNoDecays.push_back(nodecay);
172}
173
174void TEpos::AddExtraInputLine(const char *line) {
175 fExtraInputLines.push_back(line);
176}
177
178void TEpos::GenerateInputFile() {
179 ofstream file(GetInputFileName(), ios_base::out | ios_base::trunc);
180 char epo[256];
60ed90b3 181 char *epoEnv = getenv("EPO");
182 if (epoEnv) {
183 strcpy(epo, epoEnv);
184 } else {
185 strcpy(epo, getenv("ALICE_ROOT"));
186 }
9ef1c2d9 187 strcat(epo, "/EPOS/epos167");
188
189 file << "fname pathnx " << epo << "/" << endl;
190 file << "fname histo none" << endl;
191 file << "fname copy none" << endl;
192 file << "fname log none" << endl;
193 file << "fname check none" << endl;
879c2333 194// file << "fname data /tmp/epos.out" << endl;
9ef1c2d9 195 file << "fname initl " << epo << "/epos.initl" << endl;
196 file << "fname inidi " << epo << "/epos.inidi" << endl;
197 file << "fname inidr " << epo << "/epos.inidr" << endl;
198 file << "fname iniev " << epo << "/epos.iniev" << endl;
199 file << "fname inirj " << epo << "/epos.inirj" << endl;
200 file << "fname inics " << epo << "/epos.inics" << endl;
201 file << "fname inigrv " << epo << "/epos.inigrv" << endl;
202 file << "fqgsjet dat " << epo << "/qgsjet/qgsjet.dat" << endl;
203 file << "fqgsjet ncs " << epo << "/qgsjet/qgsjet.ncs" << endl;
204 file << "fqgsjetII dat " << epo << "/qgsjetII/qgsdat-II-03" << endl;
205 file << "fqgsjetII ncs " << epo << "/qgsjetII/sectnu-II-03" << endl;
206 file << "nodecay 120" << endl;
207 file << "nodecay -120" << endl;
208 file << "nodecay 130" << endl;
209 file << "nodecay -130" << endl;
210 file << "nodecay -20" << endl;
211 file << "nodecay 20" << endl;
212 file << "nodecay 14" << endl;
213 file << "nodecay -14" << endl;
214 file << "set ndecay 1111110" << endl;
215 file << "echo on" << endl;
216
217// .optns file
60ed90b3 218 int precision = file.precision();
219 file.precision(15);
220 file << "set seedj " << (gRandom->Rndm() * 1e14) << endl;
221 file.precision(precision);
9ef1c2d9 222 file << "application hadron" << endl;
223 file << "set laproj " << fLaproj << endl;
224 file << "set maproj " << fMaproj << endl;
225 file << "set latarg " << fLatarg << endl;
226 file << "set matarg " << fMatarg << endl;
227 file << "set bminim " << fBminim << endl;
228 file << "set bmaxim " << fBmaxim << endl;
229 file << "set phimin " << fPhimin << endl;
230 file << "set phimax " << fPhimax << endl;
231 file << "set ecms " << fEcms << endl;
232
233 for(unsigned int i = 0; i < fNoDecays.size(); ++i) {
234 file << "nodecay " << fNoDecays[i] << endl;
235 }
236
237 file << "switch splitting " << (fSplitting ? "on" : "off") << endl;
238
239 file << "frame nucleon-nucleon" << endl;
240
241 for(unsigned int i = 0; i < fExtraInputLines.size(); ++i) {
242 file << fExtraInputLines[i] << endl;
243 }
244
879c2333 245// file << "output epos" << endl;
246// file << "record event nevt nptl b endrecord" << endl;
247// file << "record particle i id fa mo c1 c2 st endrecord" << endl;
9ef1c2d9 248
249 file << "input " << epo << "/epos.param" << endl;
250 file << "runprogram" << endl;
251 file.close();
252}
253
254Float_t TEpos::GetBimevt() { return cevt.bimevt; }
255Float_t TEpos::GetPhievt() { return cevt.phievt; }
256Int_t TEpos::GetKolevt() { return cevt.kolevt; }
257Int_t TEpos::GetKoievt() { return cevt.koievt; }
258Float_t TEpos::GetPmxevt() { return cevt.pmxevt; }
259Float_t TEpos::GetEgyevt() { return cevt.egyevt; }
260Int_t TEpos::GetNpjevt() { return cevt.npjevt; }
261Int_t TEpos::GetNtgevt() { return cevt.ntgevt; }
262Int_t TEpos::GetNpnevt() { return cevt.npnevt; }
263Int_t TEpos::GetNppevt() { return cevt.nppevt; }
264Int_t TEpos::GetNtnevt() { return cevt.ntnevt; }
265Int_t TEpos::GetNtpevt() { return cevt.ntpevt; }
266Int_t TEpos::GetJpnevt() { return cevt.jpnevt; }
267Int_t TEpos::GetJppevt() { return cevt.jppevt; }
268Int_t TEpos::GetJtnevt() { return cevt.jtnevt; }
269Int_t TEpos::GetJtpevt() { return cevt.jtpevt; }
270Float_t TEpos::GetXbjevt() { return cevt.xbjevt; }
271Float_t TEpos::GetQsqevt() { return cevt.qsqevt; }
272Int_t TEpos::GetNglevt() { return cevt.nglevt; }
273Float_t TEpos::GetZppevt() { return cevt.zppevt; }
274Float_t TEpos::GetZptevt() { return cevt.zptevt; }
275