AliPhysics  d497afb (d497afb)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliTrackContainer.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, 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 
17 #include "AliAODEvent.h"
18 #include "AliESDEvent.h"
19 #include "AliVEvent.h"
20 #include "AliLog.h"
21 #include "AliVCuts.h"
22 #include "AliESDtrack.h"
23 
24 #include "AliTLorentzVector.h"
27 #include "AliTrackContainer.h"
28 
30 ClassImp(AliTrackContainer);
32 
34 
40  fTrackFilterType(AliEmcalTrackSelection::kHybridTracks),
41  fListOfCuts(0),
42  fSelectionModeAny(kFALSE),
43  fAODFilterBits(0),
44  fTrackCutsPeriod(),
45  fEmcalTrackSelection(0),
46  fFilteredTracks(0),
47  fTrackTypes(5000)
48 {
49  fBaseClassName = "AliVTrack";
50  SetClassName("AliVTrack");
51  fMassHypothesis = 0.139;
52 }
53 
59 AliTrackContainer::AliTrackContainer(const char *name, const char *period):
61  fTrackFilterType(AliEmcalTrackSelection::kHybridTracks),
62  fListOfCuts(0),
63  fSelectionModeAny(kFALSE),
64  fAODFilterBits(0),
65  fTrackCutsPeriod(period),
66  fEmcalTrackSelection(0),
67  fFilteredTracks(0),
68  fTrackTypes(5000)
69 {
70  fBaseClassName = "AliVTrack";
71  SetClassName("AliVTrack");
72 
73  if (fTrackCutsPeriod.IsNull() && !AliTrackContainer::fgDefTrackCutsPeriod.IsNull()) {
74  AliInfo(Form("Default track cuts period is %s", AliTrackContainer::fgDefTrackCutsPeriod.Data()));
76  }
77  fMassHypothesis = 0.139;
78 }
79 
86 void AliTrackContainer::SetArray(const AliVEvent *event)
87 {
89 
93  }
94  else {
96 
97  AliInfo("Using custom track cuts");
98 
99  if (fLoadedClass) {
100  if (fLoadedClass->InheritsFrom("AliAODTrack")) {
101  AliInfo(Form("Objects are of type %s: AOD track selection will be done.", fLoadedClass->GetName()));
103  }
104  else if (fLoadedClass->InheritsFrom("AliESDtrack")) {
105  AliInfo(Form("Objects are of type %s: ESD track selection will be done.", fLoadedClass->GetName()));
107  }
108  else {
109  AliWarning(Form("Objects are of type %s: no track filtering will be done!!", fLoadedClass->GetName()));
110  }
111  }
112 
113  if (fEmcalTrackSelection) {
114  if (fSelectionModeAny) {
116  }
117  else {
119  }
120 
122  }
123  }
124  else {
125  if (!fTrackCutsPeriod.IsNull()) {
126  AliInfo(Form("Using track cuts %d for period %s", fTrackFilterType, fTrackCutsPeriod.Data()));
127  }
128  else {
129  AliInfo(Form("Using track cuts %d (no data period was provided!)", fTrackFilterType));
130  }
131 
132  if (fLoadedClass->InheritsFrom("AliAODTrack")) {
133  AliInfo(Form("Objects are of type %s: AOD track selection will be done.", fLoadedClass->GetName()));
135  }
136  else if (fLoadedClass->InheritsFrom("AliESDtrack")) {
137  AliInfo(Form("Objects are of type %s: ESD track selection will be done.", fLoadedClass->GetName()));
139  }
140  else {
141  AliWarning(Form("Objects are of type %s: no track filtering will be done!!", fLoadedClass->GetName()));
142  }
143  }
144  }
145 }
146 
152 void AliTrackContainer::NextEvent(const AliVEvent * event)
153 {
154  AliParticleContainer::NextEvent(event);
155 
156  fTrackTypes.Reset(kUndefined);
157  if (fEmcalTrackSelection) {
159 
160  const TClonesArray* trackBitmaps = fEmcalTrackSelection->GetAcceptedTrackBitmaps();
161  TIter nextBitmap(trackBitmaps);
162  TBits* bits = 0;
163  Int_t i = 0;
164  while ((bits = static_cast<TBits*>(nextBitmap()))) {
165  if (i >= fTrackTypes.GetSize()) fTrackTypes.Set((i+1)*2);
166  AliVTrack* vTrack = static_cast<AliVTrack*>(fFilteredTracks->At(i));
167  if (!vTrack) {
168  fTrackTypes[i] = kRejected;
169  }
171  if (bits->FirstSetBit() == 0) {
173  }
174  else if (bits->FirstSetBit() == 1) {
175  if ((vTrack->GetStatus()&AliVTrack::kITSrefit) != 0) {
177  }
178  else {
180  }
181  }
182  }
183  i++;
184  }
185  }
186  else {
187  fFilteredTracks = fClArray;
188  }
189 }
190 
197 {
198  //Get i^th jet in array
199 
200  if (i < 0 || i >= fFilteredTracks->GetEntriesFast()) return 0;
201  AliVTrack *vp = static_cast<AliVTrack*>(fFilteredTracks->At(i));
202  return vp;
203 }
204 
211 {
212  UInt_t rejectionReason;
213  if (i == -1) i = fCurrentID;
214  if (AcceptTrack(i, rejectionReason)) {
215  return GetTrack(i);
216  }
217  else {
218  AliDebug(2,"Track not accepted.");
219  return 0;
220  }
221 }
222 
229 {
230  const Int_t n = GetNEntries();
231  AliVTrack *p = 0;
232  do {
233  fCurrentID++;
234  if (fCurrentID >= n) break;
235  p = GetAcceptTrack(fCurrentID);
236  } while (!p);
237 
238  return p;
239 }
240 
247 {
248  const Int_t n = GetNEntries();
249  AliVTrack *p = 0;
250  do {
251  fCurrentID++;
252  if (fCurrentID >= n) break;
253  p = GetTrack(fCurrentID);
254  } while (!p);
255 
256  return p;
257 }
258 
265 Char_t AliTrackContainer::GetTrackType(const AliVTrack* track) const
266 {
267  Int_t id = fFilteredTracks->IndexOf(track);
268  if (id >= 0) {
269  return fTrackTypes[id];
270  }
271  else {
272  return kUndefined;
273  }
274 }
275 
285 Bool_t AliTrackContainer::GetMomentumFromTrack(TLorentzVector &mom, const AliVTrack* track, Double_t mass) const
286 {
287  if (track) {
288  if (mass < 0) mass = track->M();
289 
290  Bool_t useConstrainedParams = kFALSE;
291  if (fLoadedClass->InheritsFrom("AliESDtrack") && fTrackFilterType == AliEmcalTrackSelection::kHybridTracks) {
292  Char_t trackType = GetTrackType(track);
293  if (trackType == kHybridConstrained || trackType == kHybridConstrainedNoITSrefit) {
294  useConstrainedParams = kTRUE;
295  }
296  }
297 
298  if (useConstrainedParams) {
299  const AliESDtrack *esdtrack = static_cast<const AliESDtrack*>(track);
300  mom.SetPtEtaPhiM(esdtrack->GetConstrainedParam()->Pt(), esdtrack->GetConstrainedParam()->Eta(), esdtrack->GetConstrainedParam()->Phi(), mass);
301  }
302  else {
303  mom.SetPtEtaPhiM(track->Pt(), track->Eta(), track->Phi(), mass);
304  }
305  return kTRUE;
306  }
307  else {
308  mom.SetPtEtaPhiM(0, 0, 0, 0);
309  return kFALSE;
310  }
311 }
312 
320 Bool_t AliTrackContainer::GetMomentumFromTrack(TLorentzVector &mom, const AliVTrack* part) const
321 {
322  return GetMomentumFromTrack(mom,part,fMassHypothesis);
323 }
324 
334 Bool_t AliTrackContainer::GetMomentum(TLorentzVector &mom, Int_t i) const
335 {
336  Double_t mass = fMassHypothesis;
337 
338  if (i == -1) i = fCurrentID;
339  AliVTrack *vp = GetTrack(i);
340  if (vp) {
341  if (mass < 0) mass = vp->M();
342 
343  if (fLoadedClass->InheritsFrom("AliESDtrack") && fTrackFilterType == AliEmcalTrackSelection::kHybridTracks &&
344  (fTrackTypes[i] == kHybridConstrained || fTrackTypes[i] == kHybridConstrainedNoITSrefit)) {
345  AliESDtrack *track = static_cast<AliESDtrack*>(vp);
346  mom.SetPtEtaPhiM(track->GetConstrainedParam()->Pt(), track->GetConstrainedParam()->Eta(), track->GetConstrainedParam()->Phi(), mass);
347  }
348  else {
349  mom.SetPtEtaPhiM(vp->Pt(), vp->Eta(), vp->Phi(), mass);
350  }
351  return kTRUE;
352  }
353  else {
354  mom.SetPtEtaPhiM(0, 0, 0, 0);
355  return kFALSE;
356  }
357 }
358 
369 {
370  Double_t mass = fMassHypothesis;
371 
372  AliVTrack *vp = GetNextTrack();
373  if (vp) {
374  if (mass < 0) mass = vp->M();
375 
376  if (fLoadedClass->InheritsFrom("AliESDtrack") && fTrackFilterType == AliEmcalTrackSelection::kHybridTracks &&
377  (fTrackTypes[fCurrentID] == kHybridConstrained || fTrackTypes[fCurrentID] == kHybridConstrainedNoITSrefit)) {
378  AliESDtrack *track = static_cast<AliESDtrack*>(vp);
379  mom.SetPtEtaPhiM(track->GetConstrainedParam()->Pt(), track->GetConstrainedParam()->Eta(), track->GetConstrainedParam()->Phi(), mass);
380  }
381  else {
382  mom.SetPtEtaPhiM(vp->Pt(), vp->Eta(), vp->Phi(), mass);
383  }
384  return kTRUE;
385  }
386  else {
387  mom.SetPtEtaPhiM(0, 0, 0, 0);
388  return kFALSE;
389  }
390 }
391 
402 Bool_t AliTrackContainer::GetAcceptMomentum(TLorentzVector &mom, Int_t i) const
403 {
404 
405  Double_t mass = fMassHypothesis;
406 
407  if (i == -1) i = fCurrentID;
408  AliVTrack *vp = GetAcceptTrack(i);
409  if (vp) {
410  if (mass < 0) mass = vp->M();
411 
412  if (fLoadedClass->InheritsFrom("AliESDtrack") && fTrackFilterType == AliEmcalTrackSelection::kHybridTracks &&
413  (fTrackTypes[i] == kHybridConstrained || fTrackTypes[i] == kHybridConstrainedNoITSrefit)) {
414  AliESDtrack *track = static_cast<AliESDtrack*>(vp);
415  mom.SetPtEtaPhiM(track->GetConstrainedParam()->Pt(), track->GetConstrainedParam()->Eta(), track->GetConstrainedParam()->Phi(), mass);
416  }
417  else {
418  mom.SetPtEtaPhiM(vp->Pt(), vp->Eta(), vp->Phi(), mass);
419  }
420 
421  return kTRUE;
422  }
423  else {
424  mom.SetPtEtaPhiM(0, 0, 0, 0);
425  return kFALSE;
426  }
427 }
428 
439 {
440  Double_t mass = fMassHypothesis;
441 
442  AliVTrack *vp = GetNextAcceptTrack();
443  if (vp) {
444  if (mass < 0) mass = vp->M();
445 
446  if (fLoadedClass->InheritsFrom("AliESDtrack") && fTrackFilterType == AliEmcalTrackSelection::kHybridTracks &&
447  (fTrackTypes[fCurrentID] == kHybridConstrained || fTrackTypes[fCurrentID] == kHybridConstrainedNoITSrefit)) {
448  AliESDtrack *track = static_cast<AliESDtrack*>(vp);
449  mom.SetPtEtaPhiM(track->GetConstrainedParam()->Pt(), track->GetConstrainedParam()->Eta(), track->GetConstrainedParam()->Phi(), mass);
450  }
451  else {
452  mom.SetPtEtaPhiM(vp->Pt(), vp->Eta(), vp->Phi(), mass);
453  }
454 
455  return kTRUE;
456  }
457  else {
458  mom.SetPtEtaPhiM(0, 0, 0, 0);
459  return kFALSE;
460  }
461 }
462 
473 Bool_t AliTrackContainer::AcceptTrack(const AliVTrack *vp, UInt_t &rejectionReason) const
474 {
475  Bool_t r = ApplyTrackCuts(vp, rejectionReason);
476  if (!r) return kFALSE;
477 
478  AliTLorentzVector mom;
479  if(!GetMomentumFromTrack(mom, vp)) return false;
480 
481  return ApplyKinematicCuts(mom, rejectionReason);
482 }
483 
496 {
497  Bool_t r = ApplyTrackCuts(GetTrack(i), rejectionReason);
498  if (!r) return kFALSE;
499 
500  AliTLorentzVector mom;
501  if(!GetMomentum(mom, i)) return false;
502 
503  return ApplyKinematicCuts(mom, rejectionReason);
504 }
505 
515 Bool_t AliTrackContainer::ApplyTrackCuts(const AliVTrack* vp, UInt_t &rejectionReason) const
516 {
517  return ApplyParticleCuts(vp, rejectionReason);
518 }
519 
525 {
526  if (!fListOfCuts) {
527  fListOfCuts = new TObjArray;
528  fListOfCuts->SetOwner(true);
529  }
530  fListOfCuts->Add(cuts);
531 }
532 
538 {
539  if (!fListOfCuts) return 0;
540  return fListOfCuts->GetEntries();
541 }
542 
549 {
550  if (!fListOfCuts) return NULL;
551  if (icut < fListOfCuts->GetEntries()) {
552  return static_cast<AliVCuts *>(fListOfCuts->At(icut));
553  }
554  return NULL;
555 }
556 
563  return AliTrackIterableContainer(this, false);
564 }
565 
572  return AliTrackIterableContainer(this, true);
573 }
574 
581  return AliTrackIterableMomentumContainer(this, false);
582 }
583 
590  return AliTrackIterableMomentumContainer(this, true);
591 }
592 
599 const char* AliTrackContainer::GetTitle() const
600 {
601  static TString trackString;
602  trackString = TString::Format("%s_pT%04d", GetArrayName().Data(), static_cast<int>(GetMinPt()*1000.0));
603  return trackString.Data();
604 }
605 
606 TString AliTrackContainer::GetDefaultArrayName(const AliVEvent *const ev) const {
607  if(ev->IsA() == AliAODEvent::Class()) return "tracks";
608  else if(ev->IsA() == AliESDEvent::Class()) return "Tracks";
609  else return "";
610 }
Interface for virtual track selection.
double Double_t
Definition: External.C:58
TObjArray * fFilteredTracks
! tracks filtered using fEmcalTrackSelection
void SetArray(const AliVEvent *event)
static TString fgDefTrackCutsPeriod
! default period string used to generate track cuts
const AliTrackIterableContainer accepted() const
Double_t mass
Container with name, TClonesArray and cuts for particles.
EMCALIterableContainer::AliEmcalIterableContainerT< AliVTrack, EMCALIterableContainer::operator_star_object< AliVTrack > > AliTrackIterableContainer
Declaration of class AliTLorentzVector.
char Char_t
Definition: External.C:18
Track selected under the constrained hybrid track cuts.
virtual Bool_t ApplyParticleCuts(const AliVParticle *vp, UInt_t &rejectionReason) const
UInt_t fAODFilterBits
track filter bits
const TClonesArray * GetAcceptedTrackBitmaps() const
void NextEvent(const AliVEvent *event)
const AliTrackIterableContainer all() const
void SetSelectionModeAny()
Set selection mode to any.
AliVCuts * GetTrackCuts(Int_t icut)
virtual Bool_t GetNextMomentum(TLorentzVector &mom)
AliEmcalTrackSelection * fEmcalTrackSelection
! track selection object
virtual Bool_t GetMomentum(TLorentzVector &mom, Int_t i) const
ETrackFilterType_t fTrackFilterType
track filter type
TString fTrackCutsPeriod
period string used to generate track cuts
Container for particles within the EMCAL framework.
Track selected under the constrained hybrid track cuts without ITS refit.
virtual Bool_t GetAcceptMomentum(TLorentzVector &mom, Int_t i) const
virtual Bool_t GetMomentumFromTrack(TLorentzVector &mom, const AliVTrack *track, Double_t mass) const
virtual Bool_t ApplyTrackCuts(const AliVTrack *vp, UInt_t &rejectionReason) const
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
EMCALIterableContainer::AliEmcalIterableContainerT< AliVTrack, EMCALIterableContainer::operator_star_pair< AliVTrack > > AliTrackIterableMomentumContainer
virtual Bool_t AcceptTrack(const AliVTrack *vp, UInt_t &rejectionReason) const
Int_t GetNumberOfCutObjects() const
TArrayC fTrackTypes
! track types
TObjArray * fListOfCuts
list of track cut objects
void AddTrackCuts(AliVCuts *cuts)
Add new track cuts to the list of cuts.
Implement virtual track selection for AOD analysis.
virtual AliVTrack * GetNextTrack()
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
Bool_t fSelectionModeAny
accept track if any of the cuts is fulfilled
virtual AliVTrack * GetTrack(Int_t i=-1) const
Track selected under the global hybrid track cuts.
TObjArray * GetAcceptedTracks(const TClonesArray *const tracks)
Select tracks from a TClonesArray of input tracks.
virtual AliVTrack * GetNextAcceptTrack()
Char_t GetTrackType(const AliVTrack *track) const
void AddTrackCuts(AliVCuts *cuts)
virtual TString GetDefaultArrayName(const AliVEvent *const ev) const
void SetArray(const AliVEvent *event)
virtual AliVTrack * GetAcceptTrack(Int_t i=-1) const
virtual Bool_t GetNextAcceptMomentum(TLorentzVector &mom)
void SetSelectionModeAll()
Set selection mode to all.
const AliTrackIterableMomentumContainer accepted_momentum() const
const char * GetTitle() const
virtual Bool_t ApplyKinematicCuts(const AliTLorentzVector &mom, UInt_t &rejectionReason) const
bool Bool_t
Definition: External.C:53
Implementation of virtual track selection for ESDs.
Track status undefined.
const AliTrackIterableMomentumContainer all_momentum() const