]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/SPECTRA/AliAnalysisCentralCutMC.cxx
Protection from C.Andrei plus some cosmetics and coding conventions
[u/mrichter/AliRoot.git] / PWG2 / SPECTRA / AliAnalysisCentralCutMC.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// ***************************************************
17// * MC particle level cuts for azimuthal isotropic *
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#include "AliMCParticle.h"
28
29#include "AliAnalysisCentralCutMC.h"
bde49c8a 30//____________________________________________________________________
31ClassImp(AliAnalysisCentralCutMC)
32
33//____________________________________________________________________
34AliAnalysisCentralCutMC::AliAnalysisCentralCutMC(const Char_t* name, const Char_t* title)
35 :AliAnalysisCuts(name,title)
36 ,fOnlyPrim(0)
37 ,fMCEvt(0)
38 ,fPDGCode(0)
39 ,fPtMin(0)
40 ,fPtMax(0)
41 ,fEtaMin(0)
42 ,fEtaMax(0)
43{
44 //constructor
45
46 fOnlyPrim = kFALSE; //implicit consider si part secundare
47
48 SetPDGCode();
49 SetPtRange();
50 SetEtaRange();
51}
52
53//____________________________________________________________________
54AliAnalysisCentralCutMC::~AliAnalysisCentralCutMC(){
55// Destructor
56
57 if(fMCEvt) delete fMCEvt;
58
59}
60
61//___________________________________________________________________________
62Bool_t AliAnalysisCentralCutMC::IsSelected(TObject* const obj){
63// Check if the particle passes the cuts
64
65 AliMCParticle *part = dynamic_cast<AliMCParticle *>(obj);
66
67 if(!part){
68 printf("AliAnalysisCentralCutMC:IsSelected ->Can't get particle!\n");
69 return kFALSE;
70 }
71
72 if(!fMCEvt){
73 printf("AliAnalysisCentralCutMC:IsSelected ->Can't get MCEvent!\n");
74 return kFALSE;
75 }
76
77 AliStack *stack = fMCEvt->Stack();
78 if(!stack){
79 printf("AliAnalysisCentralCutMC:IsSelected ->Can't get Stack!\n");
80 return kFALSE;
81 }
82
83 Double_t pt = part->Pt();
84
85 Double_t eta = part->Eta();
86
87
88 if(fOnlyPrim){
89 if(!IsPrimary(part, stack)) return kFALSE;
90 }
91
92 if(fPDGCode != 0){
93 if(!CheckPDG(part, fPDGCode)) return kFALSE;
94 }
95
96 if((pt < fPtMin) || (pt > fPtMax)) return kFALSE;
97
98 if((eta < fEtaMin) || (eta > fEtaMax)) return kFALSE;
99
100
101 return kTRUE;
102}
103
104//___________________________________________________________________________
105Bool_t AliAnalysisCentralCutMC::IsPrimary(AliMCParticle* const part, AliStack* const stack){
106// Check if the particle is primary
107
108 Int_t index = part->GetLabel();
109
110 TParticle* p = stack->Particle(index);
111 if(!p){
112 printf("AliAnalysisCentralCutMC:IsPrimary -> Can't get TParticle!\n");
113 return kFALSE;
114 }
115
116 Int_t ist = p->GetStatusCode();
117
118 if (ist > 1) return kFALSE;
119
120// Int_t pdg = TMath::Abs(p->GetPdgCode());
121
122 if (index < stack->GetNprimary()) {
123 return kTRUE;
124 }
125 else return kFALSE;
126
127}
128
129
130void AliAnalysisCentralCutMC::ReceiveEvt(TObject* mcEvent) {
131// Receive the event send from the task
132// The event is needed in order to get the Stack
133
134 if (!mcEvent){
135 printf("Pointer to MC Event is null! \n");
136 return;
137 }
138
139 fMCEvt = dynamic_cast<AliMCEvent*> (mcEvent);
140 if(!fMCEvt){
141 printf("AliAnalysisCentralCutMC:ReceiveEvt -> Can't get fMCEvt!\n");
142 return;
143 }
144
145}
146
147
148Bool_t AliAnalysisCentralCutMC::CheckPDG(AliMCParticle* const mcPart, Int_t const pdg) {
149// Checks if the particle is of the wanted type
150
151 TParticle* part = mcPart->Particle();
152
153 if(!part){
154 printf("AliAnalysisCentralCutMC:IsPrimary -> Can't get TParticle!\n");
155 return kFALSE;
156 }
157
158 Int_t pdgCode = part->GetPdgCode();
159
160 if (pdgCode != pdg ) return kFALSE;
161
162 return kTRUE;
163
164}