2011 track cuts
[u/mrichter/AliRoot.git] / PWG / EMCAL / AliEmcalTrackPropagatorTask.cxx
CommitLineData
6ea93b32 1// $Id$
2//
3// Task to propagate tracks to EMCAL surface.
4//
cd231d42 5// Author: C.Loizides
6ea93b32 6
7#include <TClonesArray.h>
8#include "AliAnalysisManager.h"
9#include "AliEMCALRecoUtils.h"
10#include "AliESDEvent.h"
11#include "AliEmcalTrackPropagatorTask.h"
12
13ClassImp(AliEmcalTrackPropagatorTask)
14
15//________________________________________________________________________
16AliEmcalTrackPropagatorTask::AliEmcalTrackPropagatorTask() :
27fde6c7 17 AliAnalysisTaskSE("AliEmcalTrackPropagatorTask"),
6ea93b32 18 fRecoUtils(0),
19 fTracksName(),
20 fDist(430),
b6ed62e4 21 fMinPtCut(0.35),
6ea93b32 22 fEsdEv(0),
23 fTracks(0)
24{
25 // Constructor.
26}
27
28//________________________________________________________________________
29AliEmcalTrackPropagatorTask::AliEmcalTrackPropagatorTask(const char *name) :
27fde6c7 30 AliAnalysisTaskSE("AliEmcalTrackPropagatorTask"),
6ea93b32 31 fRecoUtils(0),
32 fTracksName("TpcSpdVertexConstrainedTracks"),
33 fDist(430),
b6ed62e4 34 fMinPtCut(0.35),
6ea93b32 35 fEsdEv(0),
36 fTracks(0)
37{
38 // Constructor.
27fde6c7 39
40 if (!name)
41 return;
42
43 SetName(name);
44
6ea93b32 45 fBranchNames = "ESD:AliESDHeader.,Tracks";
46}
47
48//________________________________________________________________________
49AliEmcalTrackPropagatorTask::~AliEmcalTrackPropagatorTask()
50{
a7985532 51 // Destructor.
6ea93b32 52
53 delete fRecoUtils;
54}
55
56//________________________________________________________________________
57void AliEmcalTrackPropagatorTask::UserCreateOutputObjects()
58{
59 // Create histograms.
60
61 if (!fRecoUtils) {
62 fRecoUtils = new AliEMCALRecoUtils;
63 fRecoUtils->SetStep(25);
a7985532 64 AliInfo("No reco utils given, creating default utils");
6ea93b32 65 }
66}
67
68//________________________________________________________________________
69void AliEmcalTrackPropagatorTask::UserExec(Option_t *)
70{
71 // Main loop, called for each event.
72
73 fEsdEv = dynamic_cast<AliESDEvent*>(InputEvent());
74 if (!fEsdEv) {
75 AliError("Task works only on ESD events, returning");
76 return;
77 }
78
79 AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
80 if (!am) {
81 AliError("Manager zero, returning");
82 return;
83 }
84
85 // get tracks from event if not yet there
86 if (fTracksName == "Tracks")
87 am->LoadBranch("Tracks");
88 fTracks = dynamic_cast<TClonesArray*>((InputEvent()->FindListObject(fTracksName)));
89 if (!fTracks) {
90 AliError(Form("Could not get tracks %s, returning", fTracksName.Data()));
91 return;
92 }
93
94 // Loop over all tracks
95 const Int_t ntr = fTracks->GetEntries();
96 for (Int_t i=0; i<ntr; ++i) {
97 AliESDtrack *eTrack = static_cast<AliESDtrack*>(fTracks->At(i));
98 if (!eTrack)
99 continue;
6c11816d 100 eTrack->ResetStatus(AliVTrack::kEMCALmatch);
6ea93b32 101 if(eTrack->Pt()<fMinPtCut)
102 continue;
103 Double_t phi = eTrack->Phi()*TMath::RadToDeg();
104 if (TMath::Abs(eTrack->Eta())>0.8 || phi <= 20 || phi >= 240)
b6ed62e4 105 continue;
6ea93b32 106 AliExternalTrackParam *trackParam = const_cast<AliExternalTrackParam*>(eTrack->GetInnerParam());
107 if(!trackParam)
108 continue;
109
110 // Extrapolate the track to EMCal surface
111 AliExternalTrackParam emcalParam(*trackParam);
6d0ab973 112 Float_t etaout=-999, phiout=-999;
6ea93b32 113 Bool_t ret = fRecoUtils->ExtrapolateTrackToEMCalSurface(&emcalParam,
114 fDist,
115 fRecoUtils->GetMass(),
116 fRecoUtils->GetStepSurface(),
117 etaout,
118 phiout);
119 if (!ret)
120 continue;
6c11816d 121 if (TMath::Abs(etaout)>0.75 || (phiout<70*TMath::DegToRad()) || (phiout>190*TMath::DegToRad()))
122 continue;
6ea93b32 123 eTrack->SetOuterParam(&emcalParam,AliExternalTrackParam::kMultSec);
e0bf6fd7 124 eTrack->SetTrackPhiEtaOnEMCal(phiout, etaout);
6c11816d 125 eTrack->SetStatus(AliVTrack::kEMCALmatch);
6ea93b32 126 }
127}