AliPhysics  vAN-20150822 (d56cf94)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
AliEMCalPtTaskTrackSelectionESD.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>
18 #include <memory>
19 
20 #include "AliESDEvent.h"
21 #include "AliESDtrack.h"
22 #include "AliESDtrackCuts.h"
23 #include "AliLog.h"
24 #include "AliPicoTrack.h"
25 #include "AliVCuts.h"
26 
30 
31 namespace EMCalTriggerPtAnalysis {
32 
36 AliEMCalPtTaskTrackSelectionESD::AliEMCalPtTaskTrackSelectionESD():
38 {
39 }
40 
46 {
47  this->AddTrackCuts(cuts);
48 }
49 
50 
57 TObjArray* AliEMCalPtTaskTrackSelectionESD::GetAcceptedTracks(const TClonesArray* const tracks) {
58  if(!fListOfTracks) fListOfTracks = new TObjArray;
59  else fListOfTracks->Clear();
60  for(TIter trackIter = TIter(tracks).Begin(); trackIter != TIter::End(); ++trackIter){
61  if(IsTrackAccepted(static_cast<AliVTrack *>(*trackIter))) fListOfTracks->Add(*trackIter);
62  }
63  return fListOfTracks;
64 }
65 
72 TObjArray* AliEMCalPtTaskTrackSelectionESD::GetAcceptedTracks(const AliVEvent* const event) {
73  if(!fListOfTracks) fListOfTracks = new TObjArray;
74  else fListOfTracks->Clear();
75  const AliESDEvent *esd = dynamic_cast<const AliESDEvent *>(event);
76  if(!esd){
77  AliError("Event not of type AliESDEvent");
78  return fListOfTracks;
79  }
80  for(int itrk = 0; itrk < esd->GetNumberOfTracks(); itrk++){
81  AliESDtrack *trk = static_cast<AliESDtrack *>(esd->GetTrack(itrk));
82  if(IsTrackAccepted(trk)) fListOfTracks->AddLast(trk);
83  }
84  return fListOfTracks;
85 }
86 
94  if(!fListOfCuts) return kTRUE;
95  AliESDtrack *esdt = dynamic_cast<AliESDtrack *>(trk);
96  if(!esdt){
97  AliPicoTrack *picoTrack = dynamic_cast<AliPicoTrack *>(trk);
98  if(picoTrack)
99  esdt = dynamic_cast<AliESDtrack*>(picoTrack->GetTrack());
100  else{
101  AliError("Neither Pico nor ESD track");
102  return kFALSE;
103  }
104  }
105 
106  bool result = true;
107  for(TIter cutIter = TIter(fListOfCuts).Begin(); cutIter != TIter::End(); ++cutIter){
108  if(!((static_cast<AliVCuts *>(*cutIter))->IsSelected(esdt))) result = false;
109  }
110  return result;
111 }
112 
113 } /* namespace EMCalTriggerPtAnalysis */
114 
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
virtual TObjArray * GetAcceptedTracks(const TClonesArray *const tracks)
Implementation of virtual track selection for ESDs.
Declaration of class AliEMCalPtTaskTrackSelectionESD.
AliVTrack * GetTrack() const
Definition: AliPicoTrack.h:59
TObjArray * fListOfTracks
TObjArray with accepted tracks.