]>
Commit | Line | Data |
---|---|---|
99345a64 | 1 | /************************************************************************* |
2 | * Copyright(c) 1998-2009, 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 | /////////////////////////////////////////////////////////////////////////// | |
c081415a | 17 | // Cut class providing cuts to V0 candidates // |
18 | // Selection or deselection of V0 candiates can be done. // | |
99345a64 | 19 | // // |
20 | // Authors: // | |
c081415a | 21 | // Julian Book <Julian.Book@cern.ch> // |
99345a64 | 22 | /* |
23 | ||
f1f59b2e | 24 | Class to provide some V0 selection using exactley the same cuts in ESDs as in AODs. |
25 | It implements the PID cut class AliDielectronPID and the standard AliDielectronVarCuts for | |
26 | the configuration of leg respective pair cuts. These pair cuts are applied on the KFparticle | |
27 | build by the legs. | |
99345a64 | 28 | |
f1f59b2e | 29 | example configuration: |
30 | ||
31 | AliDielectronV0Cuts *gammaV0Cuts = new AliDielectronV0Cuts("IsGamma","IsGamma"); | |
32 | ||
33 | // which V0 finder you want to use | |
34 | gammaV0Cuts->SetV0finder(kOnTheFly); // kAll(default), kOffline or kOnTheFly | |
35 | ||
36 | // add some pdg codes (they are used then by the KF package and important for gamma conversions) | |
37 | gammaV0Cuts->SetPdgCodes(22,11,11); // mother, daughter1 and 2 | |
38 | ||
39 | // add default PID cuts (defined in AliDielectronPID) | |
40 | gammaV0Cuts->SetDefaultPID(16); | |
41 | ||
42 | // add the pair cuts for V0 candidates | |
43 | gammaV0Cuts->AddCut(AliDielectronVarManager::kCosPointingAngle, TMath::Cos(0.02), 1.0, kFALSE); | |
44 | gammaV0Cuts->AddCut(AliDielectronVarManager::kChi2NDF, 0.0, 10.0, kFALSE); | |
45 | gammaV0Cuts->AddCut(AliDielectronVarManager::kLegDist, 0.0, 0.25, kFALSE); | |
46 | gammaV0Cuts->AddCut(AliDielectronVarManager::kR, 3.0, 90.0, kFALSE); | |
47 | gammaV0Cuts->AddCut(AliDielectronVarManager::kPsiPair, 0.0, 0.05, kFALSE); | |
48 | gammaV0Cuts->AddCut(AliDielectronVarManager::kM, 0.0, 0.05, kFALSE); | |
49 | gammaV0Cuts->AddCut(AliDielectronVarManager::kArmPt, 0.0, 0.05, kFALSE); | |
50 | ||
51 | // selection or rejection of V0 tracks | |
52 | gammaV0Cuts->SetExcludeTracks(kTRUE); | |
53 | ||
54 | // add the V0cuts directly to the track filter or to some cut group of it | |
99345a64 | 55 | |
56 | */ | |
57 | // // | |
58 | /////////////////////////////////////////////////////////////////////////// | |
59 | ||
60 | ||
61 | #include "AliDielectronV0Cuts.h" | |
62 | #include "AliDielectronVarManager.h" | |
63 | #include "AliDielectronTrackCuts.h" | |
882407d7 | 64 | #include "AliDielectronPID.h" |
99345a64 | 65 | #include "AliESDv0.h" |
f1f59b2e | 66 | #include "AliAODv0.h" |
99345a64 | 67 | |
68 | ClassImp(AliDielectronV0Cuts) | |
69 | ||
70 | ||
71 | AliDielectronV0Cuts::AliDielectronV0Cuts() : | |
72 | AliDielectronVarCuts(), | |
f2d9961b | 73 | fV0TrackArr(0), |
74 | fExcludeTracks(kTRUE), | |
f1f59b2e | 75 | fV0finder(kAll), |
f2d9961b | 76 | fMotherPdg(0), |
77 | fNegPdg(0), | |
78 | fPosPdg(0), | |
882407d7 | 79 | fPID(-1), |
f2d9961b | 80 | fOrbit(0), |
81 | fPeriod(0), | |
82 | fBunchCross(0) | |
99345a64 | 83 | { |
84 | // | |
85 | // Default costructor | |
86 | // | |
87 | } | |
88 | ||
89 | //________________________________________________________________________ | |
90 | AliDielectronV0Cuts::AliDielectronV0Cuts(const char* name, const char* title) : | |
91 | AliDielectronVarCuts(name,title), | |
f2d9961b | 92 | fV0TrackArr(0), |
93 | fExcludeTracks(kTRUE), | |
f1f59b2e | 94 | fV0finder(kAll), |
f2d9961b | 95 | fMotherPdg(0), |
96 | fNegPdg(0), | |
97 | fPosPdg(0), | |
882407d7 | 98 | fPID(-1), |
f2d9961b | 99 | fOrbit(0), |
100 | fPeriod(0), | |
101 | fBunchCross(0) | |
99345a64 | 102 | { |
103 | // | |
104 | // Named contructor | |
105 | // | |
106 | } | |
107 | ||
108 | //________________________________________________________________________ | |
109 | AliDielectronV0Cuts::~AliDielectronV0Cuts() | |
110 | { | |
111 | // | |
112 | // Destructor | |
113 | // | |
99345a64 | 114 | |
f2d9961b | 115 | } |
99345a64 | 116 | |
117 | //________________________________________________________________________ | |
f2d9961b | 118 | void AliDielectronV0Cuts::InitEvent(AliVTrack *trk) |
99345a64 | 119 | { |
120 | // | |
121 | // Init the V0 candidates | |
122 | // | |
123 | ||
f2d9961b | 124 | // take current event from the track |
125 | // TODO: this should be simplyfied by AliVTrack::GetEvent() as soon as implemented | |
126 | const AliVEvent *ev=0; | |
127 | if(trk->IsA() == AliAODTrack::Class()) | |
128 | ev=static_cast<const AliVEvent*>((static_cast<const AliAODTrack*>(trk))->GetAODEvent()); | |
129 | else if(trk->IsA() == AliESDtrack::Class()) | |
130 | ev=static_cast<const AliVEvent*>((static_cast<const AliESDtrack*>(trk))->GetESDEvent()); | |
131 | else | |
132 | return; | |
133 | ||
134 | ||
135 | // IsNewEvent | |
136 | if(!ev) return; | |
137 | if(!IsNewEvent(ev)) return; | |
138 | // printf(" Build V0 candidates according to the applied cuts \n"); | |
139 | ||
f2d9961b | 140 | // rest booleans |
141 | fV0TrackArr.ResetAllBits(); | |
99345a64 | 142 | |
143 | // basic quality cut, at least one of the V0 daughters has to fullfill | |
f2d9961b | 144 | AliDielectronVarCuts dauQAcuts1; |
35363fb9 | 145 | dauQAcuts1.AddCut(AliDielectronVarManager::kPt, 0.05, 100.0); |
146 | dauQAcuts1.AddCut(AliDielectronVarManager::kEta, -0.9, 0.9); | |
147 | dauQAcuts1.AddCut(AliDielectronVarManager::kNclsTPC, 50.0, 160.0); | |
148 | dauQAcuts1.AddCut(AliDielectronVarManager::kTPCchi2Cl, 0.0, 4.0); | |
f2d9961b | 149 | AliDielectronTrackCuts dauQAcuts2; |
0caf5fbb | 150 | // dauQAcuts2.SetRequireITSRefit(kTRUE); |
f2d9961b | 151 | dauQAcuts2.SetRequireTPCRefit(kTRUE); |
882407d7 | 152 | AliDielectronPID dauPIDcuts; |
153 | if(fPID>=0) dauPIDcuts.SetDefaults(fPID); | |
99345a64 | 154 | |
061ca303 | 155 | Int_t nV0s = 0; |
156 | Int_t nV0stored = 0; | |
f2d9961b | 157 | AliDielectronPair candidate; |
158 | candidate.SetPdgCode(fMotherPdg); | |
99345a64 | 159 | |
160 | // ESD or AOD event | |
161 | if(ev->IsA() == AliESDEvent::Class()) { | |
162 | const AliESDEvent *esdev = static_cast<const AliESDEvent*>(ev); | |
f2d9961b | 163 | |
b2ad74d0 | 164 | //printf("there are %d V0s in the event \n",esdev->GetNumberOfV0s()); |
99345a64 | 165 | // loop over V0s |
166 | for (Int_t iv=0; iv<esdev->GetNumberOfV0s(); ++iv){ | |
167 | AliESDv0 *v = esdev->GetV0(iv); | |
168 | if(!v) continue; | |
f1f59b2e | 169 | |
170 | // check the v0 finder | |
171 | if( v->GetOnFlyStatus() && fV0finder==AliDielectronV0Cuts::kOffline ) continue; | |
172 | if(!v->GetOnFlyStatus() && fV0finder==AliDielectronV0Cuts::kOnTheFly ) continue; | |
99345a64 | 173 | |
f2d9961b | 174 | // should we make use of AliESDv0Cuts::GetPdgCode() to preselect candiadtes, e.g.: |
175 | // if(fMotherPdg!=v->GetPdgCode()) continue; | |
176 | ||
177 | AliESDtrack *trNeg=esdev->GetTrack(v->GetIndex(0)); | |
178 | AliESDtrack *trPos=esdev->GetTrack(v->GetIndex(1)); | |
179 | if(!trNeg || !trPos){ | |
180 | printf("Error: Couldn't get V0 daughter: %p - %p\n",trNeg,trPos); | |
99345a64 | 181 | continue; |
182 | } | |
183 | ||
f1f59b2e | 184 | // protection against LS v0s |
185 | if(trNeg->Charge() == trPos->Charge()) continue; | |
186 | ||
882407d7 | 187 | // PID default cuts |
188 | if(fPID>=0) { | |
35363fb9 | 189 | if( !dauPIDcuts.IsSelected(trNeg) ) continue; |
190 | if( !dauPIDcuts.IsSelected(trPos) ) continue; | |
882407d7 | 191 | } |
0caf5fbb | 192 | |
35363fb9 | 193 | // basic track cuts |
194 | if( !dauQAcuts2.IsSelected(trNeg) ) continue; | |
195 | if( !dauQAcuts2.IsSelected(trPos) ) continue; | |
196 | if( !dauQAcuts1.IsSelected(trNeg) ) continue; | |
197 | if( !dauQAcuts1.IsSelected(trPos) ) continue; | |
99345a64 | 198 | |
f2d9961b | 199 | if(fMotherPdg==22) candidate.SetGammaTracks(trNeg, 11, trPos, 11); |
f1f59b2e | 200 | else candidate.SetTracks(trNeg, (trNeg->Charge()<0?fNegPdg:fPosPdg), trPos, (trPos->Charge()<0?fNegPdg:fPosPdg)); |
99345a64 | 201 | // eventually take the external trackparam and build the KFparticles by hand (see AliESDv0::GetKFInfo) |
f2d9961b | 202 | // the folowing is not needed, because the daughters where used in the v0 vertex fit (I guess) |
99345a64 | 203 | // AliKFVertex v0vtx = *v; |
204 | // candidate.SetProductionVertex(v0vtx); | |
205 | ||
f2d9961b | 206 | if(AliDielectronVarCuts::IsSelected(&candidate)) { |
99345a64 | 207 | nV0s++; |
f2d9961b | 208 | //printf(" gamma found for vtx %p dau1id %d dau2id %d \n",v,trNeg->GetID(),trPos->GetID()); |
209 | fV0TrackArr.SetBitNumber(trNeg->GetID()); | |
210 | fV0TrackArr.SetBitNumber(trPos->GetID()); | |
99345a64 | 211 | } |
212 | } | |
f2d9961b | 213 | |
99345a64 | 214 | } |
215 | else if(ev->IsA() == AliAODEvent::Class()) { | |
216 | const AliAODEvent *aodEv = static_cast<const AliAODEvent*>(ev); | |
f2d9961b | 217 | |
99345a64 | 218 | // loop over vertices |
f1f59b2e | 219 | for (Int_t ivertex=0; ivertex<aodEv->GetNumberOfV0s(); ++ivertex){ |
220 | AliAODv0 *v=aodEv->GetV0(ivertex); | |
221 | if(!v) continue; | |
222 | ||
223 | // check the v0 finder | |
224 | if( v->GetOnFlyStatus() && fV0finder==AliDielectronV0Cuts::kOffline ) continue; | |
225 | if(!v->GetOnFlyStatus() && fV0finder==AliDielectronV0Cuts::kOnTheFly ) continue; | |
99345a64 | 226 | |
f2d9961b | 227 | AliAODTrack *trNeg=dynamic_cast<AliAODTrack*>(v->GetDaughter(0)); |
228 | AliAODTrack *trPos=dynamic_cast<AliAODTrack*>(v->GetDaughter(1)); | |
229 | if(!trNeg || !trPos){ | |
230 | printf("Error: Couldn't get V0 daughter: %p - %p\n",trNeg,trPos); | |
99345a64 | 231 | continue; |
232 | } | |
061ca303 | 233 | nV0stored++; |
99345a64 | 234 | |
f1f59b2e | 235 | // protection against LS v0s |
236 | if(trNeg->Charge() == trPos->Charge()) continue; | |
237 | ||
882407d7 | 238 | // PID default cuts |
239 | if(fPID>=0) { | |
35363fb9 | 240 | if( !dauPIDcuts.IsSelected(trNeg) ) continue; |
241 | if( !dauPIDcuts.IsSelected(trPos) ) continue; | |
882407d7 | 242 | } |
0caf5fbb | 243 | |
35363fb9 | 244 | // basic track cuts |
245 | if( !dauQAcuts2.IsSelected(trNeg) ) continue; | |
246 | if( !dauQAcuts2.IsSelected(trPos) ) continue; | |
247 | if( !dauQAcuts1.IsSelected(trNeg) ) continue; | |
248 | if( !dauQAcuts1.IsSelected(trPos) ) continue; | |
99345a64 | 249 | |
f1f59b2e | 250 | AliKFVertex v0vtx = *(v->GetSecondaryVtx()); |
f2d9961b | 251 | if(fMotherPdg==22) candidate.SetGammaTracks(trNeg, 11, trPos, 11); |
252 | else candidate.SetTracks(trNeg, (trNeg->Charge()<0?fNegPdg:fPosPdg), trPos, (trPos->Charge()<0?fNegPdg:fPosPdg)); | |
99345a64 | 253 | candidate.SetProductionVertex(v0vtx); |
254 | ||
f2d9961b | 255 | if(AliDielectronVarCuts::IsSelected(&candidate)) { |
99345a64 | 256 | nV0s++; |
f2d9961b | 257 | //printf(" gamma found for vtx %p dau1id %d dau2id %d \n",v,trNeg->GetID(),trPos->GetID()); |
258 | fV0TrackArr.SetBitNumber(trNeg->GetID()); | |
259 | fV0TrackArr.SetBitNumber(trPos->GetID()); | |
99345a64 | 260 | } |
261 | } | |
882407d7 | 262 | //printf("there are %d V0s in the event \n",nV0stored); |
99345a64 | 263 | } |
264 | else | |
265 | return; | |
266 | ||
061ca303 | 267 | // printf(" Number of V0s candiates found %d/%d \n",nV0s,nV0stored); |
99345a64 | 268 | |
269 | } | |
270 | //________________________________________________________________________ | |
271 | Bool_t AliDielectronV0Cuts::IsSelected(TObject* track) | |
272 | { | |
273 | // | |
274 | // Make cut decision | |
275 | // | |
f2d9961b | 276 | |
99345a64 | 277 | if(!track) return kFALSE; |
f2d9961b | 278 | |
99345a64 | 279 | AliVTrack *vtrack = static_cast<AliVTrack*>(track); |
f2d9961b | 280 | InitEvent(vtrack); |
0caf5fbb | 281 | //printf(" track ID %d selected result %d %d \n",vtrack->GetID(),(fV0TrackArr.TestBitNumber(vtrack->GetID())),fExcludeTracks); |
f2d9961b | 282 | return ( (fV0TrackArr.TestBitNumber(vtrack->GetID()))^fExcludeTracks ); |
283 | } | |
284 | ||
285 | //________________________________________________________________________ | |
286 | Bool_t AliDielectronV0Cuts::IsNewEvent(const AliVEvent *ev) | |
287 | { | |
288 | // | |
289 | // check weather we process a new event | |
290 | // | |
99345a64 | 291 | |
f2d9961b | 292 | // printf(" current ev %d %d %d \n",fBunchCross, fOrbit, fPeriod); |
293 | // printf(" new event %p %d %d %d \n",ev, ev->GetBunchCrossNumber(), ev->GetOrbitNumber(), ev->GetPeriodNumber()); | |
99345a64 | 294 | |
f2d9961b | 295 | if( fBunchCross == ev->GetBunchCrossNumber() ) { |
296 | if( fOrbit == ev->GetOrbitNumber() ) { | |
297 | if( fPeriod == ev->GetPeriodNumber() ) { | |
298 | return kFALSE; | |
299 | } | |
300 | } | |
99345a64 | 301 | } |
302 | ||
f2d9961b | 303 | fBunchCross = ev->GetBunchCrossNumber(); |
304 | fOrbit = ev->GetOrbitNumber(); | |
305 | fPeriod = ev->GetPeriodNumber(); | |
306 | return kTRUE; | |
99345a64 | 307 | } |