AliPhysics  ec7afe5 (ec7afe5)
 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 
32  fFilterBits(0),
33  fFilterHybridTracks(kFALSE),
34  fFilterTPCTracks(kFALSE)
35 {
36  fHybridFilterBits[0] = -1;
37  fHybridFilterBits[1] = -1;
38 }
39 
42  fFilterBits(filterbits),
43  fFilterHybridTracks(kFALSE),
44  fFilterTPCTracks(kFALSE)
45 {
46  fHybridFilterBits[0] = -1;
47  fHybridFilterBits[1] = -1;
48  if(cuts) AddTrackCuts(cuts);
49 }
50 
53  fFilterBits(0),
54  fFilterHybridTracks(kFALSE),
55  fFilterTPCTracks(kFALSE)
56 {
57  fHybridFilterBits[0] = -1;
58  fHybridFilterBits[1] = -1;
59  GenerateTrackCuts(type, period);
60 }
61 
63 {
64  switch (type) {
65  case kHybridTracks:
66  if (fListOfCuts) fListOfCuts->Clear();
67  fFilterBits = 0;
68  fFilterHybridTracks = kTRUE;
69  fFilterTPCTracks = kFALSE;
71  fSelectionModeAny = kTRUE;
72  break;
73 
74  case kTPCOnlyTracks:
75  if (fListOfCuts) fListOfCuts->Clear();
76  fFilterBits = 0;
77  fFilterHybridTracks = kFALSE;
78  fHybridFilterBits[0] = -1;
79  fHybridFilterBits[1] = -1;
80  fFilterTPCTracks = kTRUE;
81  break;
82 
83  default:
84  break;
85  }
86 }
87 
88 bool AliEmcalTrackSelectionAOD::IsTrackAccepted(AliVTrack * const trk)
89 {
90  AliAODTrack *aodt = dynamic_cast<AliAODTrack*>(trk);
91  if (!aodt){
92  AliPicoTrack *picotrack = dynamic_cast<AliPicoTrack*>(trk);
93  if(picotrack) {
94  aodt = dynamic_cast<AliAODTrack *>(picotrack->GetTrack());
95  }
96  else {
97  AliError("Track neither AOD track nor pico track");
98  return kFALSE;
99  }
100  }
101  if(!aodt){
102  AliError("Failed getting AOD track");
103  return kFALSE;
104  }
105 
106  fTrackBitmap.ResetAllBits();
107  Int_t cutcounter(0);
108  if (fFilterBits) {
109  if(aodt->TestFilterBit(fFilterBits)) fTrackBitmap.SetBitNumber(cutcounter);
110  cutcounter++;
111  }
112  if (fFilterHybridTracks) {
113  if (aodt->IsHybridGlobalConstrainedGlobal()) {
114  // If the hybrid filter bits are not provided (fHybridFilterBits[0] == 0) all hybrid tracks will be selected in the same group
115  if (fHybridFilterBits[0] < 0 || aodt->TestFilterBit(BIT(fHybridFilterBits[0]))) fTrackBitmap.SetBitNumber(cutcounter);
116  if (aodt->TestFilterBit(BIT(fHybridFilterBits[1]))) fTrackBitmap.SetBitNumber(cutcounter+1);
117  }
118  cutcounter += 2;
119  }
120  if (fFilterTPCTracks) {
121  if(aodt->IsHybridTPCConstrainedGlobal()) fTrackBitmap.SetBitNumber(cutcounter);
122  cutcounter++;
123  }
124  if (fListOfCuts) {
125  for (auto cutIter : *fListOfCuts){
126  AliVCuts *trackCuts = static_cast<AliVCuts*>(static_cast<AliEmcalManagedObject *>(cutIter)->GetObject());
127  if (trackCuts->IsA() == AliESDtrackCuts::Class()) {
128  // If track cuts are AliESDtrackCuts, the track needs to be converted to an AliESDtrack before
129  AliESDtrack copyTrack(aodt);
130  if (trackCuts->IsSelected(&copyTrack)) fTrackBitmap.SetBitNumber(cutcounter);
131  }
132  else{
133  if (trackCuts->IsSelected(aodt)) fTrackBitmap.SetBitNumber(cutcounter);
134  }
135  cutcounter++;
136  }
137  }
138 
139  if (fSelectionModeAny){
140  // In case of ANY one of the cuts need to be fulfilled (equivalent to one but set)
141  return fTrackBitmap.CountBits() > 0 || cutcounter == 0;
142  }
143  else {
144  // In case of ALL all of the cuts need to be fulfilled (equivalent to all bits set)
145  return fTrackBitmap.CountBits() == cutcounter;
146  }
147 }
148 
150 {
151  period.ToLower();
152  if (period == "lhc10b" || period == "lhc10c" || period == "lhc10d" ||
153  period == "lhc10e" || period == "lhc10h" ||
154  period == "lhc11h" || period == "lhc12a" || period == "lhc12b" ||
155  period == "lhc12c" || period == "lhc12d" || period == "lhc12e" ||
156  period == "lhc12f" || period == "lhc12g" || period == "lhc12h" ||
157  period == "lhc12i" || period == "lhc13b" || period == "lhc13c" ||
158  period == "lhc13d" || period == "lhc13e" || period == "lhc13f" ||
159  period == "lhc13g" ||
160  (period.Length() == 6 && period.BeginsWith("lhc15")) // all Run-2 data, excluding MC productions
161  ) {
162  bits[0] = 8;
163  bits[1] = 9;
164  }
165 
166  else if (period == "lhc10f7a" || period == "lhc12a15e" || period.BeginsWith("lhc12a17") ||
167  period == "lhc13b4" || period == "lhc13b4_fix" || period == "lhc13b4_plus" || period == "lhc14k1a" || period == "lhc14k1b" || period == "lhc13e4" ||
168  period.BeginsWith("lhc14a1") || period.BeginsWith("lhc13b2_efix") ||
169  period.BeginsWith("lhc15g6")) {
170  bits[0] = 8;
171  bits[1] = 9;
172  }
173 
174  else if (period == "lhc11a" || period == "lhc10hold" || period == "lhc11c" || period == "lhc11d") {
175  bits[0] = 8;
176  bits[1] = 4;
177  }
178 
179  else if (period.Contains("lhc12a15a") || period == "lhc12a15f" ||
180  period == "lhc12a15g" || period.BeginsWith("lhc11a1")) {
181  bits[0] = 8;
182  bits[1] = 4;
183  }
184 
185  else {
186  ::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());
187  bits[0] = -1;
188  bits[1] = -1;
189  return kFALSE;
190  }
191 
192  return kTRUE;
193 }
Interface for virtual track selection.
TObject * GetObject(const TCollection *parent, const TString &name, const TClass *cls=0, Bool_t verbose=true)
Char_t fHybridFilterBits[2]
Filter bits of hybrid tracks.
char Char_t
Definition: External.C:18
TObjArray * fListOfCuts
List of track cut objects.
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
Bool_t fFilterHybridTracks
Filter hybrid tracks using AliAODTrack::IsHybridGlobalConstrainedGlobal.
Bool_t fFilterTPCTracks
Filter TPC-only tracks using AliAODTrack::IsHybridGlobalConstrainedGlobal.
void AddTrackCuts(AliVCuts *cuts)
Add new track cuts to the list of cuts.
Implement virtual track selection for AOD analysis.
virtual bool IsTrackAccepted(AliVTrack *const trk)
Performing track selection.
AliVTrack * GetTrack() const
Definition: AliPicoTrack.h:60
Bool_t fSelectionModeAny
Accept track if any of the cuts is fulfilled.
TBits fTrackBitmap
Bitmap of last accepted/rejected track.
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
ETrackFilterType_t
Pre-defined track filters.
virtual void GenerateTrackCuts(ETrackFilterType_t type, const char *="")
Automatically generates track cuts depending on the requested type of filtering.
static Bool_t GetHybridFilterBits(Char_t bits[], TString period)
Returns the hybrid filter bits according to a hard-coded look-up table.
AliEmcalTrackSelectionAOD()
Main constructor.
Smart pointer implementation for objects inheriting from TObject.
UInt_t fFilterBits
Track filter bits.
bool Bool_t
Definition: External.C:53