Introducing the interaction time into the aliroot generators. In case of gaussian...
[u/mrichter/AliRoot.git] / EPOS / AliGenEpos.cxx
1 //
2 // AliGenEpos.cxx
3 //
4 //  ALICE event generator based on EPOS model from Klaus Werner
5 //
6 //  Created on: Feb 28, 2009
7 //      Author: Piotr Ostrowski, postrow@if.pw.edu.pl
8 //
9
10 #include "AliGenEpos.h"
11 #include "TEpos.h"
12 #include "TParticle.h"
13 #include "TMath.h"
14 #include "AliLog.h"
15 #include "AliGenEventHeader.h"
16 #include "AliGenEposEventHeader.h"
17
18 ClassImp(AliGenEpos)
19
20 AliGenEpos::AliGenEpos() : AliGenMC(),
21                 fBmin(0),
22                 fBmax(10000),
23                 fPhiMin(0),
24                 fPhiMax(TMath::TwoPi()),
25                 fFilterModelOutput(kFALSE) {
26         SetMC(new TEpos());
27 }
28
29 AliGenEpos::AliGenEpos(Int_t npart) : AliGenMC(npart),
30                 fBmin(0),
31                 fBmax(10000),
32                 fPhiMin(0),
33                 fPhiMax(TMath::TwoPi()),
34                 fFilterModelOutput(kFALSE) {
35         SetMC(new TEpos());
36 }
37
38 void AliGenEpos::Init() {
39   // Sets up TEpos
40         AliGenMC::Init();
41         TEpos *epos = GetTEpos();
42         epos->SetLaproj(this->fZProjectile);
43         epos->SetMaproj(this->fAProjectile);
44         epos->SetLatarg(this->fZTarget);
45         epos->SetMatarg(this->fATarget);
46         epos->SetPhimin(this->fPhiMin);
47         epos->SetPhimax(this->fPhiMax);
48         epos->SetBminim(this->fBmin);
49         epos->SetBmaxim(this->fBmax);
50         epos->SetEcms(this->fEnergyCMS);
51         epos->SetSplitting(kTRUE);
52         GetTEpos()->Initialize();
53 }
54
55 void AliGenEpos::Generate() {
56   // Does actual generation and output conversion
57           Float_t polar[3]    =   {0,0,0};
58           Float_t origin0[3]  =   {0,0,0};
59           Float_t origin[3]   =   {0,0,0};
60           Float_t time0 = 0.;
61           Float_t time  = 0.;
62           fNprimaries = 0;
63           Int_t nt  = 0; //output parameter for PushTrack
64
65           Vertex();
66           for (int j=0; j < 3; j++) origin0[j] = fVertex[j];
67           time0 = fTime;
68
69           // Generate one event
70
71           GetTEpos()->GenerateEvent();
72           AliWarning("Generated");
73           GetTEpos()->ImportParticles(&fParticles);
74
75           Int_t np = fParticles.GetEntriesFast();
76           AliWarning(Form("Imported %d particles", np));
77
78           Int_t *idsOnStack = NULL;
79           idsOnStack = new Int_t[np];
80           for (int i = 0; i < np; i++) idsOnStack[i] = 0;
81           TParticle *iparticle;
82
83           for (int i = 0; i < np; i++) {
84                   iparticle = (TParticle *) fParticles.At(i);
85                   //Bool_t isNullEntry = iparticle->GetStatusCode() == 0;
86                   //Bool_t isCommentOrUnknown = iparticle->GetStatusCode() > 2;
87                   Bool_t hasDecayed = iparticle->GetStatusCode() >= 2;
88                   Bool_t isFinalState = iparticle->GetStatusCode() == 1;
89                   Int_t imo = iparticle->GetFirstMother();
90                   Bool_t  hasMother = (imo >=0);
91
92
93                   if (isFinalState) {
94                           origin[0] = iparticle->Vx();
95                           origin[1] = iparticle->Vy();
96                           origin[2] = iparticle->Vz();
97                           time      = iparticle->T();
98                           //doubled track with freeze out coordinates for femtoscopy
99                           PushTrack(0,
100                                           imo>=0?idsOnStack[imo]:-1,
101                                           iparticle->GetPdgCode(),
102                                 iparticle->Px(),iparticle->Py(),iparticle->Pz(),iparticle->Energy(),
103                                 origin[0], origin[1], origin[2],
104                                 time,
105                                 polar[0],polar[1],polar[2],
106                                 hasMother ? kPDecay:kPNoProcess,nt);
107
108                       idsOnStack[i] = nt;
109                       fNprimaries++;
110                       KeepTrack(nt);
111
112                       //real track with smeared vertex
113                       origin[0] += origin0[0];
114                       origin[1] += origin0[1];
115                       origin[2] += origin0[2];
116                       time      += time0;
117                           PushTrack(1,
118                                           nt,   //doubled track as mother
119                                           iparticle->GetPdgCode(),
120                                 iparticle->Px(),iparticle->Py(),iparticle->Pz(),iparticle->Energy(),
121                                 origin[0], origin[1], origin[2],
122                                 time,
123                                 polar[0],polar[1],polar[2],
124                                 kPDecay,nt);
125                       fNprimaries++;
126                       KeepTrack(nt);
127                   } else if(hasDecayed || !fFilterModelOutput) {
128                           // don't track it and don't smear vertex
129                           origin[0] = iparticle->Vx();
130                           origin[1] = iparticle->Vy();
131                           origin[2] = iparticle->Vz();
132                           time      = iparticle->T();
133                           PushTrack(0,
134                                           imo>=0?idsOnStack[imo]:-1,
135                                           iparticle->GetPdgCode(),
136                                 iparticle->Px(),iparticle->Py(),iparticle->Pz(),iparticle->Energy(),
137                                 origin[0], origin[1], origin[2],
138                                 time,
139                                 polar[0],polar[1],polar[2],
140                                 hasMother ? kPDecay:kPNoProcess,nt);
141                       idsOnStack[i] = nt;
142                       fNprimaries++;
143                       KeepTrack(nt);
144                   } else if(fFilterModelOutput) {
145                           //filtered internal model objects
146                           idsOnStack[i] = -1; // to erase mother field in its dauthers
147                   }
148           }
149           SetHighWaterMark(fNprimaries);
150           TArrayF eventVertex;
151           eventVertex.Set(3);
152           eventVertex[0] = origin0[0];
153           eventVertex[1] = origin0[1];
154           eventVertex[2] = origin0[2];
155         // Builds the event header, to be called after each event
156           AliGenEposEventHeader* header = new AliGenEposEventHeader("EPOS");
157
158           header->SetNProduced(fNprimaries);
159           header->SetPrimaryVertex(eventVertex);
160           header->SetInteractionTime(time0);
161
162           header->SetImpactParameter(GetTEpos()->GetBimevt());
163           header->SetReactionPlaneAngle(GetTEpos()->GetPhievt());
164
165           header->SetHardScatters(0);
166           header->SetParticipants(GetTEpos()->GetNpjevt(), GetTEpos()->GetNtgevt());
167           header->SetCollisions(GetTEpos()->GetKolevt(), 0, 0, GetTEpos()->GetNpjevt());
168           header->SetSpectators(GetTEpos()->GetJpnevt(), GetTEpos()->GetJppevt(), GetTEpos()->GetJtnevt(), GetTEpos()->GetJtpevt());
169
170         // Event Vertex
171           header->SetPrimaryVertex(fVertex);
172           
173           header->SetBimevt(GetTEpos()->GetBimevt());
174           header->SetPhievt(GetTEpos()->GetPhievt());
175           header->SetKolevt(GetTEpos()->GetKolevt());
176           header->SetKoievt(GetTEpos()->GetKoievt());
177           header->SetPmxevt(GetTEpos()->GetPmxevt());
178           header->SetEgyevt(GetTEpos()->GetEgyevt());
179           header->SetNpjevt(GetTEpos()->GetNpjevt());
180           header->SetNtgevt(GetTEpos()->GetNtgevt());
181           header->SetNpnevt(GetTEpos()->GetNpnevt());
182           header->SetNppevt(GetTEpos()->GetNppevt());
183           header->SetNtnevt(GetTEpos()->GetNtnevt());
184           header->SetNtpevt(GetTEpos()->GetNtpevt());
185           header->SetJpnevt(GetTEpos()->GetJpnevt());
186           header->SetJppevt(GetTEpos()->GetJppevt());
187           header->SetJtnevt(GetTEpos()->GetJtnevt());
188           header->SetJtpevt(GetTEpos()->GetJtpevt());
189           header->SetXbjevt(GetTEpos()->GetXbjevt());
190           header->SetQsqevt(GetTEpos()->GetQsqevt());
191           header->SetNglevt(GetTEpos()->GetNglevt());
192           header->SetZppevt(GetTEpos()->GetZppevt());
193           header->SetZptevt(GetTEpos()->GetZptevt());
194     AddHeader(header);
195     fCollisionGeometry = (AliGenEposEventHeader*)  header;
196     
197     delete[] idsOnStack;
198 }
199
200 AliGenEpos::~AliGenEpos() {
201 }
202