AliPhysics  d497547 (d497547)
 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 
153 {
154  fTrackTypes.Reset(kUndefined);
155  if (fEmcalTrackSelection) {
157 
158  const TClonesArray* trackBitmaps = fEmcalTrackSelection->GetAcceptedTrackBitmaps();
159  TIter nextBitmap(trackBitmaps);
160  TBits* bits = 0;
161  Int_t i = 0;
162  while ((bits = static_cast<TBits*>(nextBitmap()))) {
163  if (i >= fTrackTypes.GetSize()) fTrackTypes.Set((i+1)*2);
164  AliVTrack* vTrack = static_cast<AliVTrack*>(fFilteredTracks->At(i));
165  if (!vTrack) {
166  fTrackTypes[i] = kRejected;
167  }
169  if (bits->FirstSetBit() == 0) {
171  }
172  else if (bits->FirstSetBit() == 1) {
173  if ((vTrack->GetStatus()&AliVTrack::kITSrefit) != 0) {
175  }
176  else {
178  }
179  }
180  }
181  i++;
182  }
183  }
184  else {
185  fFilteredTracks = fClArray;
186  }
187 }
188 
195 {
196  //Get i^th jet in array
197 
198  if (i < 0 || i >= fFilteredTracks->GetEntriesFast()) return 0;
199  AliVTrack *vp = static_cast<AliVTrack*>(fFilteredTracks->At(i));
200  return vp;
201 }
202 
209 {
210  UInt_t rejectionReason;
211  if (i == -1) i = fCurrentID;
212  if (AcceptTrack(i, rejectionReason)) {
213  return GetTrack(i);
214  }
215  else {
216  AliDebug(2,"Track not accepted.");
217  return 0;
218  }
219 }
220 
227 {
228  const Int_t n = GetNEntries();
229  AliVTrack *p = 0;
230  do {
231  fCurrentID++;
232  if (fCurrentID >= n) break;
233  p = GetAcceptTrack(fCurrentID);
234  } while (!p);
235 
236  return p;
237 }
238 
245 {
246  const Int_t n = GetNEntries();
247  AliVTrack *p = 0;
248  do {
249  fCurrentID++;
250  if (fCurrentID >= n) break;
251  p = GetTrack(fCurrentID);
252  } while (!p);
253 
254  return p;
255 }
256 
263 Char_t AliTrackContainer::GetTrackType(const AliVTrack* track) const
264 {
265  Int_t id = fFilteredTracks->IndexOf(track);
266  if (id >= 0) {
267  return fTrackTypes[id];
268  }
269  else {
270  return kUndefined;
271  }
272 }
273 
283 Bool_t AliTrackContainer::GetMomentumFromTrack(TLorentzVector &mom, const AliVTrack* track, Double_t mass) const
284 {
285  if (track) {
286  if (mass < 0) mass = track->M();
287 
288  Bool_t useConstrainedParams = kFALSE;
289  if (fLoadedClass->InheritsFrom("AliESDtrack") && fTrackFilterType == AliEmcalTrackSelection::kHybridTracks) {
290  Char_t trackType = GetTrackType(track);
291  if (trackType == kHybridConstrained || trackType == kHybridConstrainedNoITSrefit) {
292  useConstrainedParams = kTRUE;
293  }
294  }
295 
296  if (useConstrainedParams) {
297  const AliESDtrack *esdtrack = static_cast<const AliESDtrack*>(track);
298  mom.SetPtEtaPhiM(esdtrack->GetConstrainedParam()->Pt(), esdtrack->GetConstrainedParam()->Eta(), esdtrack->GetConstrainedParam()->Phi(), mass);
299  }
300  else {
301  mom.SetPtEtaPhiM(track->Pt(), track->Eta(), track->Phi(), mass);
302  }
303  return kTRUE;
304  }
305  else {
306  mom.SetPtEtaPhiM(0, 0, 0, 0);
307  return kFALSE;
308  }
309 }
310 
318 Bool_t AliTrackContainer::GetMomentumFromTrack(TLorentzVector &mom, const AliVTrack* part) const
319 {
320  return GetMomentumFromTrack(mom,part,fMassHypothesis);
321 }
322 
332 Bool_t AliTrackContainer::GetMomentum(TLorentzVector &mom, Int_t i) const
333 {
334  Double_t mass = fMassHypothesis;
335 
336  if (i == -1) i = fCurrentID;
337  AliVTrack *vp = GetTrack(i);
338  if (vp) {
339  if (mass < 0) mass = vp->M();
340 
341  if (fLoadedClass->InheritsFrom("AliESDtrack") && fTrackFilterType == AliEmcalTrackSelection::kHybridTracks &&
342  (fTrackTypes[i] == kHybridConstrained || fTrackTypes[i] == kHybridConstrainedNoITSrefit)) {
343  AliESDtrack *track = static_cast<AliESDtrack*>(vp);
344  mom.SetPtEtaPhiM(track->GetConstrainedParam()->Pt(), track->GetConstrainedParam()->Eta(), track->GetConstrainedParam()->Phi(), mass);
345  }
346  else {
347  mom.SetPtEtaPhiM(vp->Pt(), vp->Eta(), vp->Phi(), mass);
348  }
349  return kTRUE;
350  }
351  else {
352  mom.SetPtEtaPhiM(0, 0, 0, 0);
353  return kFALSE;
354  }
355 }
356 
367 {
368  Double_t mass = fMassHypothesis;
369 
370  AliVTrack *vp = GetNextTrack();
371  if (vp) {
372  if (mass < 0) mass = vp->M();
373 
374  if (fLoadedClass->InheritsFrom("AliESDtrack") && fTrackFilterType == AliEmcalTrackSelection::kHybridTracks &&
375  (fTrackTypes[fCurrentID] == kHybridConstrained || fTrackTypes[fCurrentID] == kHybridConstrainedNoITSrefit)) {
376  AliESDtrack *track = static_cast<AliESDtrack*>(vp);
377  mom.SetPtEtaPhiM(track->GetConstrainedParam()->Pt(), track->GetConstrainedParam()->Eta(), track->GetConstrainedParam()->Phi(), mass);
378  }
379  else {
380  mom.SetPtEtaPhiM(vp->Pt(), vp->Eta(), vp->Phi(), mass);
381  }
382  return kTRUE;
383  }
384  else {
385  mom.SetPtEtaPhiM(0, 0, 0, 0);
386  return kFALSE;
387  }
388 }
389 
400 Bool_t AliTrackContainer::GetAcceptMomentum(TLorentzVector &mom, Int_t i) const
401 {
402 
403  Double_t mass = fMassHypothesis;
404 
405  if (i == -1) i = fCurrentID;
406  AliVTrack *vp = GetAcceptTrack(i);
407  if (vp) {
408  if (mass < 0) mass = vp->M();
409 
410  if (fLoadedClass->InheritsFrom("AliESDtrack") && fTrackFilterType == AliEmcalTrackSelection::kHybridTracks &&
411  (fTrackTypes[i] == kHybridConstrained || fTrackTypes[i] == kHybridConstrainedNoITSrefit)) {
412  AliESDtrack *track = static_cast<AliESDtrack*>(vp);
413  mom.SetPtEtaPhiM(track->GetConstrainedParam()->Pt(), track->GetConstrainedParam()->Eta(), track->GetConstrainedParam()->Phi(), mass);
414  }
415  else {
416  mom.SetPtEtaPhiM(vp->Pt(), vp->Eta(), vp->Phi(), mass);
417  }
418 
419  return kTRUE;
420  }
421  else {
422  mom.SetPtEtaPhiM(0, 0, 0, 0);
423  return kFALSE;
424  }
425 }
426 
437 {
438  Double_t mass = fMassHypothesis;
439 
440  AliVTrack *vp = GetNextAcceptTrack();
441  if (vp) {
442  if (mass < 0) mass = vp->M();
443 
444  if (fLoadedClass->InheritsFrom("AliESDtrack") && fTrackFilterType == AliEmcalTrackSelection::kHybridTracks &&
445  (fTrackTypes[fCurrentID] == kHybridConstrained || fTrackTypes[fCurrentID] == kHybridConstrainedNoITSrefit)) {
446  AliESDtrack *track = static_cast<AliESDtrack*>(vp);
447  mom.SetPtEtaPhiM(track->GetConstrainedParam()->Pt(), track->GetConstrainedParam()->Eta(), track->GetConstrainedParam()->Phi(), mass);
448  }
449  else {
450  mom.SetPtEtaPhiM(vp->Pt(), vp->Eta(), vp->Phi(), mass);
451  }
452 
453  return kTRUE;
454  }
455  else {
456  mom.SetPtEtaPhiM(0, 0, 0, 0);
457  return kFALSE;
458  }
459 }
460 
471 Bool_t AliTrackContainer::AcceptTrack(const AliVTrack *vp, UInt_t &rejectionReason) const
472 {
473  Bool_t r = ApplyTrackCuts(vp, rejectionReason);
474  if (!r) return kFALSE;
475 
476  AliTLorentzVector mom;
477  GetMomentumFromTrack(mom, vp);
478 
479  return ApplyKinematicCuts(mom, rejectionReason);
480 }
481 
494 {
495  Bool_t r = ApplyTrackCuts(GetTrack(i), rejectionReason);
496  if (!r) return kFALSE;
497 
498  AliTLorentzVector mom;
499  GetMomentum(mom, i);
500 
501  return ApplyKinematicCuts(mom, rejectionReason);
502 }
503 
513 Bool_t AliTrackContainer::ApplyTrackCuts(const AliVTrack* vp, UInt_t &rejectionReason) const
514 {
515  return ApplyParticleCuts(vp, rejectionReason);
516 }
517 
523 {
524  if (!fListOfCuts) {
525  fListOfCuts = new TObjArray;
526  fListOfCuts->SetOwner(true);
527  }
528  fListOfCuts->Add(cuts);
529 }
530 
536 {
537  if (!fListOfCuts) return 0;
538  return fListOfCuts->GetEntries();
539 }
540 
547 {
548  if (!fListOfCuts) return NULL;
549  if (icut < fListOfCuts->GetEntries()) {
550  return static_cast<AliVCuts *>(fListOfCuts->At(icut));
551  }
552  return NULL;
553 }
554 
561  return AliTrackIterableContainer(this, false);
562 }
563 
570  return AliTrackIterableContainer(this, true);
571 }
572 
579  return AliTrackIterableMomentumContainer(this, false);
580 }
581 
588  return AliTrackIterableMomentumContainer(this, true);
589 }
590 
597 const char* AliTrackContainer::GetTitle() const
598 {
599  static TString trackString;
600 
601  if (GetMinPt() == 0) {
602  trackString = TString::Format("%s_pT0000", GetArrayName().Data());
603  }
604  else if (GetMinPt() < 1.0) {
605  trackString = TString::Format("%s_pT0%3.0f", GetArrayName().Data(), GetMinPt()*1000.0);
606  }
607  else {
608  trackString = TString::Format("%s_pT%4.0f", GetArrayName().Data(), GetMinPt()*1000.0);
609  }
610 
611  return trackString.Data();
612 }
613 
614 TString AliTrackContainer::GetDefaultArrayName(const AliVEvent *const ev) const {
615  if(ev->IsA() == AliAODEvent::Class()) return "tracks";
616  else if(ev->IsA() == AliESDEvent::Class()) return "Tracks";
617  else return "";
618 }
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
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