AliPhysics  f05a842 (f05a842)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliEmcalTrackSelection.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 <AliEmcalTrackSelection.h>
16 #include <TObjArray.h>
17 #include <TClonesArray.h>
18 #include <AliVTrack.h>
19 #include <AliVEvent.h>
20 #include "AliVCuts.h"
21 
25 
31  TObject(),
32  fListOfTracks(NULL),
33  fListOfTrackBitmaps(NULL),
34  fTrackBitmap(64),
35  fListOfCuts(NULL),
36  fSelectionModeAny(kFALSE)
37 {
38 }
39 
45  TObject(ref),
46  fListOfTracks(NULL),
47  fListOfTrackBitmaps(NULL),
48  fTrackBitmap(64),
49  fListOfCuts(NULL),
50  fSelectionModeAny(kFALSE)
51 {
52  if(ref.fListOfTracks) fListOfTracks = new TObjArray(*(ref.fListOfTracks));
53  if(ref.fListOfTrackBitmaps) fListOfTrackBitmaps = new TClonesArray(*(ref.fListOfTrackBitmaps));
54  if(ref.fListOfCuts){
55  fListOfCuts = new TObjArray;
56  fListOfCuts->SetOwner(false);
57  for(TIter cutIter = TIter(ref.fListOfCuts).Begin(); cutIter != TIter::End(); ++cutIter)
58  fListOfCuts->Add(*cutIter);
59  }
60 }
61 
68  TObject::operator=(ref);
69  if(this != &ref){
71  if(ref.fListOfTracks) fListOfTracks = new TObjArray(*(ref.fListOfTracks));
72  if(ref.fListOfTrackBitmaps) fListOfTrackBitmaps = new TClonesArray(*(ref.fListOfTrackBitmaps));
73  if(ref.fListOfCuts){
74  fListOfCuts = new TObjArray;
75  fListOfCuts->SetOwner(false);
76  for(TIter cutIter = TIter(ref.fListOfCuts).Begin(); cutIter != TIter::End(); ++cutIter)
77  fListOfCuts->Add(*cutIter);
78  } else fListOfCuts = NULL;
79  }
80  return *this;
81 }
82 
88  if(fListOfTracks) delete fListOfTracks;
90  if(fListOfCuts) delete fListOfCuts;
91 }
92 
98  if(!fListOfCuts){
99  fListOfCuts = new TObjArray;
100  fListOfCuts->SetOwner(true);
101  }
102  fListOfCuts->Add(cuts);
103 }
104 
110  TIter next(cuts);
111  AliVCuts* item = 0;
112  while ((item = static_cast<AliVCuts*>(next())))
113  {
114  AddTrackCuts(item);
115  }
116 }
117 
123  if(!fListOfCuts) return 0;
124  return fListOfCuts->GetEntries();
125 }
126 
133  if(!fListOfCuts) return NULL;
134  if(icut < fListOfCuts->GetEntries())
135  return static_cast<AliVCuts *>(fListOfCuts->At(icut));
136  return NULL;
137 }
138 
145 TObjArray* AliEmcalTrackSelection::GetAcceptedTracks(const TClonesArray* const tracks)
146 {
147  if (!fListOfTracks) {
148  fListOfTracks = new TObjArray;
149  }
150  else {
151  fListOfTracks->Clear();
152  }
153 
154  if (!fListOfTrackBitmaps) {
155  fListOfTrackBitmaps = new TClonesArray("TBits", 1000);
156  fListOfTrackBitmaps->SetOwner(kTRUE);
157  }
158  else {
159  fListOfTrackBitmaps->Delete();
160  }
161 
162  TIter next(tracks);
163  AliVTrack* track = 0;
164  Int_t i = 0;
165  while((track = static_cast<AliVTrack*>(next()))) {
166  if (IsTrackAccepted(track)) {
167  fListOfTracks->AddLast(track);
168  }
169  else {
170  fListOfTracks->AddLast(0);
171  }
172  new ((*fListOfTrackBitmaps)[i]) TBits(fTrackBitmap);
173  i++;
174  }
175  return fListOfTracks;
176 }
177 
185 {
186  if (!fListOfTracks) {
187  fListOfTracks = new TObjArray;
188  }
189  else {
190  fListOfTracks->Clear();
191  }
192 
193  if (!fListOfTrackBitmaps) {
194  fListOfTrackBitmaps = new TClonesArray("TBits", 1000);
195  fListOfTrackBitmaps->SetOwner(kTRUE);
196  }
197  else {
198  fListOfTrackBitmaps->Delete();
199  }
200 
201  for(int itrk = 0; itrk < event->GetNumberOfTracks(); itrk++){
202  AliVTrack *trk = static_cast<AliVTrack*>(event->GetTrack(itrk));
203  if (IsTrackAccepted(trk)) {
204  fListOfTracks->AddLast(trk);
205  }
206  else {
207  fListOfTracks->AddLast(trk);
208  }
209  new ((*fListOfTrackBitmaps)[itrk]) TBits(fTrackBitmap);
210  }
211  return fListOfTracks;
212 }
Interface for virtual track selection.
AliEmcalTrackSelection & operator=(const AliEmcalTrackSelection &ref)
TObjArray * fListOfCuts
List of track cut objects.
TClonesArray * fListOfTrackBitmaps
TClonesArray with accepted tracks' bit maps.
int Int_t
Definition: External.C:63
AliVCuts * GetTrackCuts(Int_t icut)
void AddTrackCuts(AliVCuts *cuts)
TObjArray * fListOfTracks
TObjArray with accepted tracks.
TObjArray * GetAcceptedTracks(const TClonesArray *const tracks)
TBits fTrackBitmap
Bitmap of last accepted/rejected track.
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
virtual bool IsTrackAccepted(AliVTrack *const trk)=0