AliPhysics  vAN-20150507 (0645659)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
AliEMCalPtTaskTrackSelectionAOD.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2014, 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 <TObjArray.h>
17 
18 #include <AliAODEvent.h>
19 #include <AliAODTrack.h>
20 #include <AliESDtrack.h>
21 #include <AliPicoTrack.h>
23 
27 
28 namespace EMCalTriggerPtAnalysis {
29 
34 AliEMCalPtTaskTrackSelectionAOD::AliEMCalPtTaskTrackSelectionAOD() :
36  fFilterBits(0)
37 {
38 }
39 
48 AliEMCalPtTaskTrackSelectionAOD::AliEMCalPtTaskTrackSelectionAOD(AliESDtrackCuts* cuts, UInt_t filterbits):
50  fFilterBits(filterbits)
51 {
52  AddTrackCuts(cuts);
53 }
54 
64 TObjArray* AliEMCalPtTaskTrackSelectionAOD::GetAcceptedTracks(const TClonesArray* const tracks) {
65  if(!fListOfTracks) fListOfTracks = new TObjArray;
66  else fListOfTracks->Clear();
67  TIter trackIter(tracks);
68  AliVTrack *track(NULL);
69  while((track = dynamic_cast<AliVTrack *>(trackIter()))){
70  if(IsTrackAccepted(track)) fListOfTracks->AddLast(track);
71  }
72  return fListOfTracks;
73 }
74 
84  TObjArray* AliEMCalPtTaskTrackSelectionAOD::GetAcceptedTracks(const AliVEvent* const event) {
85  if(!fListOfTracks) fListOfTracks = new TObjArray;
86  else fListOfTracks->Clear();
87  const AliAODEvent *aod = dynamic_cast<const AliAODEvent *>(event);
88  if(!aod){
89  AliError("Event not of type AliAODEvent");
90  return fListOfTracks;
91  }
92  for(int itrk = 0; itrk < event->GetNumberOfTracks(); itrk++){
93  AliVTrack *trk = dynamic_cast<AliVTrack *>(event->GetTrack(itrk));
94  if(IsTrackAccepted(trk)) fListOfTracks->AddLast(trk);
95  }
96  return fListOfTracks;
97  }
98 
111  AliAODTrack *aodt = dynamic_cast<AliAODTrack *>(trk);
112  if(!aodt){
113  AliPicoTrack *picotrack = dynamic_cast<AliPicoTrack *>(trk);
114  if(picotrack) aodt = dynamic_cast<AliAODTrack *>(picotrack->GetTrack());
115  else{
116  AliError("Track neither AOD track nor pico track");
117  return kFALSE;
118  }
119  }
120  if(!aodt){
121  AliError("Failed getting AOD track");
122  return kFALSE;
123  }
124  if(fFilterBits && !aodt->TestFilterBit(fFilterBits)) return kFALSE;
125  Bool_t result = kTRUE;
126  if(fListOfCuts){
127  for(TIter cutIter = TIter(fListOfCuts).Begin(); cutIter != TIter::End(); ++cutIter){
128  AliVCuts *trackCuts = static_cast<AliVCuts *>(*cutIter);
129  if(trackCuts->IsA() == AliESDtrackCuts::Class()){
130  // If track cuts are AliESDtrackCuts, the track needs to be converted to an AliESDtrack before
131  AliESDtrack copyTrack(aodt);
132  if(!trackCuts->IsSelected(&copyTrack)) result = kFALSE;
133  } else{
134  if(!trackCuts->IsSelected(aodt)) result = kFALSE;
135  }
136  }
137 
138  }
139  return result;
140 }
141 
142 } /* namespace EMCalTriggerPtAnalysis */
143 
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
Implement virtual track selection for AOD analysis.
virtual TObjArray * GetAcceptedTracks(const TClonesArray *const tracks)
TObjArray * fListOfTracks
TObjArray with accepted tracks.
Implement virtual track selection for AOD analysis.