]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EPOS/TEpos.cxx
oving all the proton analysis related macros to the proper directory
[u/mrichter/AliRoot.git] / EPOS / TEpos.cxx
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>
19 #include <TObjArray.h>
20 #include <TParticle.h>
21 #include <TROOT.h>
22 #include <TRandom.h>
23 #include <iostream>
24 #include <fstream>
25 #include <string>
26 #include <vector>
27 #include "eposproc.h"
28 #include "EPOScommon.h"
29 #include "TEpos.h"
30
31 using namespace std;
32
33 ClassImp(TEpos)
34
35 TEpos::TEpos()  : TGenerator("EPOS", "Epos event generator"),
36                 fLaproj(0),
37                 fMaproj(0),
38                 fLatarg(0),
39                 fMatarg(0),
40                 fBminim(0.0),
41                 fBmaxim(10000.0),
42                 fPhimin(0.0),
43                 fPhimax(2*3.1415927),
44                 fEcms(-1),
45                 fSplitting(kFALSE),
46                 fNoDecays(),
47                 fExtraInputLines()
48 {
49 }
50
51 TEpos::~TEpos() {}
52
53 void TEpos::Initialize() {
54         Int_t nopeno = 0;
55         GenerateInputFile();
56         aaset(0);
57         atitle();
58         xiniall();
59
60         const char *inputFileName = GetInputFileName();
61         Int_t nameLength = strlen(inputFileName);
62         setinp(inputFileName, nameLength, nameLength);
63         aread();
64         while(copen.nopen == -1) {
65                 copen.nopen=nopeno;
66             prnt1.iecho=1;
67                 xiniall();
68             aread();
69         }
70         Int_t ishini;
71         utpri("aamain",prnt1.ish,ishini,4,6);
72         if(appli.model != 1)
73                 IniModel(appli.model);
74         ebin.nrebin = 1;
75         ainit();
76 }
77
78 void TEpos::GenerateEvent() {
79         cseed.seedj = gRandom->Rndm() * 1e10;
80         aseed(2);
81         Int_t n = 1;
82         evgen(n);
83 }
84
85 Int_t TEpos::ImportParticles(TClonesArray *particles, Option_t *) {
86         particles->Clear();
87         if (!cevt.nevt) return 0;
88         Int_t numpart = cptl.nptl;
89         printf("%d particles generated\n", numpart);
90         for (Int_t iPart=0; iPart<numpart; iPart++) {
91                 Int_t tFather = cptl.iorptl[iPart] - 1;
92                 tFather = tFather < -1 ? -1 : tFather;
93                 if (tFather> -1) {
94                         TParticle *mother = (TParticle*) (particles->UncheckedAt(tFather));
95                         mother->SetLastDaughter(iPart);
96                         if (mother->GetFirstDaughter()==-1)
97                                 mother->SetFirstDaughter(iPart);
98                 }
99                 TDatabasePDG *pdgDb = TDatabasePDG::Instance();
100                 Int_t status = cptl.istptl[iPart] + 1;
101                 Int_t pdg = pdgDb->ConvertIsajetToPdg(cptl.idptl[iPart]);
102                 if (pdg == 0) {
103                         printf("TEpos: Warning, unknown particle, index: %d, ISAJET: %d\n",iPart,cptl.idptl[iPart]);
104                 }
105                 new((*particles)[iPart]) TParticle(pdg, status,
106                                  tFather, -1, -1, -1,
107                                  cptl.pptl[iPart][0], cptl.pptl[iPart][1],cptl.pptl[iPart][2],cptl.pptl[iPart][3],
108                                  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);
109                 (*particles)[iPart]->SetUniqueID(iPart);
110         }
111
112         return numpart;
113 }
114
115 TObjArray*  TEpos::ImportParticles(Option_t *) {
116         fParticles->Clear();
117         if (!cevt.nevt) return NULL;
118         Int_t numpart = cptl.nptl;
119         printf("%d particles generated\n", numpart);
120         for (Int_t iPart=0; iPart<numpart; iPart++) {
121                 Int_t tFather = cptl.iorptl[iPart] - 1;
122                 tFather = tFather < -1 ? -1 : tFather;
123                 if (tFather> -1) {
124                         TParticle *mother = (TParticle*) (fParticles->UncheckedAt(tFather));
125                         mother->SetLastDaughter(iPart);
126                         if (mother->GetFirstDaughter()==-1)
127                                 mother->SetFirstDaughter(iPart);
128                 }
129                 TDatabasePDG *pdgDb = TDatabasePDG::Instance();
130                 Int_t status = cptl.istptl[iPart] + 1;
131                 Int_t pdg = pdgDb->ConvertIsajetToPdg(cptl.idptl[iPart]);
132                 if (pdg == 0) {
133                         printf("TEpos: Warning, unknown particle, index: %d, ISAJET: %d\n",iPart,cptl.idptl[iPart]);
134                 }
135                 TParticle* p = new TParticle(pdg, status,
136                                  tFather, -1, -1, -1,
137                                  cptl.pptl[iPart][0], cptl.pptl[iPart][1],cptl.pptl[iPart][2],cptl.pptl[iPart][3],
138                                  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);
139                 p->SetUniqueID(iPart);
140                 fParticles->Add(p);
141         }
142
143         return fParticles;
144 }
145
146 void TEpos::AddNoDecay(Int_t nodecay) {
147         fNoDecays.push_back(nodecay);
148 }
149
150 void TEpos::AddExtraInputLine(const char *line) {
151         fExtraInputLines.push_back(line);
152 }
153
154 void TEpos::GenerateInputFile() {
155         ofstream file(GetInputFileName(), ios_base::out | ios_base::trunc);
156         char epo[256];
157         strcpy(epo, getenv("ALICE_ROOT"));
158         strcat(epo, "/EPOS/epos167");
159
160         file << "fname pathnx " << epo << "/" << endl;
161         file << "fname histo none" << endl;
162         file << "fname copy none" << endl;
163         file << "fname log none" << endl;
164         file << "fname check none" << endl;
165         file << "fname data /tmp/epos.out" << endl;
166         file << "fname initl " << epo << "/epos.initl" << endl;
167         file << "fname inidi " << epo << "/epos.inidi" << endl;
168         file << "fname inidr " << epo << "/epos.inidr" << endl;
169         file << "fname iniev " << epo << "/epos.iniev" << endl;
170         file << "fname inirj " << epo << "/epos.inirj" << endl;
171         file << "fname inics " << epo << "/epos.inics" << endl;
172         file << "fname inigrv " << epo << "/epos.inigrv" << endl;
173         file << "fqgsjet dat " << epo << "/qgsjet/qgsjet.dat" << endl;
174         file << "fqgsjet ncs " << epo << "/qgsjet/qgsjet.ncs" << endl;
175         file << "fqgsjetII dat " << epo << "/qgsjetII/qgsdat-II-03" << endl;
176         file << "fqgsjetII ncs " << epo << "/qgsjetII/sectnu-II-03" << endl;
177         file << "nodecay 120" << endl;
178         file << "nodecay -120" << endl;
179         file << "nodecay 130" << endl;
180         file << "nodecay -130" << endl;
181         file << "nodecay -20" << endl;
182         file << "nodecay 20" << endl;
183         file << "nodecay 14" << endl;
184         file << "nodecay -14" << endl;
185         file << "set ndecay 1111110" << endl;
186         file << "echo on" << endl;
187
188 //      .optns file
189         file << "application hadron" << endl;
190         file << "set laproj " << fLaproj << endl;
191         file << "set maproj " << fMaproj << endl;
192         file << "set latarg " << fLatarg << endl;
193         file << "set matarg " << fMatarg << endl;
194         file << "set bminim " << fBminim << endl;
195         file << "set bmaxim " << fBmaxim << endl;
196         file << "set phimin " << fPhimin << endl;
197         file << "set phimax " << fPhimax << endl;
198         file << "set ecms " << fEcms << endl;
199
200         for(unsigned int i = 0; i < fNoDecays.size(); ++i) {
201                 file << "nodecay " << fNoDecays[i] << endl;
202         }
203
204         file << "switch splitting " << (fSplitting ? "on" : "off") << endl;
205
206         file << "frame nucleon-nucleon" << endl;
207
208         for(unsigned int i = 0; i < fExtraInputLines.size(); ++i) {
209                 file << fExtraInputLines[i] << endl;
210         }
211
212     file << "output epos" << endl;
213     file << "record event nevt nptl b endrecord" << endl;
214     file << "record particle i id fa mo c1 c2 st endrecord" << endl;
215
216         file << "input " << epo << "/epos.param" << endl;
217         file << "runprogram" << endl;
218         file.close();
219 }
220
221 Float_t TEpos::GetBimevt() { return cevt.bimevt; }
222 Float_t TEpos::GetPhievt() { return cevt.phievt; }
223 Int_t TEpos::GetKolevt() { return cevt.kolevt; }
224 Int_t TEpos::GetKoievt() { return cevt.koievt; }
225 Float_t TEpos::GetPmxevt() { return cevt.pmxevt; }
226 Float_t TEpos::GetEgyevt() { return cevt.egyevt; }
227 Int_t TEpos::GetNpjevt() { return cevt.npjevt; }
228 Int_t TEpos::GetNtgevt() { return cevt.ntgevt; }
229 Int_t TEpos::GetNpnevt() { return cevt.npnevt; }
230 Int_t TEpos::GetNppevt() { return cevt.nppevt; }
231 Int_t TEpos::GetNtnevt() { return cevt.ntnevt; }
232 Int_t TEpos::GetNtpevt() { return cevt.ntpevt; }
233 Int_t TEpos::GetJpnevt() { return cevt.jpnevt; }
234 Int_t TEpos::GetJppevt() { return cevt.jppevt; }
235 Int_t TEpos::GetJtnevt() { return cevt.jtnevt; }
236 Int_t TEpos::GetJtpevt() { return cevt.jtpevt; }
237 Float_t TEpos::GetXbjevt() { return cevt.xbjevt; }
238 Float_t TEpos::GetQsqevt() { return cevt.qsqevt; }
239 Int_t TEpos::GetNglevt() { return cevt.nglevt; }
240 Float_t TEpos::GetZppevt() { return cevt.zppevt; }
241 Float_t TEpos::GetZptevt() { return cevt.zptevt; }
242