]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/SPECTRA/AliAnalysisCentralCutEvtMC.cxx
Protection from C.Andrei plus some cosmetics and coding conventions
[u/mrichter/AliRoot.git] / PWG2 / SPECTRA / AliAnalysisCentralCutEvtMC.cxx
CommitLineData
bde49c8a 1/*************************************************************************
2* Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
7* Permission to use, copy, modify and distribute this software and its *
8* documentation strictly for non-commercial purposes is hereby granted *
9* without fee, provided that the above copyright notice appears in all *
10* copies and that both the copyright notice and this permission notice *
11* appear in the supporting documentation. The authors make no claims *
12* about the suitability of this software for any purpose. It is *
13* provided "as is" without express or implied warranty. *
14**************************************************************************/
15
8a993eac 16// ***************************************************
bde49c8a 17// * MC event level cuts for azimuthal isotropic *
8a993eac 18// * expansion in highly central collisions analysis *
19// * author: Cristian ANDREI *
20// * acristian@niham.nipne.ro *
21// ***************************************************
bde49c8a 22
23#include <TParticle.h>
24
25#include "AliMCEvent.h"
26#include "AliStack.h"
27
28#include "AliAnalysisCentralCutEvtMC.h"
bde49c8a 29//____________________________________________________________________
30ClassImp(AliAnalysisCentralCutEvtMC)
31
32//____________________________________________________________________
33AliAnalysisCentralCutEvtMC::AliAnalysisCentralCutEvtMC(const Char_t* name, const Char_t* title)
34 :AliAnalysisCuts(name,title)
35 ,fReqMult(kFALSE)
36 ,fReqDir(kFALSE)
37 ,fReqDirUnit(kFALSE)
38 ,fMultMin(0)
39 ,fMultMax(0)
40 ,fDirMin(0)
41 ,fDirMax(0)
42 ,fDirUMin(0)
43 ,fDirUMax(0)
44
45{
46 //constructor
47
48}
49
50AliAnalysisCentralCutEvtMC::~AliAnalysisCentralCutEvtMC(){
51//destructor
52
53}
54
55//___________________________________________________________________________
56Bool_t AliAnalysisCentralCutEvtMC::IsSelected(TObject *obj){
57// Checks whether the event passes the cuts
58
59 if (!obj){
60 printf("Pointer to MC Event is null! \n");
61 return kFALSE;
62 }
63
64 AliMCEvent *mcEvent = dynamic_cast<AliMCEvent*> (obj);
65 if(!mcEvent){
66 printf("AliAnalysisCentralCutEvtMC -> Can't get MCEvt!\n");
67 return kFALSE;
68 }
69
70
71 if(fReqMult){
72 Int_t mult = CalcMult(mcEvent);
73 if((mult<fMultMin)||(mult>fMultMax)){
74 return kFALSE;
75 }
76 }
77
78 if(fReqDir){
79 Double_t dir = CalcDir(mcEvent);
80 if((dir<fDirMin)||(dir>fDirMax)){
81 return kFALSE;
82 }
83 }
84
85 if(fReqDirUnit){
86 Double_t dirU = CalcDirUnit(mcEvent);
87 if((dirU<fDirUMin)||(dirU>fDirUMax)){
88 return kFALSE;
89 }
90 }
91
92 return kTRUE;
93}
94
95//___________________________________________________________________________
96Int_t AliAnalysisCentralCutEvtMC::CalcMult(AliMCEvent* const mcEvent) {
97// Computes the multiplicity of the event
98
99 AliStack *stack=mcEvent->Stack();
100 if(!stack) return -1;
101
102 Int_t nPrim = stack->GetNprimary();
103
104 Int_t charged = 0;
105 Double_t eta;
106
107 for(Int_t i = 0; i < nPrim; i++){//track loop -> compute multiplicity
108
109 TParticle *particle=stack->Particle(i);
110 if(!particle){
111 continue;
112 }
113
114 eta = particle->Eta();
115
116 if((eta > 0.5)||(eta < -0.5)){ //------------mid-rapidity
117 continue;
118 }
119
120 TParticlePDG *particlePDG = particle->GetPDG(0);
121 if(!particlePDG){
122 continue;
123 }
124
125 if(TMath::Abs(particlePDG->Charge()) < 3){
126 continue;
127 }
128
129 charged++;
130
131 }//end track loop
132
133 return charged;
134
135}
136
137//____________________________________________________________________________
138Double_t AliAnalysisCentralCutEvtMC::CalcDir(AliMCEvent* const mcEvent) {
139// computes the directivity of the event
140
141 AliStack *stack=mcEvent->Stack();
142 if(!stack) return -1;
143
144 Int_t nPrim = stack->GetNprimary();
145
146 Int_t goodtrack = 0;
147
148 Double_t eta;
149 Double_t pt;
150
151 Double_t dir;
152 Double_t px,py;
153 Double_t sumaPt = 0;
154 Double_t sumaPx = 0;
155 Double_t sumaPy = 0;
156
157 for(Int_t i = 0; i < nPrim; i++){//track loop -> compute directivity
158
159 TParticle *particle=stack->Particle(i);
160 if(!particle){
161 continue;
162 }
163
164 eta = particle->Eta();
165
166 if((eta > 1.9)||(eta < 0.0)){ // half of the SPD coverage -> directivity
167 continue;
168 }
169
170 TParticlePDG *particlePDG = particle->GetPDG(0);
171 if(!particlePDG){
172 continue;
173 }
174
175 if(TMath::Abs(particlePDG->Charge()) < 3){
176 continue;
177 }
178
179 px = particle->Px();
180 py = particle->Py();
181
182 pt = particle->Pt();
183
184 sumaPx = sumaPx + px;
185 sumaPy = sumaPy + py;
186
187 sumaPt = sumaPt + pt;
188
189 goodtrack++;
190
191 }//end track loop
192
193
194 if(sumaPt < 0.0000001){
195 return -1;
196 }
197
198 dir = (sqrt(pow(sumaPx,2)+pow(sumaPy,2)))/sumaPt;
199
200 return dir;
201}
202
203//__________________________________________________________________
204Double_t AliAnalysisCentralCutEvtMC::CalcDirUnit(AliMCEvent* const mcEvent) {
205// computes the directivity using only the SPD unity vectors
206
207 AliStack *stack=mcEvent->Stack();
208 if(!stack){
209 return -1;
210 }
211
212 Int_t nPrim = stack->GetNprimary();
213
214 Int_t goodtrack = 0;
215
216 Double_t eta;
217 Double_t pt;
218
219 Double_t dirU;
220 Double_t px,py,pxU,pyU;
221 Double_t sumaPxU = 0;
222 Double_t sumaPyU = 0;
223
224
225 for(Int_t i = 0; i < nPrim; i++){//track loop -> compute directivity
226
227 TParticle *particle=stack->Particle(i);
228 if(!particle){
229 continue;
230 }
231
232 eta = particle->Eta();
233
234 if((eta > 1.9)||(eta < 0.0)){ // half of the SPD coverage -> directivity
235 continue;
236 }
237
238 TParticlePDG *particlePDG = particle->GetPDG(0);
239 if(!particlePDG){
240 continue;
241 }
242
243 if(TMath::Abs(particlePDG->Charge()) < 3){
244 continue;
245 }
246
247 px = particle->Px();
248 py = particle->Py();
249 pt = particle->Pt();
250
251 pxU = px/pt;
252 pyU = py/pt;
253
254 sumaPxU = sumaPxU + pxU;
255 sumaPyU = sumaPyU + pyU;
256
257 goodtrack++;
258
259 }//end track loop
260
261 if(goodtrack == 0){
262 return -1;
263 }
264
265 dirU = (sqrt(pow(sumaPxU,2)+pow(sumaPyU,2)))/goodtrack;
266
267
268 return dirU;
269}