increased fDebug requirement for some output of AliAnalysisTaskPi0Flow.cxx
[u/mrichter/AliRoot.git] / PWG / EMCAL / AliEmcalPicoTrackMaker.cxx
CommitLineData
980821ba 1// $Id$
680855e5 2//
3// Class to make PicoTracks in AOD/ESD events.
4//
cd231d42 5// Author: S.Aiola, C.Loizides
680855e5 6
7#include <TClonesArray.h>
11d18b51 8#include <TRandom3.h>
9
a070db7d 10#include "AliAODEvent.h"
680855e5 11#include "AliAODTrack.h"
a070db7d 12#include "AliAnalysisManager.h"
680855e5 13#include "AliESDtrack.h"
14#include "AliESDtrackCuts.h"
15#include "AliLog.h"
a070db7d 16#include "AliPicoTrack.h"
17#include "AliVTrack.h"
680855e5 18#include "AliEmcalPicoTrackMaker.h"
19
20ClassImp(AliEmcalPicoTrackMaker)
21
22//________________________________________________________________________
23AliEmcalPicoTrackMaker::AliEmcalPicoTrackMaker() :
24 AliAnalysisTaskSE("AliEmcalPicoTrackMaker"),
25 fESDtrackCuts(0),
26 fTracksOutName("PicoTracks"),
27 fTracksInName("tracks"),
9733b37f 28 fMinTrackPt(0),
11d18b51 29 fMaxTrackPt(1000),
9733b37f 30 fMinTrackEta(-0.9),
31 fMaxTrackEta(0.9),
32 fMinTrackPhi(-10),
33 fMaxTrackPhi(10),
11d18b51 34 fTrackEfficiency(1),
680855e5 35 fTracksIn(0),
36 fTracksOut(0)
37{
38 // Constructor.
ab292aef 39
40 fAODfilterBits[0] = 0;
41 fAODfilterBits[1] = 0;
680855e5 42}
43
44//________________________________________________________________________
45AliEmcalPicoTrackMaker::AliEmcalPicoTrackMaker(const char *name) :
a070db7d 46 AliAnalysisTaskSE(name),
680855e5 47 fESDtrackCuts(0),
48 fTracksOutName("PicoTracks"),
49 fTracksInName("tracks"),
9733b37f 50 fMinTrackPt(0),
11d18b51 51 fMaxTrackPt(1000),
9733b37f 52 fMinTrackEta(-0.9),
53 fMaxTrackEta(0.9),
54 fMinTrackPhi(-10),
55 fMaxTrackPhi(10),
11d18b51 56 fTrackEfficiency(1),
680855e5 57 fTracksIn(0),
58 fTracksOut(0)
59{
60 // Constructor.
61
ab292aef 62 fAODfilterBits[0] = 0;
63 fAODfilterBits[1] = 0;
680855e5 64 fBranchNames = "ESD:AliESDHeader.,AliESDRun.,SPDVertex.,Tracks";
65}
66
67//________________________________________________________________________
68AliEmcalPicoTrackMaker::~AliEmcalPicoTrackMaker()
69{
a070db7d 70 // Destructor.
680855e5 71}
72
73//________________________________________________________________________
74void AliEmcalPicoTrackMaker::UserCreateOutputObjects()
75{
a070db7d 76 // Create my user objects.
680855e5 77
78 fTracksOut = new TClonesArray("AliPicoTrack");
79 fTracksOut->SetName(fTracksOutName);
80}
81
82//________________________________________________________________________
83void AliEmcalPicoTrackMaker::UserExec(Option_t *)
84{
85 // Main loop, called for each event.
86
87 AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
88 if (!am) {
89 AliError("Manager zero, returning");
90 return;
91 }
92
a070db7d 93 // retrieve tracks from input.
e44e8726 94 if (!fTracksIn) {
95 fTracksIn = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTracksInName));
96 if (!fTracksIn) {
97 AliError(Form("Could not retrieve tracks %s!", fTracksInName.Data()));
98 return;
99 }
100 if (!fTracksIn->GetClass()->GetBaseClass("AliVParticle")) {
101 AliError(Form("%s: Collection %s does not contain AliVParticle objects!", GetName(), fTracksInName.Data()));
102 return;
103 }
a070db7d 104 }
105
106 // add tracks to event if not yet there
c4a9715d 107 if (!(InputEvent()->FindListObject(fTracksOutName))) {
680855e5 108 InputEvent()->AddObject(fTracksOut);
c4a9715d 109 }
c4a9715d 110
a070db7d 111 // clear container (normally a null operation as the event should clean it already)
112 fTracksOut->Clear();
680855e5 113
a070db7d 114 // test if we are in ESD or AOD mode
115 Bool_t esdMode = kTRUE;
116 if (dynamic_cast<AliAODEvent*>(InputEvent())!=0)
117 esdMode = kFALSE;
118
119 // loop over tracks
120 const Int_t Ntracks = fTracksIn->GetEntriesFast();
680855e5 121 for (Int_t iTracks = 0, nacc = 0; iTracks < Ntracks; ++iTracks) {
85fbcc1d 122
e44e8726 123 AliVTrack *track = static_cast<AliVTrack*>(fTracksIn->At(iTracks));
85fbcc1d 124
a070db7d 125 if (!track)
680855e5 126 continue;
85fbcc1d 127
9733b37f 128 if (track->Pt() > fMaxTrackPt || track->Pt() < fMinTrackPt)
129 continue;
130
131 if (track->Eta() < fMinTrackEta || track->Eta() > fMaxTrackEta ||
132 track->Phi() < fMinTrackPhi || track->Phi() > fMaxTrackPhi)
85fbcc1d 133 continue;
11d18b51 134
376d84a3 135 Bool_t isEmc = kFALSE;
c4a9715d 136 Int_t label = -1;
a070db7d 137 if (esdMode) {
138 if (fESDtrackCuts) {
139 AliESDtrack *esdtrack = static_cast<AliESDtrack*>(track);
140 if (!fESDtrackCuts->AcceptTrack(esdtrack))
141 continue;
142 }
143 label = track->GetLabel();
376d84a3 144 isEmc = track->IsEMCAL();
a070db7d 145 } else {
146 AliAODTrack *aodtrack = static_cast<AliAODTrack*>(track);
680855e5 147 if (aodtrack->TestFilterBit(fAODfilterBits[0]))
148 label = 0;
a070db7d 149 else if (aodtrack->TestFilterBit(fAODfilterBits[1]))
c4a9715d 150 label = 3;
a070db7d 151 else /*not a good track*/
152 continue;
376d84a3 153
154 if (TMath::Abs(track->GetTrackEtaOnEMCal()) < 0.75 &&
155 track->GetTrackPhiOnEMCal() > 70 * TMath::DegToRad() &&
156 track->GetTrackPhiOnEMCal() < 190 * TMath::DegToRad())
157 isEmc = kTRUE;
680855e5 158 }
159
11d18b51 160 if (fTrackEfficiency < 1) {
161 Double_t r = gRandom->Rndm();
162 if (fTrackEfficiency < r)
163 continue;
164 }
165
5cb6a7e6 166 /*AliPicoTrack *picotrack =*/ new ((*fTracksOut)[nacc]) AliPicoTrack(track->Pt(),
a070db7d 167 track->Eta(),
168 track->Phi(),
169 track->Charge(),
170 label,
171 track->GetTrackEtaOnEMCal(),
172 track->GetTrackPhiOnEMCal(),
376d84a3 173 isEmc);
680855e5 174 ++nacc;
175 }
176}