]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGHF/hfe/AliAnalysisTaskHFE.cxx
move histograms for asymmetry, add one for selected
[u/mrichter/AliRoot.git] / PWGHF / hfe / AliAnalysisTaskHFE.cxx
CommitLineData
809a4336 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 *
9* without fee, provided that the above copyright notice appears in all *
10* copies and that both the copyright notice and this permission notice *
11* appear in the supporting documentation. The authors make no claims *
12* about the suitability of this software for any purpose. It is *
13* provided "as is" without express or implied warranty. *
14**************************************************************************/
50685501 15//
16// The analysis task:
17// Filling an AliCFContainer with the quantities pt, eta and phi
18// for tracks which survivied the particle cuts (MC resp. ESD tracks)
19// Track selection is done using the AliHFE package
20//
21// Author:
22// Raphaelle Bailhache <R.Bailhache@gsi.de>
23// Markus Fasel <M.Fasel@gsi.de>
24// Matus Kalisky <matus.kalisky@cern.ch>
25// MinJung Kweon <minjung@physi.uni-heidelberg.de>
26//
809a4336 27#include <TAxis.h>
8c1c76e9 28#include <TBits.h>
809a4336 29#include <TCanvas.h>
30#include <TChain.h>
259c3296 31#include <TDirectory.h>
6ad05e72 32#include <TFile.h>
faee3b18 33#include <TH3D.h>
809a4336 34#include <TIterator.h>
35#include <TList.h>
36#include <TLegend.h>
37#include <TMath.h>
38#include <TObjArray.h>
8c1c76e9 39#include <TObjString.h>
809a4336 40#include <TParticle.h>
41#include <TProfile.h>
8c1c76e9 42#include <TString.h>
faee3b18 43#include <TF1.h>
809a4336 44#include <TTree.h>
45
8c1c76e9 46#include "AliAnalysisManager.h"
9bcfd1ab 47#include "AliAODInputHandler.h"
48#include "AliAODMCParticle.h"
49#include "AliAODTrack.h"
c2690925 50#include "AliAODVertex.h"
8c1c76e9 51#include "AliCentrality.h"
809a4336 52#include "AliCFContainer.h"
53#include "AliCFManager.h"
54#include "AliESDEvent.h"
55#include "AliESDInputHandler.h"
56#include "AliESDtrack.h"
809a4336 57#include "AliLog.h"
809a4336 58#include "AliMCEvent.h"
59#include "AliMCEventHandler.h"
60#include "AliMCParticle.h"
e156c3bb 61#include "AliMultiplicity.h"
809a4336 62#include "AliPID.h"
8c1c76e9 63#include "AliPIDResponse.h"
64#include "AliOADBContainer.h"
259c3296 65#include "AliStack.h"
69ac0e6f 66#include "AliTriggerAnalysis.h"
70da6c5a 67#include "AliVVertex.h"
809a4336 68
9bcfd1ab 69#include "AliHFEcollection.h"
3a72645a 70#include "AliHFEcontainer.h"
809a4336 71#include "AliHFEcuts.h"
3a72645a 72#include "AliHFEelecbackground.h"
259c3296 73#include "AliHFEmcQA.h"
9bcfd1ab 74#include "AliHFEpairs.h"
3a72645a 75#include "AliHFEpid.h"
76#include "AliHFEpidQAmanager.h"
d2af20c5 77#include "AliHFEpostAnalysis.h"
9bcfd1ab 78#include "AliHFEsecVtxs.h"
259c3296 79#include "AliHFEsecVtx.h"
3a72645a 80#include "AliHFEsignalCuts.h"
81#include "AliHFEtaggedTrackAnalysis.h"
70da6c5a 82#include "AliHFEtools.h"
3a72645a 83#include "AliHFEvarManager.h"
809a4336 84#include "AliAnalysisTaskHFE.h"
7ea7b2c4 85#include "AliAODMCHeader.h"
86#include "TClonesArray.h"
809a4336 87
faee3b18 88ClassImp(AliAnalysisTaskHFE)
89
809a4336 90//____________________________________________________________
91AliAnalysisTaskHFE::AliAnalysisTaskHFE():
d2af20c5 92 AliAnalysisTaskSE("PID efficiency Analysis")
7ea7b2c4 93 , fAODMCHeader(NULL)
94 , fAODArrayMCInfo(NULL)
75d81601 95 , fQAlevel(0)
9bcfd1ab 96 , fPlugins(0)
3a72645a 97 , fFillSignalOnly(kTRUE)
e156c3bb 98 , fFillNoCuts(kFALSE)
a86a8fda 99 , fUseFilterAOD(kTRUE)
11ff28c5 100 , fApplyCutAOD(kFALSE)
a86a8fda 101 , fFilter(1<<4)
c2690925 102 , fBackGroundFactorApply(kFALSE)
3a72645a 103 , fRemovePileUp(kFALSE)
104 , fIdentifiedAsPileUp(kFALSE)
105 , fIdentifiedAsOutInz(kFALSE)
106 , fPassTheEventCut(kFALSE)
fd6b8522 107 , fRejectKinkMother(kTRUE)
8c1c76e9 108 , fisppMultiBin(kFALSE)
11ff28c5 109 , fPbPbUserCentralityBinning(kFALSE)
8c1c76e9 110 , fisNonHFEsystematics(kFALSE)
111 , fSpecialTrigger(NULL)
e156c3bb 112 , fCentralityF(-1)
11ff28c5 113 , fCentralityPercent(-1)
c2690925 114 , fContributors(0.5)
115 , fWeightBackGround(0.)
116 , fVz(0.0)
8c1c76e9 117 , fHadronBackgroundOADB(NULL)
3a72645a 118 , fContainer(NULL)
119 , fVarManager(NULL)
120 , fSignalCuts(NULL)
9bcfd1ab 121 , fCFM(NULL)
69ac0e6f 122 , fTriggerAnalysis(NULL)
9bcfd1ab 123 , fPID(NULL)
3a72645a 124 , fPIDqa(NULL)
e3fc062d 125 , fPIDpreselect(NULL)
9bcfd1ab 126 , fCuts(NULL)
3a72645a 127 , fTaggedTrackCuts(NULL)
6555e2ad 128 , fCleanTaggedTrack(kFALSE)
e3ae862b 129 , fVariablesTRDTaggedTrack(kFALSE)
e3fc062d 130 , fCutspreselect(NULL)
9bcfd1ab 131 , fSecVtx(NULL)
132 , fElecBackGround(NULL)
133 , fMCQA(NULL)
3a72645a 134 , fTaggedTrackAnalysis(NULL)
8c1c76e9 135 , fExtraCuts(NULL)
9bcfd1ab 136 , fQA(NULL)
137 , fOutput(NULL)
138 , fHistMCQA(NULL)
139 , fHistSECVTX(NULL)
140 , fHistELECBACKGROUND(NULL)
69ac0e6f 141 , fQACollection(NULL)
a86a8fda 142 , fQAAODCollection(NULL)
0792aa82 143{
144 //
50685501 145 // Dummy constructor
0792aa82 146 //
8c1c76e9 147 memset(fElecBackgroundFactor, 0, sizeof(Double_t) * kElecBgSpecies * kBgPtBins * kCentBins * kBgLevels);
148 memset(fkBackGroundFactorArray, 0, sizeof(TF1 *) * 12);
149 memset(fBinLimit, 0, sizeof(Double_t) * (kBgPtBins+1));
150 memset(&fisppMultiBin, kFALSE, sizeof(fisppMultiBin));
4d82fe01 151 memset(fCentralityLimits, 0, sizeof(Float_t) * 12);
11ff28c5 152
153
0792aa82 154}
155
156//____________________________________________________________
157AliAnalysisTaskHFE::AliAnalysisTaskHFE(const char * name):
d2af20c5 158 AliAnalysisTaskSE(name)
7ea7b2c4 159 , fAODMCHeader(NULL)
160 , fAODArrayMCInfo(NULL)
0792aa82 161 , fQAlevel(0)
9bcfd1ab 162 , fPlugins(0)
3a72645a 163 , fFillSignalOnly(kTRUE)
e156c3bb 164 , fFillNoCuts(kFALSE)
a86a8fda 165 , fUseFilterAOD(kTRUE)
11ff28c5 166 , fApplyCutAOD(kFALSE)
a86a8fda 167 , fFilter(1<<4)
c2690925 168 , fBackGroundFactorApply(kFALSE)
3a72645a 169 , fRemovePileUp(kFALSE)
170 , fIdentifiedAsPileUp(kFALSE)
171 , fIdentifiedAsOutInz(kFALSE)
172 , fPassTheEventCut(kFALSE)
fd6b8522 173 , fRejectKinkMother(kTRUE)
8c1c76e9 174 , fisppMultiBin(kFALSE)
11ff28c5 175 , fPbPbUserCentralityBinning(kFALSE)
8c1c76e9 176 , fisNonHFEsystematics(kFALSE)
177 , fSpecialTrigger(NULL)
e156c3bb 178 , fCentralityF(-1)
11ff28c5 179 , fCentralityPercent(-1)
c2690925 180 , fContributors(0.5)
181 , fWeightBackGround(0.)
182 , fVz(0.0)
8c1c76e9 183 , fHadronBackgroundOADB(NULL)
3a72645a 184 , fContainer(NULL)
185 , fVarManager(NULL)
186 , fSignalCuts(NULL)
9bcfd1ab 187 , fCFM(NULL)
69ac0e6f 188 , fTriggerAnalysis(NULL)
9bcfd1ab 189 , fPID(NULL)
3a72645a 190 , fPIDqa(NULL)
e3fc062d 191 , fPIDpreselect(NULL)
9bcfd1ab 192 , fCuts(NULL)
3a72645a 193 , fTaggedTrackCuts(NULL)
6555e2ad 194 , fCleanTaggedTrack(kFALSE)
e3ae862b 195 , fVariablesTRDTaggedTrack(kFALSE)
e3fc062d 196 , fCutspreselect(NULL)
9bcfd1ab 197 , fSecVtx(NULL)
198 , fElecBackGround(NULL)
199 , fMCQA(NULL)
3a72645a 200 , fTaggedTrackAnalysis(NULL)
8c1c76e9 201 , fExtraCuts(NULL)
9bcfd1ab 202 , fQA(NULL)
203 , fOutput(NULL)
204 , fHistMCQA(NULL)
205 , fHistSECVTX(NULL)
206 , fHistELECBACKGROUND(NULL)
69ac0e6f 207 , fQACollection(0x0)
a86a8fda 208 , fQAAODCollection(NULL)
809a4336 209{
dbe3abbe 210 //
211 // Default constructor
9bcfd1ab 212 //
3a72645a 213 DefineOutput(1, TList::Class());
259c3296 214 DefineOutput(2, TList::Class());
809a4336 215
3a72645a 216 fPID = new AliHFEpid("hfePid");
bf892a6a 217 fPIDqa = new AliHFEpidQAmanager;
3a72645a 218 fVarManager = new AliHFEvarManager("hfeVarManager");
fd6b8522 219
8c1c76e9 220 memset(fElecBackgroundFactor, 0, sizeof(Double_t) * kElecBgSpecies * kBgPtBins * kCentBins * kBgLevels);
221 memset(fkBackGroundFactorArray, 0, sizeof(TF1 *) * 12);
fd6b8522 222 memset(fBinLimit, 0, sizeof(Double_t) * (kBgPtBins+1));
8c1c76e9 223 memset(&fisppMultiBin, kFALSE, sizeof(fisppMultiBin));
4d82fe01 224 memset(fCentralityLimits, 0, sizeof(Float_t) * 12);
11ff28c5 225
809a4336 226}
227
dbe3abbe 228//____________________________________________________________
229AliAnalysisTaskHFE::AliAnalysisTaskHFE(const AliAnalysisTaskHFE &ref):
d2af20c5 230 AliAnalysisTaskSE(ref)
7ea7b2c4 231 , fAODMCHeader(NULL)
232 , fAODArrayMCInfo(NULL)
faee3b18 233 , fQAlevel(0)
faee3b18 234 , fPlugins(0)
3a72645a 235 , fFillSignalOnly(ref.fFillSignalOnly)
e156c3bb 236 , fFillNoCuts(ref.fFillNoCuts)
a86a8fda 237 , fUseFilterAOD(ref.fUseFilterAOD)
11ff28c5 238 , fApplyCutAOD(ref.fApplyCutAOD)
a86a8fda 239 , fFilter(ref.fFilter)
c2690925 240 , fBackGroundFactorApply(ref.fBackGroundFactorApply)
3a72645a 241 , fRemovePileUp(ref.fRemovePileUp)
242 , fIdentifiedAsPileUp(ref.fIdentifiedAsPileUp)
243 , fIdentifiedAsOutInz(ref.fIdentifiedAsOutInz)
244 , fPassTheEventCut(ref.fPassTheEventCut)
fd6b8522 245 , fRejectKinkMother(ref.fRejectKinkMother)
8c1c76e9 246 , fisppMultiBin(ref.fisppMultiBin)
11ff28c5 247 , fPbPbUserCentralityBinning(ref.fPbPbUserCentralityBinning)
8c1c76e9 248 , fisNonHFEsystematics(ref.fisNonHFEsystematics)
c2690925 249 , fSpecialTrigger(ref.fSpecialTrigger)
3a72645a 250 , fCentralityF(ref.fCentralityF)
11ff28c5 251 , fCentralityPercent(ref.fCentralityPercent)
c2690925 252 , fContributors(ref.fContributors)
253 , fWeightBackGround(ref.fWeightBackGround)
254 , fVz(ref.fVz)
8c1c76e9 255 , fHadronBackgroundOADB(ref.fHadronBackgroundOADB)
3a72645a 256 , fContainer(NULL)
257 , fVarManager(NULL)
258 , fSignalCuts(NULL)
faee3b18 259 , fCFM(NULL)
69ac0e6f 260 , fTriggerAnalysis(NULL)
faee3b18 261 , fPID(NULL)
3a72645a 262 , fPIDqa(NULL)
e3fc062d 263 , fPIDpreselect(NULL)
faee3b18 264 , fCuts(NULL)
3a72645a 265 , fTaggedTrackCuts(NULL)
6555e2ad 266 , fCleanTaggedTrack(ref.fCleanTaggedTrack)
e3ae862b 267 , fVariablesTRDTaggedTrack(ref.fVariablesTRDTaggedTrack)
e3fc062d 268 , fCutspreselect(NULL)
faee3b18 269 , fSecVtx(NULL)
270 , fElecBackGround(NULL)
271 , fMCQA(NULL)
3a72645a 272 , fTaggedTrackAnalysis(NULL)
8c1c76e9 273 , fExtraCuts(NULL)
faee3b18 274 , fQA(NULL)
275 , fOutput(NULL)
276 , fHistMCQA(NULL)
277 , fHistSECVTX(NULL)
278 , fHistELECBACKGROUND(NULL)
69ac0e6f 279 , fQACollection(NULL)
a86a8fda 280 , fQAAODCollection(NULL)
dbe3abbe 281{
282 //
283 // Copy Constructor
284 //
faee3b18 285 ref.Copy(*this);
dbe3abbe 286}
287
288//____________________________________________________________
289AliAnalysisTaskHFE &AliAnalysisTaskHFE::operator=(const AliAnalysisTaskHFE &ref){
290 //
291 // Assignment operator
292 //
faee3b18 293 if(this == &ref)
294 ref.Copy(*this);
dbe3abbe 295 return *this;
296}
297
faee3b18 298//____________________________________________________________
299void AliAnalysisTaskHFE::Copy(TObject &o) const {
300 //
301 // Copy into object o
302 //
303 AliAnalysisTaskHFE &target = dynamic_cast<AliAnalysisTaskHFE &>(o);
7ea7b2c4 304 target.fAODMCHeader = fAODMCHeader;
305 target.fAODArrayMCInfo = fAODArrayMCInfo;
faee3b18 306 target.fQAlevel = fQAlevel;
faee3b18 307 target.fPlugins = fPlugins;
3a72645a 308 target.fFillSignalOnly = fFillSignalOnly;
e156c3bb 309 target.fFillNoCuts = fFillNoCuts;
a86a8fda 310 target.fUseFilterAOD = fUseFilterAOD;
11ff28c5 311 target.fApplyCutAOD = fApplyCutAOD;
a86a8fda 312 target.fFilter = fFilter;
c2690925 313 target.fBackGroundFactorApply = fBackGroundFactorApply;
3a72645a 314 target.fRemovePileUp = fRemovePileUp;
315 target.fIdentifiedAsPileUp = fIdentifiedAsPileUp;
316 target.fIdentifiedAsOutInz = fIdentifiedAsOutInz;
317 target.fPassTheEventCut = fPassTheEventCut;
fd6b8522 318 target.fRejectKinkMother = fRejectKinkMother;
8c1c76e9 319 target.fisppMultiBin = fisppMultiBin;
11ff28c5 320 target.fPbPbUserCentralityBinning = fPbPbUserCentralityBinning;
8c1c76e9 321 target.fisNonHFEsystematics = fisNonHFEsystematics;
c2690925 322 target.fSpecialTrigger = fSpecialTrigger;
3a72645a 323 target.fCentralityF = fCentralityF;
11ff28c5 324 target.fCentralityPercent = fCentralityPercent;
c2690925 325 target.fContributors = fContributors;
326 target.fWeightBackGround = fWeightBackGround;
327 target.fVz = fVz;
8c1c76e9 328 target.fHadronBackgroundOADB = fHadronBackgroundOADB;
3a72645a 329 target.fContainer = fContainer;
330 target.fVarManager = fVarManager;
331 target.fSignalCuts = fSignalCuts;
faee3b18 332 target.fCFM = fCFM;
69ac0e6f 333 target.fTriggerAnalysis = fTriggerAnalysis;
faee3b18 334 target.fPID = fPID;
3a72645a 335 target.fPIDqa = fPIDqa;
e3fc062d 336 target.fPIDpreselect = fPIDpreselect;
faee3b18 337 target.fCuts = fCuts;
3a72645a 338 target.fTaggedTrackCuts = fTaggedTrackCuts;
6555e2ad 339 target.fCleanTaggedTrack = fCleanTaggedTrack;
e3ae862b 340 target.fVariablesTRDTaggedTrack = fVariablesTRDTaggedTrack;
e3fc062d 341 target.fCutspreselect = fCutspreselect;
faee3b18 342 target.fSecVtx = fSecVtx;
343 target.fElecBackGround = fElecBackGround;
344 target.fMCQA = fMCQA;
3a72645a 345 target.fTaggedTrackAnalysis = fTaggedTrackAnalysis;
8c1c76e9 346 target.fExtraCuts = fExtraCuts;
faee3b18 347 target.fQA = fQA;
348 target.fOutput = fOutput;
349 target.fHistMCQA = fHistMCQA;
350 target.fHistSECVTX = fHistSECVTX;
351 target.fHistELECBACKGROUND = fHistELECBACKGROUND;
69ac0e6f 352 target.fQACollection = fQACollection;
a86a8fda 353 target.fQAAODCollection = fQAAODCollection;
faee3b18 354}
355
809a4336 356//____________________________________________________________
357AliAnalysisTaskHFE::~AliAnalysisTaskHFE(){
dbe3abbe 358 //
359 // Destructor
360 //
dbe3abbe 361 if(fPID) delete fPID;
8c1c76e9 362 if(fPIDpreselect) delete fPIDpreselect;
3a72645a 363 if(fVarManager) delete fVarManager;
3a72645a 364 if(fCFM) delete fCFM;
8c1c76e9 365 if(fTriggerAnalysis) delete fTriggerAnalysis;
366 if(fSignalCuts) delete fSignalCuts;
259c3296 367 if(fSecVtx) delete fSecVtx;
dbe3abbe 368 if(fMCQA) delete fMCQA;
3a72645a 369 if(fElecBackGround) delete fElecBackGround;
8c1c76e9 370 if(fSpecialTrigger) delete fSpecialTrigger;
371 // Delete output objects only if we are not running in PROOF mode because otherwise this produces a crash during merging
372 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
373 if(mgr && mgr->GetAnalysisType() != AliAnalysisManager::kProofAnalysis){
374 if(fPIDqa) delete fPIDqa;
375 if(fOutput) delete fOutput;
376 if(fQA) delete fQA;
8c1c76e9 377 }
809a4336 378}
379
380//____________________________________________________________
d2af20c5 381void AliAnalysisTaskHFE::UserCreateOutputObjects(){
50685501 382 //
383 // Creating output container and output objects
384 // Here we also Initialize the correction framework container and
385 // the objects for
386 // - PID
387 // - MC QA
388 // - SecVtx
389 // QA histograms are created if requested
390 // Called once per worker
391 //
9bcfd1ab 392 AliDebug(3, "Creating Output Objects");
a86a8fda 393
394 // Make lists for Output
395 if(!fQA) fQA = new TList;
396 fQA->SetOwner();
397 if(!fOutput) fOutput = new TList;
398 fOutput->SetOwner();
399
70da6c5a 400 // Automatic determination of the analysis mode
faee3b18 401 AliVEventHandler *inputHandler = dynamic_cast<AliVEventHandler *>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
70da6c5a 402 if(!TString(inputHandler->IsA()->GetName()).CompareTo("AliAODInputHandler")){
403 SetAODAnalysis();
404 } else {
405 SetESDAnalysis();
406 if(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler())
407 SetHasMCData();
408 }
9bcfd1ab 409 printf("Analysis Mode: %s Analysis\n", IsAODanalysis() ? "AOD" : "ESD");
7ea7b2c4 410 if(IsAODanalysis()) {
a86a8fda 411 printf("AOD filter: %s \n", fUseFilterAOD ? "Yes" : "No");
412 if(fUseFilterAOD) printf("AOD filter used: %d \n", fFilter);
413 // First Part: Make QA histograms
414 fQAAODCollection = new AliHFEcollection("TaskQAAOD", "QA histos from the AOD Electron Task");
415 fQAAODCollection->CreateTH1F("Filterorigin", "AOD filter of tracks at the origin", 21, -1, 20);
416 fQAAODCollection->CreateTH1F("Filterend", "AOD filter of tracks after all cuts", 21, -1, 20);
417 fQA->Add(fQAAODCollection);
7ea7b2c4 418 }
9bcfd1ab 419 printf("MC Data available %s\n", HasMCData() ? "Yes" : "No");
420
69ac0e6f 421 // Enable Trigger Analysis
422 fTriggerAnalysis = new AliTriggerAnalysis;
423 fTriggerAnalysis->EnableHistograms();
424 fTriggerAnalysis->SetAnalyzeMC(HasMCData());
425
3a72645a 426 // First Part: Make QA histograms
69ac0e6f 427 fQACollection = new AliHFEcollection("TaskQA", "QA histos from the Electron Task");
3a72645a 428 fQACollection->CreateTH1F("nElectronTracksEvent", "Number of Electron Candidates", 100, 0, 100);
69ac0e6f 429 fQACollection->CreateTH1F("nElectron", "Number of electrons", 100, 0, 100);
69ac0e6f 430 fQACollection->CreateTH2F("radius", "Production Vertex", 100, 0.0, 5.0, 100, 0.0, 5.0);
e17c1f86 431 fQACollection->CreateTH2F("TPCdEdxBeforePID", "TPC dE/dx; p (GeV/c); TPC dE/dx (a.u.)", 1000, 0., 10., 200, 0., 200.);
432 fQACollection->CreateTH2F("TPCnSigmaBeforePID", "TPC dE/dx; p (GeV/c); TPC dE/dx - <TPC dE/dx>|_{el} (#sigma)", 1000, 0., 10., 1000, -10., 10.);
8c1c76e9 433
3a72645a 434 InitPIDperformanceQA();
6555e2ad 435 InitContaminationQA();
8c1c76e9 436 InitHistoITScluster();
437 fQA->Add(fQACollection);
809a4336 438
3a72645a 439 // Initialize PID
440 fPID->SetHasMCData(HasMCData());
441 if(!fPID->GetNumberOfPIDdetectors()) fPID->AddDetector("TPC", 0);
3a72645a 442 if(IsQAOn(kPIDqa)){
443 AliInfo("PID QA switched on");
3a72645a 444 fPIDqa->Initialize(fPID);
445 fQA->Add(fPIDqa->MakeList("HFEpidQA"));
446 }
8c1c76e9 447 fPID->SortDetectors();
3a72645a 448
809a4336 449 // Initialize correction Framework and Cuts
c2690925 450 const Int_t kNcutSteps = AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kNcutStepsRecTrack + AliHFEcuts::kNcutStepsDETrack + AliHFEcuts::kNcutStepsSecvtxTrack;
809a4336 451 fCFM = new AliCFManager;
3a72645a 452 fCFM->SetNStepParticle(kNcutSteps);
809a4336 453 MakeParticleContainer();
70da6c5a 454 MakeEventContainer();
9bcfd1ab 455 // Temporary fix: Initialize particle cuts with NULL
3a72645a 456 for(Int_t istep = 0; istep < kNcutSteps; istep++)
9bcfd1ab 457 fCFM->SetParticleCutsList(istep, NULL);
0792aa82 458 if(!fCuts){
459 AliWarning("Cuts not available. Default cuts will be used");
460 fCuts = new AliHFEcuts;
461 fCuts->CreateStandardCuts();
809a4336 462 }
9bcfd1ab 463 if(IsAODanalysis()) fCuts->SetAOD();
e3fc062d 464 // Make clone for V0 tagging step
0792aa82 465 fCuts->Initialize(fCFM);
e3fc062d 466 if(fCuts->IsQAOn()) fQA->Add(fCuts->GetQAhistograms());
3a72645a 467 fSignalCuts = new AliHFEsignalCuts("HFEsignalCuts", "HFE MC Signal definition");
468 fVarManager->SetSignalCuts(fSignalCuts);
0792aa82 469
259c3296 470 // add output objects to the List
3a72645a 471 fOutput->AddAt(fContainer, 0);
70da6c5a 472 fOutput->AddAt(fCFM->GetEventContainer(), 1);
3a72645a 473
dbe3abbe 474 // mcQA----------------------------------
9bcfd1ab 475 if (HasMCData() && IsQAOn(kMCqa)) {
dbe3abbe 476 AliInfo("MC QA on");
477 if(!fMCQA) fMCQA = new AliHFEmcQA;
259c3296 478 if(!fHistMCQA) fHistMCQA = new TList();
3a72645a 479 fHistMCQA->SetOwner();
8c1c76e9 480 if(IsPbPb()) fMCQA->SetPbPb();
481 if(fisppMultiBin) fMCQA->SetPPMultiBin();
a8ef1999 482 if(TestBit(kTreeStream)){
483 fMCQA->EnableDebugStreamer();
484 }
e3fc062d 485 fMCQA->CreatDefaultHistograms(fHistMCQA);
e17c1f86 486 fMCQA->SetBackgroundWeightFactor(fElecBackgroundFactor[0][0][0],fBinLimit);
259c3296 487 fQA->Add(fHistMCQA);
dbe3abbe 488 }
259c3296 489
dbe3abbe 490 // secvtx----------------------------------
9bcfd1ab 491 if (GetPlugin(kSecVtx)) {
dbe3abbe 492 AliInfo("Secondary Vertex Analysis on");
e3fc062d 493 if(!fSecVtx) fSecVtx = new AliHFEsecVtx;
9bcfd1ab 494 fSecVtx->SetHasMCData(HasMCData());
dbe3abbe 495
259c3296 496 if(!fHistSECVTX) fHistSECVTX = new TList();
3a72645a 497 fHistSECVTX->SetOwner();
9bcfd1ab 498 fSecVtx->CreateHistograms(fHistSECVTX);
75d81601 499 fOutput->Add(fHistSECVTX);
9bcfd1ab 500 }
501
502 // background----------------------------------
503 if (GetPlugin(kIsElecBackGround)) {
504 AliInfo("Electron BackGround Analysis on");
70da6c5a 505 if(!fElecBackGround){
506 AliWarning("ElecBackGround not available. Default elecbackground will be used");
507 fElecBackGround = new AliHFEelecbackground;
508 }
9bcfd1ab 509 fElecBackGround->SetHasMCData(HasMCData());
510
511 if(!fHistELECBACKGROUND) fHistELECBACKGROUND = new TList();
3a72645a 512 fHistELECBACKGROUND->SetOwner();
9bcfd1ab 513 fElecBackGround->CreateHistograms(fHistELECBACKGROUND);
514 fOutput->Add(fHistELECBACKGROUND);
515 }
3a72645a 516
517 // tagged tracks
518 if(GetPlugin(kTaggedTrackAnalysis)){
519 AliInfo("Analysis on V0-tagged tracks enabled");
c2690925 520 fTaggedTrackAnalysis = new AliHFEtaggedTrackAnalysis(Form("taggedTrackAnalysis%s", GetName()));
3a72645a 521 fTaggedTrackAnalysis->SetCuts(fTaggedTrackCuts);
6555e2ad 522 fTaggedTrackAnalysis->SetClean(fCleanTaggedTrack);
c2690925 523 AliHFEvarManager *varManager = fTaggedTrackAnalysis->GetVarManager();
524 TObjArray *array = fVarManager->GetVariables();
525 Int_t nvars = array->GetEntriesFast();
526 TString namee;
527 for(Int_t v = 0; v < nvars; v++) {
528 AliHFEvarManager::AliHFEvariable *variable = (AliHFEvarManager::AliHFEvariable *) array->At(v);
529 if(!variable) continue;
530 TString name(((AliHFEvarManager::AliHFEvariable *)variable)->GetName());
531 if(!name.CompareTo("source")) namee = TString("species");
532 else namee = TString(name);
8c1c76e9 533 Int_t nbins = variable->GetNumberOfBins();
534 if(variable->HasUserDefinedBinning()){
535 varManager->AddVariable(namee, nbins, variable->GetBinning());
536 } else {
537 varManager->AddVariable(namee, nbins, variable->GetMinimum(), variable->GetMaximum());
538 }
c2690925 539 //printf("For AliTaggedTrackAnalysis, had the variable %s and the one used %s\n",(const char*)variable->GetName(),(const char*) namee);
540 }
e3ae862b 541 if(fPIDqa->HasHighResolutionHistos())
542 fTaggedTrackAnalysis->GetPIDqa()->SetHighResolutionHistos();
3a72645a 543 fTaggedTrackAnalysis->SetPID(fPID);
e3ae862b 544 fTaggedTrackAnalysis->SetVariablesTRD(fVariablesTRDTaggedTrack);
3a72645a 545 fTaggedTrackAnalysis->InitContainer();
546 fOutput->Add(fTaggedTrackAnalysis->GetContainer());
547 fQA->Add(fTaggedTrackAnalysis->GetPIDQA());
548 fQA->Add(fTaggedTrackAnalysis->GetCutQA());
bf892a6a 549 fQA->Add(fTaggedTrackAnalysis->GetQAcollection());
3a72645a 550 }
8c1c76e9 551
3a72645a 552 PrintStatus();
4fb7b1f0 553 // Done!!!
554 PostData(1, fOutput);
555 PostData(2, fQA);
809a4336 556}
557
558//____________________________________________________________
d2af20c5 559void AliAnalysisTaskHFE::UserExec(Option_t *){
dbe3abbe 560 //
561 // Run the analysis
562 //
7ea7b2c4 563
564 //printf("test00\n");
565
9bcfd1ab 566 AliDebug(3, "Starting Single Event Analysis");
d2af20c5 567 if(!fInputEvent){
9bcfd1ab 568 AliError("Reconstructed Event not available");
7ea7b2c4 569 //printf("Reconstructed Event not available");
dbe3abbe 570 return;
571 }
7ea7b2c4 572 if(HasMCData() && IsESDanalysis()){
d2af20c5 573 AliDebug(4, Form("MC Event: %p", fMCEvent));
574 if(!fMCEvent){
9bcfd1ab 575 AliError("No MC Event, but MC Data required");
7ea7b2c4 576 //printf("No MC Event, but MC Data required");
9bcfd1ab 577 return;
578 }
dbe3abbe 579 }
722347d8 580 if(!fCuts){
581 AliError("HFE cuts not available");
7ea7b2c4 582 //printf("HFE cuts not available");
722347d8 583 return;
584 }
8c1c76e9 585 if(!fPID->IsInitialized()){
586 // Initialize PID with the given run number
587 fPID->InitializePID(fInputEvent->GetRunNumber());
588 }
809a4336 589
7ea7b2c4 590 //printf("test0\n");
591
8c1c76e9 592 // Initialize hadronic background from OADB Container
593 AliDebug(2, Form("Apply background factors: %s, OADB Container %p", fBackGroundFactorApply ? "Yes" : "No", fHadronBackgroundOADB));
594 if(fBackGroundFactorApply && !TestBit(kBackgroundInitialized)){
595 AliDebug(2, "Initializing Background from OADB");
596 if(!InitializeHadronBackground(fInputEvent->GetRunNumber())) AliError("Failed initializing hadronic background parameterization from OADB");
597 else AliDebug(2, "Successfully loaded Background from OADB");
598 SetBit(kBackgroundInitialized);
599 }
c2690925 600
7ea7b2c4 601 //printf("test1\n");
602
faee3b18 603 if(IsESDanalysis() && HasMCData()){
604 // Protect against missing MC trees
605 AliMCEventHandler *mcH = dynamic_cast<AliMCEventHandler *>(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
69ac0e6f 606 if(!mcH){
607 AliError("No MC Event Handler available");
608 return;
609 }
faee3b18 610 if(!mcH->InitOk()) return;
611 if(!mcH->TreeK()) return;
612 if(!mcH->TreeTR()) return;
613 }
614
7ea7b2c4 615 if(IsAODanalysis() && HasMCData()){
616 // take MC info
617 AliAODEvent *aodE = dynamic_cast<AliAODEvent *>(fInputEvent);
618 if(!aodE){
619 AliError("No AOD Event");
620 return;
621 }
622 fAODMCHeader = dynamic_cast<AliAODMCHeader *>(fInputEvent->FindListObject(AliAODMCHeader::StdBranchName()));
623 if(!fAODMCHeader){
624 AliError("No AliAODMCHeader");
625 //printf("No AliAODMCHeader");
626 return;
627 }
628 fAODArrayMCInfo = dynamic_cast<TClonesArray *>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
629 if(!fAODArrayMCInfo){
630 AliError("No AOD MC particles");
631 //printf("No AOD MC particles");
632 return;
633 }
634 }
635
636 //printf("test2\n");
637
3a72645a 638 // need the centrality for everything (MC also)
e156c3bb 639 fCentralityF = -1;
640 if(!ReadCentrality()) fCentralityF = -1;
c2690925 641 //printf("pass centrality\n");
7ea7b2c4 642 //printf("Reading fCentralityF %d\n",fCentralityF);
3a72645a 643
644 // See if pile up and z in the range
645 RejectionPileUpVertexRangeEventCut();
646
7ea7b2c4 647 //printf("test3\n");
648
faee3b18 649 // Protect agains missing
3a72645a 650 if(HasMCData()){
bf892a6a 651 //printf("Has MC data\n");
3a72645a 652 fSignalCuts->SetMCEvent(fMCEvent);
653 ProcessMC(); // Run the MC loop + MC QA in case MC Data are available
654 }
809a4336 655
8c1c76e9 656 AliPIDResponse *pidResponse = fInputHandler->GetPIDResponse();
657 if(!pidResponse){
658 AliDebug(1, "Using default PID Response");
eeb1e952 659 pidResponse = AliHFEtools::GetDefaultPID(HasMCData(), fInputEvent->IsA() == AliESDEvent::Class());
8c1c76e9 660 }
661 fPID->SetPIDResponse(pidResponse);
662 if(fPIDpreselect) fPIDpreselect->SetPIDResponse(pidResponse);
663
664 // Event loop
3a72645a 665 if(IsAODanalysis()){
7ea7b2c4 666 //printf("test4\n");
3a72645a 667 ProcessAOD();
668 } else {
8c1c76e9 669 const char *specialTrigger = GetSpecialTrigger(fInputEvent->GetRunNumber());
c2690925 670 // Check Trigger selection
8c1c76e9 671 if(specialTrigger){
672 AliDebug(2, Form("Special Trigger requested: %s", specialTrigger));
c2690925 673 AliESDEvent *ev = dynamic_cast<AliESDEvent *>(fInputEvent);
8c1c76e9 674 if(!(ev && ev->IsTriggerClassFired(specialTrigger))){
675 AliDebug(2, "Event not selected");
676 return;
677 } else AliDebug(2, "Event Selected");
678 } else AliDebug(2, "No Special Trigger requested");
679
faee3b18 680 ProcessESD();
681 }
9bcfd1ab 682 // Done!!!
3a72645a 683 PostData(1, fOutput);
684 PostData(2, fQA);
9bcfd1ab 685}
259c3296 686
9bcfd1ab 687//____________________________________________________________
688void AliAnalysisTaskHFE::Terminate(Option_t *){
689 //
690 // Terminate not implemented at the moment
691 //
692 if(GetPlugin(kPostProcess)){
3a72645a 693 fOutput = dynamic_cast<TList *>(GetOutputData(1));
694 fQA = dynamic_cast<TList *>(GetOutputData(2));
9bcfd1ab 695 if(!fOutput){
696 AliError("Results not available");
697 return;
259c3296 698 }
3a72645a 699 if(!fQA){
700 AliError("QA output not available");
701 return;
702 }
703 fContainer = dynamic_cast<AliHFEcontainer *>(fOutput->FindObject("trackContainer"));
704 if(!fContainer){
705 AliError("Track container not found");
706 return;
707 }
d2af20c5 708 AliHFEpostAnalysis postanalysis;
3a72645a 709 postanalysis.SetTaskResults(fContainer);
710 TList *qalist = dynamic_cast<TList *>(fQA->FindObject("list_TaskQA"));
711 if(!qalist){
712 AliError("QA List not found");
713 return;
714 }
715 postanalysis.SetTaskQA(qalist);
7ea7b2c4 716 //printf("Running post analysis\n");
3a72645a 717 //if(HasMCData())
718 postanalysis.DrawMCSignal2Background();
d2af20c5 719 postanalysis.DrawEfficiency();
720 postanalysis.DrawPIDperformance();
70da6c5a 721 postanalysis.DrawCutEfficiency();
722
723 if (GetPlugin(kIsElecBackGround)) {
724 AliHFEelecbackground elecBackGround;
725 TList *oe = 0x0;
726 if(!(oe = (TList*)dynamic_cast<TList *>(fOutput->FindObject("HFEelecbackground")))){
8c1c76e9 727 return;
70da6c5a 728 }
729 elecBackGround.Load(oe);
730 elecBackGround.Plot();
731 elecBackGround.PostProcess();
732 }
9bcfd1ab 733 }
9bcfd1ab 734}
faee3b18 735//_______________________________________________________________
736Bool_t AliAnalysisTaskHFE::IsEventInBinZero() {
737 //
738 //
739 //
740
741 //printf("test in IsEventInBinZero\n");
742 if(!fInputEvent){
743 AliError("Reconstructed Event not available");
744 return kFALSE;
745 }
dbe3abbe 746
faee3b18 747 // check vertex
748 const AliVVertex *vertex = fInputEvent->GetPrimaryVertex();
749 if(!vertex) return kTRUE;
750 //if(vertex) return kTRUE;
751
752 // check tracks
753 if(fInputEvent->GetNumberOfTracks()<=0) return kTRUE;
754 //if(fInputEvent->GetNumberOfTracks()>0) return kTRUE;
755
756
757 return kFALSE;
758
759}
9bcfd1ab 760//____________________________________________________________
761void AliAnalysisTaskHFE::ProcessMC(){
762 //
763 // Runs the MC Loop (filling the container for the MC Cut Steps with the observables pt, eta and phi)
764 // In case MC QA is on also MC QA loop is done
765 //
766 AliDebug(3, "Processing MC Information");
c2690925 767 Double_t eventContainer [4];
7ea7b2c4 768 if(IsESDanalysis()) eventContainer[0] = fMCEvent->GetPrimaryVertex()->GetZ();
769 else eventContainer[0] = fAODMCHeader->GetVtxZ();
3a72645a 770 eventContainer[2] = fCentralityF;
c2690925 771 eventContainer[3] = fContributors;
772 fVz = eventContainer[0];
bf892a6a 773 //printf("z position is %f\n",eventContainer[0]);
774 //if(fCFM->CheckEventCuts(AliHFEcuts::kEventStepGenerated, fMCEvent))
775 fCFM->GetEventContainer()->Fill(eventContainer,AliHFEcuts::kEventStepGenerated);
9bcfd1ab 776 Int_t nElectrons = 0;
777 if(IsESDanalysis()){
e156c3bb 778 if(!((fIdentifiedAsPileUp) || (TMath::Abs(fVz) > fCuts->GetVertexRange()) || (fCentralityF < 0))){ //kStepMCGeneratedZOutNoPileUpCentralityFine
9bcfd1ab 779 if (HasMCData() && IsQAOn(kMCqa)) {
780 AliDebug(2, "Running MC QA");
781
70da6c5a 782 if(fMCEvent->Stack()){
8c1c76e9 783 fMCQA->SetMCEvent(fMCEvent);
70da6c5a 784 fMCQA->SetGenEventHeader(fMCEvent->GenEventHeader());
8c1c76e9 785 fMCQA->SetCentrality(fCentralityF);
11ff28c5 786 fMCQA->SetPercentrality(fCentralityPercent);
8c1c76e9 787 if(IsPbPb()) { fMCQA->SetPbPb();}
788 else
789 {
790 if(fisppMultiBin) fMCQA->SetPPMultiBin();
791 else fMCQA->SetPP();
792 }
70da6c5a 793 fMCQA->Init();
8c1c76e9 794
c2690925 795 fMCQA->GetMesonKine();
70da6c5a 796
70da6c5a 797 // loop over all tracks for decayed electrons
e3ae862b 798 for (Int_t igen = 0; igen < fMCEvent->GetNumberOfTracks(); igen++){
70da6c5a 799 TParticle* mcpart = fMCEvent->Stack()->Particle(igen);
8c1c76e9 800 if(!mcpart) continue;
70da6c5a 801 fMCQA->GetQuarkKine(mcpart, igen, AliHFEmcQA::kCharm);
802 fMCQA->GetQuarkKine(mcpart, igen, AliHFEmcQA::kBeauty);
803 fMCQA->GetHadronKine(mcpart, AliHFEmcQA::kCharm);
804 fMCQA->GetHadronKine(mcpart, AliHFEmcQA::kBeauty);
a8ef1999 805 fMCQA->GetDecayedKine(mcpart, AliHFEmcQA::kCharm, AliHFEmcQA::kElectronPDG); // no accept cut
806 fMCQA->GetDecayedKine(mcpart, AliHFEmcQA::kBeauty, AliHFEmcQA::kElectronPDG); // no accept cut
807 fMCQA->GetDecayedKine(mcpart, AliHFEmcQA::kOthers, AliHFEmcQA::kElectronPDG); // no accept cut
9bcfd1ab 808 }
8c1c76e9 809 //fMCQA->EndOfEventAna(AliHFEmcQA::kCharm);
810 //fMCQA->EndOfEventAna(AliHFEmcQA::kBeauty);
9bcfd1ab 811 }
809a4336 812
9bcfd1ab 813 } // end of MC QA loop
c2690925 814 }
815 // -----------------------------------------------------------------
816 fCFM->SetMCEventInfo(fMCEvent);
817 // fCFM->CheckEventCuts(AliCFManager::kEvtRecCuts, fESD);
9bcfd1ab 818 } else {
d2af20c5 819 fCFM->SetMCEventInfo(fInputEvent);
9bcfd1ab 820 }
821 // Run MC loop
70da6c5a 822 AliVParticle *mctrack = NULL;
7ea7b2c4 823 Int_t numberofmctracks = 0;
824 if(IsESDanalysis()){
825 numberofmctracks = fMCEvent->GetNumberOfTracks();
826 }
827 else {
828 numberofmctracks = fAODArrayMCInfo->GetEntriesFast();
829 }
830 AliDebug(3, Form("Number of Tracks: %d",numberofmctracks));
831 //printf("Number of MC track %d\n",numberofmctracks);
832 for(Int_t imc = 0; imc <numberofmctracks; imc++){
833 if(IsESDanalysis()) {
834 if(!(mctrack = fMCEvent->GetTrack(imc))) continue;
835 }
836 else {
837 if(!(mctrack = (AliVParticle *) fAODArrayMCInfo->At(imc))) continue;
838 }
839 //printf("Test in ProcessMC\n");
3a72645a 840 AliDebug(4, "Next MC Track");
70da6c5a 841 if(ProcessMCtrack(mctrack)) nElectrons++;
dbe3abbe 842 }
dbe3abbe 843
844 // fCFM->CheckEventCuts(AliCFManager::kEvtRecCuts, fESD);
69ac0e6f 845 fQACollection->Fill("nElectron", nElectrons);
9bcfd1ab 846}
dbe3abbe 847
9bcfd1ab 848//____________________________________________________________
849void AliAnalysisTaskHFE::ProcessESD(){
dbe3abbe 850 //
9bcfd1ab 851 // Run Analysis of reconstructed event in ESD Mode
852 // Loop over Tracks, filter according cut steps defined in AliHFEcuts
dbe3abbe 853 //
eeb1e952 854 AliDebug(1, Form("Task %s", GetName()));
9bcfd1ab 855 AliDebug(3, "Processing ESD Event");
d2af20c5 856 AliESDEvent *fESD = dynamic_cast<AliESDEvent *>(fInputEvent);
9bcfd1ab 857 if(!fESD){
13242232 858 AliError("ESD Event required for ESD Analysis");
9bcfd1ab 859 return;
860 }
69ac0e6f 861
e3ae862b 862 // Set magnetic field if V0 task on
c2690925 863 if(fTaggedTrackAnalysis) {
864 fTaggedTrackAnalysis->SetMagneticField(fESD->GetMagneticField());
865 fTaggedTrackAnalysis->SetCentrality(fCentralityF);
e156c3bb 866 if(IsPbPb()) fTaggedTrackAnalysis->SetPbPb();
867 else fTaggedTrackAnalysis->SetPP();
c2690925 868 }
e3ae862b 869
69ac0e6f 870 // Do event Normalization
c2690925 871 Double_t eventContainer[4];
8c1c76e9 872 eventContainer[0] = 0.;
c2690925 873 if(HasMCData()) eventContainer[0] = fVz;
874 else {
8c1c76e9 875 if(fESD->GetPrimaryVertexSPD()) eventContainer[0] = fESD->GetPrimaryVertexSPD()->GetZ();
c2690925 876 }
69ac0e6f 877 eventContainer[1] = 0.;
3a72645a 878 eventContainer[2] = fCentralityF;
c2690925 879 eventContainer[3] = fContributors;
69ac0e6f 880 if(fTriggerAnalysis->IsOfflineTriggerFired(fESD, AliTriggerAnalysis::kV0AND))
881 eventContainer[1] = 1.;
3a72645a 882
883 //
69ac0e6f 884 fCFM->GetEventContainer()->Fill(eventContainer, AliHFEcuts::kEventStepRecNoCut);
3a72645a 885
886 //
887 if(fIdentifiedAsPileUp) return;
888 fCFM->GetEventContainer()->Fill(eventContainer, AliHFEcuts::kEventStepRecNoPileUp);
889
c2690925 890 //
e156c3bb 891 if(TMath::Abs(fCentralityF) < 0) return;
c2690925 892 fCFM->GetEventContainer()->Fill(eventContainer, AliHFEcuts::kEventStepRecCentralityOk);
893 //printf("In ProcessESD %f\n",fCentralityF);
894
3a72645a 895 //
896 if(fIdentifiedAsOutInz) return;
897 fCFM->GetEventContainer()->Fill(eventContainer, AliHFEcuts::kEventStepZRange);
898
899 //
900 if(!fPassTheEventCut) return;
69ac0e6f 901 fCFM->GetEventContainer()->Fill(eventContainer, AliHFEcuts::kEventStepReconstructed);
902
3a72645a 903
904 fContainer->NewEvent();
905
9bcfd1ab 906 if (GetPlugin(kIsElecBackGround)) {
907 fElecBackGround->SetEvent(fESD);
908 }
909 if (GetPlugin(kSecVtx)) {
910 fSecVtx->SetEvent(fESD);
911 fSecVtx->GetPrimaryCondition();
912 }
913
914 if(HasMCData()){
915 if (GetPlugin(kSecVtx)) {
faee3b18 916 fSecVtx->SetMCEvent(fMCEvent);
3a72645a 917 fSecVtx->SetMCQA(fMCQA);
9bcfd1ab 918 }
919 if (GetPlugin(kIsElecBackGround)) {
d2af20c5 920 fElecBackGround->SetMCEvent(fMCEvent);
9bcfd1ab 921 }
922 }
923
faee3b18 924 Double_t container[10];
925 memset(container, 0, sizeof(Double_t) * 10);
9bcfd1ab 926 // container for the output THnSparse
67fe7bd0 927 Double_t dataE[6]; // [pT, eta, Phi, type, 'C' or 'B']
0e30407a 928 Double_t dataDca[6]; // [source, pT, dca, centrality]
75d81601 929 Int_t nElectronCandidates = 0;
9bcfd1ab 930 AliESDtrack *track = NULL, *htrack = NULL;
931 AliMCParticle *mctrack = NULL;
8c1c76e9 932 AliMCParticle *mctrackmother = NULL;
259c3296 933 Int_t pid = 0;
dbe3abbe 934
78ea5ef4 935 Bool_t signal = kTRUE;
936
554e120d 937 fCFM->SetRecEventInfo(fESD);
8c1c76e9 938
939 // minjung for IP QA(temporary ~ 2weeks)
940 if(!fExtraCuts){
941 fExtraCuts = new AliHFEextraCuts("hfetmpCuts","HFE tmp Cuts");
942 }
943 fExtraCuts->SetRecEventInfo(fESD);
944
d2af20c5 945 // Electron background analysis
946 if (GetPlugin(kIsElecBackGround)) {
947
948 AliDebug(2, "Running BackGround Analysis");
949
950 fElecBackGround->Reset();
951
952 } // end of electron background analysis
9bcfd1ab 953 //
954 // Loop ESD
955 //
faee3b18 956 AliDebug(3, Form("Number of Tracks: %d", fESD->GetNumberOfTracks()));
dbe3abbe 957 for(Int_t itrack = 0; itrack < fESD->GetNumberOfTracks(); itrack++){
3a72645a 958 AliDebug(4, "New ESD track");
dbe3abbe 959 track = fESD->GetTrack(itrack);
c2690925 960 track->SetESDEvent(fESD);
faee3b18 961
e3fc062d 962 // fill counts of v0-identified particles
963 Int_t v0pid = -1;
964 if(track->TestBit(BIT(14))) v0pid = AliPID::kElectron;
965 else if(track->TestBit(BIT(15))) v0pid = AliPID::kPion;
966 else if(track->TestBit(BIT(16))) v0pid = AliPID::kProton;
3a72645a 967 // here the tagged track analysis will run
968 if(fTaggedTrackAnalysis && v0pid > -1){
969 AliDebug(1, Form("Track identified as %s", AliPID::ParticleName(v0pid)));
970 fTaggedTrackAnalysis->ProcessTrack(track, v0pid);
eeb1e952 971 AliDebug(1, "V0 PID done");
3a72645a 972 }
e3fc062d 973
eeb1e952 974
975 //Fill non-HFE source containers at reconstructed events cut step
faee3b18 976 AliDebug(3, Form("Doing track %d, %p", itrack, track));
eeb1e952 977
978
e3fc062d 979 //////////////////////////////////////
980 // preselect
981 /////////////////////////////////////
982 if(fPIDpreselect && fCutspreselect) {
983 if(!PreSelectTrack(track)) continue;
984 }
78ea5ef4 985
986 signal = kTRUE;
faee3b18 987
70da6c5a 988 // Fill step without any cut
dbe3abbe 989
9bcfd1ab 990 if(HasMCData()){
991 // Check if it is electrons near the vertex
d2af20c5 992 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(track->GetLabel()))))) continue;
faee3b18 993
c2690925 994 if(fFillSignalOnly && !fCFM->CheckParticleCuts(AliHFEcuts::kStepMCGenerated, mctrack)) signal = kFALSE;
faee3b18 995 else AliDebug(3, "Signal Electron");
8c1c76e9 996
997 // Fill K pt for Ke3 contributions
998 if(mctrack && (TMath::Abs(mctrack->Particle()->GetPdgCode())==321)) fQACollection->Fill("Kptspectra",mctrack->Pt());
999 else if(mctrack && (TMath::Abs(mctrack->Particle()->GetPdgCode())==130)) fQACollection->Fill("K0Lptspectra",mctrack->Pt());
e3fc062d 1000 }
3a72645a 1001 // Cache new Track information inside the var manager
1002 fVarManager->NewTrack(track, mctrack, fCentralityF, -1, signal);
1003
e156c3bb 1004 if(fFillNoCuts) {
1005 if(signal || !fFillSignalOnly){
1006 fVarManager->FillContainer(fContainer, "recTrackContReco", AliHFEcuts::kStepRecNoCut, kFALSE);
1007 fVarManager->FillContainer(fContainer, "recTrackContMC", AliHFEcuts::kStepRecNoCut, kTRUE);
e3ae862b 1008 }
dbe3abbe 1009 }
eeb1e952 1010
1011 if(fisNonHFEsystematics && IsPbPb()) {
1012 //FillProductionVertex(track);
1013 if(fMCQA && signal){
1014 fMCQA->SetCentrality(fCentralityF);
1015 if(mctrack && (TMath::Abs(mctrack->Particle()->GetPdgCode()) == 11)){
1016 Double_t weightElecBgV0[kBgLevels] = {0.,0.,0.};
1017
1018 fMCQA->SetTrkKine(track->Pt(),track->Eta(), track->Phi());
1019 fMCQA->SetContainerStep(4);
1020
1021 weightElecBgV0[0] = fMCQA->GetWeightFactor(mctrack, 0); // positive:conversion e, negative: nonHFE
1022
1023 //Fill additional containers for electron source distinction
1024 Int_t elecSource = 0;
1025 elecSource = fMCQA->GetElecSource(mctrack->Particle());
1026 const Char_t *sourceName[kElecBgSpecies]={"Pion","Eta","Omega","Phi","EtaPrime","Rho"};
1027 const Char_t *levelName[kBgLevels]={"Best","Lower","Upper"};
1028 Int_t iName = 0;
1029 for(Int_t iSource = AliHFEmcQA::kPi0; iSource <= AliHFEmcQA::kGammaRho0; iSource++){
1030 if((iSource == AliHFEmcQA::kElse)||(iSource == AliHFEmcQA::kMisID)) continue;
1031 if(elecSource == iSource){
1032
1033 if(weightElecBgV0[0]>0){
1034 fVarManager->FillContainer(fContainer, Form("conversionElecs%s%s",sourceName[iName], levelName[0]), 4, kTRUE, weightElecBgV0[0]);
1035 }
1036 else if(weightElecBgV0[0]<0){
1037 fVarManager->FillContainer(fContainer, Form("mesonElecs%s%s",sourceName[iName], levelName[0]), 4, kTRUE, -1*weightElecBgV0[0]);
1038 }
1039 break;
1040 }
1041 iName++;
1042 if(iName == kElecBgSpecies)iName = 0;
1043 }
1044 }
1045 }
1046 }
1047
70da6c5a 1048 // RecKine: ITSTPC cuts
3a72645a 1049 if(!ProcessCutStep(AliHFEcuts::kStepRecKineITSTPC, track)) continue;
70da6c5a 1050
dbe3abbe 1051
1052 // RecPrim
fd6b8522 1053 if(fRejectKinkMother) {
1054 if(track->GetKinkIndex(0) != 0) continue; } // Quick and dirty fix to reject both kink mothers and daughters
3a72645a 1055 if(!ProcessCutStep(AliHFEcuts::kStepRecPrim, track)) continue;
dbe3abbe 1056
1057 // HFEcuts: ITS layers cuts
3a72645a 1058 if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsITS, track)) continue;
fd6b8522 1059
1060 // HFE cuts: TOF PID and mismatch flag
1061 if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsTOF, track)) continue;
3a72645a 1062
8c1c76e9 1063 // HFE cuts: TPC PID cleanup
1064 if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsTPC, track)) continue;
1065
3a72645a 1066 // HFEcuts: Nb of tracklets TRD0
1067 if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsTRD, track)) continue;
1068
6555e2ad 1069 // Fill correlation maps before PID
1070 if(signal && fContainer->GetCorrelationMatrix("correlationstepbeforePID")) {
1071 //printf("Fill correlation maps before PID\n");
1072 fVarManager->FillCorrelationMatrix(fContainer->GetCorrelationMatrix("correlationstepbeforePID"));
1073 }
1074
faee3b18 1075 if(HasMCData()){
1076 FillProductionVertex(track);
faee3b18 1077
a8ef1999 1078 if(fMCQA && signal){
8c1c76e9 1079 fMCQA->SetCentrality(fCentralityF);
1080 if(mctrack && (TMath::Abs(mctrack->Particle()->GetPdgCode()) == 11)){
1081 Double_t weightElecBgV0[kBgLevels] = {0.,0.,0.};
a8ef1999 1082 Double_t hfeimpactRtmp=0., hfeimpactnsigmaRtmp=0.;
1083 fExtraCuts->GetHFEImpactParameters(track, hfeimpactRtmp, hfeimpactnsigmaRtmp);
1084 UChar_t itsPixel = track->GetITSClusterMap();
1085 Double_t ilyrhit=0, ilyrstat=0;
1086 for(Int_t ilyr=0; ilyr<6; ilyr++){
1087 if(TESTBIT(itsPixel, ilyr)) ilyrhit += TMath::Power(2,ilyr);
1088 if(fExtraCuts->CheckITSstatus(fExtraCuts->GetITSstatus(track,ilyr))) ilyrstat += TMath::Power(2,ilyr);
1089 }
1090 fMCQA->SetITSInfo(ilyrhit,ilyrstat);
1091 fMCQA->SetHFEImpactParameters(hfeimpactRtmp, hfeimpactnsigmaRtmp);
1092 fMCQA->SetTrkKine(track->Pt(),track->Eta(), track->Phi());
1093 fMCQA->SetContainerStep(3);
8c1c76e9 1094 for(Int_t iLevel = 0; iLevel < kBgLevels; iLevel++){
1095 weightElecBgV0[iLevel] = fMCQA->GetWeightFactor(mctrack, iLevel); // positive:conversion e, negative: nonHFE
eeb1e952 1096 if(!fisNonHFEsystematics || IsPbPb())break;
8c1c76e9 1097 }
1098
1099 if(fisNonHFEsystematics){
1100 //Fill additional containers for electron source distinction
1101 Int_t elecSource = 0;
1102 elecSource = fMCQA->GetElecSource(mctrack->Particle());
1103 const Char_t *sourceName[kElecBgSpecies]={"Pion","Eta","Omega","Phi","EtaPrime","Rho"};
1104 const Char_t *levelName[kBgLevels]={"Best","Lower","Upper"};
1105 Int_t iName = 0;
1106 for(Int_t iSource = AliHFEmcQA::kPi0; iSource <= AliHFEmcQA::kGammaRho0; iSource++){
1107 if((iSource == AliHFEmcQA::kElse)||(iSource == AliHFEmcQA::kMisID)) continue;
1108 if(elecSource == iSource){
1109 for(Int_t iLevel = 0; iLevel < kBgLevels; iLevel++){
a8ef1999 1110 if(weightElecBgV0[iLevel]>0){
1111 fVarManager->FillContainer(fContainer, Form("conversionElecs%s%s",sourceName[iName], levelName[iLevel]), 3, kFALSE, weightElecBgV0[iLevel]);
1112 }
1113 else if(weightElecBgV0[iLevel]<0){
1114 fVarManager->FillContainer(fContainer, Form("mesonElecs%s%s",sourceName[iName], levelName[iLevel]), 3, kFALSE, -1*weightElecBgV0[iLevel]);
1115 }
eeb1e952 1116 if(IsPbPb())break;
8c1c76e9 1117 }
1118 break;
1119 }
1120 iName++;
1121 if(iName == kElecBgSpecies)iName = 0;
1122 }
1123 }
1124 //else{
a8ef1999 1125 if(weightElecBgV0[0]>0) {
1126 fVarManager->FillContainer(fContainer, "conversionElecs", 3, kFALSE, weightElecBgV0[0]);
1127 fVarManager->FillContainer(fContainer, "conversionElecs", 4, kTRUE, weightElecBgV0[0]);
1128 }
1129 else if(weightElecBgV0[0]<0) {
1130 fVarManager->FillContainer(fContainer, "mesonElecs", 3, kFALSE, -1*weightElecBgV0[0]);
1131 fVarManager->FillContainer(fContainer, "mesonElecs", 4, kTRUE, -1*weightElecBgV0[0]);
1132 }
8c1c76e9 1133 //}
1134 }
1135 }
11ff28c5 1136
0e30407a 1137 Double_t hfeimpactR4all=0., hfeimpactnsigmaR4all=0.;
1138 Int_t sourceDca =-1;
11ff28c5 1139 if(mctrack && (TMath::Abs(mctrack->Particle()->GetPdgCode()) == 211)){
1140 if(track->Pt()>4.){
0e30407a 1141 fExtraCuts->GetHFEImpactParameters(track, hfeimpactR4all, hfeimpactnsigmaR4all);
1142 dataDca[0]=0; //pion
1143 dataDca[1]=track->Pt();
1144 dataDca[2]=hfeimpactR4all;
1145 dataDca[3]=fCentralityF;
1146 dataDca[4] = v0pid;
1147 dataDca[5] = double(track->Charge());
1148 fQACollection->Fill("Dca", dataDca);
11ff28c5 1149 }
1150 }
1151 else if(mctrack && (TMath::Abs(mctrack->Particle()->GetPdgCode()) == 11)){ // to increas statistics for Martin
1152 if(signal){
0e30407a 1153 fExtraCuts->GetHFEImpactParameters(track, hfeimpactR4all, hfeimpactnsigmaR4all);
11ff28c5 1154 if(fSignalCuts->IsCharmElectron(track)){
1155 sourceDca=1;
1156 }
1157 else if(fSignalCuts->IsBeautyElectron(track)){
1158 sourceDca=2;
1159 }
1160 else if(fSignalCuts->IsGammaElectron(track)){
1161 sourceDca=3;
1162 }
1163 else if(fSignalCuts->IsNonHFElectron(track)){
1164 sourceDca=4;
1165 }
1166 else if(fSignalCuts->IsJpsiElectron(track)){
1167 sourceDca=5;
1168 }
11ff28c5 1169 else {
0e30407a 1170 sourceDca=6;
11ff28c5 1171 }
0e30407a 1172 dataDca[0]=sourceDca;
1173 dataDca[1]=track->Pt();
1174 dataDca[2]=hfeimpactR4all;
1175 dataDca[3]=fCentralityF;
1176 dataDca[4] = v0pid;
1177 dataDca[5] = double(track->Charge());
1178 if(signal) fQACollection->Fill("Dca", dataDca);
11ff28c5 1179 }
1180 }
8c1c76e9 1181 }
e17c1f86 1182
1183 if(TMath::Abs(track->Eta()) < 0.5){
a8ef1999 1184 if(track->GetInnerParam())
1185 fQACollection->Fill("TPCdEdxBeforePID", track->GetInnerParam()->P(), track->GetTPCsignal());
e17c1f86 1186 fQACollection->Fill("TPCnSigmaBeforePID", track->P(), fInputHandler->GetPIDResponse()->NumberOfSigmasTPC(track, AliPID::kElectron));
1187 }
1188
722347d8 1189 AliHFEpidObject hfetrack;
3a72645a 1190 hfetrack.SetAnalysisType(AliHFEpidObject::kESDanalysis);
1191 hfetrack.SetRecTrack(track);
1192 if(HasMCData()) hfetrack.SetMCTrack(mctrack);
1193 hfetrack.SetCentrality(fCentralityF);
e156c3bb 1194 if(IsPbPb()) hfetrack.SetPbPb();
1195 else hfetrack.SetPP();
3a72645a 1196 fPID->SetVarManager(fVarManager);
1197 if(!fPID->IsSelected(&hfetrack, fContainer, "recTrackCont", fPIDqa)) continue;
75d81601 1198 nElectronCandidates++;
dbe3abbe 1199
8c1c76e9 1200 // Temporary histogram for chi2/ITS cluster
1201 if(IsPbPb()) {
1202 TBits shared = track->GetTPCSharedMap();
965de368 1203 Int_t sharebit=0;
8c1c76e9 1204 if(shared.CountBits() >= 2) sharebit=1;
1205
965de368 1206 Double_t itschi2percluster = 0.0;
317ae21b 1207 Double_t itsnbcls = static_cast<Double_t>(track->GetNcls(0));
1208 if(itsnbcls > 0) itschi2percluster = track->GetITSchi2()/itsnbcls;
965de368 1209
8c1c76e9 1210 Double_t itsChi2[7] = {track->Pt(),track->Eta(), track->Phi(),
a8ef1999 1211 fCentralityF,track->GetTPCsignalN(), sharebit,itschi2percluster};
8c1c76e9 1212 fQACollection->Fill("fChi2perITScluster", itsChi2);
1213 }
1214 else{
a8ef1999 1215
965de368 1216 Double_t itschi2percluster = 0.0;
317ae21b 1217 Double_t itsnbcls = static_cast<Double_t>(track->GetNcls(0));
1218 if(itsnbcls > 0) itschi2percluster = track->GetITSchi2()/itsnbcls;
965de368 1219
1220 Double_t itsChi2[3] = {track->Pt(), fCentralityF, itschi2percluster};
1221 fQACollection->Fill("fChi2perITScluster", itsChi2);
8c1c76e9 1222 }
1223
faee3b18 1224 // Fill Histogram for Hadronic Background
1225 if(HasMCData()){
1226 if(mctrack && (TMath::Abs(mctrack->Particle()->GetPdgCode()) != 11))
3a72645a 1227 fVarManager->FillContainer(fContainer, "hadronicBackground", UInt_t(0), kFALSE);
8c1c76e9 1228 else if(mctrack){
1229 // Fill Ke3 contributions
1230 Int_t glabel=TMath::Abs(mctrack->GetMother());
1231 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
1232 if(TMath::Abs(mctrackmother->Particle()->GetPdgCode())==321)
a8ef1999 1233 fQACollection->Fill("Ke3Kecorr",mctrack->Pt(),mctrackmother->Pt());
8c1c76e9 1234 else if(TMath::Abs(mctrackmother->Particle()->GetPdgCode())==130)
a8ef1999 1235 fQACollection->Fill("Ke3K0Lecorr",mctrack->Pt(),mctrackmother->Pt());
8c1c76e9 1236 }
1237 }
faee3b18 1238 }
1239
dbe3abbe 1240 // Fill Containers
dbe3abbe 1241 if(signal) {
e3fc062d 1242 // Apply weight for background contamination
8c1c76e9 1243 if(fBackGroundFactorApply) {
1244 if(IsPbPb() && fCentralityF >= 0) fWeightBackGround = fkBackGroundFactorArray[fCentralityF >= 0 ? fCentralityF : 0]->Eval(TMath::Abs(track->P()));
1245 else fWeightBackGround = fkBackGroundFactorArray[0]->Eval(TMath::Abs(track->P())); // pp case
c2690925 1246
8c1c76e9 1247 if(fWeightBackGround < 0.0) fWeightBackGround = 0.0;
1248 else if(fWeightBackGround > 1.0) fWeightBackGround = 1.0;
3a72645a 1249 // weightBackGround as special weight
c2690925 1250 fVarManager->FillContainer(fContainer, "hadronicBackground", 1, kFALSE, fWeightBackGround);
dbe3abbe 1251 }
3a72645a 1252 fVarManager->FillCorrelationMatrix(fContainer->GetCorrelationMatrix("correlationstepafterPID"));
dbe3abbe 1253 }
1254
fd6b8522 1255 Bool_t bTagged=kFALSE;
faee3b18 1256 if(GetPlugin(kSecVtx)) {
9bcfd1ab 1257 AliDebug(2, "Running Secondary Vertex Analysis");
c2690925 1258 if(fSecVtx->Process(track) && signal) {
1259 fVarManager->FillContainer(fContainer, "recTrackContSecvtxReco", AliHFEcuts::kStepHFEcutsSecvtx, kFALSE);
1260 fVarManager->FillContainer(fContainer, "recTrackContSecvtxMC", AliHFEcuts::kStepHFEcutsSecvtx, kTRUE);
e156c3bb 1261 bTagged=kTRUE;
c2690925 1262 }
78ea5ef4 1263 }
9bcfd1ab 1264
1265 if(HasMCData()){
3a72645a 1266 dataE[0] = track->Pt();
1267 dataE[1] = track->Eta();
1268 dataE[2] = track->Phi();
1269 dataE[3] = track->Charge();
1270 dataE[4] = -1.;
1271 dataE[5] = -1.;
1272
9bcfd1ab 1273 // Track selected: distinguish between true and fake
1274 AliDebug(1, Form("Candidate Selected, filling THnSparse, PID: %d\n", mctrack->Particle()->GetPdgCode()));
1275 if((pid = TMath::Abs(mctrack->Particle()->GetPdgCode())) == 11){
3a72645a 1276 Int_t type = 0;
1277 if(fSignalCuts->IsCharmElectron(track))
1278 type = 1;
1279 else if(fSignalCuts->IsBeautyElectron(track))
1280 type = 2;
9bcfd1ab 1281 AliDebug(1, Form("Type: %d\n", type));
1282 if(type){
8c1c76e9 1283 dataE[5] = type; // beauty[1] or charm[2]
1284 dataE[4] = 2; // signal electron
9bcfd1ab 1285 }
1286 else{
8c1c76e9 1287 dataE[4] = 1; // not a signal electron
1288 dataE[5] = 0;
9bcfd1ab 1289 }
1290 }
1291 else {
1292 // Fill THnSparse with the information for Fake Electrons
9bcfd1ab 1293 dataE[4] = 0;
70da6c5a 1294 dataE[5] = 0;
9bcfd1ab 1295 }
1296 // fill the performance THnSparse, if the mc origin could be defined
70da6c5a 1297 if(dataE[4] > -1){
1298 AliDebug(1, Form("Entries: [%.3f|%.3f|%.3f|%f|%f|%f]\n", dataE[0],dataE[1],dataE[2],dataE[3],dataE[4],dataE[5]));
3a72645a 1299 fQACollection->Fill("PIDperformance", dataE);
9bcfd1ab 1300 }
259c3296 1301 }
8c1c76e9 1302
9bcfd1ab 1303 // Electron background analysis
1304 if (GetPlugin(kIsElecBackGround)) {
1305
1306 AliDebug(2, "Running BackGround Analysis");
1307
1308 for(Int_t jtrack = 0; jtrack < fESD->GetNumberOfTracks(); jtrack++){
fd6b8522 1309 htrack = fESD->GetTrack(jtrack);
8c1c76e9 1310 if ( itrack == jtrack ) continue;
1311 fElecBackGround->PairAnalysis(track, htrack);
9bcfd1ab 1312 }
1313 } // end of electron background analysis
1314
3a72645a 1315 if (GetPlugin(kDEstep)) {
8c1c76e9 1316 Double_t weightElecBgV0[kBgLevels] = {0.,0.,0.,};
1317 Int_t elecSource = 0;
8c1c76e9 1318 Double_t hfeimpactR=0., hfeimpactnsigmaR=0.;
1319 fExtraCuts->GetHFEImpactParameters(track, hfeimpactR, hfeimpactnsigmaR);
a8ef1999 1320 if(HasMCData())
1321 {
0e30407a 1322 if(mctrack && (TMath::Abs(mctrack->Particle()->GetPdgCode()) != 11)){
1323 fQACollection->Fill("hadronsBeforeIPcut",track->Pt());
1324 }
a8ef1999 1325 if(fMCQA && signal) {
8c1c76e9 1326
a8ef1999 1327 fMCQA->SetContainerStep(0);
8c1c76e9 1328 for(Int_t iLevel = 0; iLevel < kBgLevels; iLevel++){
1329 weightElecBgV0[iLevel] = fMCQA->GetWeightFactor(mctrack, iLevel); // positive:conversion e, negative: nonHFE
eeb1e952 1330 if(!fisNonHFEsystematics || IsPbPb())break;
8c1c76e9 1331 }
1332
1333 if(fisNonHFEsystematics){
1334 //Fill additional containers for electron source distinction
1335 elecSource = fMCQA->GetElecSource(mctrack->Particle());
1336 const Char_t *sourceName[kElecBgSpecies]={"Pion","Eta","Omega","Phi","EtaPrime","Rho"};
1337 const Char_t *levelName[kBgLevels]={"Best","Lower","Upper"};
1338 Int_t iName = 0;
1339 for(Int_t iSource = AliHFEmcQA::kPi0; iSource <= AliHFEmcQA::kGammaRho0; iSource++){
1340 if((iSource == AliHFEmcQA::kElse)||(iSource == AliHFEmcQA::kMisID)) continue;
1341 if(elecSource == iSource){
1342 for(Int_t iLevel = 0; iLevel < kBgLevels; iLevel++){
1343 if(weightElecBgV0[iLevel]>0) fVarManager->FillContainer(fContainer, Form("conversionElecs%s%s",sourceName[iName], levelName[iLevel]), 0, kFALSE, weightElecBgV0[iLevel]);
1344 else if(weightElecBgV0[iLevel]<0) fVarManager->FillContainer(fContainer, Form("mesonElecs%s%s",sourceName[iName], levelName[iLevel]), 0, kFALSE, -1*weightElecBgV0[iLevel]);
eeb1e952 1345 if(IsPbPb())break;
8c1c76e9 1346 }
1347 break;
1348 }
1349 iName++;
1350 if(iName == kElecBgSpecies)iName = 0;
1351 }
1352 }
1353 //else{
a8ef1999 1354 if(weightElecBgV0[0]>0) {
1355 fVarManager->FillContainer(fContainer, "conversionElecs", 0, kFALSE, weightElecBgV0[0]);
1356 fVarManager->FillContainer(fContainer, "conversionElecs", 5, kTRUE, weightElecBgV0[0]);
1357 }
1358 else if(weightElecBgV0[0]<0) {
1359 fVarManager->FillContainer(fContainer, "mesonElecs", 0, kFALSE, -1*weightElecBgV0[0]);
1360 fVarManager->FillContainer(fContainer, "mesonElecs", 5, kTRUE, -1*weightElecBgV0[0]);
1361 }
e17c1f86 1362 //}
1363 if(bTagged){ // bg estimation for the secondary vertex tagged signals
1364 if(weightElecBgV0[0]>0) fVarManager->FillContainer(fContainer, "conversionElecs", 2, kFALSE, weightElecBgV0[0]);
1365 else if(weightElecBgV0[0]<0) fVarManager->FillContainer(fContainer, "mesonElecs", 2, kFALSE, -1*weightElecBgV0[0]);
1366 }
8c1c76e9 1367 }
a8ef1999 1368 } // end of MC
1369
0e30407a 1370 dataDca[0]=-1; //for data, don't know the origin
a8ef1999 1371 dataDca[1]=track->Pt();
1372 dataDca[2]=hfeimpactR;
0e30407a 1373 dataDca[3]=fCentralityF;
1374 dataDca[4] = v0pid;
1375 dataDca[5] = double(track->Charge());
a8ef1999 1376 if (!HasMCData()) fQACollection->Fill("Dca", dataDca);
a8ef1999 1377
3a72645a 1378 // Fill Containers for impact parameter analysis
1379 if(!fCFM->CheckParticleCuts(AliHFEcuts::kStepHFEcutsDca + AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kNcutStepsRecTrack,track)) continue;
fd6b8522 1380 if(HasMCData()){
a8ef1999 1381 if(fMCQA && signal) {
1382 fMCQA->SetContainerStep(1);
8c1c76e9 1383 for(Int_t iLevel = 0; iLevel < kBgLevels; iLevel++){
1384 weightElecBgV0[iLevel] = fMCQA->GetWeightFactor(mctrack, iLevel); // positive:conversion e, negative: nonHFE
eeb1e952 1385 if(!fisNonHFEsystematics || IsPbPb())break;
8c1c76e9 1386 }
1387 if(fisNonHFEsystematics){
1388 //Fill additional containers for electron source distinction
1389 elecSource = fMCQA->GetElecSource(mctrack->Particle());
1390 const Char_t *sourceName[kElecBgSpecies]={"Pion","Eta","Omega","Phi","EtaPrime","Rho"};
1391 const Char_t *levelName[kBgLevels]={"Best","Lower","Upper"};
1392 Int_t iName = 0;
1393 for(Int_t iSource = AliHFEmcQA::kPi0; iSource <= AliHFEmcQA::kGammaRho0; iSource++){
1394 if((iSource == AliHFEmcQA::kElse)||(iSource == AliHFEmcQA::kMisID)) continue;
1395 if(elecSource == iSource){
1396 for(Int_t iLevel = 0; iLevel < kBgLevels; iLevel++){
1397 if(weightElecBgV0[iLevel]>0) fVarManager->FillContainer(fContainer, Form("conversionElecs%s%s",sourceName[iName], levelName[iLevel]), 1, kFALSE, weightElecBgV0[iLevel]);
1398 else if(weightElecBgV0[iLevel]<0) fVarManager->FillContainer(fContainer, Form("mesonElecs%s%s",sourceName[iName], levelName[iLevel]), 1, kFALSE, -1*weightElecBgV0[iLevel]);
eeb1e952 1399 if(IsPbPb())break;
8c1c76e9 1400 }
1401 break;
1402 }
1403 iName++;
1404 if(iName == kElecBgSpecies)iName = 0;
1405 }
1406 }
1407 // else{
a8ef1999 1408 if(weightElecBgV0[0]>0) {
1409 fVarManager->FillContainer(fContainer, "conversionElecs", 1, kFALSE, weightElecBgV0[0]);
1410 fVarManager->FillContainer(fContainer, "conversionElecs", 6, kTRUE, weightElecBgV0[0]);
1411 }
1412 else if(weightElecBgV0[0]<0) {
1413 fVarManager->FillContainer(fContainer, "mesonElecs", 1, kFALSE, -1*weightElecBgV0[0]);
1414 fVarManager->FillContainer(fContainer, "mesonElecs", 6, kTRUE, -1*weightElecBgV0[0]);
1415 }
8c1c76e9 1416 //}
1417 }
fd6b8522 1418 }
3a72645a 1419 if(signal) {
1420 fVarManager->FillContainer(fContainer, "recTrackContDEReco", AliHFEcuts::kStepHFEcutsDca, kFALSE);
1421 fVarManager->FillContainer(fContainer, "recTrackContDEMC", AliHFEcuts::kStepHFEcutsDca, kTRUE);
1422 fVarManager->FillCorrelationMatrix(fContainer->GetCorrelationMatrix("correlationstepafterDE"));
1423 }
1424 if(HasMCData()){
6555e2ad 1425 if(mctrack && (TMath::Abs(mctrack->Particle()->GetPdgCode()) != 11)){
6555e2ad 1426 fQACollection->Fill("hadronsAfterIPcut",track->Pt());
6555e2ad 1427 }
3a72645a 1428 }
1429 }
1430
dbe3abbe 1431 }
3a72645a 1432 fQACollection->Fill("nElectronTracksEvent", nElectronCandidates);
809a4336 1433}
1434
1435//____________________________________________________________
9bcfd1ab 1436void AliAnalysisTaskHFE::ProcessAOD(){
dbe3abbe 1437 //
9bcfd1ab 1438 // Run Analysis in AOD Mode
1439 // Function is still in development
dbe3abbe 1440 //
11ff28c5 1441 //printf("Process AOD\n");
9bcfd1ab 1442 AliDebug(3, "Processing AOD Event");
c2690925 1443 Double_t eventContainer[4];
eeb1e952 1444 eventContainer[0] = 0.0;
c2690925 1445 if(HasMCData()) eventContainer[0] = fVz;
1446 else {
eeb1e952 1447 if(fInputEvent->GetPrimaryVertex()) eventContainer[0] = fInputEvent->GetPrimaryVertex()->GetZ();
c2690925 1448 }
69ac0e6f 1449 eventContainer[1] = 1.; // No Information available in AOD analysis, assume all events have V0AND
bf892a6a 1450 eventContainer[2] = fCentralityF;
c2690925 1451 eventContainer[3] = fContributors;
bf892a6a 1452
11ff28c5 1453 //printf("value event container %f, %f, %f, %f\n",eventContainer[0],eventContainer[1],eventContainer[2],eventContainer[3]);
1454
d2af20c5 1455 AliAODEvent *fAOD = dynamic_cast<AliAODEvent *>(fInputEvent);
9bcfd1ab 1456 if(!fAOD){
13242232 1457 AliError("AOD Event required for AOD Analysis");
e156c3bb 1458 return;
9bcfd1ab 1459 }
3a72645a 1460
11ff28c5 1461 //printf("Will fill\n");
3a72645a 1462 //
1463 fCFM->GetEventContainer()->Fill(eventContainer, AliHFEcuts::kEventStepRecNoCut);
11ff28c5 1464 //printf("Fill\n");
3a72645a 1465 //
1466 if(fIdentifiedAsPileUp) return;
1467 fCFM->GetEventContainer()->Fill(eventContainer, AliHFEcuts::kEventStepRecNoPileUp);
1468
1469 //
1470 if(fIdentifiedAsOutInz) return;
1471 fCFM->GetEventContainer()->Fill(eventContainer, AliHFEcuts::kEventStepZRange);
1472
1473 //
1474 if(!fPassTheEventCut) return;
1475 fCFM->GetEventContainer()->Fill(eventContainer, AliHFEcuts::kEventStepReconstructed);
11ff28c5 1476 //printf("pass\n");
3a72645a 1477
1478 fContainer->NewEvent();
0e30407a 1479
6400afdd 1480 fCFM->SetRecEventInfo(fAOD);
1481
0e30407a 1482 // Look for kink mother
1483 Int_t numberofvertices = fAOD->GetNumberOfVertices();
1484 Double_t listofmotherkink[numberofvertices];
1485 Int_t numberofmotherkink = 0;
1486 for(Int_t ivertex=0; ivertex < numberofvertices; ivertex++) {
1487 AliAODVertex *aodvertex = fAOD->GetVertex(ivertex);
1488 if(!aodvertex) continue;
1489 if(aodvertex->GetType()==AliAODVertex::kKink) {
1490 AliAODTrack *mother = (AliAODTrack *) aodvertex->GetParent();
1491 if(!mother) continue;
1492 Int_t idmother = mother->GetID();
1493 listofmotherkink[numberofmotherkink] = idmother;
1494 //printf("ID %d\n",idmother);
1495 numberofmotherkink++;
1496 }
1497 }
1498 //printf("Number of kink mother in the events %d\n",numberofmotherkink);
1499
1500
1501 // Loop over tracks
9bcfd1ab 1502 AliAODTrack *track = NULL;
1503 AliAODMCParticle *mctrack = NULL;
70da6c5a 1504 Double_t dataE[6]; // [pT, eta, Phi, Charge, type, 'C' or 'B']
9bcfd1ab 1505 Int_t nElectronCandidates = 0;
1506 Int_t pid;
3a72645a 1507 Bool_t signal;
11ff28c5 1508 //printf("Number of track %d\n",(Int_t) fAOD->GetNumberOfTracks());
9bcfd1ab 1509 for(Int_t itrack = 0; itrack < fAOD->GetNumberOfTracks(); itrack++){
f9f097c0 1510 track = fAOD->GetTrack(itrack); mctrack = NULL;
9bcfd1ab 1511 if(!track) continue;
a86a8fda 1512 // Begining
1513 Bool_t passone = kFALSE;
1514 fQAAODCollection->Fill("Filterorigin", -1);
1515 for(Int_t k=0; k<20; k++) {
1516 Int_t u = 1<<k;
1517 if((track->TestFilterBit(u))) {
1518 fQAAODCollection->Fill("Filterorigin", k);
1519 passone = kTRUE;
1520 }
11ff28c5 1521 }
a86a8fda 1522 //if(!passone) printf("what is the filter %d\n",track->GetFilterMap());
9bcfd1ab 1523
a86a8fda 1524 if(fUseFilterAOD){
1525 //printf("Filter of the track %d\n",track->GetFilterMap());
1526 if(!(track->TestFilterBit(fFilter))) continue; // Only process AOD tracks where the HFE is set
1527 }
1528 //printf("Pass the flag\n");
1529
3a72645a 1530 signal = kTRUE;
9bcfd1ab 1531 if(HasMCData()){
faee3b18 1532
9bcfd1ab 1533 Int_t label = TMath::Abs(track->GetLabel());
7ea7b2c4 1534 if(label && label < fAODArrayMCInfo->GetEntriesFast())
1535 mctrack = dynamic_cast<AliAODMCParticle *>(fAODArrayMCInfo->At(label));
3a72645a 1536 if(fFillSignalOnly && !fCFM->CheckParticleCuts(AliHFEcuts::kStepMCGenerated, mctrack)) signal = kFALSE;
9bcfd1ab 1537 }
7ea7b2c4 1538 fVarManager->NewTrack(track, mctrack, fCentralityF, -1, signal);
11ff28c5 1539
1540 if(fFillNoCuts) {
1541 if(signal || !fFillSignalOnly){
1542 fVarManager->FillContainer(fContainer, "recTrackContReco", AliHFEcuts::kStepRecNoCut, kFALSE);
1543 fVarManager->FillContainer(fContainer, "recTrackContMC", AliHFEcuts::kStepRecNoCut, kTRUE);
1544 }
1545 }
1546
1547 if(fApplyCutAOD) {
a86a8fda 1548 //printf("Apply cuts\n");
11ff28c5 1549 // RecKine: ITSTPC cuts
1550 if(!ProcessCutStep(AliHFEcuts::kStepRecKineITSTPC, track)) continue;
0e30407a 1551
1552 // Reject kink mother
1553 Bool_t kinkmotherpass = kTRUE;
1554 for(Int_t kinkmother = 0; kinkmother < numberofmotherkink; kinkmother++) {
1555 if(track->GetID() == listofmotherkink[kinkmother]) {
1556 kinkmotherpass = kFALSE;
1557 continue;
1558 }
1559 }
1560 if(!kinkmotherpass) continue;
11ff28c5 1561
1562 // RecPrim
1563 if(!ProcessCutStep(AliHFEcuts::kStepRecPrim, track)) continue;
1564
1565 // HFEcuts: ITS layers cuts
1566 if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsITS, track)) continue;
1567
1568 // HFE cuts: TOF PID and mismatch flag
1569 if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsTOF, track)) continue;
1570
1571 // HFE cuts: TPC PID cleanup
1572 if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsTPC, track)) continue;
1573
1574 // HFEcuts: Nb of tracklets TRD0
1575 if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsTRD, track)) continue;
1576 }
1577
1578 // Fill correlation maps before PID
1579 if(signal && fContainer->GetCorrelationMatrix("correlationstepbeforePID")) {
1580 //printf("Fill correlation maps before PID\n");
1581 fVarManager->FillCorrelationMatrix(fContainer->GetCorrelationMatrix("correlationstepbeforePID"));
1582 }
1583
1584 //printf("Will process to PID\n");
1585
9bcfd1ab 1586 // track accepted, do PID
1587 AliHFEpidObject hfetrack;
3a72645a 1588 hfetrack.SetAnalysisType(AliHFEpidObject::kAODanalysis);
1589 hfetrack.SetRecTrack(track);
1590 if(HasMCData()) hfetrack.SetMCTrack(mctrack);
1591 hfetrack.SetCentrality(fCentralityF);
11ff28c5 1592 if(IsPbPb()) hfetrack.SetPbPb();
1593 else hfetrack.SetPP();
3a72645a 1594 fPID->SetVarManager(fVarManager);
1595 if(!fPID->IsSelected(&hfetrack, fContainer, "recTrackCont", fPIDqa)) continue; // we will do PID here as soon as possible
c2690925 1596
a86a8fda 1597 // end AOD QA
1598 fQAAODCollection->Fill("Filterend", -1);
1599 for(Int_t k=0; k<20; k++) {
1600 Int_t u = 1<<k;
1601 if((track->TestFilterBit(u))) {
1602 fQAAODCollection->Fill("Filterend", k);
1603 }
1604 }
1605
11ff28c5 1606 // Apply weight for background contamination
1607 //Double_t weightBackGround = 1.0;
1608 if(signal) {
1609 // Apply weight for background contamination
1610 if(fBackGroundFactorApply) {
1611 if(IsPbPb() && fCentralityF >= 0) fWeightBackGround = fkBackGroundFactorArray[fCentralityF >= 0 ? fCentralityF : 0]->Eval(TMath::Abs(track->P()));
1612 else fWeightBackGround = fkBackGroundFactorArray[0]->Eval(TMath::Abs(track->P())); // pp case
1613
1614 if(fWeightBackGround < 0.0) fWeightBackGround = 0.0;
1615 else if(fWeightBackGround > 1.0) fWeightBackGround = 1.0;
1616 // weightBackGround as special weight
1617 fVarManager->FillContainer(fContainer, "hadronicBackground", 1, kFALSE, fWeightBackGround);
1618 }
1619 fVarManager->FillCorrelationMatrix(fContainer->GetCorrelationMatrix("correlationstepafterPID"));
e3fc062d 1620 }
11ff28c5 1621
9bcfd1ab 1622 nElectronCandidates++;
1623 if(HasMCData()){
3a72645a 1624 dataE[0] = track->Pt();
1625 dataE[1] = track->Eta();
1626 dataE[2] = track->Phi();
1627 dataE[3] = track->Charge();
1628 dataE[4] = -1;
1629 dataE[5] = -1;
c2690925 1630 // Track selected: distinguish between true and fake
f9f097c0 1631 AliDebug(1, Form("Candidate Selected, filling THnSparse, PID: %d\n", mctrack ? mctrack->GetPdgCode(): -1));
1632 if(mctrack && ((pid = TMath::Abs(mctrack->GetPdgCode())) == 11)){
3a72645a 1633
1634 Int_t type = 0;
1635 if(fSignalCuts->IsCharmElectron(track))
1636 type = 1;
1637 else if(fSignalCuts->IsBeautyElectron(track))
1638 type = 2;
9bcfd1ab 1639 AliDebug(1, Form("Type: %d\n", type));
1640 if(type){
8c1c76e9 1641 dataE[5] = type; // beauty[1] or charm[2]
1642 dataE[4] = 2; // signal electron
9bcfd1ab 1643 }
1644 else{
8c1c76e9 1645 dataE[4] = 1; // not a signal electron
1646 dataE[5] = 0;
9bcfd1ab 1647 }
1648 }
1649 else {
1650 // Fill THnSparse with the information for Fake Electrons
9bcfd1ab 1651 dataE[4] = 0;
70da6c5a 1652 dataE[5] = 0;
9bcfd1ab 1653 }
1654 // fill the performance THnSparse, if the mc origin could be defined
70da6c5a 1655 if(dataE[4] > -1){
1656 AliDebug(1, Form("Entries: [%.3f|%.3f|%.3f|%f|%f|%f]\n", dataE[0],dataE[1],dataE[2],dataE[3],dataE[4],dataE[5]));
3a72645a 1657 fQACollection->Fill("PIDperformance", dataE);
9bcfd1ab 1658 }
6ad05e72 1659 }
6ad05e72 1660 }
3a72645a 1661 fQACollection->Fill("nElectronTracksEvent", nElectronCandidates);
6ad05e72 1662}
1663
1664//____________________________________________________________
9bcfd1ab 1665Bool_t AliAnalysisTaskHFE::ProcessMCtrack(AliVParticle *track){
6ad05e72 1666 //
9bcfd1ab 1667 // Filter the Monte Carlo Track
1668 // Additionally Fill a THnSparse for Signal To Background Studies
1669 // Works for AOD and MC analysis Type
6ad05e72 1670 //
c2690925 1671 fVarManager->NewTrack(track, NULL, fCentralityF, -1, kTRUE);
3a72645a 1672 Double_t signalContainer[6];
9bcfd1ab 1673
3a72645a 1674 signalContainer[0] = track->Pt();
1675 signalContainer[1] = track->Eta();
1676 signalContainer[2] = track->Phi();
1677 signalContainer[3] = track->Charge()/3;
9bcfd1ab 1678
965de368 1679 Double_t vertex[3] = {0.,0.,0.}; // Production vertex cut to mask gammas which are NOT supposed to have hits in the first ITS layer(s)
3a72645a 1680 if(IsESDanalysis()){
1681 AliMCParticle *mctrack = dynamic_cast<AliMCParticle *>(track);
bf892a6a 1682 if(mctrack){
1683 vertex[0] = mctrack->Particle()->Vx();
1684 vertex[1] = mctrack->Particle()->Vy();
1685 }
9bcfd1ab 1686 } else {
1687 AliAODMCParticle *aodmctrack = dynamic_cast<AliAODMCParticle *>(track);
bf892a6a 1688 if(aodmctrack) aodmctrack->XvYvZv(vertex);
6ad05e72 1689 }
3a72645a 1690
7ea7b2c4 1691 //printf("MC Generated\n");
3a72645a 1692 if(!fCFM->CheckParticleCuts(AliHFEcuts::kStepMCGenerated, track)) return kFALSE;
7ea7b2c4 1693 //printf("MC Generated pass\n");
3a72645a 1694 fVarManager->FillContainer(fContainer, "MCTrackCont", AliHFEcuts::kStepMCGenerated, kFALSE);
1695 signalContainer[4] = 0;
1696 if(fSignalCuts->IsSelected(track)){
1697 //fVarManager->FillContainer(fContainer, "MCTrackCont", AliHFEcuts::kStepMCsignal, kFALSE);
1698 // Filling of the Signal/Background histogram using the
1699 // definition of the codes for charm and beauty as below in
1700 // th crearion of the histogram
1701 if(fSignalCuts->IsCharmElectron(track))
1702 signalContainer[4] = 1;
1703 else
1704 signalContainer[4] = 2;
1705 } else {
1706 signalContainer[4] = 0; // (and other background)
1707 }
70da6c5a 1708 signalContainer[5] = 0;
9bcfd1ab 1709 // apply cut on the sqrt of the production vertex
1710 Double_t radVertex = TMath::Sqrt(vertex[0]*vertex[0] + vertex[1] * vertex[1]);
1711 if(radVertex < 3.5){
1712 // Within first ITS layer(2) -> Background we cannot reject by ITS cut, let it pass
70da6c5a 1713 signalContainer[5] = 1;
9bcfd1ab 1714 } else if (radVertex < 7.5){
70da6c5a 1715 signalContainer[5] = 2;
9bcfd1ab 1716 }
3a72645a 1717 fQACollection->Fill("SignalToBackgroundMC", signalContainer);
3a72645a 1718
1719 // Step GeneratedZOutNoPileUp
e156c3bb 1720 if((fIdentifiedAsPileUp) || (TMath::Abs(fVz) > fCuts->GetVertexRange()) || (fCentralityF < 0)) return kFALSE;
c2690925 1721 fVarManager->FillContainer(fContainer, "MCTrackCont", AliHFEcuts::kStepMCGeneratedZOutNoPileUpCentralityFine, kFALSE);
1722 //printf("In ProcessMCtrack %f\n",fCentralityF);
3a72645a 1723
1724 // Step Generated Event Cut
1725 if(!fPassTheEventCut) return kFALSE;
1726 fVarManager->FillContainer(fContainer, "MCTrackCont", AliHFEcuts::kStepMCGeneratedEventCut, kFALSE);
1727
1728 if(!fCFM->CheckParticleCuts(AliHFEcuts::kStepMCInAcceptance, track)) return kFALSE;
1729 fVarManager->FillContainer(fContainer, "MCTrackCont", AliHFEcuts::kStepMCInAcceptance, kFALSE);
9bcfd1ab 1730 return kTRUE;
6ad05e72 1731}
1732
e3fc062d 1733//____________________________________________________________
1734Bool_t AliAnalysisTaskHFE::PreSelectTrack(AliESDtrack *track) const {
1735 //
1736 // Preselect tracks
1737 //
1738
1739
1740 Bool_t survived = kTRUE;
1741
1742 if(!fCutspreselect->CheckParticleCuts(AliHFEcuts::kStepRecKineITSTPC, track)) {
1743 survived = kFALSE;
1744 //printf("Did not pass AliHFEcuts::kStepRecKineITSTPC\n");
1745 }
1746 //else printf("Pass AliHFEcuts::kStepRecKineITSTPC\n");
1747 if(!fCutspreselect->CheckParticleCuts(AliHFEcuts::kStepRecPrim, track)) {
1748 survived = kFALSE;
1749 //printf("Did not pass AliHFEcuts::kStepRecPrim\n");
1750 }
1751 //else printf("Pass AliHFEcuts::kStepRecPrim\n");
1752 if(!fCutspreselect->CheckParticleCuts(AliHFEcuts::kStepHFEcutsITS, track)) {
1753 survived = kFALSE;
1754 //printf("Did not pass AliHFEcuts::kStepHFEcutsITS\n");
1755 }
1756 //else printf("Pass AliHFEcuts::kStepHFEcutsITS\n");
fd6b8522 1757 if(!fCutspreselect->CheckParticleCuts(AliHFEcuts::kStepHFEcutsTOF, track)) {
1758 survived = kFALSE;
1759 //printf("Did not pass AliHFEcuts::kStepHFEcutsTOF\n");
1760 }
1761 //else printf("Pass AliHFEcuts::kStepHFEcutsTOF\n");
e3fc062d 1762 if(!fCutspreselect->CheckParticleCuts(AliHFEcuts::kStepHFEcutsTRD, track)) {
1763 survived = kFALSE;
1764 //printf("Did not pass AliHFEcuts::kStepHFEcutsTRD\n");
1765 }
1766 //else printf("Pass AliHFEcuts::kStepHFEcutsTRD\n");
1767
1768 if(survived){
1769 // Apply PID
1770 AliHFEpidObject hfetrack;
3a72645a 1771 hfetrack.SetAnalysisType(AliHFEpidObject::kESDanalysis);
1772 hfetrack.SetRecTrack(track);
e3fc062d 1773 if(!fPIDpreselect->IsSelected(&hfetrack)) {
1774 //printf("Did not pass AliHFEcuts::kPID\n");
1775 survived = kFALSE;
1776 }
1777 //else printf("Pass AliHFEcuts::kPID\n");
1778 }
1779
1780 return survived;
1781
1782}
70da6c5a 1783//____________________________________________________________
1784void AliAnalysisTaskHFE::MakeEventContainer(){
1785 //
1786 // Create the event container for the correction framework and link it
3a72645a 1787 // 1st bin: Vertex z-position
1788 // 2nd bin: V0AND decision (normalization to sigma_inel)
c2690925 1789 // 3rd bin: Centrality class (for pp defined as number of contributors in vertex.)
8c1c76e9 1790 // 4th bin: Number of contributors > 0
70da6c5a 1791 //
c2690925 1792
8c1c76e9 1793 const Int_t kNvar = 4; // number of variables on the grid:
1794 Int_t nBins[kNvar] = {120, 2, 11, 2};
1795 Double_t binMin[kNvar] = {-30. , 0., 0.0, 0.};
1796 Double_t binMax[kNvar] = {30., 2., 11.0, 2.};
1797
1798 AliCFContainer *evCont = new AliCFContainer("eventContainer", "Container for events", AliHFEcuts::kNcutStepsEvent, kNvar, nBins);
c2690925 1799
8c1c76e9 1800 Double_t *vertexBins = AliHFEtools::MakeLinearBinning(nBins[0], binMin[0], binMax[0]);
1801 Double_t *v0andBins = AliHFEtools::MakeLinearBinning(nBins[1], binMin[1], binMax[1]);
1802 Double_t *centralityBins = AliHFEtools::MakeLinearBinning(nBins[2], binMin[2], binMax[2]);
1803 Double_t *contributorsBins = AliHFEtools::MakeLinearBinning(nBins[3], binMin[3], binMax[3]);
1804 evCont->SetBinLimits(0, vertexBins);
1805 evCont->SetBinLimits(1, v0andBins);
1806 evCont->SetBinLimits(2, centralityBins);
1807 evCont->SetBinLimits(3, contributorsBins);
1808 delete[] vertexBins; delete[] v0andBins; delete[] centralityBins; delete[] contributorsBins;
1809
1810 fCFM->SetEventContainer(evCont);
70da6c5a 1811}
1812
809a4336 1813//____________________________________________________________
1814void AliAnalysisTaskHFE::MakeParticleContainer(){
1815 //
1816 // Create the particle container for the correction framework manager and
1817 // link it
1818 //
3a72645a 1819 if(!fContainer) fContainer = new AliHFEcontainer("trackContainer");
1820 fVarManager->DefineVariables(fContainer);
1821
1822 // Create Correction Framework containers
1823 fContainer->CreateContainer("MCTrackCont", "Track Container filled with MC information", AliHFEcuts::kNcutStepsMCTrack);
1824 fContainer->CreateContainer("recTrackContReco", "Track Container filled with MC information", AliHFEcuts::kNcutStepsRecTrack + fPID->GetNumberOfPIDdetectors());
1825 fContainer->CreateContainer("recTrackContMC", "Track Container filled with MC information", AliHFEcuts::kNcutStepsRecTrack + fPID->GetNumberOfPIDdetectors());
1826
c2690925 1827 fContainer->CreateContainer("hadronicBackground", "Container for Hadronic Background", 2);
3a72645a 1828 fContainer->CreateContainer("recTrackContDEReco", "Container for displaced electron analysis with Reco information", 1);
1829 fContainer->CreateContainer("recTrackContDEMC", "Container for displaced electron analysis with MC information", 1);
c2690925 1830 fContainer->CreateContainer("recTrackContSecvtxReco", "Container for secondary vertexing analysis with Reco information", 1);
1831 fContainer->CreateContainer("recTrackContSecvtxMC", "Container for secondary vertexing analysis with MC information", 1);
fd6b8522 1832
1833 if(HasMCData()){
a8ef1999 1834 fContainer->CreateContainer("conversionElecs", "Container for weighted conversion electrons",7);
1835 fContainer->CreateContainer("mesonElecs", "Container for weighted electrons from meson decays",7);
e17c1f86 1836 fContainer->Sumw2("conversionElecs");
1837 fContainer->Sumw2("mesonElecs");
8c1c76e9 1838
1839 if(fisNonHFEsystematics){
1840 const Char_t *sourceName[kElecBgSpecies]={"Pion","Eta","Omega","Phi","EtaPrime","Rho"};
1841 const Char_t *levelName[kBgLevels]={"Best","Lower","Upper"};
1842 for(Int_t iSource = 0; iSource < kElecBgSpecies; iSource++){
1843 for(Int_t iLevel = 0; iLevel < kBgLevels; iLevel++){
eeb1e952 1844 fContainer->CreateContainer(Form("conversionElecs%s%s",sourceName[iSource],levelName[iLevel]), Form("Container for weighted conversion electrons from %s grandm., %s level",sourceName[iSource],levelName[iLevel]),5);
1845 fContainer->CreateContainer(Form("mesonElecs%s%s",sourceName[iSource],levelName[iLevel]), Form("Container for weighted electrons from %s decays, %s level",sourceName[iSource],levelName[iLevel]),5);
e17c1f86 1846 fContainer->Sumw2(Form("conversionElecs%s%s",sourceName[iSource],levelName[iLevel]));
1847 fContainer->Sumw2(Form("mesonElecs%s%s",sourceName[iSource],levelName[iLevel]));
eeb1e952 1848 if(IsPbPb())break;
8c1c76e9 1849 }
1850 }
1851 }
fd6b8522 1852 //fContainer->CreateContainer("charmElecs", "Container for weighted charm electrons",2);
1853 }
1854
3a72645a 1855 fContainer->CreateCorrelationMatrix("correlationstepafterPID","THnSparse with correlations");
1856 fContainer->CreateCorrelationMatrix("correlationstepafterDE","THnSparse with correlations");
6555e2ad 1857 if(!fVarManager->IsVariableDefined("centrality")) {
1858 //printf("Create the two other correlation maps\n");
1859 fContainer->CreateCorrelationMatrix("correlationstepbeforePID","THnSparse with correlations");
1860 fContainer->CreateCorrelationMatrix("correlationstepafterTOF","THnSparse with correlations");
1861 }
3a72645a 1862
1863 // Define the step names
1864 for(UInt_t istep = 0; istep < AliHFEcuts::kNcutStepsMCTrack; istep++){
1865 fContainer->SetStepTitle("MCTrackCont", AliHFEcuts::MCCutName(istep), istep);
faee3b18 1866 }
3a72645a 1867 for(UInt_t istep = 0; istep < AliHFEcuts::kNcutStepsRecTrack; istep++){
1868 fContainer->SetStepTitle("recTrackContReco", AliHFEcuts::RecoCutName(istep), istep);
1869 fContainer->SetStepTitle("recTrackContMC", AliHFEcuts::RecoCutName(istep), istep);
259c3296 1870 }
3a72645a 1871 for(UInt_t ipid = 0; ipid < fPID->GetNumberOfPIDdetectors(); ipid++){
1872 fContainer->SetStepTitle("recTrackContReco", fPID->SortedDetectorName(ipid), AliHFEcuts::kNcutStepsRecTrack + ipid);
1873 fContainer->SetStepTitle("recTrackContMC", fPID->SortedDetectorName(ipid), AliHFEcuts::kNcutStepsRecTrack + ipid);
259c3296 1874 }
3a72645a 1875}
1876
1877//____________________________________________________________
1878void AliAnalysisTaskHFE::InitPIDperformanceQA(){
259c3296 1879 // Add a histogram for Fake electrons
70da6c5a 1880 const Int_t nDim=6;
1881 Int_t nBin[nDim] = {40, 8, 18, 2, 3, 3};
3a72645a 1882 //number of variables on the grid:pt,eta,phi,charge,
1883 const Double_t kPtbound[2] = {0.1, 20.};
1884 const Double_t kEtabound[2] = {-0.8, 0.8};
1885 const Double_t kPhibound[2] = {0., 2. * TMath::Pi()};
1886 const Double_t kChargebound[2] = {-1.1, 1.1};
1887 const Double_t kAddInf1bound[2] = {0., 3.};
1888 const Double_t kAddInf2bound[2] = {0., 3.};
1889 Double_t minima[nDim] = {kPtbound[0], kEtabound[0], kPhibound[0], kChargebound[0], kAddInf1bound[0], kAddInf2bound[0]};
1890 Double_t maxima[nDim] = {kPtbound[1], kEtabound[1], kPhibound[1], kChargebound[1], kAddInf1bound[1], kAddInf2bound[1]};
1891
1892 fQACollection->CreateTHnSparse("PIDperformance", "PID performance; pT [GeV/c]; theta [rad]; phi [rad]; charge; type (0 - not el, 1 - other el, 2 - HF el; flavor (0 - no, 1 - charm, 2 - bottom)", nDim, nBin, minima, maxima);
1893 fQACollection->CreateTHnSparse("SignalToBackgroundMC", "PID performance; pT [GeV/c]; theta [rad]; phi [rad]; charge; flavor (0 - no, 1 - charm, 2 - bottom); ITS Cluster (0 - no, 1 - first (and maybe second), 2 - second)", nDim, nBin, minima, maxima);
dbe3abbe 1894
3a72645a 1895 fQACollection->BinLogAxis("PIDperformance", 0);
1896 fQACollection->BinLogAxis("SignalToBackgroundMC", 0);
1897 fQACollection->Sumw2("PIDperformance");
1898 fQACollection->Sumw2("SignalToBackgroundMC");
75d81601 1899}
1900
6555e2ad 1901//____________________________________________________________
1902void AliAnalysisTaskHFE::InitContaminationQA(){
c2690925 1903 //
1904 // Add QA for Impact Parameter cut
1905 //
a8ef1999 1906
1907 TObjArray *array = fVarManager->GetVariables();
1908 Int_t nvars = array->GetEntriesFast();
1909 for(Int_t v = 0; v < nvars; v++) {
1910 AliHFEvarManager::AliHFEvariable *variable = (AliHFEvarManager::AliHFEvariable *) array->At(v);
1911 if(!variable) continue;
1912 TString name(((AliHFEvarManager::AliHFEvariable *)variable)->GetName());
1913 if(!name.CompareTo("pt")) {
1914 const Int_t nBinPt = variable->GetNumberOfBins();
1915 const Double_t *kPtRange = variable->GetBinning();
1916
1917 fQACollection->CreateTH1Farray("hadronsBeforeIPcut", "Hadrons before IP cut", nBinPt, kPtRange);
1918 fQACollection->CreateTH1Farray("hadronsAfterIPcut", "Hadrons after IP cut", nBinPt, kPtRange);
a8ef1999 1919
1920 fQACollection->CreateTH2Farray("Ke3Kecorr", "Ke3 decay e and K correlation; Ke3K p_{t}; Ke3e p_{t}; ", nBinPt, kPtRange, 20,0.,20.);
1921 fQACollection->CreateTH2Farray("Ke3K0Lecorr", "Ke3 decay e and K0L correlation; Ke3K0L p_{t}; Ke3e p_{t}; ", nBinPt, kPtRange, 20,0.,20.);
1922 fQACollection->CreateTH1Farray("Kptspectra", "Charged Kaons: MC p_{t} ", nBinPt, kPtRange);
1923 fQACollection->CreateTH1Farray("K0Lptspectra", "K0L: MC p_{t} ", nBinPt, kPtRange);
1924
0e30407a 1925 const Double_t kDCAbound[2] = {-0.2, 0.2};
a8ef1999 1926
0e30407a 1927 const Int_t nDimDca=6;
1928 const Int_t nBinDca[nDimDca] = { 8, nBinPt, 800, 12, 6, 2};
1929 Double_t minimaDca[nDimDca] = { -1., 0., kDCAbound[0], -1., -1, -1.1};
1930 Double_t maximaDca[nDimDca] = { 7., 20., kDCAbound[1], 11., 5, 1.1};
a8ef1999 1931
1932 Double_t *sourceBins = AliHFEtools::MakeLinearBinning(nBinDca[0], minimaDca[0], maximaDca[0]);
1933 Double_t *dcaBins = AliHFEtools::MakeLinearBinning(nBinDca[2], minimaDca[2], maximaDca[2]);
0e30407a 1934 Double_t *centralityBins = AliHFEtools::MakeLinearBinning(nBinDca[3], minimaDca[3], maximaDca[3]);
1935 Double_t *v0PIDBins = AliHFEtools::MakeLinearBinning(nBinDca[4], minimaDca[4], maximaDca[4]);
1936 Double_t *chargeBins = AliHFEtools::MakeLinearBinning(nBinDca[5], minimaDca[5], maximaDca[5]);
a8ef1999 1937
0e30407a 1938 fQACollection->CreateTHnSparseNoLimits("Dca", "Dca; source (0-all, 1-charm,etc); pT [GeV/c]; dca; centrality bin; v0pid; charge", nDimDca, nBinDca);
a8ef1999 1939 ((THnSparse*)(fQACollection->Get("Dca")))->SetBinEdges(0, sourceBins);
1940 ((THnSparse*)(fQACollection->Get("Dca")))->SetBinEdges(1, kPtRange);
1941 ((THnSparse*)(fQACollection->Get("Dca")))->SetBinEdges(2, dcaBins);
0e30407a 1942 ((THnSparse*)(fQACollection->Get("Dca")))->SetBinEdges(3, centralityBins);
1943 ((THnSparse*)(fQACollection->Get("Dca")))->SetBinEdges(4, v0PIDBins);
1944 ((THnSparse*)(fQACollection->Get("Dca")))->SetBinEdges(5, chargeBins);
a8ef1999 1945
1946 break;
1947 }
1948 }
1949
8c1c76e9 1950}
1951
1952//____________________________________________________________
1953void AliAnalysisTaskHFE::InitHistoITScluster(){
1954 //
1955 // Initialize a temporary histogram to monitor the chi2/ITS cluster
1956 if(IsPbPb()) {
1957 const Int_t kNDim = 7;
1958 const Int_t kNBins[kNDim] = {88, 20,90,11, 160, 2, 1000};
1959 const Double_t kMin[kNDim] = {0.1, -1,0, 0.,0., 0, 0.};
1960 const Double_t kMax[kNDim] = {20., 1, 2.*TMath::Pi(), 11.,160, 2, 100.};
1961 fQACollection->CreateTHnSparse("fChi2perITScluster", "chi2/ITS cluster; p_{T} (GeV/c);eta;phi; centrality class;nclus;sharebit; #chi^{2}/ITS cluster", kNDim, kNBins, kMin, kMax);
1962 fQACollection->BinLogAxis("fChi2perITScluster", 0);
1963 }
1964 else
1965 {
1966 const Int_t kNDim = 3;
1967 const Int_t kNBins[kNDim] = {44, 11, 1000};
1968 const Double_t kMin[kNDim] = {0.1, 0., 0.};
1969 const Double_t kMax[kNDim] = {20., 11., 100.};
1970 fQACollection->CreateTHnSparse("fChi2perITScluster", "chi2/ITS cluster; p_{T} (GeV/c); centrality class; #chi^{2}/ITS cluster", kNDim, kNBins, kMin, kMax);
1971 fQACollection->BinLogAxis("fChi2perITScluster", 0);
1972 }
1973}
1974
1975//____________________________________________________________
1976void AliAnalysisTaskHFE::SelectSpecialTrigger(const Char_t *trgclust, Int_t runMin, Int_t runMax){
1977 //
1978 // Select only events triggered by a special trigeer cluster
1979 //
1980 if(!fSpecialTrigger) fSpecialTrigger = new AliOADBContainer("SpecialTrigger");
1981 fSpecialTrigger->AppendObject(new TObjString(trgclust), runMin, runMax);
1982}
1983
1984//____________________________________________________________
1985const Char_t * AliAnalysisTaskHFE::GetSpecialTrigger(Int_t run){
1986 //
1987 // Derive selected trigger string for given run
1988 //
1989 if(!fSpecialTrigger) return NULL;
1990 TObjString *trg = dynamic_cast<TObjString *>(fSpecialTrigger->GetObject(run));
1991 if(!trg) return NULL;
1992 return trg->String().Data();
6555e2ad 1993}
1994
75d81601 1995//____________________________________________________________
50685501 1996void AliAnalysisTaskHFE::PrintStatus() const {
78ea5ef4 1997 //
1998 // Print Analysis status
1999 //
75d81601 2000 printf("\n\tAnalysis Settings\n\t========================================\n\n");
9bcfd1ab 2001 printf("\tSecondary Vertex finding: %s\n", GetPlugin(kSecVtx) ? "YES" : "NO");
2002 printf("\tPrimary Vertex resolution: %s\n", GetPlugin(kPriVtx) ? "YES" : "NO");
3a72645a 2003 printf("\tDisplaced electron analysis step: %s\n", GetPlugin(kDEstep) ? "YES" : "NO");
2004 printf("\tTagged Track Analysis: %s\n", GetPlugin(kTaggedTrackAnalysis) ? "YES" : "NO");
75d81601 2005 printf("\n");
2006 printf("\tParticle Identification Detectors:\n");
3a72645a 2007 fPID->PrintStatus();
75d81601 2008 printf("\n");
2009 printf("\tQA: \n");
2010 printf("\t\tPID: %s\n", IsQAOn(kPIDqa) ? "YES" : "NO");
e3fc062d 2011 printf("\t\tCUTS: %s\n", (fCuts != NULL && fCuts->IsQAOn()) ? "YES" : "NO");
75d81601 2012 printf("\t\tMC: %s\n", IsQAOn(kMCqa) ? "YES" : "NO");
2013 printf("\n");
2014}
78ea5ef4 2015
faee3b18 2016//____________________________________________________________
2017Bool_t AliAnalysisTaskHFE::FillProductionVertex(const AliVParticle * const track) const{
2018 //
2019 // Find the production vertex of the associated MC track
2020 //
2021 if(!fMCEvent) return kFALSE;
2022 const AliVParticle *mctrack = NULL;
2023 TString objectType = track->IsA()->GetName();
2024 if(objectType.CompareTo("AliESDtrack") == 0 || objectType.CompareTo("AliAODTrack") == 0){
2025 // Reconstructed track
2026 mctrack = fMCEvent->GetTrack(TMath::Abs(track->GetLabel()));
2027 } else {
2028 // MCParticle
2029 mctrack = track;
2030 }
2031
2032 if(!mctrack) return kFALSE;
2033
2034 Double_t xv = 0.0;
2035 Double_t yv = 0.0;
2036
2037 if(TString(mctrack->IsA()->GetName()).CompareTo("AliMCParticle") == 0){
2038 // case MCParticle
bf892a6a 2039 const AliMCParticle *mcpart = dynamic_cast<const AliMCParticle *>(mctrack);
2040 if(mcpart){
2041 xv = mcpart->Xv();
2042 yv = mcpart->Yv();
2043 }
faee3b18 2044 } else {
2045 // case AODMCParticle
bf892a6a 2046 const AliAODMCParticle *mcpart = dynamic_cast<const AliAODMCParticle *>(mctrack);
2047 if(mcpart){
2048 xv = mcpart->Xv();
2049 yv = mcpart->Yv();
2050 }
faee3b18 2051 }
2052
2053 //printf("xv %f, yv %f\n",xv,yv);
69ac0e6f 2054 fQACollection->Fill("radius", TMath::Abs(xv),TMath::Abs(yv));
faee3b18 2055
2056 return kTRUE;
2057
2058}
9bcfd1ab 2059//__________________________________________
2060void AliAnalysisTaskHFE::SwitchOnPlugin(Int_t plug){
2061 //
2062 // Switch on Plugin
2063 // Available:
2064 // - Primary vertex studies
2065 // - Secondary vertex Studies
2066 // - Post Processing
2067 //
2068 switch(plug){
2069 case kPriVtx: SETBIT(fPlugins, plug); break;
2070 case kSecVtx: SETBIT(fPlugins, plug); break;
2071 case kIsElecBackGround: SETBIT(fPlugins, plug); break;
2072 case kPostProcess: SETBIT(fPlugins, plug); break;
3a72645a 2073 case kDEstep: SETBIT(fPlugins, plug); break;
2074 case kTaggedTrackAnalysis: SETBIT(fPlugins, plug); break;
9bcfd1ab 2075 default: AliError("Unknown Plugin");
2076 };
2077}
9bcfd1ab 2078//__________________________________________
3a72645a 2079Bool_t AliAnalysisTaskHFE::ProcessCutStep(Int_t cutStep, AliVParticle *track){
9bcfd1ab 2080 //
2081 // Check single track cuts for a given cut step
2082 // Fill the particle container
2083 //
3a72645a 2084 const Int_t kMCOffset = AliHFEcuts::kNcutStepsMCTrack;
2085 if(!fCFM->CheckParticleCuts(cutStep + kMCOffset, track)) return kFALSE;
2086 if(fVarManager->IsSignalTrack()) {
2087 fVarManager->FillContainer(fContainer, "recTrackContReco", cutStep, kFALSE);
2088 fVarManager->FillContainer(fContainer, "recTrackContMC", cutStep, kTRUE);
9bcfd1ab 2089 }
2090 return kTRUE;
2091}
3a72645a 2092//___________________________________________________
c2690925 2093Bool_t AliAnalysisTaskHFE::ReadCentrality() {
3a72645a 2094 //
2095 // Recover the centrality of the event from ESD or AOD
2096 //
11ff28c5 2097
2098 Float_t fCentralityLimitstemp[12];
2099 Float_t fCentralityLimitsdefault[12]= {0.,5.,10., 20., 30., 40., 50., 60.,70.,80., 90., 100.};
2100 if(!fPbPbUserCentralityBinning) memcpy(fCentralityLimitstemp,fCentralityLimitsdefault,sizeof(fCentralityLimitsdefault));
2101 else memcpy(fCentralityLimitstemp,fCentralityLimits,sizeof(fCentralityLimitsdefault));
2102
2103
e156c3bb 2104 Int_t bin = -1;
2105 if(IsPbPb()) {
2106 // Centrality
2107 AliCentrality *centrality = fInputEvent->GetCentrality();
11ff28c5 2108 fCentralityPercent = centrality->GetCentralityPercentile("V0M");
2109 //printf("centrality %f\n",fCentralityPercent);
2110
e156c3bb 2111 for(Int_t ibin = 0; ibin < 11; ibin++){
11ff28c5 2112 if(fCentralityPercent >= fCentralityLimitstemp[ibin] && fCentralityPercent < fCentralityLimitstemp[ibin+1]){
2113 bin = ibin;
2114 //printf("test bin %f, low %f, high %f, %d\n",fCentralityPercent,fCentralityLimitstemp[ibin],fCentralityLimitstemp[ibin+1],ibin);
e156c3bb 2115 break;
2116 }
11ff28c5 2117 }
2118
e156c3bb 2119 if(bin == -1) bin = 11; // Overflow
2120 } else {
2121 // PP: Tracklet multiplicity, use common definition
2122 Int_t itsMultiplicity = GetITSMultiplicity(fInputEvent);
2123 Int_t multiplicityLimits[8] = {0, 1, 9, 17, 25, 36, 60, 500};
2124 for(Int_t ibin = 0; ibin < 7; ibin++){
2125 if(itsMultiplicity >= multiplicityLimits[ibin] && itsMultiplicity < multiplicityLimits[ibin + 1]){
2126 bin = ibin;
2127 break;
2128 }
2129 }
2130 if(bin == -1) bin = 7; // Overflow
2131 }
2132 fCentralityF = bin;
2133 AliDebug(2, Form("Centrality class %d\n", fCentralityF));
11ff28c5 2134
c2690925 2135
e156c3bb 2136 // contributors, to be outsourced
2137 const AliVVertex *vtx;
2138 if(IsAODanalysis()){
2139 AliAODEvent *fAOD = dynamic_cast<AliAODEvent *>(fInputEvent);
2140 if(!fAOD){
2141 AliError("AOD Event required for AOD Analysis");
2142 return kFALSE;
2143 }
2144 vtx = fAOD->GetPrimaryVertex();
2145 } else {
2146 AliESDEvent *fESD = dynamic_cast<AliESDEvent *>(fInputEvent);
2147 if(!fESD){
2148 AliError("ESD Event required for ESD Analysis");
2149 return kFALSE;
2150 }
2151 vtx = fESD->GetPrimaryVertexSPD();
2152 }
2153 if(!vtx){
2154 fContributors = 0.5;
2155 return kFALSE;
2156 }
2157 else {
2158 Int_t contributorstemp = vtx->GetNContributors();
eeb1e952 2159 if( contributorstemp <= 0) {
2160 fContributors = 0.5;
2161 //printf("Number of contributors %d and vz %f\n",contributorstemp,vtx->GetZ());
2162 }
e156c3bb 2163 else fContributors = 1.5;
11ff28c5 2164 //printf("Number of contributors %d\n",contributorstemp);
e156c3bb 2165 }
2166 return kTRUE;
2167}
3a72645a 2168
e156c3bb 2169//___________________________________________________
2170Int_t AliAnalysisTaskHFE::GetITSMultiplicity(AliVEvent *ev){
2171 //
2172 // Definition of the Multiplicity according to the JPSI group (F. Kramer)
2173 //
2174 Int_t nTracklets = 0;
2175 Int_t nAcc = 0;
2176 Double_t etaRange = 1.6;
2177
2178 if (ev->IsA() == AliAODEvent::Class()) {
2179 AliAODTracklets *tracklets = ((AliAODEvent*)ev)->GetTracklets();
2180 nTracklets = tracklets->GetNumberOfTracklets();
2181 for (Int_t nn = 0; nn < nTracklets; nn++) {
2182 Double_t theta = tracklets->GetTheta(nn);
2183 Double_t eta = -TMath::Log(TMath::Tan(theta/2.0));
2184 if (TMath::Abs(eta) < etaRange) nAcc++;
2185 }
2186 } else if (ev->IsA() == AliESDEvent::Class()) {
2187 nTracklets = ((AliESDEvent*)ev)->GetMultiplicity()->GetNumberOfTracklets();
2188 for (Int_t nn = 0; nn < nTracklets; nn++) {
2189 Double_t eta = ((AliESDEvent*)ev)->GetMultiplicity()->GetEta(nn);
2190 if (TMath::Abs(eta) < etaRange) nAcc++;
2191 }
2192 } else return -1;
c2690925 2193
e156c3bb 2194 return nAcc;
3a72645a 2195}
e156c3bb 2196
8c1c76e9 2197//___________________________________________________
2198Bool_t AliAnalysisTaskHFE::InitializeHadronBackground(Int_t run){
2199 //
2200 // Initialize background factors array from the AliOADBContainer
2201 // The container is expected to provide a TObjArray with the name
2202 // "hadronBackground" and the size 12 for the given run number
2203 //
2204 AliDebug(1, "Deriving hadronic background parameterization from OADB container");
2205 TObjArray *functions = dynamic_cast<TObjArray *>(fHadronBackgroundOADB->GetObject(run, "hadronBackground"));
2206 if(!functions){
2207 AliDebug(1, "Content in the OADB Container is not a TObjArray");
2208 fBackGroundFactorApply = kFALSE;
2209 return kFALSE;
2210 }
2211 if(functions->GetSize() < 12){
2212 AliDebug(1, Form("Size not matching: 12 expected, %d provided", functions->GetSize()));
2213 fBackGroundFactorApply = kFALSE;
2214 return kFALSE;
2215 }
2216 for(Int_t icent = 0; icent < 12; icent++) fkBackGroundFactorArray[icent] = dynamic_cast<const TF1 *>(functions->UncheckedAt(icent));
2217 return kTRUE;
2218}
2219
3a72645a 2220//___________________________________________________
2221void AliAnalysisTaskHFE::RejectionPileUpVertexRangeEventCut() {
2222 //
2223 // Recover the centrality of the event from ESD or AOD
2224 //
2225 if(IsAODanalysis()){
2226
2227 AliAODEvent *fAOD = dynamic_cast<AliAODEvent *>(fInputEvent);
2228 if(!fAOD){
13242232 2229 AliError("AOD Event required for AOD Analysis");
e156c3bb 2230 return;
3a72645a 2231 }
2232 // PileUp
11ff28c5 2233 fIdentifiedAsPileUp = kFALSE;
3a72645a 2234 if(fRemovePileUp && fAOD->IsPileupFromSPD()) fIdentifiedAsPileUp = kTRUE;
2235 // Z vertex
11ff28c5 2236 fIdentifiedAsOutInz = kFALSE;
2237 //printf("Z vertex %f and out %f\n",fAOD->GetPrimaryVertex()->GetZ(),fCuts->GetVertexRange());
3a72645a 2238 if(TMath::Abs(fAOD->GetPrimaryVertex()->GetZ()) > fCuts->GetVertexRange()) fIdentifiedAsOutInz = kTRUE;
2239 // Event Cut
2240 fPassTheEventCut = kTRUE;
2241 if(!fCFM->CheckEventCuts(AliHFEcuts::kEventStepReconstructed, fAOD)) fPassTheEventCut = kFALSE;
2242
2243
2244 } else {
2245
2246 AliDebug(3, "Processing ESD Centrality");
2247 AliESDEvent *fESD = dynamic_cast<AliESDEvent *>(fInputEvent);
2248 if(!fESD){
13242232 2249 AliError("ESD Event required for ESD Analysis");
e156c3bb 2250 return;
3a72645a 2251 }
2252 // PileUp
2253 fIdentifiedAsPileUp = kFALSE;
2254 if(fRemovePileUp && fESD->IsPileupFromSPD()) fIdentifiedAsPileUp = kTRUE;
2255 // Z vertex
2256 fIdentifiedAsOutInz = kFALSE;
fd6b8522 2257 if (IsPbPb()) {
2258 //printf("PbPb\n");
2259 if(fESD->GetPrimaryVertex()){
2260 if(TMath::Abs(fESD->GetPrimaryVertex()->GetZ()) > fCuts->GetVertexRange()) fIdentifiedAsOutInz = kTRUE;
2261 }
2262 }
2263 else {
2264 //printf("pp\n");
2265 if(fESD->GetPrimaryVertexTracks()){
c2690925 2266 if(TMath::Abs(fESD->GetPrimaryVertexTracks()->GetZ()) > fCuts->GetVertexRange()) fIdentifiedAsOutInz = kTRUE;
fd6b8522 2267 }
3a72645a 2268 }
2269 //Event Cut
2270 fPassTheEventCut = kTRUE;
2271 if(!fCFM->CheckEventCuts(AliHFEcuts::kEventStepReconstructed, fESD)) fPassTheEventCut = kFALSE;
2272
2273
2274 }
2275
2276}
70da6c5a 2277