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