AliPhysics  e59a9ba (e59a9ba)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliEmcalTrackSelectionAOD.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2015, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 
16 #include <TClonesArray.h>
17 #include <TBits.h>
18 #include <TObjArray.h>
19 
20 #include <AliAODEvent.h>
21 #include <AliAODTrack.h>
23 #include <AliESDtrack.h>
24 #include <AliPicoTrack.h>
25 
29 
36  fFilterBits(0),
37  fFilterHybridTracks(kFALSE),
38  fFilterTPCTracks(kFALSE)
39 {
40  fHybridFilterBits[0] = -1;
41  fHybridFilterBits[1] = -1;
42 }
43 
52 AliEmcalTrackSelectionAOD::AliEmcalTrackSelectionAOD(AliVCuts* cuts, UInt_t filterbits):
54  fFilterBits(filterbits),
55  fFilterHybridTracks(kFALSE),
56  fFilterTPCTracks(kFALSE)
57 {
58  fHybridFilterBits[0] = -1;
59  fHybridFilterBits[1] = -1;
60  AddTrackCuts(cuts);
61 }
62 
71  fFilterBits(0),
72  fFilterHybridTracks(kFALSE),
73  fFilterTPCTracks(kFALSE)
74 {
75  fHybridFilterBits[0] = -1;
76  fHybridFilterBits[1] = -1;
77  GenerateTrackCuts(type, period);
78 }
79 
86 {
87  switch (type) {
88  case kHybridTracks:
89  if (fListOfCuts) fListOfCuts->Clear();
90  fFilterBits = 0;
91  fFilterHybridTracks = kTRUE;
92  fFilterTPCTracks = kFALSE;
94  fSelectionModeAny = kTRUE;
95  break;
96 
97  case kTPCOnlyTracks:
98  if (fListOfCuts) fListOfCuts->Clear();
99  fFilterBits = 0;
100  fFilterHybridTracks = kFALSE;
101  fHybridFilterBits[0] = -1;
102  fHybridFilterBits[1] = -1;
103  fFilterTPCTracks = kTRUE;
104  break;
105 
106  default:
107  break;
108  }
109 }
110 
123 {
124  AliAODTrack *aodt = dynamic_cast<AliAODTrack*>(trk);
125  if (!aodt){
126  AliPicoTrack *picotrack = dynamic_cast<AliPicoTrack*>(trk);
127  if(picotrack) {
128  aodt = dynamic_cast<AliAODTrack *>(picotrack->GetTrack());
129  }
130  else {
131  AliError("Track neither AOD track nor pico track");
132  return kFALSE;
133  }
134  }
135  if(!aodt){
136  AliError("Failed getting AOD track");
137  return kFALSE;
138  }
139 
140  fTrackBitmap.ResetAllBits();
141  Int_t cutcounter(0);
142  if (fFilterBits) {
143  if(aodt->TestFilterBit(fFilterBits)) fTrackBitmap.SetBitNumber(cutcounter);
144  cutcounter++;
145  }
146  if (fFilterHybridTracks) {
147  if (aodt->IsHybridGlobalConstrainedGlobal()) {
148  // If the hybrid filter bits are not provided (fHybridFilterBits[0] == 0) all hybrid tracks will be selected in the same group
149  if (fHybridFilterBits[0] < 0 || aodt->TestFilterBit(BIT(fHybridFilterBits[0]))) fTrackBitmap.SetBitNumber(cutcounter);
150  if (aodt->TestFilterBit(BIT(fHybridFilterBits[1]))) fTrackBitmap.SetBitNumber(cutcounter+1);
151  }
152  cutcounter += 2;
153  }
154  if (fFilterTPCTracks) {
155  if(aodt->IsHybridTPCConstrainedGlobal()) fTrackBitmap.SetBitNumber(cutcounter);
156  cutcounter++;
157  }
158  if (fListOfCuts) {
159  for (TIter cutIter = TIter(fListOfCuts).Begin(); cutIter != TIter::End(); ++cutIter){
160  AliVCuts *trackCuts = static_cast<AliVCuts*>(*cutIter);
161  if (trackCuts->IsA() == AliESDtrackCuts::Class()) {
162  // If track cuts are AliESDtrackCuts, the track needs to be converted to an AliESDtrack before
163  AliESDtrack copyTrack(aodt);
164  if (trackCuts->IsSelected(&copyTrack)) fTrackBitmap.SetBitNumber(cutcounter);
165  }
166  else{
167  if (trackCuts->IsSelected(aodt)) fTrackBitmap.SetBitNumber(cutcounter);
168  }
169  cutcounter++;
170  }
171  }
172 
173  if (fSelectionModeAny){
174  // In case of ANY one of the cuts need to be fulfilled (equivalent to one but set)
175  return fTrackBitmap.CountBits() > 0 || cutcounter == 0;
176  }
177  else {
178  // In case of ALL all of the cuts need to be fulfilled (equivalent to all bits set)
179  return fTrackBitmap.CountBits() == cutcounter;
180  }
181 }
182 
190 Bool_t AliEmcalTrackSelectionAOD::GetHybridFilterBits(Char_t bits[], TString period)
191 {
192  period.ToLower();
193  if (period == "lhc10b" || period == "lhc10c" || period == "lhc10d" ||
194  period == "lhc10e" || period == "lhc10h" ||
195  period == "lhc11h" || period == "lhc12a" || period == "lhc12b" ||
196  period == "lhc12c" || period == "lhc12d" || period == "lhc12e" ||
197  period == "lhc12f" || period == "lhc12g" || period == "lhc12h" ||
198  period == "lhc12i" || period == "lhc13b" || period == "lhc13c" ||
199  period == "lhc13d" || period == "lhc13e" || period == "lhc13f" ||
200  period == "lhc13g" ||
201  (period.Length() == 6 && period.BeginsWith("lhc15")) // all Run-2 data, excluding MC productions
202  ) {
203  bits[0] = 8;
204  bits[1] = 9;
205  }
206 
207  else if (period == "lhc10f7a" || period == "lhc12a15e" || period.BeginsWith("lhc12a17") ||
208  period == "lhc13b4" || period == "lhc13b4_fix" || period == "lhc13b4_plus" || period == "lhc14k1a" || period == "lhc14k1b" || period == "lhc13e4" ||
209  period.BeginsWith("lhc14a1") || period.BeginsWith("lhc13b2_efix") ||
210  period.BeginsWith("lhc15g6")) {
211  bits[0] = 8;
212  bits[1] = 9;
213  }
214 
215  else if (period == "lhc11a" || period == "lhc10hold" || period == "lhc11c" || period == "lhc11d") {
216  bits[0] = 8;
217  bits[1] = 4;
218  }
219 
220  else if (period.Contains("lhc12a15a") || period == "lhc12a15f" ||
221  period == "lhc12a15g" || period.BeginsWith("lhc11a1")) {
222  bits[0] = 8;
223  bits[1] = 4;
224  }
225 
226  else {
227  ::Error("AliEmcalTrackSelectionAOD::GetHybridFilterBits", "Could not find period %s! Hybrid tracks will be selected, but will not be able to distinguish between global and constrained.", period.Data());
228  bits[0] = -1;
229  bits[1] = -1;
230  return kFALSE;
231  }
232 
233  return kTRUE;
234 }
Interface for virtual track selection.
Char_t fHybridFilterBits[2]
Filter bits of hybrid tracks.
TObjArray * fListOfCuts
List of track cut objects.
Bool_t fFilterHybridTracks
Filter hybrid tracks using AliAODTrack::IsHybridGlobalConstrainedGlobal.
Bool_t fFilterTPCTracks
Filter TPC-only tracks using AliAODTrack::IsHybridGlobalConstrainedGlobal.
void AddTrackCuts(AliVCuts *cuts)
Implement virtual track selection for AOD analysis.
virtual bool IsTrackAccepted(AliVTrack *const trk)
AliVTrack * GetTrack() const
Definition: AliPicoTrack.h:59
Bool_t fSelectionModeAny
Accept track if any of the cuts is fulfilled.
TBits fTrackBitmap
Bitmap of last accepted/rejected track.
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
virtual void GenerateTrackCuts(ETrackFilterType_t type, const char *="")
static Bool_t GetHybridFilterBits(Char_t bits[], TString period)
UInt_t fFilterBits
Track filter bits.