]> git.uio.no Git - u/mrichter/AliRoot.git/blame - CORRFW/AliCFParticleGenCuts.cxx
Hidden symbols removed (Marian)
[u/mrichter/AliRoot.git] / CORRFW / AliCFParticleGenCuts.cxx
CommitLineData
563113d0 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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// ---- CORRECTION FRAMEWORK ----
18// class AliCFParticleGenCuts implementation
19// Using this class a user may define selections relative to
20// MC particle (AliMCParticle) using generation-level information.
21////////////////////////////////////////////////////////////////////////////
22// author : R. Vernet (renaud.vernet@cern.ch)
23////////////////////////////////////////////////////////////////////////////
24
25#include "AliLog.h"
26#include "AliCFParticleGenCuts.h"
27#include "TParticle.h"
28#include "TParticlePDG.h"
29#include "AliMCEventHandler.h"
30#include "AliMCEvent.h"
31#include "TObject.h"
32#include "AliStack.h"
33
34ClassImp(AliCFParticleGenCuts)
35
36//______________________________
37AliCFParticleGenCuts::AliCFParticleGenCuts() :
38 AliCFCutBase(),
39 fMCInfo(0x0),
40 fRequireIsCharged(0),
41 fRequireIsPrimary(0),
42 fRequireIsSecondary(0),
43 fRequirePdgCode(0),
44 fPdgCode(0),
45 fProdVtxXMin (-1.e+09),
46 fProdVtxYMin (-1.e+09),
47 fProdVtxZMin (-1.e+09),
48 fProdVtxXMax ( 1.e+09),
49 fProdVtxYMax ( 1.e+09),
50 fProdVtxZMax ( 1.e+09),
51 fDecayVtxXMin(-1.e+09),
52 fDecayVtxYMin(-1.e+09),
53 fDecayVtxZMin(-1.e+09),
54 fDecayVtxXMax( 1.e+09),
55 fDecayVtxYMax( 1.e+09),
56 fDecayVtxZMax( 1.e+09),
57 fDecayLengthMin(0),
58 fDecayLengthMax(1.e+09),
59 fDecayRxyMin(0),
60 fDecayRxyMax(1.e+09)
61{
62 //
63 //ctor
64 //
65}
66
67//______________________________
68AliCFParticleGenCuts::AliCFParticleGenCuts(const Char_t* name, const Char_t* title) :
69 AliCFCutBase(name,title),
70 fMCInfo(0x0),
71 fRequireIsCharged(0),
72 fRequireIsPrimary(0),
73 fRequireIsSecondary(0),
74 fRequirePdgCode(0),
75 fPdgCode(0),
76 fProdVtxXMin (-1.e+09),
77 fProdVtxYMin (-1.e+09),
78 fProdVtxZMin (-1.e+09),
79 fProdVtxXMax ( 1.e+09),
80 fProdVtxYMax ( 1.e+09),
81 fProdVtxZMax ( 1.e+09),
82 fDecayVtxXMin(-1.e+09),
83 fDecayVtxYMin(-1.e+09),
84 fDecayVtxZMin(-1.e+09),
85 fDecayVtxXMax( 1.e+09),
86 fDecayVtxYMax( 1.e+09),
87 fDecayVtxZMax( 1.e+09),
88 fDecayLengthMin(0),
89 fDecayLengthMax(1.e+09),
90 fDecayRxyMin(0),
91 fDecayRxyMax(1.e+09)
92{
93 //
94 //ctor
95 //
96}
97
98//______________________________
99AliCFParticleGenCuts::AliCFParticleGenCuts(const AliCFParticleGenCuts& c) :
100 AliCFCutBase(c),
101 fMCInfo(c.fMCInfo),
102 fRequireIsCharged(c.fRequireIsCharged),
103 fRequireIsPrimary(c.fRequireIsPrimary),
104 fRequireIsSecondary(c.fRequireIsSecondary),
105 fRequirePdgCode(c.fRequirePdgCode),
106 fPdgCode(c.fPdgCode),
107 fProdVtxXMin (c.fProdVtxXMin),
108 fProdVtxYMin (c.fProdVtxYMin),
109 fProdVtxZMin (c.fProdVtxZMin),
110 fProdVtxXMax (c.fProdVtxXMax),
111 fProdVtxYMax (c.fProdVtxYMax),
112 fProdVtxZMax (c.fProdVtxZMax),
113 fDecayVtxXMin(c.fDecayVtxXMin),
114 fDecayVtxYMin(c.fDecayVtxYMin),
115 fDecayVtxZMin(c.fDecayVtxZMin),
116 fDecayVtxXMax(c.fDecayVtxXMax),
117 fDecayVtxYMax(c.fDecayVtxYMax),
118 fDecayVtxZMax(c.fDecayVtxZMax),
119 fDecayLengthMin(c.fDecayLengthMin),
120 fDecayLengthMax(c.fDecayLengthMin),
121 fDecayRxyMin(c.fDecayLengthMin),
122 fDecayRxyMax(c.fDecayLengthMin)
123{
124 //
125 //copy ctor
126 //
127}
128
129//______________________________
130AliCFParticleGenCuts& AliCFParticleGenCuts::operator=(const AliCFParticleGenCuts& c)
131{
132 //
133 // Assignment operator
134 //
135 if (this != &c) {
136 AliCFCutBase::operator=(c) ;
137 fMCInfo=c.fMCInfo;
138 fRequireIsCharged=c.fRequireIsCharged;
139 fRequireIsPrimary=c.fRequireIsPrimary;
140 fRequireIsSecondary=c.fRequireIsSecondary;
141 fRequirePdgCode=c.fRequirePdgCode;
142 fPdgCode=c.fPdgCode;
143 fProdVtxXMin=c.fProdVtxXMin;
144 fProdVtxYMin=c.fProdVtxYMin;
145 fProdVtxZMin=c.fProdVtxZMin;
146 fProdVtxXMax=c.fProdVtxXMax;
147 fProdVtxYMax=c.fProdVtxYMax;
148 fProdVtxZMax=c.fProdVtxZMax;
149 fDecayVtxXMin=c.fDecayVtxXMin;
150 fDecayVtxYMin=c.fDecayVtxYMin;
151 fDecayVtxZMin=c.fDecayVtxZMin;
152 fDecayVtxXMax=c.fDecayVtxXMax;
153 fDecayVtxYMax=c.fDecayVtxYMax;
154 fDecayVtxZMax=c.fDecayVtxZMax;
155 fDecayLengthMin=c.fDecayVtxZMax;
156 fDecayLengthMax=c.fDecayLengthMax;
157 fDecayRxyMin=c.fDecayRxyMin;
158 fDecayRxyMax=c.fDecayRxyMax;
159 }
160 return *this ;
161}
162
163//______________________________
164Bool_t AliCFParticleGenCuts::IsSelected(TObject* obj) {
165 //
166 // check if selections on 'obj' are passed
167 // 'obj' must be an AliMCParticle
168 //
169
170 if (!obj) return kFALSE ;
171 TString className(obj->ClassName());
172 if (className.CompareTo("AliMCParticle") != 0) {
173 AliError("argument must point to an AliMCParticle !");
174 return kFALSE ;
175 }
176
177 AliMCParticle* mcPart = (AliMCParticle*) obj ;
178 TParticle* part = mcPart->Particle();
179 AliStack *stack=fMCInfo->MCEvent()->Stack();
180
181 // is this particle charged?
182 if ( fRequireIsCharged ) {
183 if(!IsCharged(mcPart))return kFALSE;
184 }
185
186 // primary cuts
187 if ( fRequireIsPrimary ) {
188 if(!IsPrimary(mcPart,stack))return kFALSE;
189 }
190
191 //secondary cut
192 if ( fRequireIsSecondary && part->IsPrimary() ) return kFALSE ;
193
194 //PDG code cut
195 if ( fRequirePdgCode){
196 if(!IsA(mcPart,fPdgCode)) return kFALSE ;
197 }
198 // production vertex cuts
199 Double32_t partVx=(Double32_t)part->Vx();
200 Double32_t partVy=(Double32_t)part->Vy();
201 Double32_t partVz=(Double32_t)part->Vz();
202 if ( partVx < fProdVtxXMin || partVx > fProdVtxXMax ) return kFALSE ;
203 if ( partVy < fProdVtxYMin || partVy > fProdVtxYMax ) return kFALSE ;
204 if ( partVz < fProdVtxZMin || partVz > fProdVtxZMax ) return kFALSE ;
205
206 //decay vertex cuts
207 if ( part->GetNDaughters() > 0 ) {
208 TParticle* daughter = fMCInfo->MCEvent()->Stack()->Particle(part->GetFirstDaughter()) ;
209 Double32_t decayVx=(Double32_t)daughter->Vx();
210 Double32_t decayVy=(Double32_t)daughter->Vy();
211 Double32_t decayVz=(Double32_t)daughter->Vz();
212 if ( decayVx < fDecayVtxXMin || decayVx > fDecayVtxXMax ) return kFALSE ;
213 if ( decayVy < fDecayVtxYMin || decayVy > fDecayVtxYMax ) return kFALSE ;
214 if ( decayVz < fDecayVtxZMin || decayVz > fDecayVtxZMax ) return kFALSE ;
215
216 //decay length cut
217 Double32_t decayL = TMath::Sqrt(TMath::Power(partVx-decayVx,2) +
218 TMath::Power(partVy-decayVy,2) +
219 TMath::Power(partVz-decayVz,2) ) ;
220 if (decayL < fDecayLengthMin || decayL > fDecayLengthMax) return kFALSE ;
221
222 Double32_t decayRxy = TMath::Sqrt(TMath::Power(decayVx,2) +
223 TMath::Power(decayVy,2) ) ;
224 if (decayRxy < fDecayRxyMin || decayRxy > fDecayRxyMax) return kFALSE ;
225 }
226
227
228 return kTRUE ;
229}
230//______________________________
231Bool_t AliCFParticleGenCuts::IsCharged(AliMCParticle *mcPart) {
232 //
233 //check if particle is charged.
234 //
235 TParticle* part = mcPart->Particle();
236 TParticlePDG* pdgPart = part->GetPDG();
237 if(!pdgPart)return kFALSE;
238 if (pdgPart->Charge() == 0) return kFALSE;
239 return kTRUE;
240}
241//______________________________
242Bool_t AliCFParticleGenCuts::IsPrimary(AliMCParticle *mcPart, AliStack *stack) {
243 //
244 //check if particle is primary (standard definition)
245 //
246 if (!stack->IsPhysicalPrimary(mcPart->Label())) return kFALSE ;
247 return kTRUE;
248}
249//______________________________
250Bool_t AliCFParticleGenCuts::IsPrimaryCharged(AliMCParticle *mcPart, AliStack *stack) {
251 //
252 //check if a charged particle is primary (standard definition)
253 //
254 if (!stack->IsPhysicalPrimary(mcPart->Label()) || !IsCharged(mcPart)) return kFALSE ;
255 return kTRUE;
256}
257//______________________________
258Bool_t AliCFParticleGenCuts::IsA(AliMCParticle *mcPart, Int_t pdg, Bool_t abs) {
259 //
260 //Check on the pdg code of the MC particle. if abs=kTRUE then check on the
261 //absolute value. By default is set to kFALSE.
262 //
263 TParticle* part = mcPart->Particle();
264 Int_t pdgCode = part->GetPdgCode();
265 if(abs)pdgCode=TMath::Abs(pdgCode);
266 if(pdgCode != pdg )return kFALSE;
267 return kTRUE;
268}
269//______________________________
270void AliCFParticleGenCuts::SetEvtInfo(TObject* mcInfo) {
271 //
272 // Sets pointer to MC event information (AliMCEventHandler)
273 //
274
275 if (!mcInfo) {
276 AliError("Pointer to MC Event Handler is null !");
277 return;
278 }
279
280 TString className(mcInfo->ClassName());
281 if (className.CompareTo("AliMCEventHandler") != 0) {
282 AliError("argument must point to an AliMCEventHandler !");
283 return ;
284 }
285
286 fMCInfo = (AliMCEventHandler*) mcInfo ;
287}