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