AliPhysics  v5-06-11-01 (156c7f3)
 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  fTrackCuts(NULL),
37  fFilterBits(0)
38  {
39  }
40 
49  AliEMCalPtTaskTrackSelectionAOD::AliEMCalPtTaskTrackSelectionAOD(AliESDtrackCuts* cuts, UInt_t filterbits):
51  fTrackCuts(cuts),
52  fFilterBits(filterbits)
53  {
54  }
55 
64  fTrackCuts(NULL),
65  fFilterBits(ref.fFilterBits)
66  {
67  if(ref.fTrackCuts) fTrackCuts = new AliESDtrackCuts(*(ref.fTrackCuts));
68  }
69 
78  if(this != &ref){
80  if(fTrackCuts) {
81  delete fTrackCuts;
82  fTrackCuts = NULL;
83  }
84  if(ref.fTrackCuts) fTrackCuts = new AliESDtrackCuts(*(ref.fTrackCuts));
85  }
86  return *this;
87  }
88 
93  if(fTrackCuts) delete fTrackCuts;
94  if(fListOfTracks) delete fListOfTracks;
95  }
96 
106  TObjArray* AliEMCalPtTaskTrackSelectionAOD::GetAcceptedTracks(const TClonesArray* const tracks) {
107  if(!fListOfTracks) fListOfTracks = new TObjArray;
108  else fListOfTracks->Clear();
109  TIter trackIter(tracks);
110  AliVTrack *track(NULL);
111  while((track = dynamic_cast<AliVTrack *>(trackIter()))){
112  if(IsTrackAccepted(track)) fListOfTracks->AddLast(track);
113  }
114  return fListOfTracks;
115  }
116 
126  TObjArray* AliEMCalPtTaskTrackSelectionAOD::GetAcceptedTracks(const AliVEvent* const event) {
127  if(!fListOfTracks) fListOfTracks = new TObjArray;
128  else fListOfTracks->Clear();
129  const AliAODEvent *aod = dynamic_cast<const AliAODEvent *>(event);
130  if(!aod){
131  AliError("Event not of type AliAODEvent");
132  return fListOfTracks;
133  }
134  for(int itrk = 0; itrk < event->GetNumberOfTracks(); itrk++){
135  AliVTrack *trk = dynamic_cast<AliVTrack *>(event->GetTrack(itrk));
136  if(IsTrackAccepted(trk)) fListOfTracks->AddLast(trk);
137  }
138  return fListOfTracks;
139  }
140 
153  AliAODTrack *aodt = dynamic_cast<AliAODTrack *>(trk);
154  if(!aodt){
155  AliPicoTrack *picotrack = dynamic_cast<AliPicoTrack *>(trk);
156  if(picotrack) aodt = dynamic_cast<AliAODTrack *>(picotrack->GetTrack());
157  else{
158  AliError("Track neither AOD track nor pico track");
159  return kFALSE;
160  }
161  }
162  if(!aodt){
163  AliError("Failed getting AOD track");
164  return kFALSE;
165  }
166  if(fFilterBits && !aodt->TestFilterBit(fFilterBits)) return kFALSE;
167  if(fTrackCuts){
168  AliESDtrack copyTrack(aodt);
169  return fTrackCuts->AcceptTrack(&copyTrack);
170  }
171  return kTRUE;
172  }
173 
174 
175 } /* namespace EMCalTriggerPtAnalysis */
176 
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
Implement virtual track selection for AOD analysis.
AliEMCalPtTaskTrackSelectionAOD & operator=(const AliEMCalPtTaskTrackSelectionAOD &ref)
AliEMCalPtTaskVTrackSelection & operator=(const AliEMCalPtTaskVTrackSelection &ref)
virtual TObjArray * GetAcceptedTracks(const TClonesArray *const tracks)
Implement virtual track selection for AOD analysis.