]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG3/hfe/AliAnalysisTaskDisplacedElectrons.cxx
Update of the HFE package
[u/mrichter/AliRoot.git] / PWG3 / hfe / AliAnalysisTaskDisplacedElectrons.cxx
CommitLineData
70da6c5a 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**************************************************************************/
15//
16// The analysis task:
17// study displaced electrons from beauty and charm
18// with cut on impact parameters in various pT bins
19//
20//
21// Authors:
22// Hongyan Yang <hongyan@physi.uni-heidelberg.de>
faee3b18 23// Carlo Bombonati <Carlo.Bombonati@cern.ch>
70da6c5a 24//
25
26#include <TChain.h>
27#include <TFile.h>
28#include <TH1F.h>
29#include <TH1I.h>
30#include "AliLog.h"
31
32#include <TList.h>
33#include <TMath.h>
34#include <TObjArray.h>
35#include <TParticle.h>
36#include <TString.h>
70da6c5a 37#include <TCanvas.h>
38
39#include "AliCFManager.h"
40#include "AliMCEvent.h"
41#include "AliMCEventHandler.h"
faee3b18 42#include "AliMCParticle.h"
43#include "AliStack.h"
44
70da6c5a 45#include "AliESDEvent.h"
46#include "AliESDInputHandler.h"
47#include "AliESDtrack.h"
faee3b18 48#include "AliESDpid.h"
70da6c5a 49
faee3b18 50#include "AliAnalysisManager.h"
70da6c5a 51
52#include "AliHFEpid.h"
53#include "AliHFEcuts.h"
faee3b18 54#include "AliHFEtools.h"
70da6c5a 55#include "AliHFEdisplacedElectrons.h"
70da6c5a 56#include "AliAnalysisTaskDisplacedElectrons.h"
57
58
59//____________________________________________________________
60AliAnalysisTaskDisplacedElectrons::AliAnalysisTaskDisplacedElectrons():
61 AliAnalysisTaskSE("Task for displaced electron study")
faee3b18 62 , fDeDebugLevel(0)
63 , fNminITSCluster(0)
64 , fNminPrimVtxContrib(0)
65 , fDePIDdetectors("")
66 , fDePIDstrategy(0)
67 , fDePlugins(0)
68 , fDeCuts(0x0)
69 , fDeDefaultPID(0x0)
70 , fDePID(0x0)
71 , fDeCFM(0x0)
70da6c5a 72 , fDisplacedElectrons(0x0)
faee3b18 73 , fDeNEvents(0x0)
74 , fElectronsMcPt(0x0)
75 , fElectronsEsdPt(0x0)
76 , fElectronsDataPt(0x0)
77 , fDeCorrection(0x0)
78 , fDeQA(0x0)
70da6c5a 79 , fHistDisplacedElectrons(0x0)
80{
81 //
82 // Dummy constructor
83 //
84 DefineInput(0, TChain::Class());
faee3b18 85 DefineOutput(1, TList::Class()); // displacedElectron
86 DefineOutput(2, TList::Class()); // correction framework
87 DefineOutput(3, TList::Class()); // QA
70da6c5a 88
70da6c5a 89 // Initialize pid
faee3b18 90
91 fDeDefaultPID = new AliESDpid;
92 fDePID = new AliHFEpid;
70da6c5a 93
94
95}
96
97//____________________________________________________________
98AliAnalysisTaskDisplacedElectrons::AliAnalysisTaskDisplacedElectrons(const char * name):
99 AliAnalysisTaskSE(name)
faee3b18 100 , fDeDebugLevel(0)
101 , fNminITSCluster(0)
102 , fNminPrimVtxContrib(0)
103 , fDePIDdetectors("")
104 , fDePIDstrategy(0)
105 , fDePlugins(0)
106 , fDeCuts(0x0)
107 , fDeDefaultPID(0x0)
108 , fDePID(0x0)
109 , fDeCFM(0x0)
70da6c5a 110 , fDisplacedElectrons(0x0)
faee3b18 111 , fDeNEvents(0x0)
112 , fElectronsMcPt(0x0)
113 , fElectronsEsdPt(0x0)
114 , fElectronsDataPt(0x0)
115 , fDeCorrection(0x0)
116 , fDeQA(0x0)
70da6c5a 117 , fHistDisplacedElectrons(0x0)
118{
119 //
120 // Default constructor
121 //
122 DefineInput(0, TChain::Class());
70da6c5a 123 DefineOutput(1, TList::Class());
faee3b18 124 DefineOutput(2, TList::Class());
125 DefineOutput(3, TList::Class());
126
127 // Initialize pid
128 fDeDefaultPID = new AliESDpid;
129 fDePID = new AliHFEpid;
70da6c5a 130
70da6c5a 131}
132
133//____________________________________________________________
134AliAnalysisTaskDisplacedElectrons::AliAnalysisTaskDisplacedElectrons(const AliAnalysisTaskDisplacedElectrons &ref):
135 AliAnalysisTaskSE(ref)
faee3b18 136 , fDeDebugLevel(ref.fDeDebugLevel)
137 , fNminITSCluster(ref.fNminITSCluster)
138 , fNminPrimVtxContrib(ref.fNminPrimVtxContrib)
139 , fDePIDdetectors(ref.fDePIDdetectors)
140 , fDePIDstrategy(ref.fDePIDstrategy)
141 , fDePlugins(ref.fDePlugins)
142 , fDeCuts(ref.fDeCuts)
143 , fDeDefaultPID(ref.fDeDefaultPID)
144 , fDePID(ref.fDePID)
145 , fDeCFM(ref.fDeCFM)
70da6c5a 146 , fDisplacedElectrons(ref.fDisplacedElectrons)
faee3b18 147 , fDeNEvents(ref.fDeNEvents)
148 , fElectronsMcPt(ref.fElectronsMcPt)
149 , fElectronsEsdPt(ref.fElectronsEsdPt)
150 , fElectronsDataPt(ref.fElectronsDataPt)
151 , fDeCorrection(ref.fDeCorrection)
152 , fDeQA(ref.fDeQA)
70da6c5a 153 , fHistDisplacedElectrons(ref.fHistDisplacedElectrons)
154{
155 //
156 // Copy Constructor
157 //
158}
159
160//____________________________________________________________
161AliAnalysisTaskDisplacedElectrons &AliAnalysisTaskDisplacedElectrons::operator=(const AliAnalysisTaskDisplacedElectrons &ref){
162 //
163 // Assignment operator
164 //
165 if(this == &ref) return *this;
166 AliAnalysisTask::operator=(ref);
faee3b18 167 fDeDebugLevel = ref.fDeDebugLevel;
168 fNminITSCluster = ref.fNminITSCluster;
169 fNminPrimVtxContrib = ref.fNminPrimVtxContrib;
170 fDePIDdetectors = ref.fDePIDdetectors;
171 fDePIDstrategy = ref.fDePIDstrategy;
172 fDePlugins = ref.fDePlugins;
173 fDeDefaultPID = ref.fDeDefaultPID;
174 fDePID = ref.fDePID;
175 fDeCuts = ref.fDeCuts;
176 fDeCFM = ref.fDeCFM;
70da6c5a 177 fDisplacedElectrons = ref.fDisplacedElectrons;
faee3b18 178 fDeNEvents = ref.fDeNEvents;
179 fElectronsMcPt = ref.fElectronsMcPt;
180 fElectronsEsdPt = ref.fElectronsEsdPt;
181 fElectronsDataPt = ref.fElectronsDataPt;
182 fDeCorrection = ref.fDeCorrection;
183 fDeQA = ref.fDeQA;
70da6c5a 184 fHistDisplacedElectrons = ref.fHistDisplacedElectrons;
185
186 return *this;
187}
188
189//____________________________________________________________
190AliAnalysisTaskDisplacedElectrons::~AliAnalysisTaskDisplacedElectrons(){
191 //
192 // Destructor
193 //
194
faee3b18 195 if(fDeDefaultPID) delete fDeDefaultPID;
196 if(fDePID) delete fDePID;
197 if(fDeCFM) delete fDeCFM;
198 if(fDisplacedElectrons) delete fDisplacedElectrons;
199
200 if(fDeNEvents) delete fDeNEvents;
201 if(fElectronsMcPt) delete fElectronsMcPt;
202 if(fElectronsEsdPt) delete fElectronsEsdPt;
203 if(fElectronsDataPt) delete fElectronsDataPt;
204 if(fDeCorrection){
205 fDeCorrection->Clear();
206 delete fDeCorrection;
70da6c5a 207 }
faee3b18 208 if(fDeQA){
209 fDeQA->Clear();
210 delete fDeQA;
70da6c5a 211 }
70da6c5a 212 if(fHistDisplacedElectrons){
213 fHistDisplacedElectrons->Clear();
214 delete fHistDisplacedElectrons;
215 }
70da6c5a 216}
217
218//____________________________________________________________
219void AliAnalysisTaskDisplacedElectrons::UserCreateOutputObjects(){
220 // create output objects
faee3b18 221 // fDeNEvents
70da6c5a 222 // MC and Data containers
223
faee3b18 224
225 if(!fDeQA) fDeQA = new TList;
226 fDeQA->SetName("variousQAhistograms");
227
228 fDeNEvents = new TH1I("nDeEvents", "Number of Events in the DE Analysis", 2, 0, 2);
70da6c5a 229 const Int_t nBins = 14;
230 const Float_t ptBins[nBins] = {0.0,0.5,1.0,1.5,2.0,2.5,3.0,4.0,5.0,7.0,9.0,12.0,16.0,20.0};
faee3b18 231 fElectronsMcPt = new TH1F("mcElectronPt", "MC: p_{T} distribution of identified electrons (mcpid);p_{T} (GeV/c);Counts;", nBins-1, ptBins);
232 fElectronsEsdPt = new TH1F("esdElectronPt", "ESD: p_{T} distribution of identified electrons (hfepid);p_{T} (GeV/c);Counts;", nBins-1, ptBins);
233 fElectronsDataPt = new TH1F("dataElectronPt", "DATA: p_{T} distribution of identified electrons (hfepid);p_{T} (GeV/c);Counts;", nBins-1, ptBins);
234
235 fDeQA->AddAt(fDeNEvents,0);
236 if(HasMCData()){
237 fDeQA->AddAt(fElectronsMcPt, 1);
238 fDeQA->AddAt(fElectronsEsdPt, 2);
239 }
240 else
241 fDeQA->AddAt(fElectronsDataPt, 1);
242
70da6c5a 243 // Initialize correction Framework and Cuts
faee3b18 244 fDeCFM = new AliCFManager;
70da6c5a 245 MakeEventContainer();
246 MakeParticleContainer();
247
faee3b18 248 if(!fDeCorrection) fDeCorrection = new TList();
249 fDeCorrection->SetName("deCorrections");
250 fDeCorrection->AddAt(fDeCFM->GetEventContainer(), 0);
251 fDeCorrection->AddAt(fDeCFM->GetParticleContainer(), 1);
252 fDeCorrection->Print();
253
254 for(Int_t istep = 0; istep < fDeCFM->GetEventContainer()->GetNStep(); istep++)
255 fDeCFM->SetEventCutsList(istep, 0x0);
256 for(Int_t istep = 0; istep < fDeCFM->GetParticleContainer()->GetNStep(); istep++)
257 fDeCFM->SetParticleCutsList(istep, 0x0);
258
259 if(!fDeCuts){
70da6c5a 260 AliWarning("Cuts not available. Default cuts will be used");
faee3b18 261 fDeCuts = new AliHFEcuts;
262 fDeCuts->CreateStandardCuts();
70da6c5a 263 }
264
faee3b18 265 fDeCuts->Initialize(fDeCFM);
70da6c5a 266
faee3b18 267 if(GetPlugin(kDePidQA)){
268 AliInfo("PID QA switched on");
269 // fPID->SetDebugLevel(2);
270 fDePID->SetQAOn();
271 fDeQA->Add(fDePID->GetQAhistograms());
272 }
273
274 fDePID->SetHasMCData(HasMCData());
275 if(!fDePIDdetectors.Length() && ! fDePIDstrategy) AddPIDdetector("TPC");
276 if(fDePIDstrategy)
277 fDePID->InitializePID(Form("Strategy%d", fDePIDstrategy));
70da6c5a 278 else
faee3b18 279 fDePID->InitializePID(fDePIDdetectors.Data()); // Only restrictions to TPC allowed
280
70da6c5a 281 // displaced electron study----------------------------------
282 if(GetPlugin(kDisplacedElectrons)){
283
284 fDisplacedElectrons = new AliHFEdisplacedElectrons;
faee3b18 285 fDisplacedElectrons->SetDebugLevel(fDeDebugLevel);
70da6c5a 286 fDisplacedElectrons->SetHasMCData(HasMCData());
faee3b18 287 fDisplacedElectrons->SetMinPrimVtxContrib(fNminPrimVtxContrib);
288 fDisplacedElectrons->SetNitsCluster(fNminITSCluster);
289
70da6c5a 290 if(!fHistDisplacedElectrons) fHistDisplacedElectrons = new TList();
70da6c5a 291 fDisplacedElectrons->CreateOutputs(fHistDisplacedElectrons);
70da6c5a 292 }
faee3b18 293
70da6c5a 294}
295
296
297
298//____________________________________________________________
299void AliAnalysisTaskDisplacedElectrons::UserExec(Option_t *){
300 //
301 // Run the analysis
302 //
303
faee3b18 304 if(fDeDebugLevel>=10) AliInfo("analyse single event");
305
306 if(!fInputEvent){
307 AliError("Reconstructed Event not available");
70da6c5a 308 return;
70da6c5a 309 }
310
faee3b18 311 //
312 AliESDInputHandler *inH = dynamic_cast<AliESDInputHandler *>(fInputHandler);
70da6c5a 313
faee3b18 314 // pure MC analysis:
315
70da6c5a 316 if(HasMCData()){
faee3b18 317 // Protect against missing MC trees
318 AliMCEventHandler *mcH = dynamic_cast<AliMCEventHandler *>(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
319 if(!mcH->InitOk()) return;
320 if(!mcH->TreeK()) return;
321 if(!mcH->TreeTR()) return;
322
323 AliDebug(4, Form("MC Event: %p", fMCEvent));
324 if(!fMCEvent){
70da6c5a 325 AliError("No MC Event, but MC Data required");
326 return;
327 }
faee3b18 328
329 ProcessMC();
70da6c5a 330 }
faee3b18 331
332
333 // from now on, only ESD are analyzed
334 // using HFE pid, using HFE cuts
335 // using CORRFW
336
337 AliESDpid *workingPID = inH->GetESDpid();
338 if(workingPID){
339 AliDebug(1, "Using ESD PID from the input handler");
340 fDePID->SetESDpid(workingPID);
341 } else {
342 AliDebug(1, "Using default ESD PID");
343 fDePID->SetESDpid(AliHFEtools::GetDefaultPID(HasMCData()));
344 }
345
346 if(!fDeCuts){
70da6c5a 347 AliError("HFE cuts not available");
348 return;
349 }
faee3b18 350
351 // ESD case with MC
352 if(HasMCData() && IsESDanalysis()) {
353 // Protect against missing MC trees
354 AliMCEventHandler *mcH = dynamic_cast<AliMCEventHandler *>(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
355 if(!mcH->InitOk()) return;
356 if(!mcH->TreeK()) return;
357 if(!mcH->TreeTR()) return;
358
359 AliDebug(4, Form("MC Event: %p", fMCEvent));
360 if(!fMCEvent){
361 AliError("No MC Event, but MC Data required");
362 return;
363 }
364
365 ProcessESD();
366 }
367
368 // now only for data ESDs without MC
369 if(!HasMCData() && IsESDanalysis()) {
370 ProcessData();
371 }
372
373 fDeNEvents->Fill(1);
374 PostData(1, fHistDisplacedElectrons);
375 PostData(2, fDeCorrection);
376 PostData(3, fDeQA);
377
378}
379
380//____________________________________________________________
381void AliAnalysisTaskDisplacedElectrons::ProcessMC(){
382 //
383 // handel pure MC analysis
384 //
385
386 Int_t nMCelectrons = 0;
387 AliESDEvent *fESD = dynamic_cast<AliESDEvent *>(fInputEvent);
388
389 Double_t mcContainer[4]; // container for the output in THnSparse
390 memset(mcContainer, 0, sizeof(Double_t) * 4);
391
392 fDeCFM->SetMCEventInfo(fMCEvent);
393
394 Double_t nContributor = 0;
395 const AliVVertex *mcPrimVtx = fMCEvent->GetPrimaryVertex();
396 if(mcPrimVtx) nContributor = mcPrimVtx->GetNContributors();
397
398 //
399 // cut at MC event level
400 //
401
402 if(!fDeCFM->CheckEventCuts(AliHFEcuts::kEventStepGenerated, fMCEvent)) return;
403 if(GetPlugin(kCorrection)) fDeCFM->GetEventContainer()->Fill(&nContributor,AliHFEcuts::kEventStepGenerated);
404
405 AliStack *stack = 0x0;
406
407 if(!fMCEvent->Stack())return;
408 stack = fMCEvent->Stack();
409 Int_t nTracks = stack->GetNtrack();
410
411 AliMCParticle *mcTrack = 0x0;
412
413 for(Int_t itrack = 0; itrack<nTracks; itrack++){
414 if(!(stack->Particle(itrack))) continue;
415 if(mcTrack)mcTrack = 0x0;
416 mcTrack= dynamic_cast<AliMCParticle*>(fMCEvent->GetTrack(itrack));
417 //TParticle *mcPart = stack->Particle(itrack);
418
419 mcContainer[0] = mcTrack->Pt();
420 mcContainer[1] = mcTrack->Eta();
421 mcContainer[2] = mcTrack->Phi();
422 mcContainer[3] = mcTrack->Charge();
423
424
425
426 if (!stack->IsPhysicalPrimary(mcTrack->GetLabel())) continue;
427 // no cut but require primary
428 if(GetPlugin(kCorrection))fDeCFM->GetParticleContainer()->Fill(mcContainer, 0);
429
430 // all pions for reference
431 if(TMath::Abs(mcTrack->Particle()->GetPdgCode())==AliHFEdisplacedElectrons::kPDGpion && GetPlugin(kCorrection))
432 fDeCFM->GetParticleContainer()->Fill(mcContainer, 1);
433
434 // cut for signal: all MC electrons
435 if(TMath::Abs(mcTrack->Particle()->GetPdgCode())==AliHFEdisplacedElectrons::kPDGelectron && GetPlugin(kCorrection))
436 fDeCFM->GetParticleContainer()->Fill(mcContainer, 2);
437
438 // cut at track level kinematics: pt and eta
439 if(TMath::Abs(mcContainer[1])>=0.8 || mcContainer[0]>20 || mcContainer[0]<0.1) continue;
440
441 if(TMath::Abs(mcTrack->Particle()->GetPdgCode())==AliHFEdisplacedElectrons::kPDGelectron){
442 nMCelectrons++;
443 fElectronsMcPt->Fill(mcContainer[0]);
444 }
445
446 if(GetPlugin(kCorrection))fDeCFM->GetParticleContainer()->Fill(mcContainer, 3);
447
448
449 // fill MC THnSparse
450 fDisplacedElectrons->FillMcOutput(fESD, fMCEvent, mcTrack);
451
452 } // mc track loop
453
454 if(fDeDebugLevel>=10) printf("there are %d electrons in this MC event", nMCelectrons);
455
456}
457
458//____________________________________________________________
459void AliAnalysisTaskDisplacedElectrons::ProcessESD(){
460
461 // this is to handel ESD tracks with MC information
462 // MC pid is only used when HFE pid is implemented, for comparison
463 // corrections are taken into account
70da6c5a 464
465 // process data: ESD tracks with MC information
70da6c5a 466
faee3b18 467 Double_t esdContainer[4]; // container for the output in THnSparse
468 memset(esdContainer, 0, sizeof(Double_t) * 4);
469 AliESDEvent *fESD = dynamic_cast<AliESDEvent *>(fInputEvent);
470
471 fDeCFM->SetRecEventInfo(fESD);
472 Double_t nContrib = fESD->GetPrimaryVertex()->GetNContributors();
473
70da6c5a 474 Bool_t alreadyseen = kFALSE;
475 LabelContainer cont(fESD->GetNumberOfTracks());
70da6c5a 476
faee3b18 477 Int_t nHFEelectrons=0;
70da6c5a 478 AliESDtrack *track = 0x0;
faee3b18 479 AliStack *stack = 0x0;
70da6c5a 480
faee3b18 481 if(!(stack = fMCEvent->Stack()))return;
482
483 //
484 // cut at ESD event level
485 //
486 if(!fDeCFM->CheckEventCuts(AliHFEcuts::kEventStepReconstructed, fESD)) return;
487 if(GetPlugin(kCorrection)) fDeCFM->GetEventContainer()->Fill(&nContrib, AliHFEcuts::kEventStepReconstructed);
488
70da6c5a 489 for(Int_t itrack = 0; itrack < fESD->GetNumberOfTracks(); itrack++){
490 track = fESD->GetTrack(itrack);
491
70da6c5a 492 if(GetPlugin(kDisplacedElectrons)) {
70da6c5a 493
faee3b18 494 esdContainer[0] = track->Pt();
495 esdContainer[1] = track->Eta();
496 esdContainer[2] = track->Phi();
497 esdContainer[3] = track->Charge();
70da6c5a 498
faee3b18 499 // before any cut
500 alreadyseen = cont.Find(TMath::Abs(track->GetLabel()));
501 cont.Append(TMath::Abs(track->GetLabel())); // check double counting
502 if(alreadyseen) continue; // avoid double counting
503 if(GetPlugin(kCorrection)) fDeCFM->GetParticleContainer()->Fill(esdContainer, 1+AliHFEcuts::kStepRecNoCut);
70da6c5a 504
faee3b18 505 // 1st track cut
506 // RecKine: ITSTPC cuts : ITS & TPC refit, covmatrix: (2, 2, 0.5, 0.5, 2); min_tpccls: 50, chi2_tpccls: 3.5
507 if(!fDeCFM->CheckParticleCuts(AliHFEcuts::kStepRecKineITSTPC, track)) continue;
508 if(GetPlugin(kCorrection)) fDeCFM->GetParticleContainer()->Fill(esdContainer, 1+AliHFEcuts::kStepRecKineITSTPC);
70da6c5a 509
faee3b18 510 // 2nd track cut
70da6c5a 511 // RecPrim: cut on track quality : DCA to vertex max: 3cm and 10cm; reject kink daughters
faee3b18 512 if(!fDeCFM->CheckParticleCuts(AliHFEcuts::kStepRecPrim, track)) continue;
513 if(GetPlugin(kCorrection)) fDeCFM->GetParticleContainer()->Fill(esdContainer, 1+AliHFEcuts::kStepRecPrim);
70da6c5a 514
faee3b18 515 // 3rd track cut
70da6c5a 516 // HFEcuts: ITS layers cuts: ITS pixel layer: kFirst, kSecond, kBoth, kNone or kAny
faee3b18 517 if(!fDeCFM->CheckParticleCuts(AliHFEcuts::kStepHFEcutsITS, track)) continue;
518 if(GetPlugin(kCorrection))fDeCFM->GetParticleContainer()->Fill(esdContainer, 1+AliHFEcuts::kStepHFEcutsITS);
519
520 /*
521 // 4th track cut
522 // TRD: number of tracklets in TRD
523 if(!fDeCFM->CheckParticleCuts(AliHFEcuts::kStepHFEcutsTRD, track)) continue;
524 if(GetPlugin(kCorrection)) fDeCFM->GetParticleContainer()->Fill(esdContainer, 1+AliHFEcuts::kStepHFEcutsTRD);
525 */
70da6c5a 526
faee3b18 527 // 5th track cut
528 // track accepted, do PID
529 // --> only electron candidate will be processed
70da6c5a 530 AliHFEpidObject hfetrack;
531 hfetrack.fAnalysisType = AliHFEpidObject::kESDanalysis;
532 hfetrack.fRecTrack = track;
faee3b18 533 // if(HasMCData())hfetrack.fMCtrack = mctrack;
70da6c5a 534
faee3b18 535 if(!fDePID->IsSelected(&hfetrack)) continue;
70da6c5a 536
faee3b18 537 else if(fDeDebugLevel>=10)
538 AliInfo("ESD info: this particle is identified as electron by HFEpid method \n");
539 if(GetPlugin(kCorrection)) fDeCFM->GetParticleContainer()->Fill(esdContainer, 1+AliHFEcuts::kStepPID);
70da6c5a 540
faee3b18 541 // Fill Containers
542 nHFEelectrons++;
543 fElectronsEsdPt->Fill(esdContainer[0]);
544 fDisplacedElectrons->FillEsdOutput(fESD, track, stack);
545
546 } // displaced electron analysis on ESD with MC plugin
70da6c5a 547 } // track loop
faee3b18 548
549 if(fDeDebugLevel>=10) printf("there are %d HFE electrons in this ESD event", nHFEelectrons);
550
551}
70da6c5a 552
70da6c5a 553
554
faee3b18 555//____________________________________________________________
556void AliAnalysisTaskDisplacedElectrons::ProcessData(){
557
558 // this is a track loop over real data
559 // no MC information at all
560 // HFE pid is used
561
562 AliESDEvent *fESD = dynamic_cast<AliESDEvent *>(fInputEvent);
563
564 Double_t dataContainer[4]; // container for the output in THnSparse
565 memset(dataContainer, 0, sizeof(Double_t) * 4);
70da6c5a 566
faee3b18 567 Bool_t alreadyseen = kFALSE;
568 LabelContainer cont(fESD->GetNumberOfTracks());
70da6c5a 569
70da6c5a 570
faee3b18 571 AliESDtrack *track = 0x0;
572 Int_t nHFEelectrons= 0;
70da6c5a 573
faee3b18 574 fDeCFM->SetRecEventInfo(fESD);
575 Double_t nContrib = fESD->GetPrimaryVertex()->GetNContributors();
576 if(!fDeCFM->CheckEventCuts(AliHFEcuts::kEventStepReconstructed, fESD)) return;
577 if(GetPlugin(kCorrection)) fDeCFM->GetEventContainer()->Fill(&nContrib, AliHFEcuts::kEventStepReconstructed);
578
579
580 for(Int_t itrack = 0; itrack < fESD->GetNumberOfTracks(); itrack++){
581 track = fESD->GetTrack(itrack);
582
583 if(GetPlugin(kDisplacedElectrons)) {
70da6c5a 584
faee3b18 585 dataContainer[0] = track->Pt();
586 dataContainer[1] = track->Eta();
587 dataContainer[2] = track->Phi();
588 dataContainer[3] = track->Charge();
589
590 alreadyseen = cont.Find(TMath::Abs(track->GetLabel())); // double counted track
591 cont.Append(TMath::Abs(track->GetLabel()));
592 if(alreadyseen) continue; // avoid double counting
593 if(GetPlugin(kCorrection))fDeCFM->GetParticleContainer()->Fill(&dataContainer[4],
594 1+AliHFEcuts::kStepRecNoCut + AliHFEcuts::kNcutStepsESDtrack);
70da6c5a 595
faee3b18 596 // 1st track cut
597 // RecKine: ITSTPC cuts : ITS & TPC refit, covmatrix: (2, 2, 0.5, 0.5, 2); min_tpccls: 50, chi2_tpccls: 3.5
598 if(!fDeCFM->CheckParticleCuts(AliHFEcuts::kStepRecKineITSTPC, track)) continue;
599 if(GetPlugin(kCorrection)) fDeCFM->GetParticleContainer()->Fill(&dataContainer[4],
600 1+AliHFEcuts::kStepRecKineITSTPC + AliHFEcuts::kNcutStepsESDtrack);
70da6c5a 601
faee3b18 602 // 2nd track cut
603 // RecPrim: cut on track quality : DCA to vertex max: 3cm and 10cm; reject kink daughters
604 if(!fDeCFM->CheckParticleCuts(AliHFEcuts::kStepRecPrim, track)) continue;
605 if(GetPlugin(kCorrection)) fDeCFM->GetParticleContainer()->Fill(&dataContainer[4],
606 1+AliHFEcuts::kStepRecPrim + AliHFEcuts::kNcutStepsESDtrack);
607
608 // 3rd track cut
609 // HFEcuts: ITS layers cuts: ITS pixel layer: kFirst, kSecond, kBoth, kNone or kAny
610 if(!fDeCFM->CheckParticleCuts(AliHFEcuts::kStepHFEcutsITS, track)) continue;
611 if(GetPlugin(kCorrection)) fDeCFM->GetParticleContainer()->Fill(&dataContainer[4],
612 1+AliHFEcuts::kStepHFEcutsITS + AliHFEcuts::kNcutStepsESDtrack);
70da6c5a 613
faee3b18 614 /*
615 // 4th track cut
616 // TRD: number of tracklets in TRD0
617 if(!fDeCFM->CheckParticleCuts(AliHFEcuts::kStepHFEcutsTRD, track)) continue;
618 if(GetPlugin(kCorrection)) if(HasMCData())fDeCFM->GetParticleContainer()->Fill(&dataContainer[4],
619 1+AliHFEcuts::kStepHFEcutsTRD + AliHFEcuts::kNcutStepsESDtrack);
620 */
621
622
623 // 5th track cut
624 // track accepted, do PID --> only electron candidate will be processed
70da6c5a 625
faee3b18 626 AliHFEpidObject hfetrack;
627 hfetrack.fAnalysisType = AliHFEpidObject::kESDanalysis;
628 hfetrack.fRecTrack = track;
629 // if(HasMCData())hfetrack.fMCtrack = mctrack;
630
631 if(!fDePID->IsSelected(&hfetrack)) continue;
632 else if(fDeDebugLevel>=10)
633 AliInfo("ESD info: this particle is identified as electron by HFEpid method \n");
634 if(GetPlugin(kCorrection)) fDeCFM->GetParticleContainer()->Fill(dataContainer, 1+AliHFEcuts::kStepPID + AliHFEcuts::kNcutStepsESDtrack);
635
636 nHFEelectrons++;
637 fElectronsDataPt->Fill(dataContainer[0]);
638 fDisplacedElectrons->FillDataOutput(fESD, track);
639 } // analyze displaced electrons plugin switched on
640 } // track loop
70da6c5a 641
faee3b18 642 if(fDeDebugLevel>=10) printf("there are %d HFE electrons in this DATA event", nHFEelectrons);
643}
70da6c5a 644
645
faee3b18 646//____________________________________________________________
647void AliAnalysisTaskDisplacedElectrons::Terminate(Option_t *){
648 //
649 // Terminate not implemented at the moment
650 //
651
652 fHistDisplacedElectrons = dynamic_cast<TList *>(GetOutputData(1));
653 fDeCorrection = dynamic_cast<TList *>(GetOutputData(2));
654 fDeQA = dynamic_cast<TList *>(GetOutputData(3));
655 if(!fDeCorrection) AliError("correction list not available\n");
656 if(!fHistDisplacedElectrons) AliError("de list not available\n");
657 if(!fDeQA) AliError("qa list is not available\n");
658
659 fHistDisplacedElectrons->Print();
660 fDeCorrection->Print();
661 fDeQA->Print();
70da6c5a 662
faee3b18 663 AliInfo("analysis done!\n");
664
665}
70da6c5a 666
667//____________________________________________________________
668void AliAnalysisTaskDisplacedElectrons::PrintStatus() const {
669
670 //
671 // Print Analysis status
672 //
faee3b18 673 printf("\n");
674 printf("\t Analysis Settings\n\t========================================\n");
675 printf("\t running over %s\n", HasMCData()?"MC data":"pp collision data");
676 printf("\t displaced electrons' analysis is %s\n", GetPlugin(kDisplacedElectrons)?"ON":"OFF");
677 printf("\t correction container is %s\n", GetPlugin(kCorrection)?"ON":"OFF");
678 printf("\t hfe pid qa is %s\n", GetPlugin(kDePidQA)?"ON":"OFF");
679 printf("\t post processing is %s\n", GetPlugin(kPostProcess)?"ON":"OFF");
680 printf("\t cuts: %s\n", (fDeCuts != NULL) ? "YES" : "NO");
70da6c5a 681 printf("\t ");
682 printf("\n");
683}
684
685//__________________________________________
686void AliAnalysisTaskDisplacedElectrons::SwitchOnPlugin(Int_t plug){
687 //
688 // Switch on Plugin
689 // Available:
690 // - analyze impact parameter
691 // - Post Processing
692
693 switch(plug)
694 {
695 case kDisplacedElectrons:
faee3b18 696 SETBIT(fDePlugins, plug);
70da6c5a 697 break;
698 case kCorrection:
faee3b18 699 SETBIT(fDePlugins, plug);
700 break;
701 case kDePidQA:
702 SETBIT(fDePlugins, plug);
703 break;
704 case kPostProcess:
705 SETBIT(fDePlugins, plug);
70da6c5a 706 break;
707 default:
708 AliError("Unknown Plugin");
709 };
710}
711
70da6c5a 712//____________________________________________________________
713void AliAnalysisTaskDisplacedElectrons::MakeParticleContainer(){
714 //
faee3b18 715 // Create the particle container for the correction framework manager and
716 // link it
70da6c5a 717 //
faee3b18 718 const Int_t kNvar = 4;
719 //number of variables on the grid:pt,eta, phi, charge
720 const Double_t kPtbound[2] = {0.1, 10.};
721 const Double_t kEtabound[2] = {-0.8, 0.8};
722 const Double_t kPhibound[2] = {0., 2. * TMath::Pi()};
70da6c5a 723
724 //arrays for the number of bins in each dimension
725 Int_t iBin[kNvar];
faee3b18 726 iBin[0] = 40; // bins in pt
727 iBin[1] = 8; // bins in eta
70da6c5a 728 iBin[2] = 18; // bins in phi
729 iBin[3] = 2; // bins in charge
faee3b18 730
70da6c5a 731 //arrays for lower bounds :
732 Double_t* binEdges[kNvar];
faee3b18 733 binEdges[0] = AliHFEtools::MakeLogarithmicBinning(iBin[0], kPtbound[0], kPtbound[1]);
734 binEdges[1] = AliHFEtools::MakeLinearBinning(iBin[1], kEtabound[0], kEtabound[1]);
735 binEdges[2] = AliHFEtools::MakeLinearBinning(iBin[2], kPhibound[0], kPhibound[1]);
736 binEdges[3] = AliHFEtools::MakeLinearBinning(iBin[3], -1.1, 1.1); // Numeric precision
737
738 //------------------------------------------------
739 // one "container" for MC+ESD+Data
740 //----------pure MC track-------------------------
741 // 0: MC generated
742 // 1: MC pion total ---- be careful!!!!
743 // 2: MC electrons total
744 // 3: MC electrons in acceptance
745 //-------ESD track with MC info-------------------
746 // 4: ESD track with MC: no cut
747 // 5: ESD track with MC: cut on kine its tpc
748 // 6: ESD track with MC: rec prim
749 // 7: ESD track with MC: hfe cuts its
750 // 8: ESD track with MC: hfe cuts trd
751 // 9: ESD track with MC: hfe pid
752 //-----------data track---------------------------
753 // 10: DATA track wo MC: no cut
754 // 11: DATA track wo MC: cut on kine its tpc
755 // 12: DATA track wo MC: rec prim
756 // 13: DATA track wo MC: hfe cuts its
757 // 14: DATA track wo MC: hfe cuts trd
758 // 15: DATA track wo MC: hfe pid
759 //------------------------------------------------
760
761 AliCFContainer* container = new AliCFContainer("deTrackContainer", "Container for tracks",
762 (1 + AliHFEcuts::kNcutStepsTrack + AliHFEcuts::kNcutStepsESDtrack), kNvar, iBin);
763
70da6c5a 764 //setting the bin limits
faee3b18 765 for(Int_t ivar = 0; ivar < kNvar; ivar++){
70da6c5a 766 container -> SetBinLimits(ivar, binEdges[ivar]);
70da6c5a 767 }
faee3b18 768 fDeCFM->SetParticleContainer(container);
70da6c5a 769}
770
faee3b18 771
70da6c5a 772//____________________________________________________________
773void AliAnalysisTaskDisplacedElectrons::MakeEventContainer(){
774 //
775 // Create the event container for the correction framework and link it
776 //
faee3b18 777
778 // event container
779 // 0: MC event
780 // 1: ESD event
781
70da6c5a 782 const Int_t kNvar = 1; // number of variables on the grid: number of tracks per event
783 const Double_t kNTrackBound[2] = {-0.5, 200.5};
784 const Int_t kNBins = 201;
785
faee3b18 786 AliCFContainer *evCont = new AliCFContainer("deEventContainer", "Container for DE events", AliHFEcuts::kNcutStepsEvent, kNvar, &kNBins);
70da6c5a 787
788 Double_t trackBins[kNBins];
789 for(Int_t ibin = 0; ibin < kNBins; ibin++) trackBins[ibin] = kNTrackBound[0] + static_cast<Double_t>(ibin);
790 evCont->SetBinLimits(0,trackBins);
791
faee3b18 792 fDeCFM->SetEventContainer(evCont);
70da6c5a 793
794}
795
796
797
798//__________________________________________________________
799void AliAnalysisTaskDisplacedElectrons::AddPIDdetector(TString detector){
800 //
801 // Adding PID detector to the task
802 //
faee3b18 803 if(!fDePIDdetectors.Length())
804 fDePIDdetectors = detector;
70da6c5a 805 else
faee3b18 806 fDePIDdetectors += ":" + detector;
70da6c5a 807}
808
809
810
811//____________________________________________________________
812AliAnalysisTaskDisplacedElectrons::LabelContainer::LabelContainer(Int_t capacity):
813 fContainer(NULL),
814 fBegin(NULL),
815 fEnd(NULL),
816 fLast(NULL),
817 fCurrent(NULL)
818{
819 //
820 // Default constructor
821 //
822 fContainer = new Int_t[capacity];
823 fBegin = &fContainer[0];
824 fEnd = &fContainer[capacity - 1];
825 fLast = fCurrent = fBegin;
826}
827
828//____________________________________________________________
829Bool_t AliAnalysisTaskDisplacedElectrons::LabelContainer::Append(Int_t label){
830 //
831 // Add Label to the container
832 //
833 if(fLast > fEnd) return kFALSE;
834 *fLast++ = label;
835 return kTRUE;
836}
837
838//____________________________________________________________
839Bool_t AliAnalysisTaskDisplacedElectrons::LabelContainer::Find(Int_t label) const {
840 //
841 // Find track in the list of labels
842 //
843 for(Int_t *entry = fBegin; entry <= fLast; entry++)
844 if(*entry == label) return kTRUE;
845 return kFALSE;
846}
847
848//____________________________________________________________
faee3b18 849Int_t AliAnalysisTaskDisplacedElectrons::LabelContainer::Next() {
70da6c5a 850 //
851 // Mimic iterator
852 //
853 if(fCurrent > fLast) return -1;
854 return *fCurrent++;
855}