]>
Commit | Line | Data |
---|---|---|
1528f6d1 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
11c1e680 | 3 | * * |
4 | * Authors: Svein Lindal, Daniel Lohner * | |
5 | * Version 1.0 * | |
6 | * * | |
7 | * * | |
8 | * based on: on older version (see aliroot up to v5-04-42-AN) * | |
9 | * AliV0Reader.cxx * | |
10 | * Authors: Kathrin Koch, Kenneth Aamodt, Ana Marin * | |
11 | * * | |
e5b6e8a6 | 12 | * Permission to use, copy, modify and distribute this software and its * |
13 | * documentation strictly for non-commercial purposes is hereby granted * | |
14 | * without fee, provided that the above copyright notice appears in all * | |
15 | * copies and that both the copyright notice and this permission notice * | |
16 | * appear in the supporting documentation. The authors make no claims * | |
17 | * about the suitability of this software for any purpose. It is * | |
18 | * provided "as is" without express or implied warranty. * | |
1528f6d1 | 19 | **************************************************************************/ |
20 | ||
21 | //////////////////////////////////////////////// | |
e5b6e8a6 | 22 | //--------------------------------------------- |
1528f6d1 | 23 | // Class reconstructing conversion photons from V0s |
24 | //--------------------------------------------- | |
25 | //////////////////////////////////////////////// | |
26 | ||
27 | #include "AliV0ReaderV1.h" | |
28 | #include "AliKFParticle.h" | |
29 | #include "AliAODv0.h" | |
30 | #include "AliESDv0.h" | |
31 | #include "AliAODEvent.h" | |
32 | #include "AliESDEvent.h" | |
0a2b2b4b | 33 | #include "AliPID.h" |
34 | #include "AliMCEvent.h" | |
35 | #include "AliStack.h" | |
36 | #include "AliMCEventHandler.h" | |
37 | #include "AliESDpid.h" | |
38 | #include "AliESDtrackCuts.h" | |
39 | #include "TRandom3.h" | |
40 | #include "AliGenCocktailEventHeader.h" | |
41 | #include "TList.h" | |
1528f6d1 | 42 | #include "AliKFConversionPhoton.h" |
43 | #include "AliAODConversionPhoton.h" | |
44 | #include "AliConversionPhotonBase.h" | |
45 | #include "TVector.h" | |
46 | #include "AliKFVertex.h" | |
47 | #include "AliAODTrack.h" | |
48 | #include "AliESDtrack.h" | |
49 | #include "AliAnalysisManager.h" | |
50 | #include "AliInputEventHandler.h" | |
51 | #include "AliAODHandler.h" | |
52 | #include "AliPIDResponse.h" | |
53 | #include "TChain.h" | |
a280ac15 | 54 | #include "TFile.h" |
a280ac15 | 55 | #include "TString.h" |
56 | #include "TObjArray.h" | |
1528f6d1 | 57 | |
58 | class iostream; | |
59 | ||
60 | ||
61 | using namespace std; | |
62 | ||
63 | ClassImp(AliV0ReaderV1) | |
64 | ||
65 | //________________________________________________________________________ | |
66 | AliV0ReaderV1::AliV0ReaderV1(const char *name) : AliAnalysisTaskSE(name), | |
67 | fConversionCuts(NULL), | |
68 | fConversionGammas(NULL), | |
69 | fUseImprovedVertex(kTRUE), | |
70 | fUseOwnXYZCalculation(kTRUE), | |
71 | fUseConstructGamma(kFALSE), | |
72 | kUseAODConversionPhoton(kTRUE), | |
73 | fCreateAOD(kFALSE), | |
74 | fDeltaAODBranchName("GammaConv"), | |
75 | fDeltaAODFilename("AliAODGammaConversion.root"), | |
1186afd2 | 76 | fRelabelAODs(kFALSE), |
a280ac15 | 77 | fEventIsSelected(kFALSE), |
78 | fPeriodName("") | |
1528f6d1 | 79 | { |
80 | // Default constructor | |
81 | ||
82 | DefineInput(0, TChain::Class()); | |
83 | } | |
84 | ||
85 | //________________________________________________________________________ | |
86 | AliV0ReaderV1::~AliV0ReaderV1() | |
87 | { | |
88 | // default deconstructor | |
89 | ||
90 | if(fConversionGammas){ | |
91 | fConversionGammas->Delete();// Clear Objects | |
92 | delete fConversionGammas; | |
93 | fConversionGammas=0x0; | |
94 | } | |
95 | } | |
2bdd97ae | 96 | /* |
97 | //________________________________________________________________________ | |
98 | AliV0ReaderV1::AliV0ReaderV1(AliV0ReaderV1 &original) : AliAnalysisTaskSE(original), | |
99 | fConversionCuts(NULL), | |
100 | fConversionGammas(NULL), | |
101 | fUseImprovedVertex(original.fUseImprovedVertex), | |
102 | fUseOwnXYZCalculation(original.fUseOwnXYZCalculation), | |
103 | fUseConstructGamma(original.fUseConstructGamma), | |
104 | kUseAODConversionPhoton(original.kUseAODConversionPhoton), | |
105 | fCreateAOD(original.fCreateAOD), | |
106 | fDeltaAODBranchName(original.fDeltaAODBranchName), | |
107 | fDeltaAODFilename(original.fDeltaAODFilename), | |
108 | fEventIsSelected(original.fEventIsSelected) | |
109 | { | |
110 | // Default constructor | |
111 | ||
112 | DefineInput(0, TChain::Class()); | |
113 | } | |
114 | ||
115 | //____________________________________________________________ | |
116 | AliV0ReaderV1 &AliV0ReaderV1::operator=(const AliV0ReaderV1 &ref){ | |
117 | // | |
118 | // Assignment operator | |
119 | // Only copies pointers, object is not the owner of the references | |
120 | // | |
121 | if(this != &ref){ | |
122 | AliAnalysisTaskSE::operator=(ref); | |
123 | fUseImprovedVertex=ref.fUseImprovedVertex; | |
124 | fUseOwnXYZCalculation=ref.fUseOwnXYZCalculation; | |
125 | fUseConstructGamma=ref.fUseConstructGamma; | |
126 | kUseAODConversionPhoton=ref.kUseAODConversionPhoton; | |
127 | fCreateAOD=ref.fCreateAOD; | |
128 | fDeltaAODBranchName=ref.fDeltaAODBranchName; | |
129 | fDeltaAODFilename=ref.fDeltaAODFilename; | |
130 | fEventIsSelected=ref.fEventIsSelected; | |
131 | } | |
132 | return *this; | |
133 | } | |
134 | */ | |
1528f6d1 | 135 | //________________________________________________________________________ |
136 | void AliV0ReaderV1::Init() | |
137 | { | |
138 | // Initialize function to be called once before analysis | |
1528f6d1 | 139 | if(fConversionCuts==NULL){ |
140 | if(fConversionCuts==NULL)AliError("No Cut Selection initialized"); | |
141 | } | |
1528f6d1 | 142 | if(fCreateAOD){kUseAODConversionPhoton=kTRUE;} |
143 | ||
144 | if(fConversionGammas != NULL){ | |
145 | delete fConversionGammas; | |
146 | fConversionGammas=NULL; | |
147 | } | |
148 | ||
149 | if(fConversionGammas == NULL){ | |
150 | if(kUseAODConversionPhoton){ | |
151 | fConversionGammas = new TClonesArray("AliAODConversionPhoton",100);} | |
152 | else{ | |
153 | fConversionGammas = new TClonesArray("AliKFConversionPhoton",100);} | |
154 | } | |
155 | fConversionGammas->Delete();//Reset the TClonesArray | |
2a1b1442 | 156 | } |
157 | ||
158 | //________________________________________________________________________ | |
159 | void AliV0ReaderV1::UserCreateOutputObjects() | |
160 | { | |
1528f6d1 | 161 | // Create AODs |
162 | ||
163 | if(fCreateAOD){ | |
164 | if(fConversionCuts){ | |
165 | fDeltaAODBranchName.Append("_"); | |
166 | fDeltaAODBranchName.Append(fConversionCuts->GetCutNumber()); | |
167 | fDeltaAODBranchName.Append("_gamma"); | |
168 | } | |
169 | fConversionGammas->SetName(fDeltaAODBranchName.Data()); | |
170 | ||
171 | AddAODBranch("TClonesArray", &fConversionGammas, fDeltaAODFilename.Data()); | |
172 | AliAnalysisManager::GetAnalysisManager()->RegisterExtraFile(fDeltaAODFilename.Data()); | |
173 | } | |
1528f6d1 | 174 | |
1528f6d1 | 175 | } |
1528f6d1 | 176 | //________________________________________________________________________ |
11c1e680 | 177 | Bool_t AliV0ReaderV1::Notify() |
178 | { | |
a280ac15 | 179 | if (fPeriodName.CompareTo("") == 0){ |
180 | AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager(); | |
181 | if(man) { | |
182 | AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler()); | |
183 | if (inputHandler){ | |
184 | TTree* tree = (TTree*) inputHandler->GetTree(); | |
185 | TFile* file = (TFile*) tree->GetCurrentFile(); | |
186 | TString fileName(file->GetName()); | |
187 | TObjArray *arr = fileName.Tokenize("/"); | |
188 | for (Int_t i = 0; i < arr->GetEntriesFast();i++ ){ | |
189 | TObjString* testObjString = (TObjString*)arr->At(i); | |
190 | if (testObjString->GetString().Contains("LHC")){ | |
191 | fPeriodName = testObjString->GetString(); | |
192 | i = arr->GetEntriesFast(); | |
193 | } | |
11c1e680 | 194 | } |
a280ac15 | 195 | } |
196 | } | |
ccfa8c0d | 197 | if(!fConversionCuts->GetDoEtaShift()) return kTRUE; // No Eta Shift requested, continue |
198 | if(fConversionCuts->GetEtaShift() == 0.0){ // Eta Shift requested but not set, get shift automatically | |
199 | fConversionCuts->GetCorrectEtaShiftFromPeriod(fPeriodName); | |
200 | fConversionCuts->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once | |
201 | return kTRUE; | |
11c1e680 | 202 | } |
ccfa8c0d | 203 | else{ |
204 | printf(" Gamma Conversion Reader %s :: Eta Shift Manually Set to %f \n\n", | |
205 | (fConversionCuts->GetCutNumber()).Data(),fConversionCuts->GetEtaShift()); | |
206 | fConversionCuts->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once | |
11c1e680 | 207 | } |
a280ac15 | 208 | } |
ccfa8c0d | 209 | |
11c1e680 | 210 | return kTRUE; |
211 | } | |
212 | //________________________________________________________________________ | |
213 | void AliV0ReaderV1::UserExec(Option_t *option){ | |
214 | ||
2a1b1442 | 215 | // Check if correctly initialized |
216 | if(!fConversionGammas)Init(); | |
217 | ||
1528f6d1 | 218 | // User Exec |
219 | fEventIsSelected=ProcessEvent(fInputEvent,fMCEvent); | |
0f9c22de | 220 | |
221 | // AOD Output | |
222 | FillAODOutput(); | |
223 | ||
1528f6d1 | 224 | } |
225 | ||
226 | //________________________________________________________________________ | |
227 | Bool_t AliV0ReaderV1::ProcessEvent(AliVEvent *inputEvent,AliMCEvent *mcEvent) | |
228 | { | |
ccfa8c0d | 229 | |
1528f6d1 | 230 | //Reset the TClonesArray |
231 | fConversionGammas->Delete(); | |
232 | ||
233 | fInputEvent=inputEvent; | |
234 | fMCEvent=mcEvent; | |
235 | ||
236 | if(!fInputEvent){ | |
237 | AliError("No Input event"); | |
238 | return kFALSE; | |
239 | } | |
240 | ||
241 | if(!fConversionCuts){AliError("No ConversionCuts");return kFALSE;} | |
e5b6e8a6 | 242 | |
1528f6d1 | 243 | // Event Cuts |
244 | if(!fConversionCuts->EventIsSelected(fInputEvent,fMCEvent))return kFALSE; | |
245 | ||
246 | // Set Magnetic Field | |
247 | AliKFParticle::SetField(fInputEvent->GetMagneticField()); | |
248 | ||
249 | if(fInputEvent->IsA()==AliESDEvent::Class()){ | |
250 | ProcessESDV0s(); | |
251 | } | |
252 | if(fInputEvent->IsA()==AliAODEvent::Class()){ | |
253 | GetAODConversionGammas(); | |
254 | } | |
255 | ||
1528f6d1 | 256 | return kTRUE; |
257 | } | |
258 | ///________________________________________________________________________ | |
259 | void AliV0ReaderV1::FillAODOutput() | |
260 | { | |
261 | // Fill AOD Output with reconstructed Photons | |
262 | ||
263 | if(fInputEvent->IsA()==AliESDEvent::Class()){ | |
264 | ///Make sure delta aod is filled if standard aod is filled (for synchronization when reading aod with standard aod) | |
265 | if(fCreateAOD) { | |
266 | AliAODHandler * aodhandler = dynamic_cast<AliAODHandler*>(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()); | |
e5b6e8a6 | 267 | if (aodhandler && aodhandler->GetFillAOD()) { |
268 | AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillExtension(kTRUE); | |
2a1b1442 | 269 | //PostData(0, fConversionGammas); |
e5b6e8a6 | 270 | |
1528f6d1 | 271 | } |
272 | } | |
273 | } | |
274 | } | |
275 | ||
276 | ///________________________________________________________________________ | |
277 | const AliExternalTrackParam *AliV0ReaderV1::GetExternalTrackParam(AliESDv0 *fCurrentV0,Int_t &tracklabel,Int_t charge){ | |
278 | ||
279 | // Get External Track Parameter with given charge | |
280 | ||
281 | if(!(charge==1||charge==-1)){AliError("Charge not defined");return 0x0;} | |
282 | ||
283 | // Check for sign flip | |
284 | if(fCurrentV0){ | |
285 | if(!fCurrentV0->GetParamN()||!fCurrentV0->GetParamP())return 0x0; | |
286 | if(!fConversionCuts->GetTrack(fInputEvent,fCurrentV0->GetNindex())||!fConversionCuts->GetTrack(fInputEvent,fCurrentV0->GetPindex()))return 0x0; | |
287 | if((fConversionCuts->GetTrack(fInputEvent,fCurrentV0->GetPindex()))->Charge()==charge){ | |
288 | tracklabel=fCurrentV0->GetPindex(); | |
289 | return fCurrentV0->GetParamP();} | |
290 | if((fConversionCuts->GetTrack(fInputEvent,fCurrentV0->GetNindex()))->Charge()==charge){ | |
291 | tracklabel=fCurrentV0->GetNindex(); | |
292 | return fCurrentV0->GetParamN();} | |
293 | } | |
294 | return 0x0; | |
295 | } | |
296 | ||
297 | ///________________________________________________________________________ | |
298 | Bool_t AliV0ReaderV1::ProcessESDV0s() | |
299 | { | |
300 | // Process ESD V0s for conversion photon reconstruction | |
1528f6d1 | 301 | AliESDEvent *fESDEvent=dynamic_cast<AliESDEvent*>(fInputEvent); |
302 | ||
303 | AliKFConversionPhoton *fCurrentMotherKFCandidate=NULL; | |
e5b6e8a6 | 304 | |
1528f6d1 | 305 | if(fESDEvent){ |
306 | ||
307 | for(Int_t currentV0Index=0;currentV0Index<fESDEvent->GetNumberOfV0s();currentV0Index++){ | |
308 | AliESDv0 *fCurrentV0=(AliESDv0*)(fESDEvent->GetV0(currentV0Index)); | |
309 | if(!fCurrentV0){ | |
310 | printf("Requested V0 does not exist"); | |
ccfa8c0d | 311 | continue; |
312 | } | |
1528f6d1 | 313 | |
314 | fCurrentMotherKFCandidate=ReconstructV0(fCurrentV0,currentV0Index); | |
315 | ||
316 | if(fCurrentMotherKFCandidate){ | |
1528f6d1 | 317 | // Add Gamma to the TClonesArray |
318 | ||
319 | if(kUseAODConversionPhoton){ | |
320 | new((*fConversionGammas)[fConversionGammas->GetEntriesFast()]) AliAODConversionPhoton(fCurrentMotherKFCandidate); | |
ae947965 | 321 | AliAODConversionPhoton * currentConversionPhoton = (AliAODConversionPhoton*)(fConversionGammas->At(fConversionGammas->GetEntriesFast()-1)); |
322 | currentConversionPhoton->SetMass(fCurrentMotherKFCandidate->M()); | |
323 | currentConversionPhoton->SetMassToZero(); | |
324 | ||
1528f6d1 | 325 | } |
326 | else{ | |
327 | new((*fConversionGammas)[fConversionGammas->GetEntriesFast()]) AliKFConversionPhoton(*fCurrentMotherKFCandidate); | |
328 | } | |
329 | ||
330 | delete fCurrentMotherKFCandidate; | |
331 | fCurrentMotherKFCandidate=NULL; | |
332 | } | |
333 | } | |
334 | } | |
335 | return kTRUE; | |
336 | } | |
337 | ||
338 | ///________________________________________________________________________ | |
339 | AliKFConversionPhoton *AliV0ReaderV1::ReconstructV0(AliESDv0 *fCurrentV0,Int_t currentV0Index) | |
340 | { | |
341 | // Reconstruct conversion photon from ESD v0 | |
342 | fConversionCuts->FillPhotonCutIndex(AliConversionCuts::kPhotonIn); | |
343 | ||
344 | //checks if on the fly mode is set | |
345 | if(!fConversionCuts->SelectV0Finder(fCurrentV0->GetOnFlyStatus())){ | |
e5b6e8a6 | 346 | fConversionCuts->FillPhotonCutIndex(AliConversionCuts::kOnFly); |
347 | return 0x0; | |
1528f6d1 | 348 | } |
349 | ||
350 | // TrackLabels | |
351 | Int_t currentTrackLabels[2]={-1,-1}; | |
352 | ||
353 | // Get Daughter KF Particles | |
354 | ||
355 | const AliExternalTrackParam *fCurrentExternalTrackParamPositive=GetExternalTrackParamP(fCurrentV0,currentTrackLabels[0]); | |
356 | const AliExternalTrackParam *fCurrentExternalTrackParamNegative=GetExternalTrackParamN(fCurrentV0,currentTrackLabels[1]); | |
357 | ||
358 | if(!fCurrentExternalTrackParamPositive||!fCurrentExternalTrackParamNegative)return 0x0; | |
359 | ||
360 | // Apply some Cuts before Reconstruction | |
361 | ||
362 | AliVTrack * posTrack = fConversionCuts->GetTrack(fInputEvent,currentTrackLabels[0]); | |
363 | AliVTrack * negTrack = fConversionCuts->GetTrack(fInputEvent,currentTrackLabels[1]); | |
364 | ||
365 | if(!negTrack || !posTrack) { | |
e5b6e8a6 | 366 | fConversionCuts->FillPhotonCutIndex(AliConversionCuts::kNoTracks); |
367 | return 0x0; | |
1528f6d1 | 368 | } |
369 | ||
370 | // Track Cuts | |
371 | if(!fConversionCuts->TracksAreSelected(negTrack, posTrack)){ | |
e5b6e8a6 | 372 | fConversionCuts->FillPhotonCutIndex(AliConversionCuts::kTrackCuts); |
373 | return 0x0; | |
1528f6d1 | 374 | } |
375 | ||
376 | // PID Cuts | |
e5b6e8a6 | 377 | if(!fConversionCuts->dEdxCuts(negTrack) || !fConversionCuts->dEdxCuts(posTrack)) { |
378 | fConversionCuts->FillPhotonCutIndex(AliConversionCuts::kdEdxCuts); | |
379 | return 0x0; | |
380 | } | |
1528f6d1 | 381 | |
382 | // Reconstruct Photon | |
383 | ||
384 | AliKFConversionPhoton *fCurrentMotherKF=NULL; | |
385 | ||
386 | AliKFParticle fCurrentNegativeKFParticle(*(fCurrentExternalTrackParamNegative),11); | |
387 | AliKFParticle fCurrentPositiveKFParticle(*(fCurrentExternalTrackParamPositive),-11); | |
388 | ||
389 | // Reconstruct Gamma | |
390 | ||
391 | if(fUseConstructGamma){ | |
ae947965 | 392 | fCurrentMotherKF = new AliKFConversionPhoton(); |
393 | fCurrentMotherKF->ConstructGamma(fCurrentNegativeKFParticle,fCurrentPositiveKFParticle); | |
1528f6d1 | 394 | }else{ |
ae947965 | 395 | fCurrentMotherKF = new AliKFConversionPhoton(fCurrentNegativeKFParticle,fCurrentPositiveKFParticle); |
396 | fCurrentMotherKF->SetMassConstraint(0,0.0001); | |
1528f6d1 | 397 | } |
398 | ||
399 | // Set Track Labels | |
400 | ||
401 | fCurrentMotherKF->SetTrackLabels(currentTrackLabels[0],currentTrackLabels[1]); | |
402 | ||
403 | // Set V0 index | |
404 | ||
405 | fCurrentMotherKF->SetV0Index(currentV0Index); | |
406 | ||
407 | //Set MC Label | |
408 | ||
409 | if(fMCEvent){ | |
410 | ||
411 | AliStack *fMCStack= fMCEvent->Stack(); | |
412 | ||
e5b6e8a6 | 413 | Int_t labelp=TMath::Abs(fConversionCuts->GetTrack(fInputEvent,fCurrentMotherKF->GetTrackLabelPositive())->GetLabel()); |
414 | Int_t labeln=TMath::Abs(fConversionCuts->GetTrack(fInputEvent,fCurrentMotherKF->GetTrackLabelNegative())->GetLabel()); | |
1528f6d1 | 415 | |
416 | TParticle *fNegativeMCParticle = fMCStack->Particle(labeln); | |
417 | TParticle *fPositiveMCParticle = fMCStack->Particle(labelp); | |
418 | ||
419 | if(fPositiveMCParticle&&fNegativeMCParticle){ | |
420 | fCurrentMotherKF->SetMCLabelPositive(labelp); | |
421 | fCurrentMotherKF->SetMCLabelNegative(labeln); | |
422 | } | |
423 | } | |
424 | ||
425 | // Update Vertex (moved for same eta compared to old) | |
426 | if(fUseImprovedVertex == kTRUE){ | |
427 | AliKFVertex primaryVertexImproved(*fInputEvent->GetPrimaryVertex()); | |
428 | primaryVertexImproved+=*fCurrentMotherKF; | |
429 | fCurrentMotherKF->SetProductionVertex(primaryVertexImproved); | |
430 | } | |
431 | ||
432 | // SetPsiPair | |
433 | ||
434 | Double_t PsiPair=GetPsiPair(fCurrentV0,fCurrentExternalTrackParamPositive,fCurrentExternalTrackParamNegative); | |
435 | fCurrentMotherKF->SetPsiPair(PsiPair); | |
436 | ||
e5b6e8a6 | 437 | |
1528f6d1 | 438 | // Recalculate ConversionPoint |
439 | Double_t dca[2]={0,0}; | |
440 | if(fUseOwnXYZCalculation){ | |
441 | Double_t convpos[3]={0,0,0}; | |
442 | if(!GetConversionPoint(fCurrentExternalTrackParamPositive,fCurrentExternalTrackParamNegative,convpos,dca)){ | |
e5b6e8a6 | 443 | fConversionCuts->FillPhotonCutIndex(AliConversionCuts::kConvPointFail); |
444 | delete fCurrentMotherKF; | |
445 | fCurrentMotherKF=NULL; | |
446 | return 0x0; | |
1528f6d1 | 447 | } |
448 | ||
449 | fCurrentMotherKF->SetConversionPoint(convpos); | |
450 | } | |
451 | ||
452 | if(fCurrentMotherKF->GetNDF() > 0.) | |
453 | fCurrentMotherKF->SetChi2perNDF(fCurrentMotherKF->GetChi2()/fCurrentMotherKF->GetNDF()); //->Photon is created before all chi2 relevant changes are performed, set it "by hand" | |
e5b6e8a6 | 454 | |
455 | ||
456 | // Set Dilepton Mass (moved down for same eta compared to old) | |
457 | fCurrentMotherKF->SetMass(fCurrentMotherKF->M()); | |
458 | ||
1528f6d1 | 459 | // Apply Photon Cuts |
460 | ||
461 | if(!fConversionCuts->PhotonCuts(fCurrentMotherKF,fInputEvent)){ | |
462 | fConversionCuts->FillPhotonCutIndex(AliConversionCuts::kPhotonCuts); | |
463 | delete fCurrentMotherKF; | |
464 | fCurrentMotherKF=NULL; | |
465 | return 0x0; | |
466 | } | |
467 | ||
1528f6d1 | 468 | fConversionCuts->FillPhotonCutIndex(AliConversionCuts::kPhotonOut); |
469 | return fCurrentMotherKF; | |
470 | } | |
471 | ||
472 | ///________________________________________________________________________ | |
473 | Double_t AliV0ReaderV1::GetPsiPair(const AliESDv0* v0, const AliExternalTrackParam *positiveparam,const AliExternalTrackParam *negativeparam) const { | |
474 | // | |
475 | // Angle between daughter momentum plane and plane | |
476 | // | |
477 | ||
a280ac15 | 478 | AliExternalTrackParam nt(*negativeparam); |
479 | AliExternalTrackParam pt(*positiveparam); | |
1528f6d1 | 480 | |
481 | Float_t magField = fInputEvent->GetMagneticField(); | |
482 | ||
483 | Double_t xyz[3] = {0.,0.,0.}; | |
484 | v0->GetXYZ(xyz[0],xyz[1],xyz[2]); | |
e5b6e8a6 | 485 | |
a280ac15 | 486 | // Double_t pPlus[3] = {pt.Px(),pt.Py(),pt.Pz()}; |
487 | // Double_t pMinus[3] = {nt.Px(),nt.Py(),nt.Pz()}; | |
488 | ||
489 | // Double_t u[3] = {pPlus[0]+pMinus[0],pPlus[1]+pMinus[1],pPlus[2]+pMinus[2]}; | |
490 | // Double_t normu = sqrt( (u[0]*u[0]) + (u[1]*u[1]) + (u[2]*u[2]) ); | |
11c1e680 | 491 | |
a280ac15 | 492 | // u[0] = u[0] / normu; |
493 | // u[1] = u[1] / normu; | |
494 | // u[2] = u[2] / normu; | |
495 | ||
496 | // Double_t normpPlus = sqrt( (pPlus[0]*pPlus[0]) + (pPlus[1]*pPlus[1]) + (pPlus[2]*pPlus[2]) ); | |
497 | // Double_t normpMinus = sqrt( (pMinus[0]*pMinus[0]) + (pMinus[1]*pMinus[1]) + (pMinus[2]*pMinus[2]) ); | |
498 | ||
499 | // pPlus[0] = pPlus[0] / normpPlus; | |
500 | // pPlus[1] = pPlus[1] / normpPlus; | |
501 | // pPlus[2] = pPlus[2] / normpPlus; | |
502 | ||
503 | // pMinus[0] = pMinus[0] / normpMinus; | |
504 | // pMinus[1] = pMinus[1] / normpMinus; | |
505 | // pMinus[2] = pMinus[2] / normpMinus; | |
506 | ||
507 | // Double_t v[3] = {0,0,0}; // pPlus X pMinus | |
508 | // v[0] = (pPlus[1]*pMinus[2]) - (pPlus[2]*pMinus[1]); | |
509 | // v[1] = (pPlus[2]*pMinus[0]) - (pPlus[0]*pMinus[2]); | |
510 | // v[2] = (pPlus[0]*pMinus[1]) - (pPlus[1]*pMinus[0]); | |
11c1e680 | 511 | |
a280ac15 | 512 | // Double_t w[3] = {0,0,0}; // u X v |
513 | // w[0] = (u[1]*v[2]) - (u[2]*v[1]); | |
514 | // w[1] = (u[2]*v[0]) - (u[0]*v[2]); | |
515 | // w[2] = (u[0]*v[1]) - (u[1]*v[0]); | |
516 | ||
517 | // Double_t z[3] = {0,0,1}; | |
518 | // Double_t wc[3] = {0,0,0}; // u X v | |
519 | // wc[0] = (u[1]*z[2]) - (u[2]*z[1]); | |
520 | // wc[1] = (u[2]*z[0]) - (u[0]*z[2]); | |
521 | // wc[2] = (u[0]*z[1]) - (u[1]*z[0]); | |
522 | ||
523 | // Double_t PhiV = TMath::ACos((w[0]*wc[0]) + (w[1]*wc[1]) + (w[2]*wc[2])); | |
524 | //return abs(PhiV); | |
525 | ||
526 | ||
527 | // TVector3 pPlus(pt.Px(),pt.Py(),pt.Pz()); | |
528 | // TVector3 pMinus(nt.Px(),nt.Py(),nt.Pz()); | |
529 | ||
530 | // TVector3 u = pMinus + pPlus; | |
531 | // u = u*(1/u.Mag()); | |
532 | ||
533 | // TVector3 pHPlus = pPlus*(1/pPlus.Mag()); | |
534 | // TVector3 pHMinus = pMinus*(1/pMinus.Mag()); | |
535 | ||
536 | // TVector3 v = pHPlus.Cross(pHMinus); | |
537 | // TVector3 w = u.Cross(v); | |
538 | // TVector3 z(0,0,1); | |
539 | // TVector3 wc = u.Cross(z); | |
540 | ||
541 | // Double_t PhiV = w * wc; | |
542 | ||
1528f6d1 | 543 | Double_t mn[3] = {0,0,0}; |
544 | Double_t mp[3] = {0,0,0}; | |
e5b6e8a6 | 545 | |
1528f6d1 | 546 | v0->GetNPxPyPz(mn[0],mn[1],mn[2]);//reconstructed cartesian momentum components of negative daughter; |
e5b6e8a6 | 547 | v0->GetPPxPyPz(mp[0],mp[1],mp[2]);//reconstructed cartesian momentum components of positive daughter; |
1528f6d1 | 548 | |
549 | Double_t deltat = 1.; | |
a280ac15 | 550 | deltat = TMath::ATan(mp[2]/(TMath::Sqrt(mp[0]*mp[0] + mp[1]*mp[1])+1.e-13)) - TMath::ATan(mn[2]/(TMath::Sqrt(mn[0]*mn[0] + mn[1]*mn[1])+1.e-13));//difference of angles of the two daughter tracks with z-axis |
e5b6e8a6 | 551 | Double_t radiussum = TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]) + 50;//radius to which tracks shall be propagated |
552 | ||
1528f6d1 | 553 | Double_t momPosProp[3] = {0,0,0}; |
554 | Double_t momNegProp[3] = {0,0,0}; | |
e5b6e8a6 | 555 | |
1528f6d1 | 556 | Double_t psiPair = 4.; |
557 | if(nt.PropagateTo(radiussum,magField) == 0) return psiPair; //propagate tracks to the outside -> Better Purity and Efficiency | |
1528f6d1 | 558 | if(pt.PropagateTo(radiussum,magField) == 0) return psiPair; //propagate tracks to the outside -> Better Purity and Efficiency |
e5b6e8a6 | 559 | |
1528f6d1 | 560 | pt.GetPxPyPz(momPosProp);//Get momentum vectors of tracks after propagation |
561 | nt.GetPxPyPz(momNegProp); | |
562 | ||
563 | Double_t pEle = | |
564 | TMath::Sqrt(momNegProp[0]*momNegProp[0]+momNegProp[1]*momNegProp[1]+momNegProp[2]*momNegProp[2]);//absolute momentum value of negative daughter | |
565 | ||
566 | Double_t pPos = | |
567 | TMath::Sqrt(momPosProp[0]*momPosProp[0]+momPosProp[1]*momPosProp[1]+momPosProp[2]*momPosProp[2]);//absolute momentum value of positive daughter | |
568 | ||
569 | Double_t scalarproduct = | |
570 | momPosProp[0]*momNegProp[0]+momPosProp[1]*momNegProp[1]+momPosProp[2]*momNegProp[2];//scalar product of propagated positive and negative daughters' momenta | |
571 | ||
572 | Double_t chipair = TMath::ACos(scalarproduct/(pEle*pPos));//Angle between propagated daughter tracks | |
573 | ||
574 | psiPair = TMath::Abs(TMath::ASin(deltat/chipair)); | |
575 | ||
576 | return psiPair; | |
577 | } | |
578 | ||
579 | ///________________________________________________________________________ | |
580 | Bool_t AliV0ReaderV1::GetHelixCenter(const AliExternalTrackParam *track,Double_t center[2]){ | |
581 | ||
582 | // Get Center of the helix track parametrization | |
583 | ||
584 | Int_t charge=track->Charge(); | |
585 | Double_t b=fInputEvent->GetMagneticField(); | |
586 | ||
587 | Double_t helix[6]; | |
588 | track->GetHelixParameters(helix,b); | |
589 | ||
590 | Double_t xpos = helix[5]; | |
591 | Double_t ypos = helix[0]; | |
592 | Double_t radius = TMath::Abs(1./helix[4]); | |
593 | Double_t phi = helix[2]; | |
594 | ||
595 | if(phi < 0){ | |
596 | phi = phi + 2*TMath::Pi(); | |
597 | } | |
598 | ||
599 | phi -= TMath::Pi()/2.; | |
600 | Double_t xpoint = radius * TMath::Cos(phi); | |
601 | Double_t ypoint = radius * TMath::Sin(phi); | |
602 | ||
603 | if(b<0){ | |
604 | if(charge > 0){ | |
605 | xpoint = - xpoint; | |
606 | ypoint = - ypoint; | |
607 | } | |
608 | ||
609 | if(charge < 0){ | |
610 | xpoint = xpoint; | |
611 | ypoint = ypoint; | |
612 | } | |
613 | } | |
614 | if(b>0){ | |
615 | if(charge > 0){ | |
616 | xpoint = xpoint; | |
617 | ypoint = ypoint; | |
618 | } | |
619 | ||
620 | if(charge < 0){ | |
621 | xpoint = - xpoint; | |
622 | ypoint = - ypoint; | |
623 | } | |
624 | } | |
625 | center[0] = xpos + xpoint; | |
626 | center[1] = ypos + ypoint; | |
627 | ||
628 | return 1; | |
629 | } | |
630 | ///________________________________________________________________________ | |
631 | Bool_t AliV0ReaderV1::GetConversionPoint(const AliExternalTrackParam *pparam,const AliExternalTrackParam *nparam,Double_t convpos[3],Double_t dca[2]){ | |
632 | ||
633 | // Recalculate Conversion Point | |
634 | ||
635 | if(!pparam||!nparam)return kFALSE; | |
e5b6e8a6 | 636 | |
1528f6d1 | 637 | Double_t helixcenterpos[2]; |
638 | GetHelixCenter(pparam,helixcenterpos); | |
639 | ||
640 | Double_t helixcenterneg[2]; | |
641 | GetHelixCenter(nparam,helixcenterneg); | |
642 | ||
643 | Double_t helixpos[6]; | |
644 | pparam->GetHelixParameters(helixpos,fInputEvent->GetMagneticField()); | |
645 | Double_t posradius = TMath::Abs(1./helixpos[4]); | |
646 | ||
647 | Double_t helixneg[6]; | |
648 | nparam->GetHelixParameters(helixneg,fInputEvent->GetMagneticField()); | |
649 | Double_t negradius = TMath::Abs(1./helixneg[4]); | |
650 | ||
651 | // Calculate xy-position | |
652 | ||
653 | Double_t xpos = helixcenterpos[0]; | |
654 | Double_t ypos = helixcenterpos[1]; | |
655 | Double_t xneg = helixcenterneg[0]; | |
656 | Double_t yneg = helixcenterneg[1]; | |
657 | ||
658 | convpos[0] = (xpos*negradius + xneg*posradius)/(negradius+posradius); | |
659 | convpos[1] = (ypos*negradius+ yneg*posradius)/(negradius+posradius); | |
660 | ||
661 | ||
662 | // Calculate Track XY vertex position | |
663 | ||
664 | Double_t deltaXPos = convpos[0] - xpos; | |
665 | Double_t deltaYPos = convpos[1] - ypos; | |
666 | ||
667 | Double_t deltaXNeg = convpos[0] - xneg; | |
668 | Double_t deltaYNeg = convpos[1] - yneg; | |
669 | ||
670 | Double_t alphaPos = TMath::Pi() + TMath::ATan2(-deltaYPos,-deltaXPos); | |
671 | Double_t alphaNeg = TMath::Pi() + TMath::ATan2(-deltaYNeg,-deltaXNeg); | |
672 | ||
673 | Double_t vertexXNeg = xneg + TMath::Abs(negradius)*TMath::Cos(alphaNeg); | |
674 | Double_t vertexYNeg = yneg + TMath::Abs(negradius)*TMath::Sin(alphaNeg); | |
675 | ||
676 | Double_t vertexXPos = xpos + TMath::Abs(posradius)*TMath::Cos(alphaPos); | |
677 | Double_t vertexYPos = ypos + TMath::Abs(posradius)*TMath::Sin(alphaPos); | |
678 | ||
679 | AliExternalTrackParam p(*pparam); | |
680 | AliExternalTrackParam n(*nparam); | |
681 | ||
682 | TVector2 vertexPos(vertexXPos,vertexYPos); | |
683 | TVector2 vertexNeg(vertexXNeg,vertexYNeg); | |
684 | ||
685 | // Convert to local coordinate system | |
686 | TVector2 vertexPosRot=vertexPos.Rotate(-p.GetAlpha()); | |
687 | TVector2 vertexNegRot=vertexNeg.Rotate(-n.GetAlpha()); | |
688 | ||
689 | // Propagate Track Params to Vertex | |
690 | ||
691 | if(!p.PropagateTo(vertexPosRot.X(),fInputEvent->GetMagneticField()))return kFALSE; | |
692 | if(!n.PropagateTo(vertexNegRot.X(),fInputEvent->GetMagneticField()))return kFALSE; | |
693 | ||
694 | // Check whether propagation was sucessful | |
695 | ||
696 | if(TMath::Abs(vertexPos.Mod()-TMath::Sqrt(p.GetX()*p.GetX()+p.GetY()*p.GetY()))>0.01)return kFALSE; | |
697 | if(TMath::Abs(vertexNeg.Mod()-TMath::Sqrt(n.GetX()*n.GetX()+n.GetY()*n.GetY()))>0.01)return kFALSE; | |
698 | ||
699 | // Calculate z position | |
700 | ||
701 | convpos[2] = (p.GetZ()*negradius+n.GetZ()*posradius)/(negradius+posradius); | |
702 | ||
703 | // Calculate DCA | |
704 | TVector2 vdca=vertexPos-vertexNeg; | |
705 | dca[0]=vdca.Mod(); | |
706 | dca[1]=TMath::Abs(n.GetZ()-p.GetZ()); | |
707 | ||
708 | return kTRUE; | |
709 | } | |
710 | //________________________________________________________________________ | |
711 | Bool_t AliV0ReaderV1::GetAODConversionGammas(){ | |
712 | ||
713 | // Get reconstructed conversion photons from satellite AOD file | |
714 | ||
715 | AliAODEvent *fAODEvent=dynamic_cast<AliAODEvent*>(fInputEvent); | |
716 | ||
717 | if(fAODEvent){ | |
718 | ||
e5b6e8a6 | 719 | if(fConversionGammas == NULL){ |
720 | fConversionGammas = new TClonesArray("AliAODConversionPhoton",100); | |
721 | } | |
1528f6d1 | 722 | fConversionGammas->Delete();//Reset the TClonesArray |
723 | ||
724 | //Get Gammas from satellite AOD gamma branch | |
725 | ||
726 | AliAODConversionPhoton *gamma=0x0; | |
e5b6e8a6 | 727 | |
1528f6d1 | 728 | TClonesArray *fInputGammas=dynamic_cast<TClonesArray*>(fAODEvent->FindListObject(fDeltaAODBranchName.Data())); |
729 | if(!fInputGammas){ | |
e5b6e8a6 | 730 | FindDeltaAODBranchName(); |
731 | fInputGammas=dynamic_cast<TClonesArray*>(fAODEvent->FindListObject(fDeltaAODBranchName.Data()));} | |
1528f6d1 | 732 | if(!fInputGammas){AliError("No Gamma Satellites found");return kFALSE;} |
733 | // Apply Selection Cuts to Gammas and create local working copy | |
734 | if(fInputGammas){ | |
e5b6e8a6 | 735 | for(Int_t i=0;i<fInputGammas->GetEntriesFast();i++){ |
736 | gamma=dynamic_cast<AliAODConversionPhoton*>(fInputGammas->At(i)); | |
737 | if(gamma){ | |
1186afd2 | 738 | if(fRelabelAODs)RelabelAODPhotonCandidates(gamma); |
e5b6e8a6 | 739 | if(fConversionCuts->PhotonIsSelected(gamma,fInputEvent)){ |
740 | new((*fConversionGammas)[fConversionGammas->GetEntriesFast()]) AliAODConversionPhoton(*gamma);} | |
741 | } | |
742 | } | |
1528f6d1 | 743 | } |
744 | } | |
745 | ||
746 | if(fConversionGammas->GetEntries()){return kTRUE;} | |
747 | ||
748 | return kFALSE; | |
749 | } | |
750 | ||
751 | //________________________________________________________________________ | |
752 | void AliV0ReaderV1::FindDeltaAODBranchName(){ | |
753 | ||
754 | // Find delta AOD branchname containing reconstructed photons | |
755 | ||
756 | TList *list=fInputEvent->GetList(); | |
757 | for(Int_t ii=0;ii<list->GetEntries();ii++){ | |
758 | TString name((list->At(ii))->GetName()); | |
759 | if(name.BeginsWith(fDeltaAODBranchName)&&name.EndsWith("gamma")){ | |
760 | fDeltaAODBranchName=name; | |
761 | AliInfo(Form("Set DeltaAOD BranchName to: %s",fDeltaAODBranchName.Data())); | |
762 | return; | |
763 | } | |
764 | } | |
765 | } | |
1186afd2 | 766 | //________________________________________________________________________ |
767 | void AliV0ReaderV1::RelabelAODPhotonCandidates(AliAODConversionPhoton *PhotonCandidate){ | |
768 | ||
769 | // Relabeling For AOD Event | |
770 | // ESDiD -> AODiD | |
771 | // MCLabel -> AODMCLabel | |
772 | Bool_t AODLabelPos = kFALSE; | |
773 | Bool_t AODLabelNeg = kFALSE; | |
774 | ||
775 | for(Int_t i = 0; i<fInputEvent->GetNumberOfTracks();i++){ | |
776 | AliAODTrack *tempDaughter = static_cast<AliAODTrack*>(fInputEvent->GetTrack(i)); | |
777 | if(!AODLabelPos){ | |
778 | if( tempDaughter->GetID() == PhotonCandidate->GetTrackLabelPositive() ){ | |
779 | PhotonCandidate->SetMCLabelPositive(abs(tempDaughter->GetLabel())); | |
780 | PhotonCandidate->SetLabelPositive(i); | |
781 | AODLabelPos = kTRUE; | |
782 | } | |
783 | } | |
784 | if(!AODLabelNeg){ | |
785 | if( tempDaughter->GetID() == PhotonCandidate->GetTrackLabelNegative()){ | |
786 | PhotonCandidate->SetMCLabelNegative(abs(tempDaughter->GetLabel())); | |
787 | PhotonCandidate->SetLabelNegative(i); | |
788 | AODLabelNeg = kTRUE; | |
789 | } | |
790 | } | |
791 | if(AODLabelNeg && AODLabelPos){ | |
792 | return; | |
793 | } | |
794 | } | |
795 | if(!AODLabelPos || !AODLabelNeg){ | |
796 | AliError(Form("NO AOD Daughters Found Pos: %i %i Neg: %i %i",AODLabelPos,PhotonCandidate->GetTrackLabelPositive(),AODLabelNeg,PhotonCandidate->GetTrackLabelNegative())); | |
797 | } | |
798 | ||
799 | } | |
800 | ||
1528f6d1 | 801 | //________________________________________________________________________ |
802 | void AliV0ReaderV1::Terminate(Option_t *) | |
803 | { | |
804 | ||
805 | } |