]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGHF/hfe/AliHFENonPhotonicElectron.cxx
Update of the hfe package from gsi svn
[u/mrichter/AliRoot.git] / PWGHF / hfe / AliHFENonPhotonicElectron.cxx
CommitLineData
76d0b522 1/*************************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
ff8249bd 9
76d0b522 10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 * *
16 *************************************************************************************/
17
18/*************************************************************************************
19 * *
20 * Class for the Selection of Non-Heavy-Flavour-Electrons trought *
21 * the invariant mass method. The selection can be done from two *
22 * different algorithms, which can be choosed calling the function *
23 * "SetAlgorithm(TString Algorithm)". *
24 * *
25 * Authors: R.Bailhache, C.A.Schmidt *
26 * *
27 *************************************************************************************/
28
29#include "TVector2.h"
30#include "THnSparse.h"
31#include "TMath.h"
32#include "TLorentzVector.h"
33#include "TParticle.h"
34#include "TList.h"
35#include "TDatabasePDG.h"
36
37#include "AliVEvent.h"
38#include "AliMCEvent.h"
39#include "AliESDEvent.h"
40#include "AliMCParticle.h"
41#include "AliAODMCParticle.h"
42#include "AliAODEvent.h"
43#include "AliAODVertex.h"
44#include "AliAODTrack.h"
45#include "AliVTrack.h"
46#include "AliESDtrack.h"
47#include "AliESDtrackCuts.h"
48#include "AliPIDResponse.h"
8a9b2231 49#include "AliPID.h"
76d0b522 50
51#include "AliKFParticle.h"
52#include "AliKFVertex.h"
53
54#include "AliHFEcuts.h"
55#include "AliHFEpid.h"
56#include "AliHFEpidQAmanager.h"
57#include "AliHFEtools.h"
ff8249bd 58#include "AliHFEmcQA.h"
76d0b522 59
60#include "AliHFENonPhotonicElectron.h"
61
62ClassImp(AliHFENonPhotonicElectron)
63//________________________________________________________________________
64AliHFENonPhotonicElectron::AliHFENonPhotonicElectron(const char *name, const Char_t *title)
8a9b2231 65 :TNamed (name, title)
66 ,fIsAOD (kFALSE)
67 ,fMCEvent (NULL)
68 ,fAODArrayMCInfo (NULL)
ff8249bd 69 ,fLevelBack(-1)
8a9b2231 70 ,fHFEBackgroundCuts (NULL)
71 ,fPIDBackground (0x0)
72 ,fPIDBackgroundQA (0)
73 ,fkPIDRespons (NULL)
1452614c 74 ,fPtBinning()
75 ,fEtaBinning()
8a9b2231 76 ,fAlgorithmMA (kTRUE)
8a9b2231 77 ,fChi2OverNDFCut (3.0)
78 ,fMaxDCA (3.0)
79// ,fMaxOpeningTheta (0.02)
80// ,fMaxOpeningPhi (0.1)
81 ,fMaxOpening3D (TMath::Pi())
82 ,fMaxInvMass (1000)
83 ,fSetMassConstraint (kFALSE)
4437a0d2 84 ,fSelectCategory1tracks(kTRUE)
85 ,fSelectCategory2tracks(kFALSE)
bbeea05b 86 ,fITSmeanShift(0.)
8a9b2231 87 ,fArraytrack (NULL)
88 ,fCounterPoolBackground (0)
89 ,fnumberfound (0)
90 ,fListOutput (NULL)
91 ,fAssElectron (NULL)
92 ,fIncElectron (NULL)
93 ,fUSign (NULL)
94 ,fLSign (NULL)
c3e32eae 95 ,fUSmatches(NULL)
96 ,fLSmatches(NULL)
4437a0d2 97 ,fHnsigmaITS(NULL)
ff8249bd 98 ,fWeightsSource(NULL)
8a9b2231 99// ,fUSignAngle (NULL)
100// ,fLSignAngle (NULL)
76d0b522 101{
102 //
103 // Constructor
104 //
8a9b2231 105 fPIDBackground = new AliHFEpid("hfePidBackground");
76d0b522 106 fPIDBackgroundQA = new AliHFEpidQAmanager;
107}
108
109//________________________________________________________________________
110AliHFENonPhotonicElectron::AliHFENonPhotonicElectron()
8a9b2231 111 :TNamed ()
112 ,fIsAOD (kFALSE)
113 ,fMCEvent (NULL)
114 ,fAODArrayMCInfo (NULL)
ff8249bd 115 ,fLevelBack(-1)
8a9b2231 116 ,fHFEBackgroundCuts (NULL)
117 ,fPIDBackground (0x0)
118 ,fPIDBackgroundQA (0)
119 ,fkPIDRespons (NULL)
1452614c 120 ,fPtBinning()
121 ,fEtaBinning()
8a9b2231 122 ,fAlgorithmMA (kTRUE)
8a9b2231 123 ,fChi2OverNDFCut (3.0)
124 ,fMaxDCA (3.0)
125// ,fMaxOpeningTheta (0.02)
126// ,fMaxOpeningPhi (0.1)
127 ,fMaxOpening3D (TMath::TwoPi())
128 ,fMaxInvMass (1000)
129 ,fSetMassConstraint (kFALSE)
4437a0d2 130 ,fSelectCategory1tracks(kTRUE)
131 ,fSelectCategory2tracks(kFALSE)
bbeea05b 132 ,fITSmeanShift(0.)
8a9b2231 133 ,fArraytrack (NULL)
134 ,fCounterPoolBackground (0)
135 ,fnumberfound (0)
136 ,fListOutput (NULL)
137 ,fAssElectron (NULL)
138 ,fIncElectron (NULL)
139 ,fUSign (NULL)
140 ,fLSign (NULL)
c3e32eae 141 ,fUSmatches(NULL)
142 ,fLSmatches(NULL)
4437a0d2 143 ,fHnsigmaITS(NULL)
ff8249bd 144 ,fWeightsSource(NULL)
145 ,fIncElectronRadius(NULL)
146 ,fRecElectronRadius(NULL)
8a9b2231 147// ,fUSignAngle (NULL)
148// ,fLSignAngle (NULL)
76d0b522 149{
150 //
151 // Constructor
152 //
153 fPIDBackground = new AliHFEpid("hfePidBackground");
154 fPIDBackgroundQA = new AliHFEpidQAmanager;
155}
156
157//________________________________________________________________________
158AliHFENonPhotonicElectron::AliHFENonPhotonicElectron(const AliHFENonPhotonicElectron &ref)
159 :TNamed(ref)
8a9b2231 160 ,fIsAOD (ref.fIsAOD)
161 ,fMCEvent (NULL)
162 ,fAODArrayMCInfo (NULL)
ff8249bd 163 ,fLevelBack (ref.fLevelBack)
8a9b2231 164 ,fHFEBackgroundCuts (ref.fHFEBackgroundCuts)
165 ,fPIDBackground (ref.fPIDBackground)
166 ,fPIDBackgroundQA (ref.fPIDBackgroundQA)
167 ,fkPIDRespons (ref.fkPIDRespons)
1452614c 168 ,fPtBinning(ref.fPtBinning)
169 ,fEtaBinning(ref.fEtaBinning)
8a9b2231 170 ,fAlgorithmMA (ref.fAlgorithmMA)
8a9b2231 171 ,fChi2OverNDFCut (ref.fChi2OverNDFCut)
172 ,fMaxDCA (ref.fMaxDCA)
173// ,fMaxOpeningTheta (ref.fMaxOpeningTheta)
174// ,fMaxOpeningPhi (ref.fMaxOpeningPhi)
175 ,fMaxOpening3D (ref.fMaxOpening3D)
176 ,fMaxInvMass (ref.fMaxInvMass)
177 ,fSetMassConstraint (ref.fSetMassConstraint)
4437a0d2 178 ,fSelectCategory1tracks(ref.fSelectCategory1tracks)
179 ,fSelectCategory2tracks(ref.fSelectCategory2tracks)
bbeea05b 180 ,fITSmeanShift(ref.fITSmeanShift)
8a9b2231 181 ,fArraytrack (NULL)
182 ,fCounterPoolBackground (0)
183 ,fnumberfound (0)
184 ,fListOutput (ref.fListOutput)
185 ,fAssElectron (ref.fAssElectron)
186 ,fIncElectron (ref.fIncElectron)
187 ,fUSign (ref.fUSign)
188 ,fLSign (ref.fLSign)
c3e32eae 189 ,fUSmatches(ref.fUSmatches)
190 ,fLSmatches(ref.fLSmatches)
4437a0d2 191 ,fHnsigmaITS(ref.fHnsigmaITS)
ff8249bd 192 ,fWeightsSource(ref.fWeightsSource)
193 ,fIncElectronRadius(ref.fIncElectronRadius)
194 ,fRecElectronRadius(ref.fRecElectronRadius)
8a9b2231 195// ,fUSignAngle (ref.fUSignAngle)
196// ,fLSignAngle (ref.fLSignAngle)
76d0b522 197{
198 //
199 // Copy Constructor
200 //
201 ref.Copy(*this);
202}
203
204//____________________________________________________________
205AliHFENonPhotonicElectron &AliHFENonPhotonicElectron::operator=(const AliHFENonPhotonicElectron &ref){
206 //
207 // Assignment operator
208 //
209 if(this == &ref) ref.Copy(*this);
210 return *this;
211}
212
213//_________________________________________
214AliHFENonPhotonicElectron::~AliHFENonPhotonicElectron()
215{
216 //
217 // Destructor
218 //
8a9b2231 219 if(fArraytrack) delete fArraytrack;
220 //if(fHFEBackgroundCuts) delete fHFEBackgroundCuts;
221 if(fPIDBackground) delete fPIDBackground;
222 if(fPIDBackgroundQA) delete fPIDBackgroundQA;
76d0b522 223}
224
225//_____________________________________________________________________________________________
226void AliHFENonPhotonicElectron::Init()
227{
228 //
229 // Init
230 //
231
8a9b2231 232 //printf("Analysis Mode for AliHFENonPhotonicElectron: %s Analysis\n", fIsAOD ? "AOD" : "ESD");
233
76d0b522 234 if(!fListOutput) fListOutput = new TList;
235 fListOutput->SetName("HFENonPhotonicElectron");
236 fListOutput->SetOwner();
237
8a9b2231 238 if(!fHFEBackgroundCuts) fHFEBackgroundCuts = new AliHFEcuts();
239 if(fIsAOD) fHFEBackgroundCuts->SetAOD();
240 fHFEBackgroundCuts->Initialize();
241 if(fHFEBackgroundCuts->IsQAOn()) {
242 fListOutput->Add(fHFEBackgroundCuts->GetQAhistograms());
243 }
76d0b522 244
245 // Initialize PID
246 if(!fPIDBackground) fPIDBackground = new AliHFEpid("default pid");
8a9b2231 247 if(fMCEvent || fAODArrayMCInfo) fPIDBackground->SetHasMCData(kTRUE); // does nothing since the fMCEvent are set afterwards at the moment
248 if(!fPIDBackground->GetNumberOfPIDdetectors())
249 {
250 //fPIDBackground->AddDetector("TOF", 0);
251 fPIDBackground->AddDetector("TPC", 0);
252 }
76d0b522 253 AliInfo("PID Background QA switched on");
254 fPIDBackgroundQA->Initialize(fPIDBackground);
255 fListOutput->Add(fPIDBackgroundQA->MakeList("HFENP_PID_Background"));
256 fPIDBackground->SortDetectors();
257
1452614c 258 const Int_t kBinsPtDefault = 35;
259 Double_t binLimPtDefault[kBinsPtDefault+1] = {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.};
260 const Int_t kBinsEtaInclusiveDefault = 8;
261 Double_t binLimEtaInclusiveDefault[kBinsEtaInclusiveDefault+1] = {-0.8, -0.6, -0.4, -0.2, 0., 0.2, 0.4, 0.6, 0.8};
ff8249bd 262 const Int_t kBinsEtaAssociated = 15;
263 Double_t binLimEtaAssociat[kBinsEtaAssociated+1] = {-1.5,-1.3,-1.1,-0.9,-0.7,-0.5,-0.3,-0.1,0.1,0.3,0.5,0.7,0.9,1.1,1.3,1.5};
8a9b2231 264
1452614c 265 if(!fPtBinning.GetSize()) fPtBinning.Set(kBinsPtDefault+1, binLimPtDefault);
266 if(!fEtaBinning.GetSize()) fEtaBinning.Set(kBinsEtaInclusiveDefault+1, binLimEtaInclusiveDefault);
267
4437a0d2 268 //Int_t nBinsP = 400;
269 //Double_t minP = 0.0;
270 //Double_t maxP = 20.0;
271 //Double_t binLimP[nBinsP+1];
272 //for(Int_t i=0; i<=nBinsP; i++) binLimP[i]=(Double_t)minP + (maxP-minP)/nBinsP*(Double_t)i ;
76d0b522 273
274 Int_t nBinsC = 11;
275 Double_t minC = 0.0;
276 Double_t maxC = 11.0;
277 Double_t binLimC[nBinsC+1];
278 for(Int_t i=0; i<=nBinsC; i++) binLimC[i]=(Double_t)minC + (maxC-minC)/nBinsC*(Double_t)i ;
279
280 Int_t nBinsSource = 10;
281 Double_t minSource = 0.;
282 Double_t maxSource = 10.;
283 Double_t binLimSource[nBinsSource+1];
284 for(Int_t i=0; i<=nBinsSource; i++) binLimSource[i]=(Double_t)minSource + (maxSource-minSource)/nBinsSource*(Double_t)i ;
285
ff8249bd 286 Int_t nBinsInvMass = 30;
76d0b522 287 Double_t minInvMass = 0.;
ff8249bd 288 Double_t maxInvMass = 0.3;
76d0b522 289 Double_t binLimInvMass[nBinsInvMass+1];
290 for(Int_t i=0; i<=nBinsInvMass; i++) binLimInvMass[i]=(Double_t)minInvMass + (maxInvMass-minInvMass)/nBinsInvMass*(Double_t)i ;
291
ff8249bd 292 Int_t nBinsPhi = 8;
76d0b522 293 Double_t minPhi = 0.0;
294 Double_t maxPhi = TMath::Pi();
295 Double_t binLimPhi[nBinsPhi+1];
296 for(Int_t i=0; i<=nBinsPhi; i++)
297 {
298 binLimPhi[i]=(Double_t)minPhi + (maxPhi-minPhi)/nBinsPhi*(Double_t)i ;
299 AliDebug(2,Form("bin phi is %f for %d",binLimPhi[i],i));
300 }
301
ff8249bd 302 Int_t nBinsAngle = 72;
76d0b522 303 Double_t minAngle = 0.0;
ff8249bd 304 Double_t maxAngle = 0.4;
76d0b522 305 Double_t binLimAngle[nBinsAngle+1];
306 for(Int_t i=0; i<=nBinsAngle; i++)
307 {
308 binLimAngle[i]=(Double_t)minAngle + (maxAngle-minAngle)/nBinsAngle*(Double_t)i ;
8a9b2231 309 AliDebug(2,Form("bin phi is %f for %d",binLimAngle[i],i));
310 }
311
4437a0d2 312 // Constrain histograms
313 const Int_t nDimSingle=4;
314 const Int_t nDimPair=9;
1452614c 315 Int_t nBinPair[nDimPair] = {nBinsPhi,nBinsC,fPtBinning.GetSize()-1,nBinsInvMass,nBinsSource,nBinsAngle,fPtBinning.GetSize()-1,fEtaBinning.GetSize()-1,kBinsEtaAssociated};
4437a0d2 316
8a9b2231 317 // Associated Electron
1452614c 318 Int_t nBinAssElectron[nDimSingle] = {nBinsC,fPtBinning.GetSize()-1,nBinsSource,kBinsEtaAssociated};
4437a0d2 319 fAssElectron = new THnSparseF("fAssElectron","fAssElectron",nDimSingle,nBinAssElectron);
8a9b2231 320 fAssElectron->SetBinEdges(0,binLimC);
1452614c 321 fAssElectron->SetBinEdges(1,fPtBinning.GetArray());
8a9b2231 322 fAssElectron->SetBinEdges(2,binLimSource);
4437a0d2 323 fAssElectron->SetBinEdges(3,binLimEtaAssociat);
8a9b2231 324 fAssElectron->Sumw2();
325 AliDebug(2,"AliHFENonPhotonicElectron: fAssElectron");
326
327 // Inclusive Electron
1452614c 328 Int_t nBinIncElectron[nDimSingle] = {nBinsC,fPtBinning.GetSize()-1,nBinsSource,fEtaBinning.GetSize()-1};
4437a0d2 329 fIncElectron = new THnSparseF("fIncElectron","fIncElectron",nDimSingle,nBinIncElectron);
8a9b2231 330 fIncElectron->SetBinEdges(0,binLimC);
1452614c 331 fIncElectron->SetBinEdges(1,fPtBinning.GetArray());
8a9b2231 332 fIncElectron->SetBinEdges(2,binLimSource);
1452614c 333 fIncElectron->SetBinEdges(3,fEtaBinning.GetArray());
8a9b2231 334 fIncElectron->Sumw2();
335 AliDebug(2,"AliHFENonPhotonicElectron: fIncElectron");
76d0b522 336
337 // ee invariant mass Unlike Sign
4437a0d2 338 fUSign = new THnSparseF("fUSign","fUSign",nDimPair,nBinPair);
959ea9d8 339 fUSign->SetBinEdges(0,binLimPhi);
340 fUSign->SetBinEdges(1,binLimC);
1452614c 341 fUSign->SetBinEdges(2,fPtBinning.GetArray());
959ea9d8 342 fUSign->SetBinEdges(3,binLimInvMass);
343 fUSign->SetBinEdges(4,binLimSource);
344 fUSign->SetBinEdges(5,binLimAngle);
1452614c 345 fUSign->SetBinEdges(6,fPtBinning.GetArray());
346 fUSign->SetBinEdges(7,fEtaBinning.GetArray());
4437a0d2 347 fUSign->SetBinEdges(8,binLimEtaAssociat);
959ea9d8 348 fUSign->Sumw2();
349 AliDebug(2,"AliHFENonPhotonicElectron: fUSign");
76d0b522 350
351 // ee invariant mass Like Sign
4437a0d2 352 fLSign = new THnSparseF("fLSign","fLSign",nDimPair,nBinPair);
959ea9d8 353 fLSign->SetBinEdges(0,binLimPhi);
354 fLSign->SetBinEdges(1,binLimC);
1452614c 355 fLSign->SetBinEdges(2,fPtBinning.GetArray());
959ea9d8 356 fLSign->SetBinEdges(3,binLimInvMass);
357 fLSign->SetBinEdges(4,binLimSource);
358 fLSign->SetBinEdges(5,binLimAngle);
1452614c 359 fLSign->SetBinEdges(6,fPtBinning.GetArray());
360 fLSign->SetBinEdges(7,fEtaBinning.GetArray());
4437a0d2 361 fLSign->SetBinEdges(8,binLimEtaAssociat);
959ea9d8 362 fLSign->Sumw2();
363 AliDebug(2,"AliHFENonPhotonicElectron: fLSign");
364
c3e32eae 365 // Histograms counting the number of like sign / unlike sign matches per inclusive track
366 const Int_t nBinsMatches = 50;
367 Double_t binLimMatches[nBinsMatches+1];
368 for(int ib = 0; ib <= nBinsMatches; ib++) binLimMatches[ib] = ib;
369 const Int_t nDimMatches = 3; // centrality, pt_inc, number of matches
1452614c 370 const Int_t nBinsMatchHist[nDimMatches] = {nBinsC, fPtBinning.GetSize()-1, nBinsMatches};
c3e32eae 371 fUSmatches = new THnSparseF("fUSmatches", "fUSmatches", nDimMatches, nBinsMatchHist);
372 fUSmatches->SetBinEdges(0,binLimC);
1452614c 373 fUSmatches->SetBinEdges(1,fPtBinning.GetArray());
c3e32eae 374 fUSmatches->SetBinEdges(2,binLimMatches);
375
376 fLSmatches = new THnSparseF("fLSmatches", "fLSmatches", nDimMatches, nBinsMatchHist);
377 fLSmatches->SetBinEdges(0,binLimC);
1452614c 378 fLSmatches->SetBinEdges(1,fPtBinning.GetArray());
c3e32eae 379 fLSmatches->SetBinEdges(2,binLimMatches);
380
ff8249bd 381 // Histograms for radius studies
382 Int_t nBinsradius = 50;
383 Double_t minradius = 0.0;
384 Double_t maxradius = 100.0;
385 Double_t binLimradius[nBinsradius+1];
386 for(Int_t i=0; i<=nBinsradius; i++) binLimradius[i]=(Double_t)minradius + (maxradius-minradius)/nBinsradius*(Double_t)i ;
387 const Int_t nDimIncElectronRadius = 3; // centrality, pt_inc, radius
388 const Int_t nBinsIncElectronRadius[nDimIncElectronRadius] = {nBinsC, fPtBinning.GetSize()-1, nBinsradius};
389 fIncElectronRadius = new THnSparseF("fIncElectronRadius", "fIncElectronRadius", nDimIncElectronRadius, nBinsIncElectronRadius);
390 fIncElectronRadius->SetBinEdges(0,binLimC);
391 fIncElectronRadius->SetBinEdges(1,fPtBinning.GetArray());
392 fIncElectronRadius->SetBinEdges(2,binLimradius);
393
394 fRecElectronRadius = new THnSparseF("fRecElectronRadius", "fRecElectronRadius", nDimIncElectronRadius, nBinsIncElectronRadius);
395 fRecElectronRadius->SetBinEdges(0,binLimC);
396 fRecElectronRadius->SetBinEdges(1,fPtBinning.GetArray());
397 fRecElectronRadius->SetBinEdges(2,binLimradius);
398
959ea9d8 399/*
76d0b522 400 // ee angle Unlike Sign
401 const Int_t nDimUSignAngle=3;
402 Int_t nBinUSignAngle[nDimUSignAngle] = {nBinsAngle,nBinsC,nBinsSource};
403 fUSignAngle = new THnSparseF("fUSignAngle","fUSignAngle",nDimUSignAngle,nBinUSignAngle);
404 fUSignAngle->SetBinEdges(0,binLimAngle);
405 fUSignAngle->SetBinEdges(1,binLimC);
406 fUSignAngle->SetBinEdges(2,binLimSource);
76d0b522 407 fUSignAngle->Sumw2();
408 AliDebug(2,"AliHFENonPhotonicElectron: fUSignAngle");
409
410 // ee angle Like Sign
411 const Int_t nDimLSignAngle=3;
412 Int_t nBinLSignAngle[nDimLSignAngle] = {nBinsAngle,nBinsC,nBinsSource};
413 fLSignAngle = new THnSparseF("fLSignAngle","fLSignAngle",nDimLSignAngle,nBinLSignAngle);
414 fLSignAngle->SetBinEdges(0,binLimAngle);
415 fLSignAngle->SetBinEdges(1,binLimC);
416 fLSignAngle->SetBinEdges(2,binLimSource);
76d0b522 417 fLSignAngle->Sumw2();
418 AliDebug(2,"AliHFENonPhotonicElectron: fLSignAngle");
959ea9d8 419*/
76d0b522 420
4437a0d2 421 // control histogram for ITS PID
422 fHnsigmaITS = new TH2F("fHnsigmaITS", "Number of sigmas in the ITS", 30, 0., 0.3, 1200, -10., 10.);
423
ff8249bd 424 // control histogram for weights sources
425 fWeightsSource = new TH2F("fWeightsSource", "Source code for weights", 11, -1.5, 9.5, 29, -1.5, 27.5);
426
8a9b2231 427 fListOutput->Add(fAssElectron);
428 fListOutput->Add(fIncElectron);
959ea9d8 429 fListOutput->Add(fUSign);
430 fListOutput->Add(fLSign);
c3e32eae 431 fListOutput->Add(fUSmatches);
432 fListOutput->Add(fLSmatches);
4437a0d2 433 fListOutput->Add(fHnsigmaITS);
ff8249bd 434 fListOutput->Add(fWeightsSource);
435 fListOutput->Add(fIncElectronRadius);
436 fListOutput->Add(fRecElectronRadius);
959ea9d8 437// fListOutput->Add(fUSignAngle);
438// fListOutput->Add(fLSignAngle);
76d0b522 439
440}
441
ff8249bd 442//_____________________________________________________________________________________________
443void AliHFENonPhotonicElectron::SetWithWeights(Int_t levelBack)
444{
445 //
446 // Init the HFE level
447 //
448 if(levelBack >= 0) fLevelBack = levelBack;
449
450}
451
452//_____________________________________________________________________________________________
453void AliHFENonPhotonicElectron::SetMCEvent(AliMCEvent *mcEvent)
454{
455 //
456 // Pass the mcEvent
457 //
458
459 fMCEvent = mcEvent;
460
461}
462
463//_____________________________________________________________________________________________
464void AliHFENonPhotonicElectron::SetAODArrayMCInfo(TClonesArray *aodArrayMCInfo)
465{
466 //
467 // Pass the mcEvent info
468 //
469
470 fAODArrayMCInfo = aodArrayMCInfo;
471
472}
473
76d0b522 474//_____________________________________________________________________________________________
663a2523 475void AliHFENonPhotonicElectron::InitRun(const AliVEvent *inputEvent,const AliPIDResponse *pidResponse)
76d0b522 476{
477 //
478 // Init run
479 //
480
481 if(!pidResponse)
482 {
483 AliDebug(1, "Using default PID Response");
484 Bool_t hasmc = kFALSE;
485 if(fMCEvent || fAODArrayMCInfo) hasmc=kTRUE;
486 pidResponse = AliHFEtools::GetDefaultPID(hasmc, inputEvent->IsA() == AliESDEvent::Class());
487 }
488
489 if(!fPIDBackground) return;
490 fPIDBackground->SetPIDResponse(pidResponse);
491
492 if(!fPIDBackground->IsInitialized())
493 {
494 // Initialize PID with the given run number
495 fPIDBackground->InitializePID(inputEvent->GetRunNumber());
496 }
497
498}
499
500//_____________________________________________________________________________________________
8a9b2231 501Int_t AliHFENonPhotonicElectron::FillPoolAssociatedTracks(AliVEvent *inputEvent, Int_t binct)
76d0b522 502{
503 //
504 // Fill the pool of associated tracks
505 // Return the number of associated tracks
506 //
507
8a9b2231 508 fnumberfound = 0;
509
4437a0d2 510 fHFEBackgroundCuts->SetRecEvent(inputEvent);
76d0b522 511 Int_t nbtracks = inputEvent->GetNumberOfTracks();
512
4437a0d2 513 if( fArraytrack ){
76d0b522 514 fArraytrack->~TArrayI();
515 new(fArraytrack) TArrayI(nbtracks);
4437a0d2 516 } else {
76d0b522 517 fArraytrack = new TArrayI(nbtracks);
518 }
519
520 fCounterPoolBackground = 0;
521
4437a0d2 522 Bool_t isSelected(kFALSE);
523 Bool_t isAOD = (dynamic_cast<AliAODEvent *>(inputEvent) != NULL);
524 AliDebug(2, Form("isAOD: %s", isAOD ? "yes" : "no"));
525 for(Int_t k = 0; k < nbtracks; k++) {
76d0b522 526 AliVTrack *track = (AliVTrack *) inputEvent->GetTrack(k);
527 if(!track) continue;
4437a0d2 528
529 //
530 isSelected = kFALSE;
531 if(fSelectCategory1tracks && FilterCategory1Track(track, isAOD, binct)) isSelected = kTRUE;
532 else if(fSelectCategory2tracks && FilterCategory2Track(track, isAOD)) isSelected = kTRUE;
533
534 if(isSelected){
535 AliDebug(2,Form("fCounterPoolBackground %d, track %d",fCounterPoolBackground,k));
536 fArraytrack->AddAt(k,fCounterPoolBackground);
537 fCounterPoolBackground++;
76d0b522 538 }
539 } // loop tracks
540
8a9b2231 541 //printf(Form("Associated Pool: Tracks %d, fCounterPoolBackground %d \n", nbtracks, fCounterPoolBackground));
76d0b522 542
543 return fCounterPoolBackground;
8a9b2231 544
545}
546
547//_____________________________________________________________________________________________
548Int_t AliHFENonPhotonicElectron::CountPoolAssociated(AliVEvent *inputEvent, Int_t binct)
549{
550 //
551 // Count the pool of assiocated tracks
552 //
553
554
555 if(fnumberfound > 0) //!count only events with an inclusive electron
556 {
4437a0d2 557 Double_t valueAssElectron[4] = { binct, -1, -1}; //Centrality Pt Source
8a9b2231 558 Int_t iTrack2 = 0;
559 Int_t indexmother2 = -1;
560 AliVTrack *track2 = 0x0;
561
c3e32eae 562 for(Int_t ii = 0; ii < fCounterPoolBackground; ii++){
8a9b2231 563 iTrack2 = fArraytrack->At(ii);
564 AliDebug(2,Form("track %d",iTrack2));
565 track2 = (AliVTrack *)inputEvent->GetTrack(iTrack2);
566
c3e32eae 567 if(!track2){
568 //printf("ERROR: Could not receive track %d", iTrack2);
569 continue;
8a9b2231 570 }
571
572 // if MC look
c3e32eae 573 if(fMCEvent || fAODArrayMCInfo) valueAssElectron[2] = FindMother(TMath::Abs(track2->GetLabel()), indexmother2) ;
8a9b2231 574
575 fkPIDRespons = fPIDBackground->GetPIDResponse();
576
577 valueAssElectron[1] = track2->Pt() ;
4437a0d2 578 valueAssElectron[3] = track2->Eta() ;
8a9b2231 579
580 fAssElectron->Fill( valueAssElectron) ;
581 }
582 //printf(Form("Associated Pool: fCounterPoolBackground %d \n", fCounterPoolBackground));
583 }
584 return fnumberfound;
76d0b522 585}
586
587//_____________________________________________________________________________________________
ff8249bd 588Int_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,Int_t mcQAsource)
76d0b522 589{
590 //
591 // Look At Non HFE
592 //
593
594 /***********************************************************************************
595 * *
596 * iTrack1: index of the tagged electrons in AliVEvent *
597 * track1: tagged electron *
598 * vEvent: event *
599 * weight: weight in pt if not realistic *
600 * binct: centrality bin *
601 * deltaphi: phi-phi event plane for v2 *
602 * source: MC sources *
603 * indexmother: MC index mother *
604 * *
605 * *
606 * return -1 if nothing *
607 * return 2 if opposite charge within the mass range *
608 * return 4 if like charge within the mass range *
609 * return 6 if opposite & like charge within the mass range *
610 * *
611 ***********************************************************************************/
612
ff8249bd 613 //printf("weight %f and source %d\n",weight,source);
614
615
76d0b522 616 AliAODEvent *aodeventu = dynamic_cast<AliAODEvent*>(vEvent);
617 Int_t taggedphotonic = -1;
618
619 AliDebug(2,Form("fCounterPoolBackground %d in LookAtNonHFE!!!",fCounterPoolBackground));
620 if(!fArraytrack) return taggedphotonic;
621 AliDebug(2,Form("process track %d",iTrack1));
39427568 622 AliDebug(1,Form("Inclusive source is %d\n", source));
76d0b522 623
8a9b2231 624 fkPIDRespons = fPIDBackground->GetPIDResponse();
76d0b522 625
8a9b2231 626 //Set Fill-Arrays for THnSparse
4437a0d2 627 Double_t valueIncElectron[4] = { binct, track1->Pt(), source, track1->Eta()}; //Centrality Pt Source P
628 Double_t valueSign[9] = { deltaphi, binct, track1->Pt(), -1, source, -1, -1, track1->Eta(), -1}; //DeltaPhi Centrality Pt InvariantMass Source Angle Pt
ff8249bd 629 //Double_t valueAngle[3] = { -1, binct, source};
630 Double_t valueradius[3] = { binct, track1->Pt(), 0.}; //Angle Centrality Source
76d0b522 631
632 Int_t pdg1 = CheckPdg(TMath::Abs(track1->GetLabel()));
ff8249bd 633 Double_t radius = Radius(TMath::Abs(track1->GetLabel()));
4437a0d2 634 AliKFParticle::SetField(vEvent->GetMagneticField());
635 AliKFVertex primV(*(vEvent->GetPrimaryVertex()));
ff8249bd 636 valueradius[2] = radius;
8a9b2231 637
4437a0d2 638 AliVTrack *track2(NULL);
76d0b522 639 Int_t iTrack2 = 0;
76d0b522 640 Int_t indexmother2 = -1;
8a9b2231 641 Int_t pdg2 = -100;
642 Int_t source2 = -1;
8a9b2231 643 Float_t fCharge2 = 0;
644
c3e32eae 645 // count number of matches with opposite/same sign track in the given mass range
646 Int_t countsMatchLikesign(0),
647 countsMatchUnlikesign(0);
648
4437a0d2 649 // Values to fill
650 Double_t angle(-1.);
651 Double_t invmass(-1);
76d0b522 652
8a9b2231 653 Float_t fCharge1 = track1->Charge(); //Charge from track1
76d0b522 654
8a9b2231 655 Bool_t kUSignPhotonic = kFALSE;
656 Bool_t kLSignPhotonic = kFALSE;
76d0b522 657
8a9b2231 658 //! FILL Inclusive Electron
ff8249bd 659 fWeightsSource->Fill(source,mcQAsource);
8a9b2231 660 fIncElectron->Fill(valueIncElectron,weight);
661 fnumberfound++;
ff8249bd 662 if(source == kElectronfromconversion) {
663 fIncElectronRadius->Fill(valueradius,weight);
664 //printf("radius %f\n",radius);
665 }
8a9b2231 666 //printf(Form("Inclusive Pool: TrackNr. %d, fnumberfound %d \n", iTrack1, fnumberfound));
76d0b522 667
c3e32eae 668 for(Int_t idex = 0; idex < fCounterPoolBackground; idex++){
76d0b522 669 iTrack2 = fArraytrack->At(idex);
670 AliDebug(2,Form("track %d",iTrack2));
671 track2 = (AliVTrack *)vEvent->GetTrack(iTrack2);
672
c3e32eae 673 if(!track2){
8a9b2231 674 //printf("ERROR: Could not receive track %d", iTrack2);
76d0b522 675 continue;
676 }
677
76d0b522 678 fCharge2 = track2->Charge(); //Charge from track2
679
680 // Reset the MC info
959ea9d8 681 //valueAngle[2] = source;
682 valueSign[4] = source;
8a9b2231 683 valueSign[6] = track2->Pt();
4437a0d2 684 valueSign[8] = track2->Eta();
76d0b522 685
686 // track cuts and PID already done
687
8a9b2231 688 // Checking if it is the same Track!
689 if(iTrack2==iTrack1) continue;
690 AliDebug(2,"Different");
691
76d0b522 692 // if MC look
c3e32eae 693 if(fMCEvent || fAODArrayMCInfo){
39427568 694 AliDebug(2, "Checking for source");
76d0b522 695 source2 = FindMother(TMath::Abs(track2->GetLabel()), indexmother2);
39427568 696 AliDebug(2, Form("source is %d", source2));
76d0b522 697 pdg2 = CheckPdg(TMath::Abs(track2->GetLabel()));
698
39427568 699 if(source == kElectronfromconversion){
700 AliDebug(2, Form("Electron from conversion (source %d), paired with source %d", source, source2));
701 AliDebug(2, Form("Index of the mothers: incl %d, associated %d", indexmother, indexmother2));
702 AliDebug(2, Form("PDGs: incl %d, associated %d", pdg1, pdg2));
703 }
704
c3e32eae 705 if(source2 >=0 ){
706 if((indexmother2 == indexmother) && (source == source2) && ((pdg1*pdg2)<0.0)){
39427568 707 AliDebug(1, "Real pair");
c3e32eae 708 switch(source){
4437a0d2 709 case kElectronfromconversion:
710 valueSign[4] = kElectronfromconversionboth;
711 break;
712 case kElectronfrompi0:
713 valueSign[4] = kElectronfrompi0both;
714 break;
715 case kElectronfrometa:
716 valueSign[4] = kElectronfrometaboth;
717 break;
c3e32eae 718 };
719 }
76d0b522 720 }
721 }
722
4437a0d2 723 if(fAlgorithmMA){
724 // Use TLorentzVector
725 if(!MakePairDCA(track1, track2, vEvent, (aodeventu != NULL), invmass, angle)) continue;
c3e32eae 726 } else {
4437a0d2 727 // Use AliKF package
728 if(!MakePairKF(track1, track2, primV, invmass, angle)) continue;
729 }
76d0b522 730
4437a0d2 731 valueSign[3] = invmass;
732 valueSign[5] = angle;
76d0b522 733
4437a0d2 734 //if((fCharge1*fCharge2)>0.0) fLSignAngle->Fill(&valueAngle[0],weight);
735 //else fUSignAngle->Fill(&valueAngle[0],weight);
76d0b522 736
4437a0d2 737 if(angle > fMaxOpening3D) continue; //! Cut on Opening Angle
738 if(invmass > fMaxInvMass) continue; //! Cut on Invariant Mass
8a9b2231 739
4437a0d2 740 if((fCharge1*fCharge2)>0.0){
741 if(invmass < 1.0) fLSign->Fill( valueSign, weight);
742 // count like-sign background matched pairs per inclusive based on mass cut
743 if(invmass < 0.14) countsMatchLikesign++;
39427568 744 AliDebug(1, "Selected Like sign");
4437a0d2 745 } else {
746 if(invmass < 1.0)fUSign->Fill( valueSign, weight);
747 // count unlike-sign matched pairs per inclusive based on mass cut
ff8249bd 748 if(invmass < 0.14) {
749 countsMatchUnlikesign++;
750 if(source == kElectronfromconversionboth) fRecElectronRadius->Fill(valueradius,weight);
751 }
39427568 752 AliDebug(1, "Selected Unike sign");
76d0b522 753 }
4437a0d2 754
755 if((fCharge1*fCharge2)>0.0) kLSignPhotonic=kTRUE;
756 else kUSignPhotonic=kTRUE;
76d0b522 757 }
758
c3e32eae 759 // Fill counted
760 Double_t valCountsLS[3] = {binct, track1->Pt(), countsMatchLikesign},
761 valCountsUS[3] = {binct, track1->Pt(), countsMatchUnlikesign};
762 fUSmatches->Fill(valCountsUS);
763 fLSmatches->Fill(valCountsLS);
764
8a9b2231 765 if( kUSignPhotonic && kLSignPhotonic) taggedphotonic = 6;
766 if(!kUSignPhotonic && kLSignPhotonic) taggedphotonic = 4;
767 if( kUSignPhotonic && !kLSignPhotonic) taggedphotonic = 2;
76d0b522 768
769 return taggedphotonic;
770}
771
772//_________________________________________________________________________
39427568 773Int_t AliHFENonPhotonicElectron::FindMother(Int_t tr, Int_t &indexmother) const {
76d0b522 774 //
775 // Find the mother if MC
776 //
777
ff8249bd 778 if(!fMCEvent && !fAODArrayMCInfo) return -1;
76d0b522 779
780 Int_t pdg = CheckPdg(tr);
781 if(TMath::Abs(pdg)!= 11)
782 {
783 indexmother = -1;
784 return kNoElectron;
785 }
786
787 indexmother = IsMotherGamma(tr);
788 if(indexmother > 0) return kElectronfromconversion;
789 indexmother = IsMotherPi0(tr);
790 if(indexmother > 0) return kElectronfrompi0;
791 indexmother = IsMotherC(tr);
792 if(indexmother > 0) return kElectronfromC;
793 indexmother = IsMotherB(tr);
794 if(indexmother > 0) return kElectronfromB;
795 indexmother = IsMotherEta(tr);
796 if(indexmother > 0) return kElectronfrometa;
797
798 return kElectronfromother;
799}
800
801//________________________________________________________________________________________________
39427568 802Int_t AliHFENonPhotonicElectron::CheckPdg(Int_t tr) const {
76d0b522 803
804 //
805 // Return the pdg of the particle
806 //
807
808 Int_t pdgcode = -1;
809 if(tr < 0) return pdgcode;
810
39427568 811 AliMCParticle *mctrackesd = NULL; AliAODMCParticle *mctrackaod = NULL;
812 if(fMCEvent){
76d0b522 813 AliVParticle *mctrack = fMCEvent->GetTrack(tr);
39427568 814 if(mctrack){
815 if((mctrackesd = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(tr))))) pdgcode = mctrackesd->PdgCode();
816 else if((mctrackaod = dynamic_cast<AliAODMCParticle *>(fMCEvent->GetTrack(TMath::Abs(tr))))) pdgcode = mctrackaod->GetPdgCode();
817 }
818 } else if(fAODArrayMCInfo) {
819 if(tr < fAODArrayMCInfo->GetEntriesFast()){
820 mctrackaod = (AliAODMCParticle *) fAODArrayMCInfo->At(tr);
821 if(mctrackaod) return pdgcode = mctrackaod->GetPdgCode();
822 }
76d0b522 823 }
824
825 return pdgcode;
826}
827
ff8249bd 828//________________________________________________________________________________________________
829Double_t AliHFENonPhotonicElectron::Radius(Int_t tr) const {
830
831 //
832 // Return the production vertex radius
833 //
834
835 Double_t radius = 0.;
836 if(tr < 0) return radius;
837
838 AliMCParticle *mctrackesd = NULL; AliAODMCParticle *mctrackaod = NULL;
839 if(fMCEvent){
840 AliVParticle *mctrack = fMCEvent->GetTrack(tr);
841 if(mctrack){
842 if((mctrackesd = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(tr))))) radius = TMath::Sqrt(mctrackesd->Xv()*mctrackesd->Xv()+mctrackesd->Yv()*mctrackesd->Yv());
843 else if((mctrackaod = dynamic_cast<AliAODMCParticle *>(fMCEvent->GetTrack(TMath::Abs(tr))))) radius = TMath::Sqrt(mctrackaod->Xv()*mctrackaod->Xv()+mctrackaod->Yv()*mctrackaod->Yv());
844 }
845 } else if(fAODArrayMCInfo) {
846 if(tr < fAODArrayMCInfo->GetEntriesFast()){
847 mctrackaod = (AliAODMCParticle *) fAODArrayMCInfo->At(tr);
848 if(mctrackaod) return radius = TMath::Sqrt(mctrackaod->Xv()*mctrackaod->Xv()+mctrackaod->Yv()*mctrackaod->Yv());
849 }
850 }
851
852 return radius;
853}
854
76d0b522 855//_______________________________________________________________________________________________
39427568 856Int_t AliHFENonPhotonicElectron::GetMotherPDG(Int_t tr, Int_t &motherIndex) const {
76d0b522 857 //
39427568 858 // Returns the mother PDG of the track (return value) and the index of the
859 // mother track
76d0b522 860 //
76d0b522 861 if(tr < 0) return -1;
862
39427568 863 Int_t pdg(-1);
864 AliMCParticle *mctrackesd(NULL); AliAODMCParticle *mctrackaod(NULL);
865
866 motherIndex = -1;
867 if(fMCEvent) {
868 AliDebug(2, "Using MC Event");
76d0b522 869 AliVParticle *mctrack = fMCEvent->GetTrack(tr);
39427568 870 if(mctrack){
871 if((mctrackesd = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(tr))))){
872 // Case ESD
873 TParticle *particle = mctrackesd->Particle();
874
875 // Take mother
876 if(particle){
877 motherIndex = particle->GetFirstMother();
878 if(motherIndex >= 0){
879 AliMCParticle *mothertrack = NULL;
880 if((mothertrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(motherIndex))))){
881 TParticle * mother = mothertrack->Particle();
882 pdg = mother->GetPdgCode();
883 }
884 }
885 }
886 } else if((mctrackaod = dynamic_cast<AliAODMCParticle *>(fMCEvent->GetTrack(TMath::Abs(tr))))){
887 // Case AOD
888 // Take mother
889 motherIndex = mctrackaod->GetMother();
890 if(motherIndex >= 0){
891 AliAODMCParticle *mothertrack = dynamic_cast<AliAODMCParticle *>(fMCEvent->GetTrack(motherIndex));
892 if(mothertrack) pdg = mothertrack->GetPdgCode();
893 }
894 }
895 }
896 } else if(fAODArrayMCInfo) {
897 AliDebug(2, "Using AOD list");
898 if(tr < fAODArrayMCInfo->GetEntriesFast()){
899 mctrackaod = (AliAODMCParticle *) fAODArrayMCInfo->At(tr);
900
901 // Take mother
902 if(mctrackaod){
903 motherIndex = mctrackaod->GetMother();
904 if(motherIndex >= 0 && motherIndex < fAODArrayMCInfo->GetEntriesFast()){
905 AliAODMCParticle *mothertrack = dynamic_cast<AliAODMCParticle *>(fAODArrayMCInfo->At(TMath::Abs(motherIndex)));
906 if(mothertrack) pdg = mothertrack->GetPdgCode();
907 }
908 }
76d0b522 909 }
76d0b522 910 }
39427568 911 return pdg;
912}
76d0b522 913
39427568 914//_______________________________________________________________________________________________
915Int_t AliHFENonPhotonicElectron::IsMotherGamma(Int_t tr) const {
916
917 //
918 // Return the lab of gamma mother or -1 if not gamma
919 //
920
921 Int_t imother(-1), pdg(-1);
922 pdg = GetMotherPDG(tr, imother);
923
924 // Check gamma
925 if(imother >= 0){
926 if(TMath::Abs(pdg) == 22){
927 AliDebug(2, "Gamma Mother selected");
928 return imother;
929 }
930 if(TMath::Abs(pdg) == 11){
931 AliDebug(2, "Mother is electron - look further in hierarchy");
76d0b522 932 return IsMotherGamma(imother);
933 }
39427568 934 AliDebug(2, "Nothing selected");
76d0b522 935 return -1;
936 }
39427568 937 AliDebug(2, "Not mother");
76d0b522 938 return -1;
939}
940
941//________________________________________________________________________________________________
39427568 942Int_t AliHFENonPhotonicElectron::IsMotherPi0(Int_t tr) const {
76d0b522 943
944 //
945 // Return the lab of pi0 mother or -1 if not pi0
946 //
947
39427568 948 Int_t imother(-1), pdg(-1);
949 pdg = GetMotherPDG(tr, imother);
76d0b522 950
39427568 951 // Check pi0
952 if(imother >= 0){
953 if(TMath::Abs(pdg) == 111){
954 AliDebug(2, "Pi0 Mother selected");
955 return imother;
76d0b522 956 }
39427568 957 if(TMath::Abs(pdg) == 11){
958 AliDebug(2, "Mother is electron - look further in hierarchy");
76d0b522 959 return IsMotherPi0(imother);
960 }
39427568 961 AliDebug(2, "Nothing selected");
76d0b522 962 return -1;
963 }
39427568 964 AliDebug(2, "Not mother");
76d0b522 965 return -1;
966}
967//________________________________________________________________________________________________
39427568 968Int_t AliHFENonPhotonicElectron::IsMotherC(Int_t tr) const {
76d0b522 969
970 //
971 // Return the lab of signal mother or -1 if not from C
972 //
973
39427568 974 Int_t imother(-1), pdg(-1);
975 pdg = GetMotherPDG(tr, imother);
76d0b522 976
977 // Check C
39427568 978 if(imother >= 0){
979 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)){
980 AliDebug(2, "Charm Mother selected");
981 return imother;
76d0b522 982 }
39427568 983 if(TMath::Abs(pdg) == 11){
984 AliDebug(2, "Mother is electron - look further in hierarchy");
76d0b522 985 return IsMotherC(imother);
986 }
39427568 987 AliDebug(2, "Nothing selected");
76d0b522 988 return -1;
989 }
39427568 990 AliDebug(2, "Not mother");
76d0b522 991 return -1;
992}
39427568 993
76d0b522 994//_______________________________________________________________________________________________
39427568 995Int_t AliHFENonPhotonicElectron::IsMotherB(Int_t tr) const {
76d0b522 996
997 //
998 // Return the lab of signal mother or -1 if not B
999 //
1000
39427568 1001 Int_t imother(-1), pdg(-1);
1002 pdg = GetMotherPDG(tr, imother);
76d0b522 1003
39427568 1004 // Check B
1005 if(imother >= 0){
1006 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)){
1007 AliDebug(2, "Bottom Mother selected");
1008 return imother;
76d0b522 1009 }
39427568 1010 if(TMath::Abs(pdg) == 11){
76d0b522 1011 return IsMotherB(imother);
39427568 1012 AliDebug(2, "Mother is electron - look further in hierarchy");
76d0b522 1013 }
39427568 1014 AliDebug(2, "Nothing selected");
76d0b522 1015 return -1;
1016 }
39427568 1017 AliDebug(2, "Not mother");
76d0b522 1018 return -1;
1019}
1020
1021//_______________________________________________________________________________________________
39427568 1022Int_t AliHFENonPhotonicElectron::IsMotherEta(Int_t tr) const {
76d0b522 1023
1024 //
1025 // Return the lab of eta mother or -1 if not eta
1026 //
1027
39427568 1028 Int_t imother(-1), pdg(-1);
1029 pdg = GetMotherPDG(tr, imother);
76d0b522 1030
39427568 1031 // Check eta
1032 if(imother >= 0){
1033 if(TMath::Abs(pdg) == 221){
1034 AliDebug(2, "Eta mother selected");
1035 return imother;
76d0b522 1036 }
39427568 1037 if(TMath::Abs(pdg) == 11){
1038 AliDebug(2, "Mother is electron - look further in hierarchy");
76d0b522 1039 return IsMotherEta(imother);
1040 }
39427568 1041 AliDebug(2, "Nothing selected");
76d0b522 1042 return -1;
1043 }
39427568 1044 AliDebug(2, "Not mother");
76d0b522 1045 return -1;
1046}
4437a0d2 1047
1048//_______________________________________________________________________________________________
1049Bool_t AliHFENonPhotonicElectron::MakePairDCA(const AliVTrack *inclusive, const AliVTrack *associated, AliVEvent *vEvent, Bool_t isAOD, Double_t &invMass, Double_t &angle) const {
1050 //
1051 // Make Pairs of electrons using TLorentzVector
1052 //
1053 Double_t eMass = TDatabasePDG::Instance()->GetParticle(11)->Mass(); //Electron mass in GeV
1054 Double_t bfield = vEvent->GetMagneticField();
1055
1056 AliESDtrack *esdtrack1, *esdtrack2;
1057 if(isAOD){
1058 // call copy constructor for AODs
1059 esdtrack1 = new AliESDtrack(inclusive);
1060 esdtrack2 = new AliESDtrack(associated);
1061 } else {
1062 // call copy constructor for ESDs
500a066a 1063 esdtrack1 = new AliESDtrack(*(static_cast<const AliESDtrack *>(inclusive)));
1064 esdtrack2 = new AliESDtrack(*(static_cast<const AliESDtrack *>(associated)));
4437a0d2 1065 }
1066 if((!esdtrack1) || (!esdtrack2)){
1067 delete esdtrack1;
1068 delete esdtrack2;
1069 return kFALSE;
1070 }
1071
1072 Double_t xt1 = 0; //radial position track 1 at the DCA point
1073 Double_t xt2 = 0; //radial position track 2 at the DCA point
1074 Double_t dca = esdtrack2->GetDCA(esdtrack1,bfield,xt2,xt1); //DCA track1-track2
1075 if(dca > fMaxDCA){
1076 // Apply DCA cut already in the function
1077 delete esdtrack1;
1078 delete esdtrack2;
1079 return kFALSE;
1080 }
1081
1082 //Momenta of the track extrapolated to DCA track-track
1083 Double_t p1[3] = {0,0,0};
1084 Double_t p2[3] = {0,0,0};
1085 Bool_t kHasdcaT1 = esdtrack1->GetPxPyPzAt(xt1,bfield,p1); //Track1
1086 Bool_t kHasdcaT2 = esdtrack2->GetPxPyPzAt(xt2,bfield,p2); //Track2
1087 if(!kHasdcaT1 || !kHasdcaT2) AliWarning("It could be a problem in the extrapolation");
1088
1089 TLorentzVector electron1, electron2, mother;
1090 electron1.SetXYZM(p1[0], p1[1], p1[2], eMass);
1091 electron2.SetXYZM(p2[0], p2[1], p2[2], eMass);
1092
1093 mother = electron1 + electron2;
1094 invMass = mother.M();
1095 angle = TVector2::Phi_0_2pi(electron1.Angle(electron2.Vect()));
1096
1097 delete esdtrack1;
1098 delete esdtrack2;
1099 return kTRUE;
1100}
1101
1102//_______________________________________________________________________________________________
1103Bool_t AliHFENonPhotonicElectron::MakePairKF(const AliVTrack *inclusive, const AliVTrack *associated, AliKFVertex &primV, Double_t &invMass, Double_t &angle) const {
1104 //
1105 // Make pairs of electrons using the AliKF package
1106 //
1107
1108 //printf("AOD HFE non photonic\n");
1109
1110 Int_t fPDGtrack1 = 11;
1111 if(inclusive->Charge()>0) fPDGtrack1 = -11;
1112 Int_t fPDGtrack2 = 11;
1113 if(associated->Charge()>0) fPDGtrack2 = -11;
1114
1115 AliKFParticle ktrack1(*inclusive, fPDGtrack1);
1116 AliKFParticle ktrack2(*associated, fPDGtrack2);
1117 AliKFParticle recoGamma(ktrack1,ktrack2);
1118
1119 if(recoGamma.GetNDF()<1) return kFALSE; //! Cut on Reconstruction
1120
1121 Double_t chi2OverNDF = recoGamma.GetChi2()/recoGamma.GetNDF();
1122 if(TMath::Sqrt(TMath::Abs(chi2OverNDF))>fChi2OverNDFCut) return kFALSE;
1123
1124 if(fSetMassConstraint){
1125 primV += recoGamma;
1126 primV -= ktrack1;
1127 primV -= ktrack2;
1128 recoGamma.SetProductionVertex(primV);
1129 recoGamma.SetMassConstraint(0,0.0001);
1130 }
1131
1132 Double_t width(0.);
1133 recoGamma.GetMass(invMass,width);
1134 angle = ktrack1.GetAngle(ktrack2);
1135 return kTRUE;
1136}
1137
1138//_______________________________________________________________________________________________
1139Bool_t AliHFENonPhotonicElectron::FilterCategory1Track(const AliVTrack * const track, Bool_t isAOD, Int_t binct){
1140 //
1141 // Selection of good associated tracks for the pool
1142 // selection is done using strong cuts
1143 // Tracking in the TPC and the ITS is a minimal requirement
1144 //
1145 Bool_t survivedbackground = kTRUE;
1146
1147 if(!fHFEBackgroundCuts->CheckParticleCuts(AliHFEcuts::kStepRecKineITSTPC + AliHFEcuts::kNcutStepsMCTrack, (TObject *) track)) survivedbackground = kFALSE;
1148 AliDebug(3, Form("First cut: %s\n", survivedbackground == kTRUE ? "yes" : "no"));
1149 if(!fHFEBackgroundCuts->CheckParticleCuts(AliHFEcuts::kStepRecPrim + AliHFEcuts::kNcutStepsMCTrack, (TObject *) track)) survivedbackground = kFALSE;
1150 AliDebug(3, Form("Second cut: %s\n", survivedbackground == kTRUE ? "yes" : "no"));
1151
1152 if(survivedbackground){
1153 // PID track cuts
1154 AliHFEpidObject hfetrack2;
1155
1156 if(!isAOD) hfetrack2.SetAnalysisType(AliHFEpidObject::kESDanalysis);
1157 else hfetrack2.SetAnalysisType(AliHFEpidObject::kAODanalysis);
1158
1159 hfetrack2.SetRecTrack(track);
1160 if(binct>-1){
1161 hfetrack2.SetCentrality((Int_t)binct);
1162 AliDebug(3,Form("centrality %d and %d",binct,hfetrack2.GetCentrality()));
1163 hfetrack2.SetPbPb();
1164 }
1165
1166 if(fPIDBackground->IsSelected(&hfetrack2,0x0,"recTrackCont",fPIDBackgroundQA)){
1167 survivedbackground = kTRUE;
1168 } else survivedbackground = kFALSE;
1169 }
1170 AliDebug(3, Form("PID: %s\n", survivedbackground == kTRUE ? "yes" : "no"));
1171 return survivedbackground;
1172}
1173
1174//_______________________________________________________________________________________________
1175Bool_t AliHFENonPhotonicElectron::FilterCategory2Track(const AliVTrack * const track, Bool_t isAOD){
1176 //
1177 // Selection of category 2 tracks: These tracks are exclusively low pt tracks below
1178 // 300 MeV/c which have at least 2 hits in the 4 outer ITS layers and are identified as
1179 // electron candidates by the ITS
1180 //
1181 if(TMath::Abs(track->Pt()) > 0.3) return kFALSE;
ff8249bd 1182 if(TMath::Abs(track->Pt()) < 0.1) return kFALSE;
4437a0d2 1183 Int_t nclustersITS(0), nclustersOuter(0);
1184 if(isAOD){
500a066a 1185 const AliAODTrack *aodtrack = static_cast<const AliAODTrack *>(track);
39427568 1186 if(!(aodtrack->TestFilterBit(AliAODTrack::kTrkGlobalNoDCA) || aodtrack->TestFilterBit(AliAODTrack::kTrkITSsa))) return kFALSE;
ff8249bd 1187 if(!aodtrack->IsOn(AliAODTrack::kITSrefit)) return kFALSE;
4437a0d2 1188 nclustersITS = aodtrack->GetITSNcls();
1189 for(int ily = 2; ily < 5; ily++)
1190 if(aodtrack->HasPointOnITSLayer(ily)) nclustersOuter++;
1191 } else {
500a066a 1192 const AliESDtrack *esdtrack = static_cast<const AliESDtrack *>(track);
4437a0d2 1193 if(esdtrack->GetStatus() & AliESDtrack::kITSpureSA) return kFALSE;
ff8249bd 1194 if(esdtrack->GetStatus() & AliESDtrack::kTPCin) return kFALSE;
1195 if(esdtrack->GetStatus() & !AliESDtrack::kITSrefit) return kFALSE;
4437a0d2 1196 nclustersITS = esdtrack->GetITSclusters(NULL);
1197 for(int ily = 2; ily < 5; ily++)
1198 if(esdtrack->HasPointOnITSLayer(ily)) nclustersOuter++;
1199 }
1200 if(nclustersITS < 4) return kFALSE;
1201 if(nclustersOuter < 3) return kFALSE;
1202
1203 // Do ITS PID
1204 Double_t nsigmaITS = fPIDBackground->GetPIDResponse()->NumberOfSigmasITS(track, AliPID::kElectron);
1205 fHnsigmaITS->Fill(track->Pt(), nsigmaITS);
bbeea05b 1206 if(TMath::Abs(nsigmaITS - fITSmeanShift) > 3.) return kFALSE;
4437a0d2 1207 // if global track, we apply also TPC PID
1208 return kTRUE;
1209}