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