]>
Commit | Line | Data |
---|---|---|
fe75ca27 | 1 | // $Id: AliEmcalAodTrackFilterTask.cxx | Fri Dec 6 10:29:20 2013 +0100 | Constantin Loizides $ |
fb99243d CL |
2 | // |
3 | // Class to filter Aod tracks | |
4 | // | |
5 | // Author: C.Loizides | |
6 | ||
33a8056d | 7 | #include "AliEmcalAodTrackFilterTask.h" |
fb99243d CL |
8 | #include <TClonesArray.h> |
9 | #include <TRandom3.h> | |
fe75ca27 CL |
10 | #include <AliAODEvent.h> |
11 | #include <AliAODTrack.h> | |
12 | #include <AliAnalysisManager.h> | |
fe75ca27 | 13 | #include <AliEMCALRecoUtils.h> |
33a8056d | 14 | #include <AliLog.h> |
fb99243d | 15 | |
fe75ca27 | 16 | ClassImp(AliEmcalAodTrackFilterTask) |
fb99243d CL |
17 | |
18 | //________________________________________________________________________ | |
fe75ca27 CL |
19 | AliEmcalAodTrackFilterTask::AliEmcalAodTrackFilterTask() : |
20 | AliAnalysisTaskSE("AliEmcalAodTrackFilterTask"), | |
fb99243d CL |
21 | fTracksOutName("PicoTracks"), |
22 | fTracksInName("tracks"), | |
fb99243d | 23 | fIncludeNoITS(kTRUE), |
23670c45 | 24 | fCutMaxFrShTPCClus(0), |
fb99243d CL |
25 | fUseNegativeLabels(kTRUE), |
26 | fIsMC(kFALSE), | |
fe75ca27 | 27 | fDoPropagation(kFALSE), |
507ffd10 | 28 | fAttemptProp(kFALSE), |
29 | fAttemptPropMatch(kFALSE), | |
fe75ca27 | 30 | fDist(440), |
fb99243d CL |
31 | fTracksIn(0), |
32 | fTracksOut(0) | |
33 | { | |
34 | // Constructor. | |
35 | ||
36 | fAODfilterBits[0] = -1; | |
37 | fAODfilterBits[1] = -1; | |
38 | } | |
39 | ||
40 | //________________________________________________________________________ | |
fe75ca27 | 41 | AliEmcalAodTrackFilterTask::AliEmcalAodTrackFilterTask(const char *name) : |
fb99243d CL |
42 | AliAnalysisTaskSE(name), |
43 | fTracksOutName("PicoTracks"), | |
44 | fTracksInName("tracks"), | |
fb99243d | 45 | fIncludeNoITS(kTRUE), |
23670c45 | 46 | fCutMaxFrShTPCClus(0), |
fb99243d CL |
47 | fUseNegativeLabels(kTRUE), |
48 | fIsMC(kFALSE), | |
fe75ca27 | 49 | fDoPropagation(kFALSE), |
507ffd10 | 50 | fAttemptProp(kFALSE), |
51 | fAttemptPropMatch(kFALSE), | |
fe75ca27 | 52 | fDist(440), |
fb99243d CL |
53 | fTracksIn(0), |
54 | fTracksOut(0) | |
55 | { | |
56 | // Constructor. | |
57 | ||
58 | fAODfilterBits[0] = -1; | |
59 | fAODfilterBits[1] = -1; | |
60 | fBranchNames = "AOD:tracks"; | |
61 | } | |
62 | ||
63 | //________________________________________________________________________ | |
fe75ca27 | 64 | AliEmcalAodTrackFilterTask::~AliEmcalAodTrackFilterTask() |
fb99243d CL |
65 | { |
66 | // Destructor. | |
67 | } | |
68 | ||
69 | //________________________________________________________________________ | |
fe75ca27 | 70 | void AliEmcalAodTrackFilterTask::UserCreateOutputObjects() |
fb99243d CL |
71 | { |
72 | // Create my user objects. | |
73 | ||
74 | fTracksOut = new TClonesArray("AliAODTrack"); | |
fb99243d CL |
75 | fTracksOut->SetName(fTracksOutName); |
76 | } | |
77 | ||
78 | //________________________________________________________________________ | |
fe75ca27 | 79 | void AliEmcalAodTrackFilterTask::UserExec(Option_t *) |
fb99243d CL |
80 | { |
81 | // Main loop, called for each event. | |
82 | ||
83 | AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager(); | |
84 | if (!am) { | |
85 | AliError("Manager zero, returning"); | |
86 | return; | |
87 | } | |
88 | ||
89 | // retrieve tracks from input. | |
90 | if (!fTracksIn) { | |
91 | fTracksIn = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTracksInName)); | |
92 | if (!fTracksIn) { | |
93 | AliError(Form("Could not retrieve tracks %s!", fTracksInName.Data())); | |
94 | return; | |
95 | } | |
96 | if (!fTracksIn->GetClass()->GetBaseClass("AliVParticle")) { | |
97 | AliError(Form("%s: Collection %s does not contain AliVParticle objects!", GetName(), fTracksInName.Data())); | |
98 | return; | |
99 | } | |
100 | } | |
101 | ||
102 | // add tracks to event if not yet there | |
103 | fTracksOut->Delete(); | |
104 | if (!(InputEvent()->FindListObject(fTracksOutName))) { | |
105 | InputEvent()->AddObject(fTracksOut); | |
106 | } | |
107 | ||
108 | // loop over tracks | |
109 | const Int_t Ntracks = fTracksIn->GetEntriesFast(); | |
110 | for (Int_t iTracks = 0, nacc = 0; iTracks < Ntracks; ++iTracks) { | |
111 | ||
112 | AliAODTrack *track = static_cast<AliAODTrack*>(fTracksIn->At(iTracks)); | |
113 | ||
114 | if (!track) | |
115 | continue; | |
fb99243d | 116 | Int_t type = -1; |
fb99243d CL |
117 | if (fAODfilterBits[0] < 0) { |
118 | if (track->IsHybridGlobalConstrainedGlobal()) | |
119 | type = 3; | |
120 | else /*not a good track*/ | |
121 | continue; | |
122 | } else { | |
123 | if (track->TestFilterBit(fAODfilterBits[0])) { | |
124 | type = 0; | |
125 | } else if (track->TestFilterBit(fAODfilterBits[1])) { | |
126 | if ((track->GetStatus()&AliVTrack::kITSrefit)==0) { | |
127 | if (fIncludeNoITS) | |
128 | type = 2; | |
129 | else | |
130 | continue; | |
131 | } else { | |
132 | type = 1; | |
133 | } | |
134 | } | |
135 | else {/*not a good track*/ | |
136 | continue; | |
137 | } | |
138 | } | |
fe75ca27 | 139 | |
fb99243d CL |
140 | if (fCutMaxFrShTPCClus > 0) { |
141 | Double_t frac = Double_t(track->GetTPCnclsS()) / Double_t(track->GetTPCncls()); | |
23670c45 | 142 | if (frac > fCutMaxFrShTPCClus) { |
fb99243d | 143 | continue; |
23670c45 | 144 | } |
fb99243d | 145 | } |
fb99243d | 146 | |
33a8056d | 147 | AliAODTrack *newt = new ((*fTracksOut)[nacc]) AliAODTrack(*track); |
14ba40fc | 148 | newt->SetUniqueID(0); |
149 | newt->ResetBit(TObject::kHasUUID); | |
150 | newt->ResetBit(TObject::kIsReferenced); | |
151 | ||
507ffd10 | 152 | Bool_t propthistrack = kFALSE; |
33a8056d | 153 | if (fDoPropagation) |
507ffd10 | 154 | propthistrack = kTRUE; |
155 | else if (!newt->IsExtrapolatedToEMCAL()) { | |
156 | if (fAttemptProp) | |
157 | propthistrack = kTRUE; | |
158 | else if (fAttemptPropMatch && !newt->IsEMCAL()) | |
159 | propthistrack = kTRUE; | |
160 | } | |
161 | if (propthistrack) | |
33a8056d | 162 | AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(newt,fDist); |
507ffd10 | 163 | |
fb99243d CL |
164 | Int_t label = 0; |
165 | if (fIsMC) { | |
166 | if (fUseNegativeLabels) | |
167 | label = track->GetLabel(); | |
168 | else | |
169 | label = TMath::Abs(track->GetLabel()); | |
fb99243d CL |
170 | if (label == 0) |
171 | AliDebug(2,Form("Track %d with label==0", iTracks)); | |
172 | } | |
33a8056d | 173 | if (type==0) { |
32c97abe | 174 | newt->SetBit(BIT(22),0); |
175 | newt->SetBit(BIT(23),0); | |
33a8056d | 176 | } else if (type==1) { |
32c97abe | 177 | newt->SetBit(BIT(22),1); |
178 | newt->SetBit(BIT(23),0); | |
33a8056d | 179 | } else if (type==2) { |
32c97abe | 180 | newt->SetBit(BIT(22),0); |
181 | newt->SetBit(BIT(23),1); | |
33a8056d | 182 | } else if (type==3) { |
32c97abe | 183 | newt->SetBit(BIT(22),1); |
184 | newt->SetBit(BIT(23),1); | |
fb99243d CL |
185 | } |
186 | ++nacc; | |
187 | } | |
188 | } |