AliPhysics  c6e65cb (c6e65cb)
 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>
24 #include <AliESDtrack.h>
25 #include <AliESDtrackCuts.h>
26 #include <AliPicoTrack.h>
27 
31 
34  fFilterBits(0),
35  fFilterHybridTracks(kFALSE),
36  fFilterTPCTracks(kFALSE)
37 {
38  fHybridFilterBits[0] = -1;
39  fHybridFilterBits[1] = -1;
40 }
41 
44  fFilterBits(filterbits),
45  fFilterHybridTracks(kFALSE),
46  fFilterTPCTracks(kFALSE)
47 {
48  fHybridFilterBits[0] = -1;
49  fHybridFilterBits[1] = -1;
50  if(cuts) AddTrackCuts(cuts);
51 }
52 
55  fFilterBits(0),
56  fFilterHybridTracks(kFALSE),
57  fFilterTPCTracks(kFALSE)
58 {
59  fHybridFilterBits[0] = -1;
60  fHybridFilterBits[1] = -1;
61  GenerateTrackCuts(type, period);
62 }
63 
65 {
66  switch (type) {
67  case kHybridTracks:
68  if (fListOfCuts) fListOfCuts->Clear();
69  fFilterBits = 0;
70  fFilterHybridTracks = kTRUE;
71  fFilterTPCTracks = kFALSE;
73  fSelectionModeAny = kTRUE;
74  break;
75 
76  case kTPCOnlyTracks:
77  if (fListOfCuts) fListOfCuts->Clear();
78  fFilterBits = 0;
79  fFilterHybridTracks = kFALSE;
80  fHybridFilterBits[0] = -1;
81  fHybridFilterBits[1] = -1;
82  fFilterTPCTracks = kTRUE;
83  break;
84 
86  if (fListOfCuts) fListOfCuts->Clear();
87  AddTrackCuts(AliESDtrackCuts::GetStandardITSSATrackCuts2010());
88  fFilterHybridTracks = kFALSE;
89  fFilterTPCTracks = kFALSE;
90  fHybridFilterBits[0] = -1;
91  fHybridFilterBits[1] = -1;
92  break;
93 
94  default:
95  break;
96  }
97 }
98 
99 bool AliEmcalTrackSelectionAOD::IsTrackAccepted(AliVTrack * const trk)
100 {
101  AliAODTrack *aodt = dynamic_cast<AliAODTrack*>(trk);
102  if (!aodt){
103  AliPicoTrack *picotrack = dynamic_cast<AliPicoTrack*>(trk);
104  if(picotrack) {
105  aodt = dynamic_cast<AliAODTrack *>(picotrack->GetTrack());
106  }
107  else {
108  AliError("Track neither AOD track nor pico track");
109  return kFALSE;
110  }
111  }
112  if(!aodt){
113  AliError("Failed getting AOD track");
114  return kFALSE;
115  }
116 
117  fTrackBitmap.ResetAllBits();
118  UInt_t cutcounter(0);
119  if (fFilterBits) {
120  if(aodt->TestFilterBit(fFilterBits)) fTrackBitmap.SetBitNumber(cutcounter);
121  cutcounter++;
122  }
123  if (fFilterHybridTracks) {
124  if (aodt->IsHybridGlobalConstrainedGlobal()) {
125  // If the hybrid filter bits are not provided (fHybridFilterBits[0] == 0) all hybrid tracks will be selected in the same group
126  if (fHybridFilterBits[0] < 0 || aodt->TestFilterBit(BIT(fHybridFilterBits[0]))) fTrackBitmap.SetBitNumber(cutcounter);
127  if (aodt->TestFilterBit(BIT(fHybridFilterBits[1]))) fTrackBitmap.SetBitNumber(cutcounter+1);
128  }
129  cutcounter += 2;
130  }
131  if (fFilterTPCTracks) {
132  if(aodt->IsHybridTPCConstrainedGlobal()) fTrackBitmap.SetBitNumber(cutcounter);
133  cutcounter++;
134  }
135  if (fListOfCuts) {
136  for (auto cutIter : *fListOfCuts){
137  AliVCuts *trackCuts = static_cast<AliVCuts*>(static_cast<AliEmcalManagedObject *>(cutIter)->GetObject());
138  if (trackCuts->IsA() == AliESDtrackCuts::Class()) {
139  // If track cuts are AliESDtrackCuts, AcceptVTrack needs to be called as the interface function IsSelected supports only AliESDtracks
140  AliESDtrackCuts *esdcuts = static_cast<AliESDtrackCuts *>(trackCuts);
141  if(esdcuts->AcceptVTrack(aodt)) fTrackBitmap.SetBitNumber(cutcounter);
142  }
143  else{
144  if (trackCuts->IsSelected(aodt)) fTrackBitmap.SetBitNumber(cutcounter);
145  }
146  cutcounter++;
147  }
148  }
149 
150  if (fSelectionModeAny){
151  // In case of ANY one of the cuts need to be fulfilled (equivalent to one but set)
152  return fTrackBitmap.CountBits() > 0 || cutcounter == 0;
153  }
154  else {
155  // In case of ALL all of the cuts need to be fulfilled (equivalent to all bits set)
156  return fTrackBitmap.CountBits() == cutcounter;
157  }
158 }
159 
161 {
162  period.ToLower();
163  if (period == "lhc10b" || period == "lhc10c" || period == "lhc10d" ||
164  period == "lhc10e" || period == "lhc10h" ||
165  period == "lhc11h" || period == "lhc12a" || period == "lhc12b" ||
166  period == "lhc12c" || period == "lhc12d" || period == "lhc12e" ||
167  period == "lhc12f" || period == "lhc12g" || period == "lhc12h" ||
168  period == "lhc12i" || period == "lhc13b" || period == "lhc13c" ||
169  period == "lhc13d" || period == "lhc13e" || period == "lhc13f" ||
170  period == "lhc13g" ||
171  (period.Length() == 6 && (period.BeginsWith("lhc15") || period.BeginsWith("lhc16") || period.BeginsWith("lhc17"))) // all Run-2 data, excluding MC productions
172  ) {
173  bits[0] = 8;
174  bits[1] = 9;
175  }
176 
177  else if (period == "lhc10f7a" || period == "lhc12a15e" || period.BeginsWith("lhc12a17") ||
178  period == "lhc13b4" || period == "lhc13b4_fix" || period == "lhc13b4_plus" || period == "lhc14k1a" || period == "lhc14k1b" || period == "lhc13e4" ||
179  period.BeginsWith("lhc14a1") || period.BeginsWith("lhc13b2_efix") ||
180  period.BeginsWith("lhc15g6") || period.BeginsWith("lhc17f8")) {
181  bits[0] = 8;
182  bits[1] = 9;
183  }
184 
185  else if (period == "lhc11a" || period == "lhc10hold" || period == "lhc11c" || period == "lhc11d") {
186  bits[0] = 8;
187  bits[1] = 4;
188  }
189 
190  else if (period.Contains("lhc12a15a") || period == "lhc12a15f" ||
191  period == "lhc12a15g" || period.BeginsWith("lhc11a1")) {
192  bits[0] = 8;
193  bits[1] = 4;
194  }
195 
196  else {
197  ::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());
198  bits[0] = -1;
199  bits[1] = -1;
200  return kFALSE;
201  }
202 
203  return kTRUE;
204 }
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.
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.
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