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