AliPhysics  b555aef (b555aef)
AliEmcalTrackSelectionESD.cxx
Go to the documentation of this file.
1 /************************************************************************************
2  * Copyright (C) 2017, Copyright Holders of the ALICE Collaboration *
3  * All rights reserved. *
4  * *
5  * Redistribution and use in source and binary forms, with or without *
6  * modification, are permitted provided that the following conditions are met: *
7  * * Redistributions of source code must retain the above copyright *
8  * notice, this list of conditions and the following disclaimer. *
9  * * Redistributions in binary form must reproduce the above copyright *
10  * notice, this list of conditions and the following disclaimer in the *
11  * documentation and/or other materials provided with the distribution. *
12  * * Neither the name of the <organization> nor the *
13  * names of its contributors may be used to endorse or promote products *
14  * derived from this software without specific prior written permission. *
15  * *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND *
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED *
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
19  * DISCLAIMED. IN NO EVENT SHALL ALICE COLLABORATION BE LIABLE FOR ANY *
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; *
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND *
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
26  ************************************************************************************/
27 #include <TBits.h>
28 #include <TClonesArray.h>
29 #include <TList.h>
30 #include <TObjArray.h>
31 #include <memory>
32 #include <iostream>
33 
38 #include "AliEmcalCutBase.h"
39 #include "AliESDEvent.h"
40 #include "AliESDtrack.h"
41 #include "AliESDtrackCuts.h"
42 #include "AliLog.h"
43 #include "AliPicoTrack.h"
44 #include "AliVCuts.h"
45 
49 
52 {
53 }
54 
57 {
58  if(cuts) this->AddTrackCuts(cuts);
59 }
60 
63 {
64  GenerateTrackCuts(type, period);
65 }
66 
68 {
69  using PWG::EMCAL::AliEmcalESDHybridTrackCuts;
70  if (fListOfCuts) fListOfCuts->Clear();
71  fSelectionModeAny = kTRUE;
72 
73  switch (type) {
74  case kHybridTracks:
76  break;
77 
78  case kTPCOnlyTracks:
80  break;
81 
82  case kITSPureTracks:
83  AddTrackCuts(AliESDtrackCuts::GetStandardITSPureSATrackCuts2010(kTRUE, kFALSE));
84  break;
85 
87  {
88  auto hybridcuts = new AliEmcalESDHybridTrackCuts("hybrid_2010_wNoRefit", AliEmcalESDHybridTrackCuts::kDef2010);
89  hybridcuts->SetUseNoITSrefitTracks(kTRUE);
90  AddTrackCuts(hybridcuts);
91  break;
92  }
93 
95  {
96  auto hybridcuts = new AliEmcalESDHybridTrackCuts("hybrid_2010_wNoRefit", AliEmcalESDHybridTrackCuts::kDef2010);
97  hybridcuts->SetUseNoITSrefitTracks(kFALSE);
98  AddTrackCuts(hybridcuts);
99  break;
100  }
101 
103  {
104  auto hybridcuts = new AliEmcalESDHybridTrackCuts("hybrid_2010_wNoRefit", AliEmcalESDHybridTrackCuts::kDef2011);
105  hybridcuts->SetUseNoITSrefitTracks(kTRUE);
106  AddTrackCuts(hybridcuts);
107  break;
108  }
109 
111  {
112  auto hybridcuts = new AliEmcalESDHybridTrackCuts("hybrid_2010_wNoRefit", AliEmcalESDHybridTrackCuts::kDef2011);
113  hybridcuts->SetUseNoITSrefitTracks(kFALSE);
114  AddTrackCuts(hybridcuts);
115  break;
116  }
117 
118  default:
119  break;
120  }
121 }
122 
124  if (!fListOfCuts){
125  AliDebugStream(2) << "No cut array " << std::endl;
126  return PWG::EMCAL::AliEmcalTrackSelResultPtr(nullptr, kFALSE);
127  }
128  AliESDtrack *esdt = dynamic_cast<AliESDtrack *>(trk);
129  if (!esdt) {
130  AliPicoTrack *picoTrack = dynamic_cast<AliPicoTrack *>(trk);
131  if (picoTrack) {
132  esdt = dynamic_cast<AliESDtrack*>(picoTrack->GetTrack());
133  }
134  else {
135  AliError("Neither Pico nor ESD track");
136  return PWG::EMCAL::AliEmcalTrackSelResultPtr(nullptr, kFALSE);
137  }
138  }
139 
140  TBits trackbitmap(64);
141  trackbitmap.ResetAllBits();
142  UInt_t cutcounter = 0;
143  AliDebugStream(2) << "Found cut array with " << fListOfCuts->GetEntries() << " cuts\n" << std::endl;
144  TObjArray selectionStatus;
145  selectionStatus.SetOwner(false);
146  for(auto cutIter : *fListOfCuts){
147  AliDebugStream(3) << "executing nect cut: " << static_cast<AliVCuts *>(static_cast<AliEmcalManagedObject *>(cutIter)->GetObject())->GetName() << std::endl;
148  PWG::EMCAL::AliEmcalCutBase *mycuts = static_cast<PWG::EMCAL::AliEmcalCutBase *>(static_cast<AliEmcalManagedObject *>(cutIter)->GetObject());
149  PWG::EMCAL::AliEmcalTrackSelResultPtr selresult = mycuts->IsSelected(esdt);
150  selectionStatus.Add(&selresult);
151  if(selresult) trackbitmap.SetBitNumber(cutcounter);
152  cutcounter++;
153  }
154  // In case of ANY at least one bit has to be set, while in case of ALL all bits have to be set
155  PWG::EMCAL::AliEmcalTrackSelResultPtr result(esdt, kFALSE, new PWG::EMCAL::AliEmcalTrackSelResultCombined(&selectionStatus));
156  if (fSelectionModeAny){
157  result.SetSelectionResult(trackbitmap.CountBits() > 0 || cutcounter == 0);
158  } else {
159  result.SetSelectionResult(trackbitmap.CountBits() == cutcounter);
160  }
161  return result;
162 }
163 
165  for(auto cutIter : *fListOfCuts){
166  AliEmcalManagedObject *ptr = static_cast<AliEmcalManagedObject *>(cutIter);
167  if(ptr->GetObject()->IsA() == AliESDtrackCuts::Class()){
168  outputList->Add(ptr->GetObject());
169  // Remove ownership - taken over by output list
170  ptr->SetOwner(false);
171  }
172  }
173 }
Interface for virtual track selection.
static void AddHybridTrackCuts(AliEmcalTrackSelection *trkSel, TString period)
TObject * GetObject(const TCollection *parent, const TString &name, const TClass *cls=0, Bool_t verbose=true)
TObject * GetObject()
Providing access to managed object.
TObjArray * fListOfCuts
List of track cut objects.
Structure containing the result of a given track selection step.
virtual AliEmcalTrackSelResultPtr IsSelected(TObject *o)=0
void SetOwner(bool owner=true)
Specifying ownership over object.
void SetSelectionResult(Bool_t selectionResult)
AliEmcalTrackSelectionESD()
Dummy constructor.
Hybrid tracks using the 2011 definition including NoITSrefit tracks (ESD-only)
Hybrid tracks using the 2010 definition including NoITSrefit tracks (ESD-only)
unsigned int UInt_t
Definition: External.C:33
Hybrid tracks using the 2010 definition excluding NoITSrefit tracks (ESD-only)
Hybrid tracks using the 2011 definition excluding NoITSrefit tracks (ESD-only)
Declaration of class AliEmcalESDTrackCutsGenerator.
void AddTrackCuts(AliVCuts *cuts)
Add new track cuts to the list of cuts.
AliVTrack * GetTrack() const
Definition: AliPicoTrack.h:60
virtual void SaveQAObjects(TList *outputList)
Bool_t fSelectionModeAny
Accept track if any of the cuts is fulfilled.
static void AddTPCOnlyTrackCuts(AliEmcalTrackSelection *trkSel, TString period)
ETrackFilterType_t
Pre-defined track filters.
virtual void GenerateTrackCuts(ETrackFilterType_t type, const char *period="")
Automatically generates track cuts depending on the requested type of filtering.
Smart pointer implementation for objects inheriting from TObject.
Interface for a cut class returning selection status and user information.
virtual PWG::EMCAL::AliEmcalTrackSelResultPtr IsTrackAccepted(AliVTrack *const trk)
Check whether track is accepted.
Implementation of virtual track selection for ESDs.