AliPhysics  781d0c7 (781d0c7)
 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 "AliVEvent.h"
18 #include "AliLog.h"
19 #include "AliVCuts.h"
20 #include "AliESDtrack.h"
21 
22 #include "AliTLorentzVector.h"
25 #include "AliTrackContainer.h"
26 
30 
32 
38  fTrackFilterType(AliEmcalTrackSelection::kHybridTracks),
39  fListOfCuts(0),
40  fSelectionModeAny(kFALSE),
41  fAODFilterBits(0),
42  fTrackCutsPeriod(),
43  fEmcalTrackSelection(0),
44  fFilteredTracks(0),
45  fTrackTypes(5000)
46 {
47  fBaseClassName = "AliVTrack";
48  SetClassName("AliVTrack");
49  fMassHypothesis = 0.139;
50 }
51 
57 AliTrackContainer::AliTrackContainer(const char *name, const char *period):
59  fTrackFilterType(AliEmcalTrackSelection::kHybridTracks),
60  fListOfCuts(0),
61  fSelectionModeAny(kFALSE),
62  fAODFilterBits(0),
63  fTrackCutsPeriod(period),
64  fEmcalTrackSelection(0),
65  fFilteredTracks(0),
66  fTrackTypes(5000)
67 {
68  fBaseClassName = "AliVTrack";
69  SetClassName("AliVTrack");
70 
71  if (fTrackCutsPeriod.IsNull() && !AliTrackContainer::fgDefTrackCutsPeriod.IsNull()) {
72  AliInfo(Form("Default track cuts period is %s", AliTrackContainer::fgDefTrackCutsPeriod.Data()));
74  }
75  fMassHypothesis = 0.139;
76 }
77 
84 void AliTrackContainer::SetArray(const AliVEvent *event)
85 {
86  AliParticleContainer::SetArray(event);
87 
91  }
92  else {
94 
95  AliInfo("Using custom track cuts");
96 
97  if (fLoadedClass) {
98  if (fLoadedClass->InheritsFrom("AliAODTrack")) {
99  AliInfo(Form("Objects are of type %s: AOD track selection will be done.", fLoadedClass->GetName()));
101  }
102  else if (fLoadedClass->InheritsFrom("AliESDtrack")) {
103  AliInfo(Form("Objects are of type %s: ESD track selection will be done.", fLoadedClass->GetName()));
105  }
106  else {
107  AliWarning(Form("Objects are of type %s: no track filtering will be done!!", fLoadedClass->GetName()));
108  }
109  }
110 
111  if (fEmcalTrackSelection) {
112  if (fSelectionModeAny) {
114  }
115  else {
117  }
118 
120  }
121  }
122  else {
123  if (!fTrackCutsPeriod.IsNull()) {
124  AliInfo(Form("Using track cuts %d for period %s", fTrackFilterType, fTrackCutsPeriod.Data()));
125  }
126  else {
127  AliInfo(Form("Using track cuts %d (no data period was provided!)", fTrackFilterType));
128  }
129 
130  if (fLoadedClass->InheritsFrom("AliAODTrack")) {
131  AliInfo(Form("Objects are of type %s: AOD track selection will be done.", fLoadedClass->GetName()));
133  }
134  else if (fLoadedClass->InheritsFrom("AliESDtrack")) {
135  AliInfo(Form("Objects are of type %s: ESD track selection will be done.", fLoadedClass->GetName()));
137  }
138  else {
139  AliWarning(Form("Objects are of type %s: no track filtering will be done!!", fLoadedClass->GetName()));
140  }
141  }
142  }
143 }
144 
151 {
152  fTrackTypes.Reset(kUndefined);
153  if (fEmcalTrackSelection) {
155 
156  const TClonesArray* trackBitmaps = fEmcalTrackSelection->GetAcceptedTrackBitmaps();
157  TIter nextBitmap(trackBitmaps);
158  TBits* bits = 0;
159  Int_t i = 0;
160  while ((bits = static_cast<TBits*>(nextBitmap()))) {
161  if (i >= fTrackTypes.GetSize()) fTrackTypes.Set((i+1)*2);
162  AliVTrack* vTrack = static_cast<AliVTrack*>(fFilteredTracks->At(i));
163  if (!vTrack) {
164  fTrackTypes[i] = kRejected;
165  }
167  if (bits->FirstSetBit() == 0) {
169  }
170  else if (bits->FirstSetBit() == 1) {
171  if ((vTrack->GetStatus()&AliVTrack::kITSrefit) != 0) {
173  }
174  else {
176  }
177  }
178  }
179  i++;
180  }
181  }
182  else {
183  fFilteredTracks = fClArray;
184  }
185 }
186 
193 {
194  //Get i^th jet in array
195 
196  if (i < 0 || i >= fFilteredTracks->GetEntriesFast()) return 0;
197  AliVTrack *vp = static_cast<AliVTrack*>(fFilteredTracks->At(i));
198  return vp;
199 }
200 
207 {
208  UInt_t rejectionReason;
209  if (i == -1) i = fCurrentID;
210  if (AcceptTrack(i, rejectionReason)) {
211  return GetTrack(i);
212  }
213  else {
214  AliDebug(2,"Track not accepted.");
215  return 0;
216  }
217 }
218 
225 {
226  const Int_t n = GetNEntries();
227  AliVTrack *p = 0;
228  do {
229  fCurrentID++;
230  if (fCurrentID >= n) break;
231  p = GetAcceptTrack(fCurrentID);
232  } while (!p);
233 
234  return p;
235 }
236 
243 {
244  const Int_t n = GetNEntries();
245  AliVTrack *p = 0;
246  do {
247  fCurrentID++;
248  if (fCurrentID >= n) break;
249  p = GetTrack(fCurrentID);
250  } while (!p);
251 
252  return p;
253 }
254 
261 Char_t AliTrackContainer::GetTrackType(const AliVTrack* track) const
262 {
263  Int_t id = fFilteredTracks->IndexOf(track);
264  if (id >= 0) {
265  return fTrackTypes[id];
266  }
267  else {
268  return kUndefined;
269  }
270 }
271 
281 Bool_t AliTrackContainer::GetMomentumFromTrack(TLorentzVector &mom, const AliVTrack* track, Double_t mass) const
282 {
283  if (track) {
284  if (mass < 0) mass = track->M();
285 
286  Bool_t useConstrainedParams = kFALSE;
287  if (fLoadedClass->InheritsFrom("AliESDtrack") && fTrackFilterType == AliEmcalTrackSelection::kHybridTracks) {
288  Char_t trackType = GetTrackType(track);
289  if (trackType == kHybridConstrained || trackType == kHybridConstrainedNoITSrefit) {
290  useConstrainedParams = kTRUE;
291  }
292  }
293 
294  if (useConstrainedParams) {
295  const AliESDtrack *esdtrack = static_cast<const AliESDtrack*>(track);
296  mom.SetPtEtaPhiM(esdtrack->GetConstrainedParam()->Pt(), esdtrack->GetConstrainedParam()->Eta(), esdtrack->GetConstrainedParam()->Phi(), mass);
297  }
298  else {
299  mom.SetPtEtaPhiM(track->Pt(), track->Eta(), track->Phi(), mass);
300  }
301  return kTRUE;
302  }
303  else {
304  mom.SetPtEtaPhiM(0, 0, 0, 0);
305  return kFALSE;
306  }
307 }
308 
316 Bool_t AliTrackContainer::GetMomentumFromTrack(TLorentzVector &mom, const AliVTrack* part) const
317 {
318  return GetMomentumFromTrack(mom,part,fMassHypothesis);
319 }
320 
330 Bool_t AliTrackContainer::GetMomentum(TLorentzVector &mom, Int_t i) const
331 {
332  Double_t mass = fMassHypothesis;
333 
334  if (i == -1) i = fCurrentID;
335  AliVTrack *vp = GetTrack(i);
336  if (vp) {
337  if (mass < 0) mass = vp->M();
338 
339  if (fLoadedClass->InheritsFrom("AliESDtrack") && fTrackFilterType == AliEmcalTrackSelection::kHybridTracks &&
340  (fTrackTypes[i] == kHybridConstrained || fTrackTypes[i] == kHybridConstrainedNoITSrefit)) {
341  AliESDtrack *track = static_cast<AliESDtrack*>(vp);
342  mom.SetPtEtaPhiM(track->GetConstrainedParam()->Pt(), track->GetConstrainedParam()->Eta(), track->GetConstrainedParam()->Phi(), mass);
343  }
344  else {
345  mom.SetPtEtaPhiM(vp->Pt(), vp->Eta(), vp->Phi(), mass);
346  }
347  return kTRUE;
348  }
349  else {
350  mom.SetPtEtaPhiM(0, 0, 0, 0);
351  return kFALSE;
352  }
353 }
354 
365 {
366  Double_t mass = fMassHypothesis;
367 
368  AliVTrack *vp = GetNextTrack();
369  if (vp) {
370  if (mass < 0) mass = vp->M();
371 
372  if (fLoadedClass->InheritsFrom("AliESDtrack") && fTrackFilterType == AliEmcalTrackSelection::kHybridTracks &&
373  (fTrackTypes[fCurrentID] == kHybridConstrained || fTrackTypes[fCurrentID] == kHybridConstrainedNoITSrefit)) {
374  AliESDtrack *track = static_cast<AliESDtrack*>(vp);
375  mom.SetPtEtaPhiM(track->GetConstrainedParam()->Pt(), track->GetConstrainedParam()->Eta(), track->GetConstrainedParam()->Phi(), mass);
376  }
377  else {
378  mom.SetPtEtaPhiM(vp->Pt(), vp->Eta(), vp->Phi(), mass);
379  }
380  return kTRUE;
381  }
382  else {
383  mom.SetPtEtaPhiM(0, 0, 0, 0);
384  return kFALSE;
385  }
386 }
387 
398 Bool_t AliTrackContainer::GetAcceptMomentum(TLorentzVector &mom, Int_t i) const
399 {
400 
401  Double_t mass = fMassHypothesis;
402 
403  if (i == -1) i = fCurrentID;
404  AliVTrack *vp = GetAcceptTrack(i);
405  if (vp) {
406  if (mass < 0) mass = vp->M();
407 
408  if (fLoadedClass->InheritsFrom("AliESDtrack") && fTrackFilterType == AliEmcalTrackSelection::kHybridTracks &&
409  (fTrackTypes[i] == kHybridConstrained || fTrackTypes[i] == kHybridConstrainedNoITSrefit)) {
410  AliESDtrack *track = static_cast<AliESDtrack*>(vp);
411  mom.SetPtEtaPhiM(track->GetConstrainedParam()->Pt(), track->GetConstrainedParam()->Eta(), track->GetConstrainedParam()->Phi(), mass);
412  }
413  else {
414  mom.SetPtEtaPhiM(vp->Pt(), vp->Eta(), vp->Phi(), mass);
415  }
416 
417  return kTRUE;
418  }
419  else {
420  mom.SetPtEtaPhiM(0, 0, 0, 0);
421  return kFALSE;
422  }
423 }
424 
435 {
436  Double_t mass = fMassHypothesis;
437 
438  AliVTrack *vp = GetNextAcceptTrack();
439  if (vp) {
440  if (mass < 0) mass = vp->M();
441 
442  if (fLoadedClass->InheritsFrom("AliESDtrack") && fTrackFilterType == AliEmcalTrackSelection::kHybridTracks &&
443  (fTrackTypes[fCurrentID] == kHybridConstrained || fTrackTypes[fCurrentID] == kHybridConstrainedNoITSrefit)) {
444  AliESDtrack *track = static_cast<AliESDtrack*>(vp);
445  mom.SetPtEtaPhiM(track->GetConstrainedParam()->Pt(), track->GetConstrainedParam()->Eta(), track->GetConstrainedParam()->Phi(), mass);
446  }
447  else {
448  mom.SetPtEtaPhiM(vp->Pt(), vp->Eta(), vp->Phi(), mass);
449  }
450 
451  return kTRUE;
452  }
453  else {
454  mom.SetPtEtaPhiM(0, 0, 0, 0);
455  return kFALSE;
456  }
457 }
458 
469 Bool_t AliTrackContainer::AcceptTrack(const AliVTrack *vp, UInt_t &rejectionReason) const
470 {
471  Bool_t r = ApplyTrackCuts(vp, rejectionReason);
472  if (!r) return kFALSE;
473 
474  AliTLorentzVector mom;
475  GetMomentumFromTrack(mom, vp);
476 
477  return ApplyKinematicCuts(mom, rejectionReason);
478 }
479 
492 {
493  Bool_t r = ApplyTrackCuts(GetTrack(i), rejectionReason);
494  if (!r) return kFALSE;
495 
496  AliTLorentzVector mom;
497  GetMomentum(mom, i);
498 
499  return ApplyKinematicCuts(mom, rejectionReason);
500 }
501 
511 Bool_t AliTrackContainer::ApplyTrackCuts(const AliVTrack* vp, UInt_t &rejectionReason) const
512 {
513  return ApplyParticleCuts(vp, rejectionReason);
514 }
515 
521 {
522  if (!fListOfCuts) {
523  fListOfCuts = new TObjArray;
524  fListOfCuts->SetOwner(true);
525  }
526  fListOfCuts->Add(cuts);
527 }
528 
534 {
535  if (!fListOfCuts) return 0;
536  return fListOfCuts->GetEntries();
537 }
538 
545 {
546  if (!fListOfCuts) return NULL;
547  if (icut < fListOfCuts->GetEntries()) {
548  return static_cast<AliVCuts *>(fListOfCuts->At(icut));
549  }
550  return NULL;
551 }
552 
559  return AliTrackIterableContainer(this, false);
560 }
561 
568  return AliTrackIterableContainer(this, true);
569 }
570 
577  return AliTrackIterableMomentumContainer(this, false);
578 }
579 
586  return AliTrackIterableMomentumContainer(this, true);
587 }
588 
595 const char* AliTrackContainer::GetTitle() const
596 {
597  static TString trackString;
598 
599  if (GetMinPt() == 0) {
600  trackString = TString::Format("%s_pT0000", GetArrayName().Data());
601  }
602  else if (GetMinPt() < 1.0) {
603  trackString = TString::Format("%s_pT0%3.0f", GetArrayName().Data(), GetMinPt()*1000.0);
604  }
605  else {
606  trackString = TString::Format("%s_pT%4.0f", GetArrayName().Data(), GetMinPt()*1000.0);
607  }
608 
609  return trackString.Data();
610 }
Interface for virtual track selection.
double Double_t
Definition: External.C:58
TObjArray * fFilteredTracks
! tracks filtered using fEmcalTrackSelection
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
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)
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)
virtual AliVTrack * GetNextAcceptTrack()
Char_t GetTrackType(const AliVTrack *track) const
void AddTrackCuts(AliVCuts *cuts)
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
void SetArray(const AliVEvent *event)
virtual AliVTrack * GetAcceptTrack(Int_t i=-1) const
virtual Bool_t GetNextAcceptMomentum(TLorentzVector &mom)
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