AliPhysics  v5-07-15-01 (b3d7633)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
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 #include <TClonesArray.h>
16 #include <TBits.h>
17 #include <TObjArray.h>
18 
19 #include <AliAODEvent.h>
20 #include <AliAODTrack.h>
22 #include <AliESDtrack.h>
23 #include <AliPicoTrack.h>
24 
28 
35  fFilterBits(0)
36 {
37 }
38 
47 AliEmcalTrackSelectionAOD::AliEmcalTrackSelectionAOD(AliVCuts* cuts, UInt_t filterbits):
49  fFilterBits(filterbits)
50 {
51  AddTrackCuts(cuts);
52 }
53 
63 TObjArray* AliEmcalTrackSelectionAOD::GetAcceptedTracks(const TClonesArray* const tracks) {
64  if(!fListOfTracks) fListOfTracks = new TObjArray;
65  else fListOfTracks->Clear();
66  TIter trackIter(tracks);
67  AliVTrack *track(NULL);
68  while((track = dynamic_cast<AliVTrack *>(trackIter()))){
69  if(IsTrackAccepted(track)) fListOfTracks->AddLast(track);
70  }
71  return fListOfTracks;
72 }
73 
83  TObjArray* AliEmcalTrackSelectionAOD::GetAcceptedTracks(const AliVEvent* const event) {
84  if(!fListOfTracks) fListOfTracks = new TObjArray;
85  else fListOfTracks->Clear();
86  const AliAODEvent *aod = dynamic_cast<const AliAODEvent *>(event);
87  if(!aod){
88  AliError("Event not of type AliAODEvent");
89  return fListOfTracks;
90  }
91  for(int itrk = 0; itrk < event->GetNumberOfTracks(); itrk++){
92  AliVTrack *trk = dynamic_cast<AliVTrack *>(event->GetTrack(itrk));
93  if(IsTrackAccepted(trk)) fListOfTracks->AddLast(trk);
94  }
95  return fListOfTracks;
96  }
97 
109 bool AliEmcalTrackSelectionAOD::IsTrackAccepted(AliVTrack * const trk){
110  AliAODTrack *aodt = dynamic_cast<AliAODTrack *>(trk);
111  if(!aodt){
112  AliPicoTrack *picotrack = dynamic_cast<AliPicoTrack *>(trk);
113  if(picotrack) aodt = dynamic_cast<AliAODTrack *>(picotrack->GetTrack());
114  else{
115  AliError("Track neither AOD track nor pico track");
116  return kFALSE;
117  }
118  }
119  if(!aodt){
120  AliError("Failed getting AOD track");
121  return kFALSE;
122  }
123 
124  TBits selectedMap(64);
125  Int_t cutcounter(0);
126  if(fFilterBits){
127  if(aodt->TestFilterBit(fFilterBits)) selectedMap.SetBitNumber(cutcounter++);
128  }
129  if(fListOfCuts){
130  for(TIter cutIter = TIter(fListOfCuts).Begin(); cutIter != TIter::End(); ++cutIter){
131  AliVCuts *trackCuts = static_cast<AliVCuts *>(*cutIter);
132  if(trackCuts->IsA() == AliESDtrackCuts::Class()){
133  // If track cuts are AliESDtrackCuts, the track needs to be converted to an AliESDtrack before
134  AliESDtrack copyTrack(aodt);
135  if(trackCuts->IsSelected(&copyTrack)) selectedMap.SetBitNumber(cutcounter++);
136  } else{
137  if(trackCuts->IsSelected(aodt)) selectedMap.SetBitNumber(cutcounter++);
138  }
139  }
140  }
141  if(fSelectionModeAny){
142  // In case of ANY one of the cuts need to be fulfilled (equivalent to one but set)
143  return selectedMap.CountBits() > 0;
144  } else {
145  // In case of ALL all of the cuts need to be fulfilled (equivalent to all bits set)
146  return selectedMap.CountBits() == cutcounter;
147  }
148 }
Interface for virtual track selection.
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
virtual TObjArray * GetAcceptedTracks(const TClonesArray *const tracks)
TObjArray * fListOfCuts
List of track cut objects.
Implement virtual track selection for AOD analysis.
void AddTrackCuts(AliVCuts *cuts)
Implement virtual track selection for AOD analysis.
TObjArray * fListOfTracks
TObjArray with accepted tracks.
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.
UInt_t fFilterBits
Track filter bits.