Fix name of output container (M. Zimmermann)
[u/mrichter/AliRoot.git] / PWGGA / EMCALTasks / 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"),
11d18b51 28 fMaxTrackPt(1000),
29 fTrackEfficiency(1),
680855e5 30 fTracksIn(0),
31 fTracksOut(0)
32{
33 // Constructor.
ab292aef 34
35 fAODfilterBits[0] = 0;
36 fAODfilterBits[1] = 0;
680855e5 37}
38
39//________________________________________________________________________
40AliEmcalPicoTrackMaker::AliEmcalPicoTrackMaker(const char *name) :
a070db7d 41 AliAnalysisTaskSE(name),
680855e5 42 fESDtrackCuts(0),
43 fTracksOutName("PicoTracks"),
44 fTracksInName("tracks"),
11d18b51 45 fMaxTrackPt(1000),
46 fTrackEfficiency(1),
680855e5 47 fTracksIn(0),
48 fTracksOut(0)
49{
50 // Constructor.
51
ab292aef 52 fAODfilterBits[0] = 0;
53 fAODfilterBits[1] = 0;
680855e5 54 fBranchNames = "ESD:AliESDHeader.,AliESDRun.,SPDVertex.,Tracks";
55}
56
57//________________________________________________________________________
58AliEmcalPicoTrackMaker::~AliEmcalPicoTrackMaker()
59{
a070db7d 60 // Destructor.
680855e5 61}
62
63//________________________________________________________________________
64void AliEmcalPicoTrackMaker::UserCreateOutputObjects()
65{
a070db7d 66 // Create my user objects.
680855e5 67
68 fTracksOut = new TClonesArray("AliPicoTrack");
69 fTracksOut->SetName(fTracksOutName);
70}
71
72//________________________________________________________________________
73void AliEmcalPicoTrackMaker::UserExec(Option_t *)
74{
75 // Main loop, called for each event.
76
77 AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
78 if (!am) {
79 AliError("Manager zero, returning");
80 return;
81 }
82
a070db7d 83 // retrieve tracks from input.
e44e8726 84 if (!fTracksIn) {
85 fTracksIn = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTracksInName));
86 if (!fTracksIn) {
87 AliError(Form("Could not retrieve tracks %s!", fTracksInName.Data()));
88 return;
89 }
90 if (!fTracksIn->GetClass()->GetBaseClass("AliVParticle")) {
91 AliError(Form("%s: Collection %s does not contain AliVParticle objects!", GetName(), fTracksInName.Data()));
92 return;
93 }
a070db7d 94 }
95
96 // add tracks to event if not yet there
c4a9715d 97 if (!(InputEvent()->FindListObject(fTracksOutName))) {
680855e5 98 InputEvent()->AddObject(fTracksOut);
c4a9715d 99 }
c4a9715d 100
a070db7d 101 // clear container (normally a null operation as the event should clean it already)
102 fTracksOut->Clear();
680855e5 103
a070db7d 104 // test if we are in ESD or AOD mode
105 Bool_t esdMode = kTRUE;
106 if (dynamic_cast<AliAODEvent*>(InputEvent())!=0)
107 esdMode = kFALSE;
108
109 // loop over tracks
110 const Int_t Ntracks = fTracksIn->GetEntriesFast();
680855e5 111 for (Int_t iTracks = 0, nacc = 0; iTracks < Ntracks; ++iTracks) {
85fbcc1d 112
e44e8726 113 AliVTrack *track = static_cast<AliVTrack*>(fTracksIn->At(iTracks));
85fbcc1d 114
a070db7d 115 if (!track)
680855e5 116 continue;
85fbcc1d 117
118 if (track->Pt() > fMaxTrackPt)
119 continue;
11d18b51 120
376d84a3 121 Bool_t isEmc = kFALSE;
c4a9715d 122 Int_t label = -1;
a070db7d 123 if (esdMode) {
124 if (fESDtrackCuts) {
125 AliESDtrack *esdtrack = static_cast<AliESDtrack*>(track);
126 if (!fESDtrackCuts->AcceptTrack(esdtrack))
127 continue;
128 }
129 label = track->GetLabel();
376d84a3 130 isEmc = track->IsEMCAL();
a070db7d 131 } else {
132 AliAODTrack *aodtrack = static_cast<AliAODTrack*>(track);
680855e5 133 if (aodtrack->TestFilterBit(fAODfilterBits[0]))
134 label = 0;
a070db7d 135 else if (aodtrack->TestFilterBit(fAODfilterBits[1]))
c4a9715d 136 label = 3;
a070db7d 137 else /*not a good track*/
138 continue;
376d84a3 139
140 if (TMath::Abs(track->GetTrackEtaOnEMCal()) < 0.75 &&
141 track->GetTrackPhiOnEMCal() > 70 * TMath::DegToRad() &&
142 track->GetTrackPhiOnEMCal() < 190 * TMath::DegToRad())
143 isEmc = kTRUE;
680855e5 144 }
145
11d18b51 146 if (fTrackEfficiency < 1) {
147 Double_t r = gRandom->Rndm();
148 if (fTrackEfficiency < r)
149 continue;
150 }
151
5cb6a7e6 152 /*AliPicoTrack *picotrack =*/ new ((*fTracksOut)[nacc]) AliPicoTrack(track->Pt(),
a070db7d 153 track->Eta(),
154 track->Phi(),
155 track->Charge(),
156 label,
157 track->GetTrackEtaOnEMCal(),
158 track->GetTrackPhiOnEMCal(),
376d84a3 159 isEmc);
680855e5 160 ++nacc;
161 }
162}