1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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 ////////////////////////////////////////////////////////////////////////////
26 #include "AliCFParticleGenCuts.h"
27 #include "TParticle.h"
28 #include "TParticlePDG.h"
29 #include "AliMCEventHandler.h"
30 #include "AliMCEvent.h"
34 ClassImp(AliCFParticleGenCuts)
36 //______________________________
37 AliCFParticleGenCuts::AliCFParticleGenCuts() :
42 fRequireIsSecondary(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),
58 fDecayLengthMax(1.e+09),
67 //______________________________
68 AliCFParticleGenCuts::AliCFParticleGenCuts(const Char_t* name, const Char_t* title) :
69 AliCFCutBase(name,title),
73 fRequireIsSecondary(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),
89 fDecayLengthMax(1.e+09),
98 //______________________________
99 AliCFParticleGenCuts::AliCFParticleGenCuts(const AliCFParticleGenCuts& c) :
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)
129 //______________________________
130 AliCFParticleGenCuts& AliCFParticleGenCuts::operator=(const AliCFParticleGenCuts& c)
133 // Assignment operator
136 AliCFCutBase::operator=(c) ;
138 fRequireIsCharged=c.fRequireIsCharged;
139 fRequireIsPrimary=c.fRequireIsPrimary;
140 fRequireIsSecondary=c.fRequireIsSecondary;
141 fRequirePdgCode=c.fRequirePdgCode;
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;
163 //______________________________
164 Bool_t AliCFParticleGenCuts::IsSelected(TObject* obj) {
166 // check if selections on 'obj' are passed
167 // 'obj' must be an AliMCParticle
170 if (!obj) return kFALSE ;
171 TString className(obj->ClassName());
172 if (className.CompareTo("AliMCParticle") != 0) {
173 AliError("argument must point to an AliMCParticle !");
177 AliMCParticle* mcPart = (AliMCParticle*) obj ;
178 TParticle* part = mcPart->Particle();
179 AliStack *stack=fMCInfo->MCEvent()->Stack();
181 // is this particle charged?
182 if ( fRequireIsCharged ) {
183 if(!IsCharged(mcPart))return kFALSE;
187 if ( fRequireIsPrimary ) {
188 if(!IsPrimary(mcPart,stack))return kFALSE;
192 if ( fRequireIsSecondary && part->IsPrimary() ) return kFALSE ;
195 if ( fRequirePdgCode){
196 if(!IsA(mcPart,fPdgCode)) return kFALSE ;
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 ;
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 ;
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 ;
222 Double32_t decayRxy = TMath::Sqrt(TMath::Power(decayVx,2) +
223 TMath::Power(decayVy,2) ) ;
224 if (decayRxy < fDecayRxyMin || decayRxy > fDecayRxyMax) return kFALSE ;
230 //______________________________
231 Bool_t AliCFParticleGenCuts::IsCharged(AliMCParticle *mcPart) {
233 //check if particle is charged.
235 TParticle* part = mcPart->Particle();
236 TParticlePDG* pdgPart = part->GetPDG();
237 if(!pdgPart)return kFALSE;
238 if (pdgPart->Charge() == 0) return kFALSE;
241 //______________________________
242 Bool_t AliCFParticleGenCuts::IsPrimary(AliMCParticle *mcPart, AliStack *stack) {
244 //check if particle is primary (standard definition)
246 if (!stack->IsPhysicalPrimary(mcPart->Label())) return kFALSE ;
249 //______________________________
250 Bool_t AliCFParticleGenCuts::IsPrimaryCharged(AliMCParticle *mcPart, AliStack *stack) {
252 //check if a charged particle is primary (standard definition)
254 if (!stack->IsPhysicalPrimary(mcPart->Label()) || !IsCharged(mcPart)) return kFALSE ;
257 //______________________________
258 Bool_t AliCFParticleGenCuts::IsA(AliMCParticle *mcPart, Int_t pdg, Bool_t abs) {
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.
263 TParticle* part = mcPart->Particle();
264 Int_t pdgCode = part->GetPdgCode();
265 if(abs)pdgCode=TMath::Abs(pdgCode);
266 if(pdgCode != pdg )return kFALSE;
269 //______________________________
270 void AliCFParticleGenCuts::SetEvtInfo(TObject* mcInfo) {
272 // Sets pointer to MC event information (AliMCEventHandler)
276 AliError("Pointer to MC Event Handler is null !");
280 TString className(mcInfo->ClassName());
281 if (className.CompareTo("AliMCEventHandler") != 0) {
282 AliError("argument must point to an AliMCEventHandler !");
286 fMCInfo = (AliMCEventHandler*) mcInfo ;