AliPhysics  29d4213 (29d4213)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
AliEmcalTrackSelectionESD.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 <TBits.h>
16 #include <TClonesArray.h>
17 #include <TObjArray.h>
18 #include <memory>
19 
21 #include "AliESDEvent.h"
22 #include "AliESDtrack.h"
23 #include "AliESDtrackCuts.h"
24 #include "AliLog.h"
25 #include "AliPicoTrack.h"
26 #include "AliVCuts.h"
27 
31 
37 {
38 }
39 
45 {
46  this->AddTrackCuts(cuts);
47 }
48 
49 
56 TObjArray* AliEmcalTrackSelectionESD::GetAcceptedTracks(const TClonesArray* const tracks) {
57  if(!fListOfTracks) fListOfTracks = new TObjArray;
58  else fListOfTracks->Clear();
59  for(TIter trackIter = TIter(tracks).Begin(); trackIter != TIter::End(); ++trackIter){
60  if(IsTrackAccepted(static_cast<AliVTrack *>(*trackIter))) fListOfTracks->Add(*trackIter);
61  }
62  return fListOfTracks;
63 }
64 
71 TObjArray* AliEmcalTrackSelectionESD::GetAcceptedTracks(const AliVEvent* const event) {
72  if(!fListOfTracks) fListOfTracks = new TObjArray;
73  else fListOfTracks->Clear();
74  const AliESDEvent *esd = dynamic_cast<const AliESDEvent *>(event);
75  if(!esd){
76  AliError("Event not of type AliESDEvent");
77  return fListOfTracks;
78  }
79  for(int itrk = 0; itrk < esd->GetNumberOfTracks(); itrk++){
80  AliESDtrack *trk = static_cast<AliESDtrack *>(esd->GetTrack(itrk));
81  if(IsTrackAccepted(trk)) fListOfTracks->AddLast(trk);
82  }
83  return fListOfTracks;
84 }
85 
92 bool AliEmcalTrackSelectionESD::IsTrackAccepted(AliVTrack* const trk) {
93  if(!fListOfCuts) return kTRUE;
94  AliESDtrack *esdt = dynamic_cast<AliESDtrack *>(trk);
95  if(!esdt){
96  AliPicoTrack *picoTrack = dynamic_cast<AliPicoTrack *>(trk);
97  if(picoTrack)
98  esdt = dynamic_cast<AliESDtrack*>(picoTrack->GetTrack());
99  else{
100  AliError("Neither Pico nor ESD track");
101  return kFALSE;
102  }
103  }
104 
105  TBits selectedMap(64); // Counting track cuts among which track was SELECTED
106  Int_t cutcounter = 0;
107  for(TIter cutIter = TIter(fListOfCuts).Begin(); cutIter != TIter::End(); ++cutIter){
108  if((static_cast<AliVCuts *>(*cutIter))->IsSelected(esdt)) selectedMap.SetBitNumber(cutcounter++);
109  }
110  // In case of ANY at least one bit has to be set, while in case of ALL all bits have to be set
111  if(fSelectionModeAny){
112  return selectedMap.CountBits(0) > 0;
113  } else {
114  return selectedMap.CountBits(0) == fListOfCuts->GetEntries();
115  }
116 }
Interface for virtual track selection.
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
TObjArray * fListOfCuts
List of track cut objects.
virtual bool IsTrackAccepted(AliVTrack *const trk)
Declaration of class AliEmcalTrackSelectionESD.
void AddTrackCuts(AliVCuts *cuts)
TObjArray * fListOfTracks
TObjArray with accepted tracks.
AliVTrack * GetTrack() const
Definition: AliPicoTrack.h:59
Bool_t fSelectionModeAny
Accept track if any of the cuts is fulfilled.
virtual TObjArray * GetAcceptedTracks(const TClonesArray *const tracks)
Implementation of virtual track selection for ESDs.