fixing the trunk compilaton error by adding the correct files
[u/mrichter/AliRoot.git] / PWGGA / EMCALTasks / AliEmcalPicoTrackMaker.cxx
CommitLineData
680855e5 1// $Id: AliEmcalPicoTrackMaker.cxx $
2//
3// Class to make PicoTracks in AOD/ESD events.
4//
5//
6
7#include <TClonesArray.h>
8
9#include "AliAnalysisManager.h"
10#include "AliVEvent.h"
11#include "AliPicoTrack.h"
12#include "AliVTrack.h"
13#include "AliAODTrack.h"
14#include "AliESDtrack.h"
15#include "AliESDtrackCuts.h"
16#include "AliLog.h"
17
18#include "AliEmcalPicoTrackMaker.h"
19
20ClassImp(AliEmcalPicoTrackMaker)
21
22//________________________________________________________________________
23AliEmcalPicoTrackMaker::AliEmcalPicoTrackMaker() :
24 AliAnalysisTaskSE("AliEmcalPicoTrackMaker"),
25 fESDtrackCuts(0),
26 fTracksOutName("PicoTracks"),
27 fTracksInName("tracks"),
28 fTracksIn(0),
29 fTracksOut(0)
30{
31 // Constructor.
32}
33
34//________________________________________________________________________
35AliEmcalPicoTrackMaker::AliEmcalPicoTrackMaker(const char *name) :
36 AliAnalysisTaskSE("AliEmcalPicoTrackMaker"),
37 fESDtrackCuts(0),
38 fTracksOutName("PicoTracks"),
39 fTracksInName("tracks"),
40 fTracksIn(0),
41 fTracksOut(0)
42{
43 // Constructor.
44
45 if (!name)
46 return;
47
48 SetName(name);
49
50 fBranchNames = "ESD:AliESDHeader.,AliESDRun.,SPDVertex.,Tracks";
51}
52
53//________________________________________________________________________
54AliEmcalPicoTrackMaker::~AliEmcalPicoTrackMaker()
55{
56 //Destructor
57
58}
59
60//________________________________________________________________________
61void AliEmcalPicoTrackMaker::UserCreateOutputObjects()
62{
63 // Create histograms.
64
65 fTracksOut = new TClonesArray("AliPicoTrack");
66 fTracksOut->SetName(fTracksOutName);
67}
68
69//________________________________________________________________________
70void AliEmcalPicoTrackMaker::UserExec(Option_t *)
71{
72 // Main loop, called for each event.
73
74 AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
75 if (!am) {
76 AliError("Manager zero, returning");
77 return;
78 }
79
80 RetrieveEventObjects();
81
82 // add tracks to event if not yet there
83 if (!(InputEvent()->FindListObject(fTracksOutName)))
84 InputEvent()->AddObject(fTracksOut);
85
86 Int_t Ntracks = GetNumberOfTracks();
87 for (Int_t iTracks = 0, nacc = 0; iTracks < Ntracks; ++iTracks) {
88 AliVTrack *track = GetTrack(iTracks);
89
90 if (!AcceptTrack(track))
91 continue;
92
93 Int_t label = 0;
94
95 if (track->InheritsFrom("AliAODTrack")) {
96 AliAODTrack *aodtrack = dynamic_cast<AliAODTrack*>(track);
97 if (aodtrack->TestFilterBit(fAODfilterBits[0]))
98 label = 0;
99 else if (aodtrack->TestFilterBit(fAODfilterBits[1]))
100 label = 1;
101 else //if (aodtrack->TestFilterBit(fAODfilterBits[2]))
102 label = 2;
103 }
104 else {
105 label = track->GetLabel();
106 }
107
108 AliPicoTrack *picotrack = new ((*fTracksOut)[nacc]) AliPicoTrack(track->Pt(), track->Eta(), track->Phi(),
109 track->Charge(), label,
110 track->GetTrackEtaOnEMCal(), track->GetTrackPhiOnEMCal(), track->IsEMCAL());
111 if (track->IsEMCAL()) {
112 picotrack->SetEMCALcluster(track->GetEMCALcluster());
113 }
114 //cout << iTracks << " - is emcal = " << track->IsEMCAL() << ", phiemc = " << track->GetTrackPhiOnEMCal() << ", etaemc = " << track->GetTrackEtaOnEMCal() << ", emcid = " << track->GetEMCALcluster() << endl;
115 ++nacc;
116 }
117}
118
119
120//________________________________________________________________________
121Bool_t AliEmcalPicoTrackMaker::AcceptTrack(AliVTrack *track)
122{
123 if (!track)
124 return kFALSE;
125
126 if (track->InheritsFrom("AliAODTrack")) {
127 AliAODTrack *aodtrack = dynamic_cast<AliAODTrack*>(track);
128 if (aodtrack) {
129 //cout << "filter bit = " << fFilterBit << ", filter map = " << aodtrack->GetFilterMap() << endl;
130 return aodtrack->TestFilterBit(fAODfilterBits[0]+fAODfilterBits[1]+fAODfilterBits[2]);
131 //return aodtrack->IsHybridGlobalConstrainedGlobal();
132 }
133 else {
134 AliError("Could not cast AOD track!");
135 return kFALSE;
136 }
137 }
138 else if (track->InheritsFrom("AliESDtrack")) {
139 if (fESDtrackCuts) {
140 AliESDtrack *esdtrack = dynamic_cast<AliESDtrack*>(track);
141 if (esdtrack) {
142 return fESDtrackCuts->AcceptTrack(esdtrack);
143 }
144 else {
145 AliError("Could not cast ESD track!");
146 return kFALSE;
147 }
148 }
149 else {
150 return kTRUE;
151 }
152 }
153 else if (track->InheritsFrom("PicoTrack")) {
154 AliWarning("PicoTrack: nothing to filter!");
155 return kTRUE;
156 }
157}
158
159//________________________________________________________________________
160void AliEmcalPicoTrackMaker::RetrieveEventObjects()
161{
162 fTracksIn = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTracksInName));
163
164 if (!fTracksIn) {
165 AliError(Form("ERROR: Could not retrieve tracks %s!", fTracksInName.Data()));
166 }
167}
168
169//________________________________________________________________________
170AliVTrack* AliEmcalPicoTrackMaker::GetTrack(const Int_t i) const
171{
172 if (fTracksIn)
173 return dynamic_cast<AliVTrack*>(fTracksIn->At(i));
174 else
175 return 0;
176}
177
178//________________________________________________________________________
179Int_t AliEmcalPicoTrackMaker::GetNumberOfTracks() const
180{
181 if (fTracksIn)
182 return fTracksIn->GetEntriesFast();
183 else
184 return 0;
185}