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. *
15 *************************************************************************************/
17 /*************************************************************************************
19 * Class for the Selection of Non-Heavy-Flavour-Electrons trought *
20 * the invariant mass method. The selection can be done from two *
21 * different algorithms, which can be choosed calling the function *
22 * "SetAlgorithm(TString Algorithm)". *
24 * Authors: R.Bailhache, C.A.Schmidt *
26 *************************************************************************************/
29 #include "THnSparse.h"
31 #include "TLorentzVector.h"
32 #include "TParticle.h"
34 #include "TDatabasePDG.h"
36 #include "AliVEvent.h"
37 #include "AliMCEvent.h"
38 #include "AliESDEvent.h"
39 #include "AliMCParticle.h"
40 #include "AliAODMCParticle.h"
41 #include "AliAODEvent.h"
42 #include "AliAODVertex.h"
43 #include "AliAODTrack.h"
44 #include "AliVTrack.h"
45 #include "AliESDtrack.h"
46 #include "AliESDtrackCuts.h"
47 #include "AliPIDResponse.h"
50 #include "AliKFParticle.h"
51 #include "AliKFVertex.h"
53 #include "AliHFEcuts.h"
54 #include "AliHFEpid.h"
55 #include "AliHFEpidQAmanager.h"
56 #include "AliHFEtools.h"
58 #include "AliHFENonPhotonicElectron.h"
60 ClassImp(AliHFENonPhotonicElectron)
61 //________________________________________________________________________
62 AliHFENonPhotonicElectron::AliHFENonPhotonicElectron(const char *name, const Char_t *title)
66 ,fAODArrayMCInfo (NULL)
67 ,fHFEBackgroundCuts (NULL)
72 ,fUseFilterAOD (kTRUE)
74 ,fChi2OverNDFCut (3.0)
76 // ,fMaxOpeningTheta (0.02)
77 // ,fMaxOpeningPhi (0.1)
78 ,fMaxOpening3D (TMath::Pi())
80 ,fSetMassConstraint (kFALSE)
82 ,fCounterPoolBackground (0)
91 // ,fUSignAngle (NULL)
92 // ,fLSignAngle (NULL)
97 fPIDBackground = new AliHFEpid("hfePidBackground");
98 fPIDBackgroundQA = new AliHFEpidQAmanager;
101 //________________________________________________________________________
102 AliHFENonPhotonicElectron::AliHFENonPhotonicElectron()
106 ,fAODArrayMCInfo (NULL)
107 ,fHFEBackgroundCuts (NULL)
108 ,fPIDBackground (0x0)
109 ,fPIDBackgroundQA (0)
111 ,fAlgorithmMA (kTRUE)
112 ,fUseFilterAOD (kTRUE)
114 ,fChi2OverNDFCut (3.0)
116 // ,fMaxOpeningTheta (0.02)
117 // ,fMaxOpeningPhi (0.1)
118 ,fMaxOpening3D (TMath::TwoPi())
120 ,fSetMassConstraint (kFALSE)
122 ,fCounterPoolBackground (0)
131 // ,fUSignAngle (NULL)
132 // ,fLSignAngle (NULL)
137 fPIDBackground = new AliHFEpid("hfePidBackground");
138 fPIDBackgroundQA = new AliHFEpidQAmanager;
141 //________________________________________________________________________
142 AliHFENonPhotonicElectron::AliHFENonPhotonicElectron(const AliHFENonPhotonicElectron &ref)
146 ,fAODArrayMCInfo (NULL)
147 ,fHFEBackgroundCuts (ref.fHFEBackgroundCuts)
148 ,fPIDBackground (ref.fPIDBackground)
149 ,fPIDBackgroundQA (ref.fPIDBackgroundQA)
150 ,fkPIDRespons (ref.fkPIDRespons)
151 ,fAlgorithmMA (ref.fAlgorithmMA)
152 ,fUseFilterAOD (ref.fUseFilterAOD)
153 ,fFilter (ref.fFilter)
154 ,fChi2OverNDFCut (ref.fChi2OverNDFCut)
155 ,fMaxDCA (ref.fMaxDCA)
156 // ,fMaxOpeningTheta (ref.fMaxOpeningTheta)
157 // ,fMaxOpeningPhi (ref.fMaxOpeningPhi)
158 ,fMaxOpening3D (ref.fMaxOpening3D)
159 ,fMaxInvMass (ref.fMaxInvMass)
160 ,fSetMassConstraint (ref.fSetMassConstraint)
162 ,fCounterPoolBackground (0)
164 ,fListOutput (ref.fListOutput)
165 ,fAssElectron (ref.fAssElectron)
166 ,fIncElectron (ref.fIncElectron)
169 ,fUSmatches(ref.fUSmatches)
170 ,fLSmatches(ref.fLSmatches)
171 // ,fUSignAngle (ref.fUSignAngle)
172 // ,fLSignAngle (ref.fLSignAngle)
180 //____________________________________________________________
181 AliHFENonPhotonicElectron &AliHFENonPhotonicElectron::operator=(const AliHFENonPhotonicElectron &ref){
183 // Assignment operator
185 if(this == &ref) ref.Copy(*this);
189 //_________________________________________
190 AliHFENonPhotonicElectron::~AliHFENonPhotonicElectron()
195 if(fArraytrack) delete fArraytrack;
196 //if(fHFEBackgroundCuts) delete fHFEBackgroundCuts;
197 if(fPIDBackground) delete fPIDBackground;
198 if(fPIDBackgroundQA) delete fPIDBackgroundQA;
201 //_____________________________________________________________________________________________
202 void AliHFENonPhotonicElectron::Init()
208 //printf("Analysis Mode for AliHFENonPhotonicElectron: %s Analysis\n", fIsAOD ? "AOD" : "ESD");
210 if(!fListOutput) fListOutput = new TList;
211 fListOutput->SetName("HFENonPhotonicElectron");
212 fListOutput->SetOwner();
214 if(!fHFEBackgroundCuts) fHFEBackgroundCuts = new AliHFEcuts();
215 if(fIsAOD) fHFEBackgroundCuts->SetAOD();
216 fHFEBackgroundCuts->Initialize();
217 if(fHFEBackgroundCuts->IsQAOn()) {
218 fListOutput->Add(fHFEBackgroundCuts->GetQAhistograms());
222 if(!fPIDBackground) fPIDBackground = new AliHFEpid("default pid");
223 if(fMCEvent || fAODArrayMCInfo) fPIDBackground->SetHasMCData(kTRUE); // does nothing since the fMCEvent are set afterwards at the moment
224 if(!fPIDBackground->GetNumberOfPIDdetectors())
226 //fPIDBackground->AddDetector("TOF", 0);
227 fPIDBackground->AddDetector("TPC", 0);
229 AliInfo("PID Background QA switched on");
230 fPIDBackgroundQA->Initialize(fPIDBackground);
231 fListOutput->Add(fPIDBackgroundQA->MakeList("HFENP_PID_Background"));
232 fPIDBackground->SortDetectors();
235 //Double_t binLimPt[25] = {0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1., 1.1, 1.2, 1.3, 1.4, 1.5, 1.75, 2., 2.25, 2.5, 3., 3.5, 4., 5., 6.};
236 Double_t binLimPt[36] = {0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1., 1.1, 1.2, 1.3, 1.4, 1.5, 1.75, 2., 2.25, 2.5, 2.75, 3., 3.5, 4., 4.5, 5., 5.5, 6., 7., 8., 10., 12., 14., 16., 18., 20.};
240 Double_t maxP = 20.0;
241 Double_t binLimP[nBinsP+1];
242 for(Int_t i=0; i<=nBinsP; i++) binLimP[i]=(Double_t)minP + (maxP-minP)/nBinsP*(Double_t)i ;
246 Double_t maxC = 11.0;
247 Double_t binLimC[nBinsC+1];
248 for(Int_t i=0; i<=nBinsC; i++) binLimC[i]=(Double_t)minC + (maxC-minC)/nBinsC*(Double_t)i ;
250 Int_t nBinsSource = 10;
251 Double_t minSource = 0.;
252 Double_t maxSource = 10.;
253 Double_t binLimSource[nBinsSource+1];
254 for(Int_t i=0; i<=nBinsSource; i++) binLimSource[i]=(Double_t)minSource + (maxSource-minSource)/nBinsSource*(Double_t)i ;
256 Int_t nBinsInvMass = 1000;
257 Double_t minInvMass = 0.;
258 Double_t maxInvMass = 10.;
259 Double_t binLimInvMass[nBinsInvMass+1];
260 for(Int_t i=0; i<=nBinsInvMass; i++) binLimInvMass[i]=(Double_t)minInvMass + (maxInvMass-minInvMass)/nBinsInvMass*(Double_t)i ;
262 Int_t nBinsPhi = 180;
263 Double_t minPhi = 0.0;
264 Double_t maxPhi = TMath::Pi();
265 Double_t binLimPhi[nBinsPhi+1];
266 for(Int_t i=0; i<=nBinsPhi; i++)
268 binLimPhi[i]=(Double_t)minPhi + (maxPhi-minPhi)/nBinsPhi*(Double_t)i ;
269 AliDebug(2,Form("bin phi is %f for %d",binLimPhi[i],i));
272 Int_t nBinsAngle = 180;
273 Double_t minAngle = 0.0;
274 Double_t maxAngle = TMath::Pi();
275 Double_t binLimAngle[nBinsAngle+1];
276 for(Int_t i=0; i<=nBinsAngle; i++)
278 binLimAngle[i]=(Double_t)minAngle + (maxAngle-minAngle)/nBinsAngle*(Double_t)i ;
279 AliDebug(2,Form("bin phi is %f for %d",binLimAngle[i],i));
282 // Associated Electron
283 const Int_t nDimAssElectron=3;
284 Int_t nBinAssElectron[nDimAssElectron] = {nBinsC,nBinsPt,nBinsSource};
285 fAssElectron = new THnSparseF("fAssElectron","fAssElectron",nDimAssElectron,nBinAssElectron);
286 fAssElectron->SetBinEdges(0,binLimC);
287 fAssElectron->SetBinEdges(1,binLimPt);
288 fAssElectron->SetBinEdges(2,binLimSource);
289 fAssElectron->Sumw2();
290 AliDebug(2,"AliHFENonPhotonicElectron: fAssElectron");
292 // Inclusive Electron
293 const Int_t nDimIncElectron=3;
294 Int_t nBinIncElectron[nDimIncElectron] = {nBinsC,nBinsPt,nBinsSource};
295 fIncElectron = new THnSparseF("fIncElectron","fIncElectron",nDimIncElectron,nBinIncElectron);
296 fIncElectron->SetBinEdges(0,binLimC);
297 fIncElectron->SetBinEdges(1,binLimPt);
298 fIncElectron->SetBinEdges(2,binLimSource);
299 fIncElectron->Sumw2();
300 AliDebug(2,"AliHFENonPhotonicElectron: fIncElectron");
302 // ee invariant mass Unlike Sign
303 const Int_t nDimUSign=7;
304 Int_t nBinUSign[nDimUSign] = {nBinsPhi,nBinsC,nBinsPt,nBinsInvMass,nBinsSource,nBinsAngle,nBinsPt};
305 fUSign = new THnSparseF("fUSign","fUSign",nDimUSign,nBinUSign);
306 fUSign->SetBinEdges(0,binLimPhi);
307 fUSign->SetBinEdges(1,binLimC);
308 fUSign->SetBinEdges(2,binLimPt);
309 fUSign->SetBinEdges(3,binLimInvMass);
310 fUSign->SetBinEdges(4,binLimSource);
311 fUSign->SetBinEdges(5,binLimAngle);
312 fUSign->SetBinEdges(6,binLimPt);
314 AliDebug(2,"AliHFENonPhotonicElectron: fUSign");
316 // ee invariant mass Like Sign
317 const Int_t nDimLSign=7;
318 Int_t nBinLSign[nDimLSign] = {nBinsPhi,nBinsC,nBinsPt,nBinsInvMass,nBinsSource,nBinsAngle,nBinsPt};
319 fLSign = new THnSparseF("fLSign","fLSign",nDimLSign,nBinLSign);
320 fLSign->SetBinEdges(0,binLimPhi);
321 fLSign->SetBinEdges(1,binLimC);
322 fLSign->SetBinEdges(2,binLimPt);
323 fLSign->SetBinEdges(3,binLimInvMass);
324 fLSign->SetBinEdges(4,binLimSource);
325 fLSign->SetBinEdges(5,binLimAngle);
326 fLSign->SetBinEdges(6,binLimPt);
328 AliDebug(2,"AliHFENonPhotonicElectron: fLSign");
330 // Histograms counting the number of like sign / unlike sign matches per inclusive track
331 const Int_t nBinsMatches = 50;
332 Double_t binLimMatches[nBinsMatches+1];
333 for(int ib = 0; ib <= nBinsMatches; ib++) binLimMatches[ib] = ib;
334 const Int_t nDimMatches = 3; // centrality, pt_inc, number of matches
335 const Int_t nBinsMatchHist[nDimMatches] = {nBinsC, nBinsPt, nBinsMatches};
336 fUSmatches = new THnSparseF("fUSmatches", "fUSmatches", nDimMatches, nBinsMatchHist);
337 fUSmatches->SetBinEdges(0,binLimC);
338 fUSmatches->SetBinEdges(1,binLimPt);
339 fUSmatches->SetBinEdges(2,binLimMatches);
341 fLSmatches = new THnSparseF("fLSmatches", "fLSmatches", nDimMatches, nBinsMatchHist);
342 fLSmatches->SetBinEdges(0,binLimC);
343 fLSmatches->SetBinEdges(1,binLimPt);
344 fLSmatches->SetBinEdges(2,binLimMatches);
347 // ee angle Unlike Sign
348 const Int_t nDimUSignAngle=3;
349 Int_t nBinUSignAngle[nDimUSignAngle] = {nBinsAngle,nBinsC,nBinsSource};
350 fUSignAngle = new THnSparseF("fUSignAngle","fUSignAngle",nDimUSignAngle,nBinUSignAngle);
351 fUSignAngle->SetBinEdges(0,binLimAngle);
352 fUSignAngle->SetBinEdges(1,binLimC);
353 fUSignAngle->SetBinEdges(2,binLimSource);
354 fUSignAngle->Sumw2();
355 AliDebug(2,"AliHFENonPhotonicElectron: fUSignAngle");
357 // ee angle Like Sign
358 const Int_t nDimLSignAngle=3;
359 Int_t nBinLSignAngle[nDimLSignAngle] = {nBinsAngle,nBinsC,nBinsSource};
360 fLSignAngle = new THnSparseF("fLSignAngle","fLSignAngle",nDimLSignAngle,nBinLSignAngle);
361 fLSignAngle->SetBinEdges(0,binLimAngle);
362 fLSignAngle->SetBinEdges(1,binLimC);
363 fLSignAngle->SetBinEdges(2,binLimSource);
364 fLSignAngle->Sumw2();
365 AliDebug(2,"AliHFENonPhotonicElectron: fLSignAngle");
368 fListOutput->Add(fAssElectron);
369 fListOutput->Add(fIncElectron);
370 fListOutput->Add(fUSign);
371 fListOutput->Add(fLSign);
372 fListOutput->Add(fUSmatches);
373 fListOutput->Add(fLSmatches);
374 // fListOutput->Add(fUSignAngle);
375 // fListOutput->Add(fLSignAngle);
379 //_____________________________________________________________________________________________
380 void AliHFENonPhotonicElectron::InitRun(const AliVEvent *inputEvent,const AliPIDResponse *pidResponse)
388 AliDebug(1, "Using default PID Response");
389 Bool_t hasmc = kFALSE;
390 if(fMCEvent || fAODArrayMCInfo) hasmc=kTRUE;
391 pidResponse = AliHFEtools::GetDefaultPID(hasmc, inputEvent->IsA() == AliESDEvent::Class());
394 if(!fPIDBackground) return;
395 fPIDBackground->SetPIDResponse(pidResponse);
397 if(!fPIDBackground->IsInitialized())
399 // Initialize PID with the given run number
400 fPIDBackground->InitializePID(inputEvent->GetRunNumber());
405 //_____________________________________________________________________________________________
406 Int_t AliHFENonPhotonicElectron::FillPoolAssociatedTracks(AliVEvent *inputEvent, Int_t binct)
409 // Fill the pool of associated tracks
410 // Return the number of associated tracks
415 Int_t nbtracks = inputEvent->GetNumberOfTracks();
419 fArraytrack->~TArrayI();
420 new(fArraytrack) TArrayI(nbtracks);
424 fArraytrack = new TArrayI(nbtracks);
427 fCounterPoolBackground = 0;
429 for(Int_t k = 0; k < nbtracks; k++)
431 AliVTrack *track = (AliVTrack *) inputEvent->GetTrack(k);
435 Bool_t survivedbackground = kTRUE;
436 AliAODEvent *aodeventu = dynamic_cast<AliAODEvent *>(inputEvent);
444 AliAODTrack *aodtrack = dynamic_cast<AliAODTrack *>(track);
450 if(!(aodtrack->TestFilterBit(fFilter))) survivedbackground = kFALSE;
456 if(!fHFEBackgroundCuts->CheckParticleCuts(AliHFEcuts::kStepRecKineITSTPC + AliHFEcuts::kNcutStepsMCTrack, (TObject *) track)) survivedbackground = kFALSE;
457 if(!fHFEBackgroundCuts->CheckParticleCuts(AliHFEcuts::kStepRecPrim + AliHFEcuts::kNcutStepsMCTrack, (TObject *) track)) survivedbackground = kFALSE;
460 if(survivedbackground)
463 AliHFEpidObject hfetrack2;
465 if(!aodeventu) hfetrack2.SetAnalysisType(AliHFEpidObject::kESDanalysis);
466 else hfetrack2.SetAnalysisType(AliHFEpidObject::kAODanalysis);
468 hfetrack2.SetRecTrack(track);
471 hfetrack2.SetCentrality((Int_t)binct);
472 AliDebug(2,Form("centrality %d and %d",binct,hfetrack2.GetCentrality()));
476 if(fPIDBackground->IsSelected(&hfetrack2,0x0,"recTrackCont",fPIDBackgroundQA))
478 fArraytrack->AddAt(k,fCounterPoolBackground);
479 fCounterPoolBackground++;
480 AliDebug(2,Form("fCounterPoolBackground %d, track %d",fCounterPoolBackground,k));
485 //printf(Form("Associated Pool: Tracks %d, fCounterPoolBackground %d \n", nbtracks, fCounterPoolBackground));
487 return fCounterPoolBackground;
491 //_____________________________________________________________________________________________
492 Int_t AliHFENonPhotonicElectron::CountPoolAssociated(AliVEvent *inputEvent, Int_t binct)
495 // Count the pool of assiocated tracks
499 if(fnumberfound > 0) //!count only events with an inclusive electron
501 Double_t valueAssElectron[3] = { binct, -1, -1}; //Centrality Pt Source
503 Int_t indexmother2 = -1;
504 AliVTrack *track2 = 0x0;
506 for(Int_t ii = 0; ii < fCounterPoolBackground; ii++){
507 iTrack2 = fArraytrack->At(ii);
508 AliDebug(2,Form("track %d",iTrack2));
509 track2 = (AliVTrack *)inputEvent->GetTrack(iTrack2);
512 //printf("ERROR: Could not receive track %d", iTrack2);
517 if(fMCEvent || fAODArrayMCInfo) valueAssElectron[2] = FindMother(TMath::Abs(track2->GetLabel()), indexmother2) ;
519 fkPIDRespons = fPIDBackground->GetPIDResponse();
521 valueAssElectron[1] = track2->Pt() ;
523 fAssElectron->Fill( valueAssElectron) ;
525 //printf(Form("Associated Pool: fCounterPoolBackground %d \n", fCounterPoolBackground));
530 //_____________________________________________________________________________________________
531 Int_t AliHFENonPhotonicElectron::LookAtNonHFE(Int_t iTrack1, AliVTrack *track1, AliVEvent *vEvent, Double_t weight, Int_t binct, Double_t deltaphi, Int_t source, Int_t indexmother)
537 /***********************************************************************************
539 * iTrack1: index of the tagged electrons in AliVEvent *
540 * track1: tagged electron *
542 * weight: weight in pt if not realistic *
543 * binct: centrality bin *
544 * deltaphi: phi-phi event plane for v2 *
545 * source: MC sources *
546 * indexmother: MC index mother *
549 * return -1 if nothing *
550 * return 2 if opposite charge within the mass range *
551 * return 4 if like charge within the mass range *
552 * return 6 if opposite & like charge within the mass range *
554 ***********************************************************************************/
556 AliAODEvent *aodeventu = dynamic_cast<AliAODEvent*>(vEvent);
557 Int_t taggedphotonic = -1;
559 AliDebug(2,Form("fCounterPoolBackground %d in LookAtNonHFE!!!",fCounterPoolBackground));
560 if(!fArraytrack) return taggedphotonic;
561 AliDebug(2,Form("process track %d",iTrack1));
563 fkPIDRespons = fPIDBackground->GetPIDResponse();
565 //Set Fill-Arrays for THnSparse
566 Double_t valueIncElectron[3] = { binct, track1->Pt(), source}; //Centrality Pt Source P
567 Double_t valueSign[7] = { deltaphi, binct, track1->Pt(), -1, source, -1, -1}; //DeltaPhi Centrality Pt InvariantMass Source Angle Pt
568 //Double_t valueAngle[3] = { -1, binct, source}; //Angle Centrality Source
570 Int_t pdg1 = CheckPdg(TMath::Abs(track1->GetLabel()));
571 Double_t eMass = TDatabasePDG::Instance()->GetParticle(11)->Mass(); //Electron mass in GeV
572 Double_t bfield = vEvent->GetMagneticField();
574 AliVTrack *track2 = 0x0;
576 Int_t indexmother2 = -1;
579 Int_t fPDGtrack2 = 0;
580 Float_t fCharge2 = 0;
582 // count number of matches with opposite/same sign track in the given mass range
583 Int_t countsMatchLikesign(0),
584 countsMatchUnlikesign(0);
588 TLorentzVector electron1;
589 TLorentzVector electron2;
590 TLorentzVector mother;
592 Double_t xt1 = 0; //radial position track 1 at the DCA point
593 Double_t xt2 = 0; //radial position track 2 at the DCA point
594 Double_t p1[3] = {0,0,0};
595 Double_t p2[3] = {0,0,0};
596 Double_t angleESD = -1;
597 Double_t invmassESD = -1;
599 Double_t chi2OverNDF = -1;
601 Double_t angleAOD = -1;
602 Double_t invmassAOD = -1;
604 AliKFVertex primV(*(vEvent->GetPrimaryVertex()));
606 Float_t fCharge1 = track1->Charge(); //Charge from track1
607 Int_t fPDGtrack1 = 11;
608 if(fCharge1>0) fPDGtrack1 = -11;
609 AliKFParticle ktrack1(*track1, fPDGtrack1);
610 AliESDtrack *esdtrack1 = dynamic_cast<AliESDtrack *>(track1); //ESD-track1
612 AliESDtrack *esdtrack2 = 0x0;
614 Bool_t kUSignPhotonic = kFALSE;
615 Bool_t kLSignPhotonic = kFALSE;
616 Bool_t kHasdcaT1 = kFALSE;
617 Bool_t kHasdcaT2 = kFALSE;
619 //! FILL Inclusive Electron
620 fIncElectron->Fill(valueIncElectron,weight);
622 //printf(Form("Inclusive Pool: TrackNr. %d, fnumberfound %d \n", iTrack1, fnumberfound));
624 for(Int_t idex = 0; idex < fCounterPoolBackground; idex++){
625 iTrack2 = fArraytrack->At(idex);
626 AliDebug(2,Form("track %d",iTrack2));
627 track2 = (AliVTrack *)vEvent->GetTrack(iTrack2);
630 //printf("ERROR: Could not receive track %d", iTrack2);
634 fCharge2 = track2->Charge(); //Charge from track2
637 //valueAngle[2] = source;
638 valueSign[4] = source;
639 valueSign[6] = track2->Pt();
641 // track cuts and PID already done
643 // Checking if it is the same Track!
644 if(iTrack2==iTrack1) continue;
645 AliDebug(2,"Different");
648 if(fMCEvent || fAODArrayMCInfo){
649 source2 = FindMother(TMath::Abs(track2->GetLabel()), indexmother2);
650 pdg2 = CheckPdg(TMath::Abs(track2->GetLabel()));
653 if((indexmother2 == indexmother) && (source == source2) && ((pdg1*pdg2)<0.0)){
655 case kElectronfromconversion:
656 valueSign[4] = kElectronfromconversionboth;
658 case kElectronfrompi0:
659 valueSign[4] = kElectronfrompi0both;
661 case kElectronfrometa:
662 valueSign[4] = kElectronfrometaboth;
670 if(fAlgorithmMA && (!aodeventu)){
675 esdtrack2 = dynamic_cast<AliESDtrack *>(track2); //ESD-track2
676 if((!esdtrack1) || (!esdtrack2)) continue;
678 dca12 = esdtrack2->GetDCA(esdtrack1,bfield,xt2,xt1); //DCA track1-track2
680 if(dca12 > fMaxDCA) continue; //! Cut on DCA
682 //Momento of the track extrapolated to DCA track-track
683 kHasdcaT1 = esdtrack1->GetPxPyPzAt(xt1,bfield,p1); //Track1
684 kHasdcaT2 = esdtrack2->GetPxPyPzAt(xt2,bfield,p2); //Track2
685 if(!kHasdcaT1 || !kHasdcaT2) AliWarning("It could be a problem in the extrapolation");
687 electron1.SetXYZM(p1[0], p1[1], p1[2], eMass);
688 electron2.SetXYZM(p2[0], p2[1], p2[2], eMass);
690 // electron1.SetXYZM(esdtrack1->Px(), esdtrack1->Py(), esdtrack1->Pz(), eMass);
691 // electron2.SetXYZM(esdtrack2->Px(), esdtrack2->Py(), esdtrack2->Pz(), eMass);
693 mother = electron1 + electron2;
694 invmassESD = mother.M();
695 angleESD = TVector2::Phi_0_2pi(electron1.Angle(electron2.Vect()));
697 //valueAngle[0] = angleESD;
698 valueSign[3] = invmassESD;
699 valueSign[5] = angleESD;
701 //if((fCharge1*fCharge2)>0.0) fLSignAngle->Fill(&valueAngle[0],weight);
702 //else fUSignAngle->Fill(&valueAngle[0],weight);
704 if(angleESD > fMaxOpening3D) continue; //! Cut on Opening Angle
705 if(invmassESD > fMaxInvMass) continue; //! Cut on Invariant Mass
707 if((fCharge1*fCharge2)>0.0){
708 fLSign->Fill( valueSign, weight);
709 // count like-sign background matched pairs per inclusive based on mass cut
710 if(invmassESD < 0.14) countsMatchLikesign++;
712 fUSign->Fill( valueSign, weight);
713 // count unlike-sign matched pairs per inclusive based on mass cut
714 if(invmassESD < 0.14) countsMatchUnlikesign++;
717 if((fCharge1*fCharge2)>0.0) kLSignPhotonic=kTRUE;
718 else kUSignPhotonic=kTRUE;
721 * AOD-AliKF-Analysis *
724 //printf("AOD HFE non photonic\n");
727 if(fCharge2>0) fPDGtrack2 = -11;
729 AliKFParticle::SetField(vEvent->GetMagneticField());
730 AliKFParticle ktrack2(*track2, fPDGtrack2);
731 AliKFParticle recoGamma(ktrack1,ktrack2);
733 if(recoGamma.GetNDF()<1) continue; //! Cut on Reconstruction
735 chi2OverNDF = recoGamma.GetChi2()/recoGamma.GetNDF();
736 if(TMath::Sqrt(TMath::Abs(chi2OverNDF))>fChi2OverNDFCut) continue;
739 //Double_t dca12 = ktrack1.GetDistanceFromParticle(ktrack2);
740 //if(dca12 > fMaxDCA) continue;
742 // if set mass constraint
743 if(fSetMassConstraint) //&& pVtx)
748 recoGamma.SetProductionVertex(primV);
749 recoGamma.SetMassConstraint(0,0.0001);
752 recoGamma.GetMass(invmassAOD,width);
753 angleAOD = ktrack1.GetAngle(ktrack2);
755 //valueAngle[0] = angleAOD;
756 valueSign[3] = invmassAOD;
757 valueSign[5] = angleAOD;
759 //if((fCharge1*fCharge2)>0.0) fLSignAngle->Fill(&valueAngle[0],weight);
760 //else fUSignAngle->Fill(&valueAngle[0],weight);
762 if(angleAOD > fMaxOpening3D) continue; //! Cut on Opening Angle
763 if(invmassAOD > fMaxInvMass) continue; //! Cut on Invariant Mass
765 if((fCharge1*fCharge2)>0.0){
766 fLSign->Fill( valueSign, weight);
767 // count like-sign background matched pairs per inclusive based on mass cut
768 if(invmassAOD < 0.14) countsMatchLikesign++;
770 fUSign->Fill( valueSign, weight);
771 // count unlike-sign matched pairs per inclusive based on mass cut
772 if(invmassAOD < 0.14) countsMatchUnlikesign++;
775 if((fCharge1*fCharge2)>0.0) kLSignPhotonic=kTRUE;
776 else kUSignPhotonic=kTRUE;
781 Double_t valCountsLS[3] = {binct, track1->Pt(), countsMatchLikesign},
782 valCountsUS[3] = {binct, track1->Pt(), countsMatchUnlikesign};
783 fUSmatches->Fill(valCountsUS);
784 fLSmatches->Fill(valCountsLS);
786 if( kUSignPhotonic && kLSignPhotonic) taggedphotonic = 6;
787 if(!kUSignPhotonic && kLSignPhotonic) taggedphotonic = 4;
788 if( kUSignPhotonic && !kLSignPhotonic) taggedphotonic = 2;
790 return taggedphotonic;
793 //_________________________________________________________________________
794 Int_t AliHFENonPhotonicElectron::FindMother(Int_t tr, Int_t &indexmother){
796 // Find the mother if MC
799 if(!fMCEvent && !fAODArrayMCInfo) return 0;
801 Int_t pdg = CheckPdg(tr);
802 if(TMath::Abs(pdg)!= 11)
808 indexmother = IsMotherGamma(tr);
809 if(indexmother > 0) return kElectronfromconversion;
810 indexmother = IsMotherPi0(tr);
811 if(indexmother > 0) return kElectronfrompi0;
812 indexmother = IsMotherC(tr);
813 if(indexmother > 0) return kElectronfromC;
814 indexmother = IsMotherB(tr);
815 if(indexmother > 0) return kElectronfromB;
816 indexmother = IsMotherEta(tr);
817 if(indexmother > 0) return kElectronfrometa;
819 return kElectronfromother;
822 //________________________________________________________________________________________________
823 Int_t AliHFENonPhotonicElectron::CheckPdg(Int_t tr) {
826 // Return the pdg of the particle
830 if(tr < 0) return pdgcode;
834 AliVParticle *mctrack = fMCEvent->GetTrack(tr);
835 if(!mctrack) return -1;
836 AliMCParticle *mctrackesd = NULL;
837 if(!(mctrackesd = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(tr))))) return pdgcode;
838 pdgcode = mctrackesd->PdgCode();
843 if((tr+1)>fAODArrayMCInfo->GetEntriesFast()) return -1;
844 AliAODMCParticle *mctrackaod = (AliAODMCParticle *) fAODArrayMCInfo->At(tr);
845 if(!mctrackaod) return pdgcode;
846 pdgcode = mctrackaod->GetPdgCode();
852 //_______________________________________________________________________________________________
853 Int_t AliHFENonPhotonicElectron::IsMotherGamma(Int_t tr) {
856 // Return the lab of gamma mother or -1 if not gamma
859 if(tr < 0) return -1;
863 AliVParticle *mctrack = fMCEvent->GetTrack(tr);
864 if(!mctrack) return -1;
865 AliMCParticle *mctrackesd = NULL;
866 if(!(mctrackesd = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(tr))))) return -1;
867 TParticle *particle = 0x0;
868 particle = mctrackesd->Particle();
871 if(!particle) return -1;
872 Int_t imother = particle->GetFirstMother();
873 if(imother < 0) return -1;
874 AliMCParticle *mothertrack = NULL;
875 if(!(mothertrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(imother))))) return -1;
876 TParticle * mother = mothertrack->Particle();
877 if(!mother) return -1;
880 Int_t pdg = mother->GetPdgCode();
881 if(TMath::Abs(pdg) == 22) return imother;
882 if(TMath::Abs(pdg) == 11)
884 return IsMotherGamma(imother);
892 if((tr+1)>fAODArrayMCInfo->GetEntriesFast()) return -1;
893 AliAODMCParticle *mctrackaod = (AliAODMCParticle *) fAODArrayMCInfo->At(tr);
894 if(!mctrackaod) return -1;
897 Int_t imother = mctrackaod->GetMother();
898 if(imother < 0 || ((imother+1)>fAODArrayMCInfo->GetEntriesFast())) return -1;
899 AliAODMCParticle *mothertrack = NULL;
900 if(!(mothertrack = dynamic_cast<AliAODMCParticle *>(fAODArrayMCInfo->At(TMath::Abs(imother))))) return -1;
903 Int_t pdg = mothertrack->GetPdgCode();
904 if(TMath::Abs(pdg) == 22) return imother;
905 if(TMath::Abs(pdg) == 11)
907 return IsMotherGamma(imother);
916 //________________________________________________________________________________________________
917 Int_t AliHFENonPhotonicElectron::IsMotherPi0(Int_t tr) {
920 // Return the lab of pi0 mother or -1 if not pi0
923 if(tr < 0) return -1;
927 AliVParticle *mctrack = fMCEvent->GetTrack(tr);
928 if(!mctrack) return -1;
929 AliMCParticle *mctrackesd = NULL;
930 if(!(mctrackesd = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(tr))))) return -1;
931 TParticle *particle = 0x0;
932 particle = mctrackesd->Particle();
934 if(!particle) return -1;
935 Int_t imother = particle->GetFirstMother();
936 if(imother < 0) return -1;
937 AliMCParticle *mothertrack = NULL;
938 if(!(mothertrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(imother))))) return -1;
939 TParticle * mother = mothertrack->Particle();
940 if(!mother) return -1;
942 Int_t pdg = mother->GetPdgCode();
943 if(TMath::Abs(pdg) == 111) return imother;
944 if(TMath::Abs(pdg) == 11)
946 return IsMotherPi0(imother);
952 if(fAODArrayMCInfo) {
954 if((tr+1)>fAODArrayMCInfo->GetEntriesFast()) return -1;
955 AliAODMCParticle *mctrackaod = (AliAODMCParticle *) fAODArrayMCInfo->At(tr);
956 if(!mctrackaod) return -1;
959 Int_t imother = mctrackaod->GetMother();
960 if(imother < 0 || ((imother+1)>fAODArrayMCInfo->GetEntriesFast())) return -1;
961 AliAODMCParticle *mothertrack = NULL;
962 if(!(mothertrack = dynamic_cast<AliAODMCParticle *>(fAODArrayMCInfo->At(TMath::Abs(imother))))) return -1;
964 Int_t pdg = mothertrack->GetPdgCode();
965 if(TMath::Abs(pdg) == 111) return imother;
966 if(TMath::Abs(pdg) == 11)
968 return IsMotherPi0(imother);
976 //________________________________________________________________________________________________
977 Int_t AliHFENonPhotonicElectron::IsMotherC(Int_t tr) {
980 // Return the lab of signal mother or -1 if not from C
983 if(tr < 0) return -1;
987 AliVParticle *mctrack = fMCEvent->GetTrack(tr);
988 if(!mctrack) return -1;
989 AliMCParticle *mctrackesd = NULL;
990 if(!(mctrackesd = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(tr))))) return -1;
991 TParticle *particle = 0x0;
992 particle = mctrackesd->Particle();
995 if(!particle) return -1;
996 Int_t imother = particle->GetFirstMother();
997 if(imother < 0) return -1;
998 AliMCParticle *mothertrack = NULL;
999 if(!(mothertrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(imother))))) return -1;
1000 TParticle * mother = mothertrack->Particle();
1001 if(!mother) return -1;
1004 Int_t pdg = mother->GetPdgCode();
1005 if((TMath::Abs(pdg)==411) || (TMath::Abs(pdg)==421) || (TMath::Abs(pdg)==431) || (TMath::Abs(pdg)==4122) || (TMath::Abs(pdg)==4132) || (TMath::Abs(pdg)==4232) || (TMath::Abs(pdg)==43320)) return imother;
1006 if(TMath::Abs(pdg) == 11)
1008 return IsMotherC(imother);
1016 if((tr+1)>fAODArrayMCInfo->GetEntriesFast()) return -1;
1017 AliAODMCParticle *mctrackaod = (AliAODMCParticle *) fAODArrayMCInfo->At(tr);
1018 if(!mctrackaod) return -1;
1021 Int_t imother = mctrackaod->GetMother();
1022 if(imother < 0 || ((imother+1)>fAODArrayMCInfo->GetEntriesFast())) return -1;
1023 AliAODMCParticle *mothertrack = NULL;
1024 if(!(mothertrack = dynamic_cast<AliAODMCParticle *>(fAODArrayMCInfo->At(TMath::Abs(imother))))) return -1;
1027 Int_t pdg = mothertrack->GetPdgCode();
1028 if((TMath::Abs(pdg)==411) || (TMath::Abs(pdg)==421) || (TMath::Abs(pdg)==431) || (TMath::Abs(pdg)==4122) || (TMath::Abs(pdg)==4132) || (TMath::Abs(pdg)==4232) || (TMath::Abs(pdg)==43320)) return imother;
1029 if(TMath::Abs(pdg) == 11)
1031 return IsMotherC(imother);
1039 //_______________________________________________________________________________________________
1040 Int_t AliHFENonPhotonicElectron::IsMotherB(Int_t tr) {
1043 // Return the lab of signal mother or -1 if not B
1046 if(tr < 0) return -1;
1050 AliVParticle *mctrack = fMCEvent->GetTrack(tr);
1051 if(!mctrack) return -1;
1052 AliMCParticle *mctrackesd = NULL;
1053 if(!(mctrackesd = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(tr))))) return -1;
1054 TParticle *particle = 0x0;
1055 particle = mctrackesd->Particle();
1058 if(!particle) return -1;
1059 Int_t imother = particle->GetFirstMother();
1060 if(imother < 0) return -1;
1061 AliMCParticle *mothertrack = NULL;
1062 if(!(mothertrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(imother))))) return -1;
1063 TParticle * mother = mothertrack->Particle();
1064 if(!mother) return -1;
1067 Int_t pdg = mother->GetPdgCode();
1068 if((TMath::Abs(pdg)==511) || (TMath::Abs(pdg)==521) || (TMath::Abs(pdg)==531) || (TMath::Abs(pdg)==5122) || (TMath::Abs(pdg)==5132) || (TMath::Abs(pdg)==5232) || (TMath::Abs(pdg)==53320)) return imother;
1069 if(TMath::Abs(pdg) == 11)
1071 return IsMotherB(imother);
1079 if((tr+1)>fAODArrayMCInfo->GetEntriesFast()) return -1;
1080 AliAODMCParticle *mctrackaod = (AliAODMCParticle *) fAODArrayMCInfo->At(tr);
1081 if(!mctrackaod) return -1;
1084 Int_t imother = mctrackaod->GetMother();
1085 if(imother < 0 || ((imother+1)>fAODArrayMCInfo->GetEntriesFast())) return -1;
1086 AliAODMCParticle *mothertrack = NULL;
1087 if(!(mothertrack = dynamic_cast<AliAODMCParticle *>(fAODArrayMCInfo->At(TMath::Abs(imother))))) return -1;
1089 Int_t pdg = mothertrack->GetPdgCode();
1090 if((TMath::Abs(pdg)==511) || (TMath::Abs(pdg)==521) || (TMath::Abs(pdg)==531) || (TMath::Abs(pdg)==5122) || (TMath::Abs(pdg)==5132) || (TMath::Abs(pdg)==5232) || (TMath::Abs(pdg)==53320)) return imother;
1091 if(TMath::Abs(pdg) == 11)
1093 return IsMotherB(imother);
1102 //_______________________________________________________________________________________________
1103 Int_t AliHFENonPhotonicElectron::IsMotherEta(Int_t tr) {
1106 // Return the lab of eta mother or -1 if not eta
1109 if(tr < 0) return -1;
1113 AliVParticle *mctrack = fMCEvent->GetTrack(tr);
1114 if(!mctrack) return -1;
1115 AliMCParticle *mctrackesd = NULL;
1116 if(!(mctrackesd = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(tr))))) return -1;
1117 TParticle *particle = 0x0;
1118 particle = mctrackesd->Particle();
1121 if(!particle) return -1;
1122 Int_t imother = particle->GetFirstMother();
1123 if(imother < 0) return -1;
1124 AliMCParticle *mothertrack = NULL;
1125 if(!(mothertrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(imother))))) return -1;
1126 TParticle * mother = mothertrack->Particle();
1127 if(!mother) return -1;
1130 Int_t pdg = mother->GetPdgCode();
1131 if(TMath::Abs(pdg) == 221) return imother;
1132 if(TMath::Abs(pdg) == 11)
1134 return IsMotherEta(imother);
1142 if((tr+1)>fAODArrayMCInfo->GetEntriesFast()) return -1;
1143 AliAODMCParticle *mctrackaod = (AliAODMCParticle *) fAODArrayMCInfo->At(tr);
1144 if(!mctrackaod) return -1;
1147 Int_t imother = mctrackaod->GetMother();
1148 if(imother < 0 || ((imother+1)>fAODArrayMCInfo->GetEntriesFast())) return -1;
1149 AliAODMCParticle *mothertrack = NULL;
1150 if(!(mothertrack = dynamic_cast<AliAODMCParticle *>(fAODArrayMCInfo->At(TMath::Abs(imother))))) return -1;
1153 Int_t pdg = mothertrack->GetPdgCode();
1154 if(TMath::Abs(pdg) == 221) return imother;
1155 if(TMath::Abs(pdg) == 11)
1157 return IsMotherEta(imother);