]>
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"), | |
a280ac15 | 76 | fEventIsSelected(kFALSE), |
77 | fPeriodName("") | |
1528f6d1 | 78 | { |
79 | // Default constructor | |
80 | ||
81 | DefineInput(0, TChain::Class()); | |
82 | } | |
83 | ||
84 | //________________________________________________________________________ | |
85 | AliV0ReaderV1::~AliV0ReaderV1() | |
86 | { | |
87 | // default deconstructor | |
88 | ||
89 | if(fConversionGammas){ | |
90 | fConversionGammas->Delete();// Clear Objects | |
91 | delete fConversionGammas; | |
92 | fConversionGammas=0x0; | |
93 | } | |
94 | } | |
2bdd97ae | 95 | /* |
96 | //________________________________________________________________________ | |
97 | AliV0ReaderV1::AliV0ReaderV1(AliV0ReaderV1 &original) : AliAnalysisTaskSE(original), | |
98 | fConversionCuts(NULL), | |
99 | fConversionGammas(NULL), | |
100 | fUseImprovedVertex(original.fUseImprovedVertex), | |
101 | fUseOwnXYZCalculation(original.fUseOwnXYZCalculation), | |
102 | fUseConstructGamma(original.fUseConstructGamma), | |
103 | kUseAODConversionPhoton(original.kUseAODConversionPhoton), | |
104 | fCreateAOD(original.fCreateAOD), | |
105 | fDeltaAODBranchName(original.fDeltaAODBranchName), | |
106 | fDeltaAODFilename(original.fDeltaAODFilename), | |
107 | fEventIsSelected(original.fEventIsSelected) | |
108 | { | |
109 | // Default constructor | |
110 | ||
111 | DefineInput(0, TChain::Class()); | |
112 | } | |
113 | ||
114 | //____________________________________________________________ | |
115 | AliV0ReaderV1 &AliV0ReaderV1::operator=(const AliV0ReaderV1 &ref){ | |
116 | // | |
117 | // Assignment operator | |
118 | // Only copies pointers, object is not the owner of the references | |
119 | // | |
120 | if(this != &ref){ | |
121 | AliAnalysisTaskSE::operator=(ref); | |
122 | fUseImprovedVertex=ref.fUseImprovedVertex; | |
123 | fUseOwnXYZCalculation=ref.fUseOwnXYZCalculation; | |
124 | fUseConstructGamma=ref.fUseConstructGamma; | |
125 | kUseAODConversionPhoton=ref.kUseAODConversionPhoton; | |
126 | fCreateAOD=ref.fCreateAOD; | |
127 | fDeltaAODBranchName=ref.fDeltaAODBranchName; | |
128 | fDeltaAODFilename=ref.fDeltaAODFilename; | |
129 | fEventIsSelected=ref.fEventIsSelected; | |
130 | } | |
131 | return *this; | |
132 | } | |
133 | */ | |
1528f6d1 | 134 | //________________________________________________________________________ |
135 | void AliV0ReaderV1::Init() | |
136 | { | |
137 | // Initialize function to be called once before analysis | |
1528f6d1 | 138 | if(fConversionCuts==NULL){ |
139 | if(fConversionCuts==NULL)AliError("No Cut Selection initialized"); | |
140 | } | |
141 | ||
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); | |
220 | } | |
221 | ||
222 | //________________________________________________________________________ | |
223 | Bool_t AliV0ReaderV1::ProcessEvent(AliVEvent *inputEvent,AliMCEvent *mcEvent) | |
224 | { | |
ccfa8c0d | 225 | |
1528f6d1 | 226 | //Reset the TClonesArray |
227 | fConversionGammas->Delete(); | |
228 | ||
229 | fInputEvent=inputEvent; | |
230 | fMCEvent=mcEvent; | |
231 | ||
232 | if(!fInputEvent){ | |
233 | AliError("No Input event"); | |
234 | return kFALSE; | |
235 | } | |
236 | ||
237 | if(!fConversionCuts){AliError("No ConversionCuts");return kFALSE;} | |
e5b6e8a6 | 238 | |
1528f6d1 | 239 | // Event Cuts |
240 | if(!fConversionCuts->EventIsSelected(fInputEvent,fMCEvent))return kFALSE; | |
241 | ||
242 | // Set Magnetic Field | |
243 | AliKFParticle::SetField(fInputEvent->GetMagneticField()); | |
244 | ||
245 | if(fInputEvent->IsA()==AliESDEvent::Class()){ | |
246 | ProcessESDV0s(); | |
247 | } | |
248 | if(fInputEvent->IsA()==AliAODEvent::Class()){ | |
249 | GetAODConversionGammas(); | |
250 | } | |
251 | ||
252 | // AOD Output | |
253 | FillAODOutput(); | |
254 | ||
255 | return kTRUE; | |
256 | } | |
257 | ///________________________________________________________________________ | |
258 | void AliV0ReaderV1::FillAODOutput() | |
259 | { | |
260 | // Fill AOD Output with reconstructed Photons | |
261 | ||
262 | if(fInputEvent->IsA()==AliESDEvent::Class()){ | |
263 | ///Make sure delta aod is filled if standard aod is filled (for synchronization when reading aod with standard aod) | |
264 | if(fCreateAOD) { | |
265 | AliAODHandler * aodhandler = dynamic_cast<AliAODHandler*>(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()); | |
e5b6e8a6 | 266 | if (aodhandler && aodhandler->GetFillAOD()) { |
267 | AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillExtension(kTRUE); | |
2a1b1442 | 268 | //PostData(0, fConversionGammas); |
e5b6e8a6 | 269 | |
1528f6d1 | 270 | } |
271 | } | |
272 | } | |
273 | } | |
274 | ||
275 | ///________________________________________________________________________ | |
276 | const AliExternalTrackParam *AliV0ReaderV1::GetExternalTrackParam(AliESDv0 *fCurrentV0,Int_t &tracklabel,Int_t charge){ | |
277 | ||
278 | // Get External Track Parameter with given charge | |
279 | ||
280 | if(!(charge==1||charge==-1)){AliError("Charge not defined");return 0x0;} | |
281 | ||
282 | // Check for sign flip | |
283 | if(fCurrentV0){ | |
284 | if(!fCurrentV0->GetParamN()||!fCurrentV0->GetParamP())return 0x0; | |
285 | if(!fConversionCuts->GetTrack(fInputEvent,fCurrentV0->GetNindex())||!fConversionCuts->GetTrack(fInputEvent,fCurrentV0->GetPindex()))return 0x0; | |
286 | if((fConversionCuts->GetTrack(fInputEvent,fCurrentV0->GetPindex()))->Charge()==charge){ | |
287 | tracklabel=fCurrentV0->GetPindex(); | |
288 | return fCurrentV0->GetParamP();} | |
289 | if((fConversionCuts->GetTrack(fInputEvent,fCurrentV0->GetNindex()))->Charge()==charge){ | |
290 | tracklabel=fCurrentV0->GetNindex(); | |
291 | return fCurrentV0->GetParamN();} | |
292 | } | |
293 | return 0x0; | |
294 | } | |
295 | ||
296 | ///________________________________________________________________________ | |
297 | Bool_t AliV0ReaderV1::ProcessESDV0s() | |
298 | { | |
299 | // Process ESD V0s for conversion photon reconstruction | |
1528f6d1 | 300 | AliESDEvent *fESDEvent=dynamic_cast<AliESDEvent*>(fInputEvent); |
301 | ||
302 | AliKFConversionPhoton *fCurrentMotherKFCandidate=NULL; | |
e5b6e8a6 | 303 | |
1528f6d1 | 304 | if(fESDEvent){ |
305 | ||
306 | for(Int_t currentV0Index=0;currentV0Index<fESDEvent->GetNumberOfV0s();currentV0Index++){ | |
307 | AliESDv0 *fCurrentV0=(AliESDv0*)(fESDEvent->GetV0(currentV0Index)); | |
308 | if(!fCurrentV0){ | |
309 | printf("Requested V0 does not exist"); | |
ccfa8c0d | 310 | continue; |
311 | } | |
1528f6d1 | 312 | |
313 | fCurrentMotherKFCandidate=ReconstructV0(fCurrentV0,currentV0Index); | |
314 | ||
315 | if(fCurrentMotherKFCandidate){ | |
316 | ||
317 | // Add Gamma to the TClonesArray | |
318 | ||
319 | if(kUseAODConversionPhoton){ | |
320 | new((*fConversionGammas)[fConversionGammas->GetEntriesFast()]) AliAODConversionPhoton(fCurrentMotherKFCandidate); | |
321 | } | |
322 | else{ | |
323 | new((*fConversionGammas)[fConversionGammas->GetEntriesFast()]) AliKFConversionPhoton(*fCurrentMotherKFCandidate); | |
324 | } | |
325 | ||
326 | delete fCurrentMotherKFCandidate; | |
327 | fCurrentMotherKFCandidate=NULL; | |
328 | } | |
329 | } | |
330 | } | |
331 | return kTRUE; | |
332 | } | |
333 | ||
334 | ///________________________________________________________________________ | |
335 | AliKFConversionPhoton *AliV0ReaderV1::ReconstructV0(AliESDv0 *fCurrentV0,Int_t currentV0Index) | |
336 | { | |
337 | // Reconstruct conversion photon from ESD v0 | |
338 | fConversionCuts->FillPhotonCutIndex(AliConversionCuts::kPhotonIn); | |
339 | ||
340 | //checks if on the fly mode is set | |
341 | if(!fConversionCuts->SelectV0Finder(fCurrentV0->GetOnFlyStatus())){ | |
e5b6e8a6 | 342 | fConversionCuts->FillPhotonCutIndex(AliConversionCuts::kOnFly); |
343 | return 0x0; | |
1528f6d1 | 344 | } |
345 | ||
346 | // TrackLabels | |
347 | Int_t currentTrackLabels[2]={-1,-1}; | |
348 | ||
349 | // Get Daughter KF Particles | |
350 | ||
351 | const AliExternalTrackParam *fCurrentExternalTrackParamPositive=GetExternalTrackParamP(fCurrentV0,currentTrackLabels[0]); | |
352 | const AliExternalTrackParam *fCurrentExternalTrackParamNegative=GetExternalTrackParamN(fCurrentV0,currentTrackLabels[1]); | |
353 | ||
354 | if(!fCurrentExternalTrackParamPositive||!fCurrentExternalTrackParamNegative)return 0x0; | |
355 | ||
356 | // Apply some Cuts before Reconstruction | |
357 | ||
358 | AliVTrack * posTrack = fConversionCuts->GetTrack(fInputEvent,currentTrackLabels[0]); | |
359 | AliVTrack * negTrack = fConversionCuts->GetTrack(fInputEvent,currentTrackLabels[1]); | |
360 | ||
361 | if(!negTrack || !posTrack) { | |
e5b6e8a6 | 362 | fConversionCuts->FillPhotonCutIndex(AliConversionCuts::kNoTracks); |
363 | return 0x0; | |
1528f6d1 | 364 | } |
365 | ||
366 | // Track Cuts | |
367 | if(!fConversionCuts->TracksAreSelected(negTrack, posTrack)){ | |
e5b6e8a6 | 368 | fConversionCuts->FillPhotonCutIndex(AliConversionCuts::kTrackCuts); |
369 | return 0x0; | |
1528f6d1 | 370 | } |
371 | ||
372 | // PID Cuts | |
e5b6e8a6 | 373 | if(!fConversionCuts->dEdxCuts(negTrack) || !fConversionCuts->dEdxCuts(posTrack)) { |
374 | fConversionCuts->FillPhotonCutIndex(AliConversionCuts::kdEdxCuts); | |
375 | return 0x0; | |
376 | } | |
1528f6d1 | 377 | |
378 | // Reconstruct Photon | |
379 | ||
380 | AliKFConversionPhoton *fCurrentMotherKF=NULL; | |
381 | ||
382 | AliKFParticle fCurrentNegativeKFParticle(*(fCurrentExternalTrackParamNegative),11); | |
383 | AliKFParticle fCurrentPositiveKFParticle(*(fCurrentExternalTrackParamPositive),-11); | |
384 | ||
385 | // Reconstruct Gamma | |
386 | ||
387 | if(fUseConstructGamma){ | |
1528f6d1 | 388 | fCurrentMotherKF = new AliKFConversionPhoton(); |
389 | fCurrentMotherKF->ConstructGamma(fCurrentNegativeKFParticle,fCurrentPositiveKFParticle); | |
390 | }else{ | |
391 | fCurrentMotherKF = new AliKFConversionPhoton(fCurrentNegativeKFParticle,fCurrentPositiveKFParticle); | |
392 | fCurrentMotherKF->SetMassConstraint(0,0); | |
393 | } | |
394 | ||
395 | // Set Track Labels | |
396 | ||
397 | fCurrentMotherKF->SetTrackLabels(currentTrackLabels[0],currentTrackLabels[1]); | |
398 | ||
399 | // Set V0 index | |
400 | ||
401 | fCurrentMotherKF->SetV0Index(currentV0Index); | |
402 | ||
403 | //Set MC Label | |
404 | ||
405 | if(fMCEvent){ | |
406 | ||
407 | AliStack *fMCStack= fMCEvent->Stack(); | |
408 | ||
e5b6e8a6 | 409 | Int_t labelp=TMath::Abs(fConversionCuts->GetTrack(fInputEvent,fCurrentMotherKF->GetTrackLabelPositive())->GetLabel()); |
410 | Int_t labeln=TMath::Abs(fConversionCuts->GetTrack(fInputEvent,fCurrentMotherKF->GetTrackLabelNegative())->GetLabel()); | |
1528f6d1 | 411 | |
412 | TParticle *fNegativeMCParticle = fMCStack->Particle(labeln); | |
413 | TParticle *fPositiveMCParticle = fMCStack->Particle(labelp); | |
414 | ||
415 | if(fPositiveMCParticle&&fNegativeMCParticle){ | |
416 | fCurrentMotherKF->SetMCLabelPositive(labelp); | |
417 | fCurrentMotherKF->SetMCLabelNegative(labeln); | |
418 | } | |
419 | } | |
420 | ||
421 | // Update Vertex (moved for same eta compared to old) | |
422 | if(fUseImprovedVertex == kTRUE){ | |
423 | AliKFVertex primaryVertexImproved(*fInputEvent->GetPrimaryVertex()); | |
424 | primaryVertexImproved+=*fCurrentMotherKF; | |
425 | fCurrentMotherKF->SetProductionVertex(primaryVertexImproved); | |
426 | } | |
427 | ||
428 | // SetPsiPair | |
429 | ||
430 | Double_t PsiPair=GetPsiPair(fCurrentV0,fCurrentExternalTrackParamPositive,fCurrentExternalTrackParamNegative); | |
431 | fCurrentMotherKF->SetPsiPair(PsiPair); | |
432 | ||
e5b6e8a6 | 433 | |
1528f6d1 | 434 | // Recalculate ConversionPoint |
435 | Double_t dca[2]={0,0}; | |
436 | if(fUseOwnXYZCalculation){ | |
437 | Double_t convpos[3]={0,0,0}; | |
438 | if(!GetConversionPoint(fCurrentExternalTrackParamPositive,fCurrentExternalTrackParamNegative,convpos,dca)){ | |
e5b6e8a6 | 439 | fConversionCuts->FillPhotonCutIndex(AliConversionCuts::kConvPointFail); |
440 | delete fCurrentMotherKF; | |
441 | fCurrentMotherKF=NULL; | |
442 | return 0x0; | |
1528f6d1 | 443 | } |
444 | ||
445 | fCurrentMotherKF->SetConversionPoint(convpos); | |
446 | } | |
447 | ||
448 | if(fCurrentMotherKF->GetNDF() > 0.) | |
449 | fCurrentMotherKF->SetChi2perNDF(fCurrentMotherKF->GetChi2()/fCurrentMotherKF->GetNDF()); //->Photon is created before all chi2 relevant changes are performed, set it "by hand" | |
e5b6e8a6 | 450 | |
451 | ||
452 | // Set Dilepton Mass (moved down for same eta compared to old) | |
453 | fCurrentMotherKF->SetMass(fCurrentMotherKF->M()); | |
454 | ||
1528f6d1 | 455 | // Apply Photon Cuts |
456 | ||
457 | if(!fConversionCuts->PhotonCuts(fCurrentMotherKF,fInputEvent)){ | |
458 | fConversionCuts->FillPhotonCutIndex(AliConversionCuts::kPhotonCuts); | |
459 | delete fCurrentMotherKF; | |
460 | fCurrentMotherKF=NULL; | |
461 | return 0x0; | |
462 | } | |
463 | ||
1528f6d1 | 464 | fConversionCuts->FillPhotonCutIndex(AliConversionCuts::kPhotonOut); |
465 | return fCurrentMotherKF; | |
466 | } | |
467 | ||
468 | ///________________________________________________________________________ | |
469 | Double_t AliV0ReaderV1::GetPsiPair(const AliESDv0* v0, const AliExternalTrackParam *positiveparam,const AliExternalTrackParam *negativeparam) const { | |
470 | // | |
471 | // Angle between daughter momentum plane and plane | |
472 | // | |
473 | ||
a280ac15 | 474 | AliExternalTrackParam nt(*negativeparam); |
475 | AliExternalTrackParam pt(*positiveparam); | |
1528f6d1 | 476 | |
477 | Float_t magField = fInputEvent->GetMagneticField(); | |
478 | ||
479 | Double_t xyz[3] = {0.,0.,0.}; | |
480 | v0->GetXYZ(xyz[0],xyz[1],xyz[2]); | |
e5b6e8a6 | 481 | |
a280ac15 | 482 | // Double_t pPlus[3] = {pt.Px(),pt.Py(),pt.Pz()}; |
483 | // Double_t pMinus[3] = {nt.Px(),nt.Py(),nt.Pz()}; | |
484 | ||
485 | // Double_t u[3] = {pPlus[0]+pMinus[0],pPlus[1]+pMinus[1],pPlus[2]+pMinus[2]}; | |
486 | // Double_t normu = sqrt( (u[0]*u[0]) + (u[1]*u[1]) + (u[2]*u[2]) ); | |
11c1e680 | 487 | |
a280ac15 | 488 | // u[0] = u[0] / normu; |
489 | // u[1] = u[1] / normu; | |
490 | // u[2] = u[2] / normu; | |
491 | ||
492 | // Double_t normpPlus = sqrt( (pPlus[0]*pPlus[0]) + (pPlus[1]*pPlus[1]) + (pPlus[2]*pPlus[2]) ); | |
493 | // Double_t normpMinus = sqrt( (pMinus[0]*pMinus[0]) + (pMinus[1]*pMinus[1]) + (pMinus[2]*pMinus[2]) ); | |
494 | ||
495 | // pPlus[0] = pPlus[0] / normpPlus; | |
496 | // pPlus[1] = pPlus[1] / normpPlus; | |
497 | // pPlus[2] = pPlus[2] / normpPlus; | |
498 | ||
499 | // pMinus[0] = pMinus[0] / normpMinus; | |
500 | // pMinus[1] = pMinus[1] / normpMinus; | |
501 | // pMinus[2] = pMinus[2] / normpMinus; | |
502 | ||
503 | // Double_t v[3] = {0,0,0}; // pPlus X pMinus | |
504 | // v[0] = (pPlus[1]*pMinus[2]) - (pPlus[2]*pMinus[1]); | |
505 | // v[1] = (pPlus[2]*pMinus[0]) - (pPlus[0]*pMinus[2]); | |
506 | // v[2] = (pPlus[0]*pMinus[1]) - (pPlus[1]*pMinus[0]); | |
11c1e680 | 507 | |
a280ac15 | 508 | // Double_t w[3] = {0,0,0}; // u X v |
509 | // w[0] = (u[1]*v[2]) - (u[2]*v[1]); | |
510 | // w[1] = (u[2]*v[0]) - (u[0]*v[2]); | |
511 | // w[2] = (u[0]*v[1]) - (u[1]*v[0]); | |
512 | ||
513 | // Double_t z[3] = {0,0,1}; | |
514 | // Double_t wc[3] = {0,0,0}; // u X v | |
515 | // wc[0] = (u[1]*z[2]) - (u[2]*z[1]); | |
516 | // wc[1] = (u[2]*z[0]) - (u[0]*z[2]); | |
517 | // wc[2] = (u[0]*z[1]) - (u[1]*z[0]); | |
518 | ||
519 | // Double_t PhiV = TMath::ACos((w[0]*wc[0]) + (w[1]*wc[1]) + (w[2]*wc[2])); | |
520 | //return abs(PhiV); | |
521 | ||
522 | ||
523 | // TVector3 pPlus(pt.Px(),pt.Py(),pt.Pz()); | |
524 | // TVector3 pMinus(nt.Px(),nt.Py(),nt.Pz()); | |
525 | ||
526 | // TVector3 u = pMinus + pPlus; | |
527 | // u = u*(1/u.Mag()); | |
528 | ||
529 | // TVector3 pHPlus = pPlus*(1/pPlus.Mag()); | |
530 | // TVector3 pHMinus = pMinus*(1/pMinus.Mag()); | |
531 | ||
532 | // TVector3 v = pHPlus.Cross(pHMinus); | |
533 | // TVector3 w = u.Cross(v); | |
534 | // TVector3 z(0,0,1); | |
535 | // TVector3 wc = u.Cross(z); | |
536 | ||
537 | // Double_t PhiV = w * wc; | |
538 | ||
1528f6d1 | 539 | Double_t mn[3] = {0,0,0}; |
540 | Double_t mp[3] = {0,0,0}; | |
e5b6e8a6 | 541 | |
1528f6d1 | 542 | v0->GetNPxPyPz(mn[0],mn[1],mn[2]);//reconstructed cartesian momentum components of negative daughter; |
e5b6e8a6 | 543 | v0->GetPPxPyPz(mp[0],mp[1],mp[2]);//reconstructed cartesian momentum components of positive daughter; |
1528f6d1 | 544 | |
545 | Double_t deltat = 1.; | |
a280ac15 | 546 | 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 | 547 | Double_t radiussum = TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]) + 50;//radius to which tracks shall be propagated |
548 | ||
1528f6d1 | 549 | Double_t momPosProp[3] = {0,0,0}; |
550 | Double_t momNegProp[3] = {0,0,0}; | |
e5b6e8a6 | 551 | |
1528f6d1 | 552 | Double_t psiPair = 4.; |
553 | if(nt.PropagateTo(radiussum,magField) == 0) return psiPair; //propagate tracks to the outside -> Better Purity and Efficiency | |
1528f6d1 | 554 | if(pt.PropagateTo(radiussum,magField) == 0) return psiPair; //propagate tracks to the outside -> Better Purity and Efficiency |
e5b6e8a6 | 555 | |
1528f6d1 | 556 | pt.GetPxPyPz(momPosProp);//Get momentum vectors of tracks after propagation |
557 | nt.GetPxPyPz(momNegProp); | |
558 | ||
559 | Double_t pEle = | |
560 | TMath::Sqrt(momNegProp[0]*momNegProp[0]+momNegProp[1]*momNegProp[1]+momNegProp[2]*momNegProp[2]);//absolute momentum value of negative daughter | |
561 | ||
562 | Double_t pPos = | |
563 | TMath::Sqrt(momPosProp[0]*momPosProp[0]+momPosProp[1]*momPosProp[1]+momPosProp[2]*momPosProp[2]);//absolute momentum value of positive daughter | |
564 | ||
565 | Double_t scalarproduct = | |
566 | momPosProp[0]*momNegProp[0]+momPosProp[1]*momNegProp[1]+momPosProp[2]*momNegProp[2];//scalar product of propagated positive and negative daughters' momenta | |
567 | ||
568 | Double_t chipair = TMath::ACos(scalarproduct/(pEle*pPos));//Angle between propagated daughter tracks | |
569 | ||
570 | psiPair = TMath::Abs(TMath::ASin(deltat/chipair)); | |
571 | ||
572 | return psiPair; | |
573 | } | |
574 | ||
575 | ///________________________________________________________________________ | |
576 | Bool_t AliV0ReaderV1::GetHelixCenter(const AliExternalTrackParam *track,Double_t center[2]){ | |
577 | ||
578 | // Get Center of the helix track parametrization | |
579 | ||
580 | Int_t charge=track->Charge(); | |
581 | Double_t b=fInputEvent->GetMagneticField(); | |
582 | ||
583 | Double_t helix[6]; | |
584 | track->GetHelixParameters(helix,b); | |
585 | ||
586 | Double_t xpos = helix[5]; | |
587 | Double_t ypos = helix[0]; | |
588 | Double_t radius = TMath::Abs(1./helix[4]); | |
589 | Double_t phi = helix[2]; | |
590 | ||
591 | if(phi < 0){ | |
592 | phi = phi + 2*TMath::Pi(); | |
593 | } | |
594 | ||
595 | phi -= TMath::Pi()/2.; | |
596 | Double_t xpoint = radius * TMath::Cos(phi); | |
597 | Double_t ypoint = radius * TMath::Sin(phi); | |
598 | ||
599 | if(b<0){ | |
600 | if(charge > 0){ | |
601 | xpoint = - xpoint; | |
602 | ypoint = - ypoint; | |
603 | } | |
604 | ||
605 | if(charge < 0){ | |
606 | xpoint = xpoint; | |
607 | ypoint = ypoint; | |
608 | } | |
609 | } | |
610 | if(b>0){ | |
611 | if(charge > 0){ | |
612 | xpoint = xpoint; | |
613 | ypoint = ypoint; | |
614 | } | |
615 | ||
616 | if(charge < 0){ | |
617 | xpoint = - xpoint; | |
618 | ypoint = - ypoint; | |
619 | } | |
620 | } | |
621 | center[0] = xpos + xpoint; | |
622 | center[1] = ypos + ypoint; | |
623 | ||
624 | return 1; | |
625 | } | |
626 | ///________________________________________________________________________ | |
627 | Bool_t AliV0ReaderV1::GetConversionPoint(const AliExternalTrackParam *pparam,const AliExternalTrackParam *nparam,Double_t convpos[3],Double_t dca[2]){ | |
628 | ||
629 | // Recalculate Conversion Point | |
630 | ||
631 | if(!pparam||!nparam)return kFALSE; | |
e5b6e8a6 | 632 | |
1528f6d1 | 633 | Double_t helixcenterpos[2]; |
634 | GetHelixCenter(pparam,helixcenterpos); | |
635 | ||
636 | Double_t helixcenterneg[2]; | |
637 | GetHelixCenter(nparam,helixcenterneg); | |
638 | ||
639 | Double_t helixpos[6]; | |
640 | pparam->GetHelixParameters(helixpos,fInputEvent->GetMagneticField()); | |
641 | Double_t posradius = TMath::Abs(1./helixpos[4]); | |
642 | ||
643 | Double_t helixneg[6]; | |
644 | nparam->GetHelixParameters(helixneg,fInputEvent->GetMagneticField()); | |
645 | Double_t negradius = TMath::Abs(1./helixneg[4]); | |
646 | ||
647 | // Calculate xy-position | |
648 | ||
649 | Double_t xpos = helixcenterpos[0]; | |
650 | Double_t ypos = helixcenterpos[1]; | |
651 | Double_t xneg = helixcenterneg[0]; | |
652 | Double_t yneg = helixcenterneg[1]; | |
653 | ||
654 | convpos[0] = (xpos*negradius + xneg*posradius)/(negradius+posradius); | |
655 | convpos[1] = (ypos*negradius+ yneg*posradius)/(negradius+posradius); | |
656 | ||
657 | ||
658 | // Calculate Track XY vertex position | |
659 | ||
660 | Double_t deltaXPos = convpos[0] - xpos; | |
661 | Double_t deltaYPos = convpos[1] - ypos; | |
662 | ||
663 | Double_t deltaXNeg = convpos[0] - xneg; | |
664 | Double_t deltaYNeg = convpos[1] - yneg; | |
665 | ||
666 | Double_t alphaPos = TMath::Pi() + TMath::ATan2(-deltaYPos,-deltaXPos); | |
667 | Double_t alphaNeg = TMath::Pi() + TMath::ATan2(-deltaYNeg,-deltaXNeg); | |
668 | ||
669 | Double_t vertexXNeg = xneg + TMath::Abs(negradius)*TMath::Cos(alphaNeg); | |
670 | Double_t vertexYNeg = yneg + TMath::Abs(negradius)*TMath::Sin(alphaNeg); | |
671 | ||
672 | Double_t vertexXPos = xpos + TMath::Abs(posradius)*TMath::Cos(alphaPos); | |
673 | Double_t vertexYPos = ypos + TMath::Abs(posradius)*TMath::Sin(alphaPos); | |
674 | ||
675 | AliExternalTrackParam p(*pparam); | |
676 | AliExternalTrackParam n(*nparam); | |
677 | ||
678 | TVector2 vertexPos(vertexXPos,vertexYPos); | |
679 | TVector2 vertexNeg(vertexXNeg,vertexYNeg); | |
680 | ||
681 | // Convert to local coordinate system | |
682 | TVector2 vertexPosRot=vertexPos.Rotate(-p.GetAlpha()); | |
683 | TVector2 vertexNegRot=vertexNeg.Rotate(-n.GetAlpha()); | |
684 | ||
685 | // Propagate Track Params to Vertex | |
686 | ||
687 | if(!p.PropagateTo(vertexPosRot.X(),fInputEvent->GetMagneticField()))return kFALSE; | |
688 | if(!n.PropagateTo(vertexNegRot.X(),fInputEvent->GetMagneticField()))return kFALSE; | |
689 | ||
690 | // Check whether propagation was sucessful | |
691 | ||
692 | if(TMath::Abs(vertexPos.Mod()-TMath::Sqrt(p.GetX()*p.GetX()+p.GetY()*p.GetY()))>0.01)return kFALSE; | |
693 | if(TMath::Abs(vertexNeg.Mod()-TMath::Sqrt(n.GetX()*n.GetX()+n.GetY()*n.GetY()))>0.01)return kFALSE; | |
694 | ||
695 | // Calculate z position | |
696 | ||
697 | convpos[2] = (p.GetZ()*negradius+n.GetZ()*posradius)/(negradius+posradius); | |
698 | ||
699 | // Calculate DCA | |
700 | TVector2 vdca=vertexPos-vertexNeg; | |
701 | dca[0]=vdca.Mod(); | |
702 | dca[1]=TMath::Abs(n.GetZ()-p.GetZ()); | |
703 | ||
704 | return kTRUE; | |
705 | } | |
706 | //________________________________________________________________________ | |
707 | Bool_t AliV0ReaderV1::GetAODConversionGammas(){ | |
708 | ||
709 | // Get reconstructed conversion photons from satellite AOD file | |
710 | ||
711 | AliAODEvent *fAODEvent=dynamic_cast<AliAODEvent*>(fInputEvent); | |
712 | ||
713 | if(fAODEvent){ | |
714 | ||
e5b6e8a6 | 715 | if(fConversionGammas == NULL){ |
716 | fConversionGammas = new TClonesArray("AliAODConversionPhoton",100); | |
717 | } | |
1528f6d1 | 718 | fConversionGammas->Delete();//Reset the TClonesArray |
719 | ||
720 | //Get Gammas from satellite AOD gamma branch | |
721 | ||
722 | AliAODConversionPhoton *gamma=0x0; | |
e5b6e8a6 | 723 | |
1528f6d1 | 724 | TClonesArray *fInputGammas=dynamic_cast<TClonesArray*>(fAODEvent->FindListObject(fDeltaAODBranchName.Data())); |
725 | if(!fInputGammas){ | |
e5b6e8a6 | 726 | FindDeltaAODBranchName(); |
727 | fInputGammas=dynamic_cast<TClonesArray*>(fAODEvent->FindListObject(fDeltaAODBranchName.Data()));} | |
1528f6d1 | 728 | if(!fInputGammas){AliError("No Gamma Satellites found");return kFALSE;} |
729 | // Apply Selection Cuts to Gammas and create local working copy | |
730 | if(fInputGammas){ | |
e5b6e8a6 | 731 | for(Int_t i=0;i<fInputGammas->GetEntriesFast();i++){ |
732 | gamma=dynamic_cast<AliAODConversionPhoton*>(fInputGammas->At(i)); | |
733 | if(gamma){ | |
734 | if(fConversionCuts->PhotonIsSelected(gamma,fInputEvent)){ | |
735 | new((*fConversionGammas)[fConversionGammas->GetEntriesFast()]) AliAODConversionPhoton(*gamma);} | |
736 | } | |
737 | } | |
1528f6d1 | 738 | } |
739 | } | |
740 | ||
741 | if(fConversionGammas->GetEntries()){return kTRUE;} | |
742 | ||
743 | return kFALSE; | |
744 | } | |
745 | ||
746 | //________________________________________________________________________ | |
747 | void AliV0ReaderV1::FindDeltaAODBranchName(){ | |
748 | ||
749 | // Find delta AOD branchname containing reconstructed photons | |
750 | ||
751 | TList *list=fInputEvent->GetList(); | |
752 | for(Int_t ii=0;ii<list->GetEntries();ii++){ | |
753 | TString name((list->At(ii))->GetName()); | |
754 | if(name.BeginsWith(fDeltaAODBranchName)&&name.EndsWith("gamma")){ | |
755 | fDeltaAODBranchName=name; | |
756 | AliInfo(Form("Set DeltaAOD BranchName to: %s",fDeltaAODBranchName.Data())); | |
757 | return; | |
758 | } | |
759 | } | |
760 | } | |
1528f6d1 | 761 | //________________________________________________________________________ |
762 | void AliV0ReaderV1::Terminate(Option_t *) | |
763 | { | |
764 | ||
765 | } |