1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 // Class for heavy-flavour electron with EMCal triggered events
17 // Author: Shingo Sakai
25 #include "THnSparse.h"
26 #include "TLorentzVector.h"
30 #include "AliAnalysisTask.h"
31 #include "AliAnalysisManager.h"
33 #include "AliESDEvent.h"
34 #include "AliESDHandler.h"
35 #include "AliAODEvent.h"
36 #include "AliAODHandler.h"
38 #include "AliAnalysisTaskHFECal.h"
39 #include "TGeoGlobalMagField.h"
41 #include "AliAnalysisTaskSE.h"
42 #include "TRefArray.h"
44 #include "AliESDInputHandler.h"
45 #include "AliESDpid.h"
46 #include "AliESDtrackCuts.h"
47 #include "AliPhysicsSelection.h"
48 #include "AliESDCaloCluster.h"
49 #include "AliAODCaloCluster.h"
50 #include "AliEMCALRecoUtils.h"
51 #include "AliEMCALGeometry.h"
52 #include "AliGeomManager.h"
54 #include "TGeoManager.h"
58 #include "AliEMCALTrack.h"
61 #include "AliKFParticle.h"
62 #include "AliKFVertex.h"
65 #include "AliPIDResponse.h"
66 #include "AliHFEcontainer.h"
67 #include "AliHFEcuts.h"
68 #include "AliHFEpid.h"
69 #include "AliHFEpidBase.h"
70 #include "AliHFEpidQAmanager.h"
71 #include "AliHFEtools.h"
72 #include "AliCFContainer.h"
73 #include "AliCFManager.h"
75 #include "AliCentrality.h"
77 ClassImp(AliAnalysisTaskHFECal)
78 //________________________________________________________________________
79 AliAnalysisTaskHFECal::AliAnalysisTaskHFECal(const char *name)
80 : AliAnalysisTaskSE(name)
85 ,fIdentifiedAsOutInz(kFALSE)
86 ,fPassTheEventCut(kFALSE)
87 ,fRejectKinkMother(kFALSE)
92 ,fOpeningAngleCut(0.1)
108 ,fTrackPtBefTrkCuts(0)
109 ,fTrackPtAftTrkCuts(0)
116 fPID = new AliHFEpid("hfePid");
117 fTrackCuts = new AliESDtrackCuts();
119 // Define input and output slots here
120 // Input slot #0 works with a TChain
121 DefineInput(0, TChain::Class());
122 // Output slot #0 id reserved by the base class for AOD
123 // Output slot #1 writes into a TH1 container
124 // DefineOutput(1, TH1I::Class());
125 DefineOutput(1, TList::Class());
126 // DefineOutput(3, TTree::Class());
129 //________________________________________________________________________
130 AliAnalysisTaskHFECal::AliAnalysisTaskHFECal()
131 : AliAnalysisTaskSE("DefaultAnalysis_AliAnalysisTaskHFECal")
136 ,fIdentifiedAsOutInz(kFALSE)
137 ,fPassTheEventCut(kFALSE)
138 ,fRejectKinkMother(kFALSE)
143 ,fOpeningAngleCut(0.1)
159 ,fTrackPtBefTrkCuts(0)
160 ,fTrackPtAftTrkCuts(0)
165 //Default constructor
166 fPID = new AliHFEpid("hfePid");
168 fTrackCuts = new AliESDtrackCuts();
171 // Define input and output slots here
172 // Input slot #0 works with a TChain
173 DefineInput(0, TChain::Class());
174 // Output slot #0 id reserved by the base class for AOD
175 // Output slot #1 writes into a TH1 container
176 // DefineOutput(1, TH1I::Class());
177 DefineOutput(1, TList::Class());
178 //DefineOutput(3, TTree::Class());
180 //_________________________________________
182 AliAnalysisTaskHFECal::~AliAnalysisTaskHFECal()
192 //_________________________________________
194 void AliAnalysisTaskHFECal::UserExec(Option_t*)
197 //Called for each event
199 // create pointer to event
200 fESD = dynamic_cast<AliESDEvent*>(InputEvent());
202 printf("ERROR: fESD not available\n");
207 AliError("HFE cuts not available");
211 if(!fPID->IsInitialized()){
212 // Initialize PID with the given run number
213 AliWarning("PID not initialised, get from Run no");
214 fPID->InitializePID(fESD->GetRunNumber());
219 Int_t fNOtrks = fESD->GetNumberOfTracks();
220 const AliESDVertex *pVtx = fESD->GetPrimaryVertex();
222 Double_t pVtxZ = -999;
223 pVtxZ = pVtx->GetZ();
225 if(TMath::Abs(pVtxZ)>10) return;
228 if(fNOtrks<2) return;
231 AliPIDResponse *pidResponse = fInputHandler->GetPIDResponse();
233 AliDebug(1, "Using default PID Response");
234 pidResponse = AliHFEtools::GetDefaultPID(kFALSE, fInputEvent->IsA() == AliAODEvent::Class());
237 fPID->SetPIDResponse(pidResponse);
239 fCFM->SetRecEventInfo(fESD);
242 AliCentrality *centrality = fESD->GetCentrality();
243 cent = centrality->GetCentralityPercentile("V0M");
251 for(Int_t iCluster=0; iCluster<fESD->GetNumberOfCaloClusters(); iCluster++)
253 AliESDCaloCluster *clust = fESD->GetCaloCluster(iCluster);
256 double clustE = clust->E();
257 float emcx[3]; // cluster pos
258 clust->GetPosition(emcx);
259 TVector3 clustpos(emcx[0],emcx[1],emcx[2]);
260 double emcphi = clustpos.Phi();
261 double emceta = clustpos.Eta();
263 calInfo[0] = emcphi; calInfo[1] = emceta; calInfo[2] = clustE; calInfo[3] = cent;
264 fEMCAccE->Fill(calInfo);
269 for (Int_t iTracks = 0; iTracks < fESD->GetNumberOfTracks(); iTracks++) {
270 AliESDtrack* track = fESD->GetTrack(iTracks);
272 printf("ERROR: Could not receive track %d\n", iTracks);
276 if(TMath::Abs(track->Eta())>0.7) continue;
278 fTrackPtBefTrkCuts->Fill(track->Pt());
279 // RecKine: ITSTPC cuts
280 if(!ProcessCutStep(AliHFEcuts::kStepRecKineITSTPC, track)) continue;
283 if(fRejectKinkMother) { // Quick and dirty fix to reject both kink mothers and daughters
284 if(track->GetKinkIndex(0) != 0) continue;
288 if(!ProcessCutStep(AliHFEcuts::kStepRecPrim, track)) continue;
290 // HFEcuts: ITS layers cuts
291 if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsITS, track)) continue;
294 fTrackPtAftTrkCuts->Fill(track->Pt());
296 Double_t mom = -999., eop=-999., pt = -999., dEdx=-999., fTPCnSigma=-10, phi=-999., eta=-999.;
298 // Track extrapolation
302 Int_t charge = track->Charge();
307 dEdx = track->GetTPCsignal();
308 fTPCnSigma = fPID->GetPIDResponse() ? fPID->GetPIDResponse()->NumberOfSigmasTPC(track, AliPID::kElectron) : 1000;
310 double ncells = -1.0;
314 double rmatch = -1.0;
315 double nmatch = -1.0;
318 Int_t clsId = track->GetEMCALcluster();
320 AliESDCaloCluster *clust = fESD->GetCaloCluster(clsId);
321 if(clust && clust->IsEMCAL()){
323 double clustE = clust->E();
324 eop = clustE/fabs(mom);
325 //double clustT = clust->GetTOF();
326 ncells = clust->GetNCells();
327 m02 = clust->GetM02();
328 m20 = clust->GetM20();
329 disp = clust->GetDispersion();
330 double delphi = clust->GetTrackDx();
331 double deleta = clust->GetTrackDz();
332 rmatch = sqrt(pow(delphi,2)+pow(deleta,2));
333 nmatch = clust->GetNTracksMatched();
336 valdedx[0] = mom; valdedx[1] = pt; valdedx[2] = dEdx; valdedx[3] = phi; valdedx[4] = eta; valdedx[5] = fTPCnSigma;
337 valdedx[6] = eop; valdedx[7] = rmatch; valdedx[8] = ncells, valdedx[9] = m02; valdedx[10] = m20; valdedx[11] = disp;
338 valdedx[12] = cent; valdedx[13] = charge;
339 fEleInfo->Fill(valdedx);
345 fdEdxBef->Fill(mom,dEdx);
346 fTPCnsigma->Fill(mom,fTPCnSigma);
349 // HFE cuts: TPC PID cleanup
350 if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsTPC, track)) continue;
352 if(fTPCnSigma >= 1.0 && fTPCnSigma <= 3)fTrkEovPBef->Fill(pt,eop);
357 AliHFEpidObject hfetrack;
358 hfetrack.SetAnalysisType(AliHFEpidObject::kESDanalysis);
359 hfetrack.SetRecTrack(track);
361 if(!fPID->IsSelected(&hfetrack, NULL, "", fPIDqa)) pidpassed = 0;
363 if(pidpassed==0) continue;
365 fTrkEovPAft->Fill(pt,eop);
366 fdEdxAft->Fill(mom,dEdx);
367 fIncpT->Fill(cent,pt);
369 Bool_t fFlagPhotonicElec = kFALSE;
370 SelectPhotonicElectron(iTracks,cent,track,fFlagPhotonicElec);
372 if(fFlagPhotonicElec) fPhoElecPt->Fill(cent,pt);
374 PostData(1, fOutputList);
376 //_________________________________________
377 void AliAnalysisTaskHFECal::UserCreateOutputObjects()
379 //--------Initialize PID
380 fPID->SetHasMCData(kFALSE);
381 if(!fPID->GetNumberOfPIDdetectors())
383 fPID->AddDetector("TPC", 0);
384 fPID->AddDetector("EMCAL", 1);
387 fPID->SortDetectors();
388 fPIDqa = new AliHFEpidQAmanager();
389 fPIDqa->Initialize(fPID);
391 //--------Initialize correction Framework and Cuts
392 fCFM = new AliCFManager;
393 const Int_t kNcutSteps = AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kNcutStepsRecTrack + AliHFEcuts::kNcutStepsDETrack;
394 fCFM->SetNStepParticle(kNcutSteps);
395 for(Int_t istep = 0; istep < kNcutSteps; istep++)
396 fCFM->SetParticleCutsList(istep, NULL);
399 AliWarning("Cuts not available. Default cuts will be used");
400 fCuts = new AliHFEcuts;
401 fCuts->CreateStandardCuts();
403 fCuts->Initialize(fCFM);
405 //---------Output Tlist
406 fOutputList = new TList();
407 fOutputList->SetOwner();
408 fOutputList->Add(fPIDqa->MakeList("PIDQA"));
410 fNoEvents = new TH1F("fNoEvents","",4,-0.5,3.5) ;
411 fOutputList->Add(fNoEvents);
413 Int_t binsE[4] = {250, 100, 1000, 100};
414 Double_t xminE[4] = {1.0, -1, 0.0, 0};
415 Double_t xmaxE[4] = {3.5, 1, 100.0, 100};
416 fEMCAccE = new THnSparseD("fEMCAccE","EMC acceptance & E;#eta;#phi;Energy;Centrality",4,binsE,xminE,xmaxE);
417 fOutputList->Add(fEMCAccE);
419 fTrkpt = new TH1F("fTrkpt","track pt",100,0,50);
420 fOutputList->Add(fTrkpt);
422 fTrackPtBefTrkCuts = new TH1F("fTrackPtBefTrkCuts","track pt before track cuts",100,0,50);
423 fOutputList->Add(fTrackPtBefTrkCuts);
425 fTrackPtAftTrkCuts = new TH1F("fTrackPtAftTrkCuts","track pt after track cuts",100,0,50);
426 fOutputList->Add(fTrackPtAftTrkCuts);
428 fTPCnsigma = new TH2F("fTPCnsigma", "TPC - n sigma",100,0,50,200,-10,10);
429 fOutputList->Add(fTPCnsigma);
431 fTrkEovPBef = new TH2F("fTrkEovPBef","track E/p before HFE pid",100,0,50,100,0,2);
432 fOutputList->Add(fTrkEovPBef);
434 fTrkEovPAft = new TH2F("fTrkEovPAft","track E/p after HFE pid",100,0,50,100,0,2);
435 fOutputList->Add(fTrkEovPAft);
437 fdEdxBef = new TH2F("fdEdxBef","track dEdx vs p before HFE pid",100,0,50,150,0,150);
438 fOutputList->Add(fdEdxBef);
440 fdEdxAft = new TH2F("fdEdxAft","track dEdx vs p after HFE pid",100,0,50,150,0,150);
441 fOutputList->Add(fdEdxAft);
443 fIncpT = new TH2F("fIncpT","HFE pid electro vs. centrality",100,0,100,100,0,50);
444 fOutputList->Add(fIncpT);
446 fInvmassLS = new TH2F("fInvmassLS", "Inv mass of LS (e,e); mass(GeV/c^2); counts;", 100,0,100,500,0,0.5);
447 fOutputList->Add(fInvmassLS);
449 fInvmassULS = new TH2F("fInvmassULS", "Inv mass of ULS (e,e); mass(GeV/c^2); counts;", 100,0,100,500,0,0.5);
450 fOutputList->Add(fInvmassULS);
452 fOpeningAngleLS = new TH1F("fOpeningAngleLS","Opening angle for LS pairs",100,0,1);
453 fOutputList->Add(fOpeningAngleLS);
455 fOpeningAngleULS = new TH1F("fOpeningAngleULS","Opening angle for ULS pairs",100,0,1);
456 fOutputList->Add(fOpeningAngleULS);
458 fPhotoElecPt = new TH1F("fPhotoElecPt", "photonic electron pt",100,0,50);
459 fOutputList->Add(fPhotoElecPt);
461 fPhoElecPt = new TH2F("fPhoElecPt", "Semi-inclusive electron pt",100,0,100,100,0,50);
462 fOutputList->Add(fPhoElecPt);
464 fCent = new TH1F("fCent","Centrality",100,0,100) ;
465 fOutputList->Add(fCent);
467 // Make common binning
468 const Double_t kMinP = 0.;
469 const Double_t kMaxP = 50.;
470 const Double_t kTPCSigMim = 40.;
471 const Double_t kTPCSigMax = 140.;
473 // 1st histogram: TPC dEdx with/without EMCAL (p, pT, TPC Signal, phi, eta, Sig, e/p, ,match, cell, M02, M20, Disp, Centrality, select)
474 Int_t nBins[14] = { 500, 500, 200, 60, 20, 600, 300, 100, 40, 200, 200, 200, 100, 3};
475 Double_t min[14] = {kMinP, kMinP, kTPCSigMim, 1.0, -1.0, -8.0, 0, 0, 0, 0.0, 0.0, 0.0, 0, -1.5};
476 Double_t max[14] = {kMaxP, kMaxP, kTPCSigMax, 4.0, 1.0, 4.0, 3.0, 0.1, 40, 2.0, 2.0, 2.0, 100, 1.5};
477 fEleInfo = new THnSparseD("fEleInfo", "p [GeV/c]; pT [GeV/c]; TPC signal;phi;eta;nSig; E/p;Rmatch;Ncell;M02;M20;Disp; Centrality; charge", 14, nBins, min, max);
478 fOutputList->Add(fEleInfo);
480 //_________________________________________________________
482 PostData(1,fOutputList);
485 //________________________________________________________________________
486 void AliAnalysisTaskHFECal::Terminate(Option_t *)
488 // Info("Terminate");
489 AliAnalysisTaskSE::Terminate();
492 //________________________________________________________________________
493 Bool_t AliAnalysisTaskHFECal::ProcessCutStep(Int_t cutStep, AliVParticle *track)
495 // Check single track cuts for a given cut step
496 const Int_t kMCOffset = AliHFEcuts::kNcutStepsMCTrack;
497 if(!fCFM->CheckParticleCuts(cutStep + kMCOffset, track)) return kFALSE;
500 //_________________________________________
501 void AliAnalysisTaskHFECal::SelectPhotonicElectron(Int_t itrack, Double_t cent, AliESDtrack *track, Bool_t &fFlagPhotonicElec)
503 //Identify non-heavy flavour electrons using Invariant mass method
505 fTrackCuts->SetAcceptKinkDaughters(kFALSE);
506 fTrackCuts->SetRequireTPCRefit(kTRUE);
507 fTrackCuts->SetEtaRange(-0.7,0.7);
508 fTrackCuts->SetRequireSigmaToVertex(kTRUE);
509 fTrackCuts->SetMaxChi2PerClusterTPC(3.5);
510 fTrackCuts->SetMinNClustersTPC(100);
512 const AliESDVertex *pVtx = fESD->GetPrimaryVertex();
514 Bool_t flagPhotonicElec = kFALSE;
516 for(Int_t jTracks = itrack+1; jTracks<fESD->GetNumberOfTracks(); jTracks++){
517 AliESDtrack* trackAsso = fESD->GetTrack(jTracks);
519 printf("ERROR: Could not receive track %d\n", jTracks);
523 Double_t dEdxAsso = -999., ptAsso=-999., openingAngle = -999.;
524 Double_t mass=999., width = -999;
525 Bool_t fFlagLS=kFALSE, fFlagULS=kFALSE;
527 dEdxAsso = trackAsso->GetTPCsignal();
528 ptAsso = trackAsso->Pt();
529 Int_t chargeAsso = trackAsso->Charge();
530 Int_t charge = track->Charge();
532 if(ptAsso <0.3) continue;
533 if(!fTrackCuts->AcceptTrack(trackAsso)) continue;
534 if(dEdxAsso <70 || dEdxAsso>100) continue; //11a pass1
536 Int_t fPDGe1 = 11; Int_t fPDGe2 = 11;
537 if(charge>0) fPDGe1 = -11;
538 if(chargeAsso>0) fPDGe2 = -11;
540 if(charge == chargeAsso) fFlagLS = kTRUE;
541 if(charge != chargeAsso) fFlagULS = kTRUE;
543 AliKFParticle ge1(*track, fPDGe1);
544 AliKFParticle ge2(*trackAsso, fPDGe2);
545 AliKFParticle recg(ge1, ge2);
547 if(recg.GetNDF()<1) continue;
548 Double_t chi2recg = recg.GetChi2()/recg.GetNDF();
549 if(TMath::Sqrt(TMath::Abs(chi2recg))>3.) continue;
551 AliKFVertex primV(*pVtx);
553 recg.SetProductionVertex(primV);
555 recg.SetMassConstraint(0,0.0001);
557 openingAngle = ge1.GetAngle(ge2);
558 if(fFlagLS) fOpeningAngleLS->Fill(openingAngle);
559 if(fFlagULS) fOpeningAngleULS->Fill(openingAngle);
561 if(openingAngle > fOpeningAngleCut) continue;
563 recg.GetMass(mass,width);
565 if(fFlagLS) fInvmassLS->Fill(cent,mass);
566 if(fFlagULS) fInvmassULS->Fill(cent,mass);
568 if(mass<fInvmassCut && fFlagULS && !flagPhotonicElec){
569 flagPhotonicElec = kTRUE;
573 fFlagPhotonicElec = flagPhotonicElec;