AliPhysics  2c6b7ad (2c6b7ad)
AliEmcalESDHybridTrackCuts.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 <algorithm>
28 #include <functional>
29 #include <iostream>
30 #include <string>
31 
32 #include "TFormula.h"
33 
34 #include "AliESDtrack.h"
35 #include "AliESDtrackCuts.h"
38 #include "AliLog.h"
39 
41 ClassImp(PWG::EMCAL::AliEmcalESDHybridTrackCuts)
43 
44 using namespace PWG::EMCAL;
45 
46 AliEmcalESDHybridTrackCuts::AliEmcalESDHybridTrackCuts():
48  fLocalInitialized(kFALSE),
49  fHybridTrackDefinition(kDef2010),
50  fHybridTrackCutsGlobal(nullptr),
51  fHybridTrackCutsConstrained(nullptr),
52  fHybridTrackCutsNoItsRefit(nullptr),
53  fRequireTPCTRDClusters(false),
54  fMinClustersTPCTRD(0),
55  fPtDepParamClusterCut(0.)
56 {
57 
58 }
59 
60 AliEmcalESDHybridTrackCuts::AliEmcalESDHybridTrackCuts(const char *name, HybridDefinition_t hybriddef):
61  AliEmcalCutBase(name, ""),
62  fLocalInitialized(kFALSE),
63  fHybridTrackDefinition(hybriddef),
64  fHybridTrackCutsGlobal(nullptr),
65  fHybridTrackCutsConstrained(nullptr),
66  fHybridTrackCutsNoItsRefit(nullptr),
67  fRequireTPCTRDClusters(false),
68  fMinClustersTPCTRD(0),
69  fPtDepParamClusterCut(0.)
70 {
71 
72 }
73 
74 AliEmcalESDHybridTrackCuts::~AliEmcalESDHybridTrackCuts(){
75  if(fHybridTrackCutsGlobal) delete fHybridTrackCutsGlobal;
76  if(fHybridTrackCutsConstrained) delete fHybridTrackCutsConstrained;
77  if(fHybridTrackCutsNoItsRefit) delete fHybridTrackCutsNoItsRefit;
78 }
79 
80 AliEmcalTrackSelResultPtr AliEmcalESDHybridTrackCuts::IsSelected(TObject *o){
81  AliDebugStream(1) << "AliEmcalESDHybridTrackCuts::IsSelected(): Called" << std::endl;
82  if(!fLocalInitialized) Init();
83  AliDebugStream(1) << "Global cuts: " << (fHybridTrackCutsGlobal ? "yes" : "no") << std::endl;
84  AliDebugStream(1) << "Constrained cuts: " << (fHybridTrackCutsConstrained ? "yes" : "no") << std::endl;
85  AliDebugStream(1) << "Non-refit cuts: " << (fHybridTrackCutsNoItsRefit ? "yes" : "no") << std::endl;
86  if(auto esdtrack = dynamic_cast<AliESDtrack *>(o)) {
87  AliEmcalTrackSelResultHybrid::HybridType_t tracktype = AliEmcalTrackSelResultHybrid::kUndefined;
88  if(fHybridTrackCutsGlobal && fHybridTrackCutsGlobal->AcceptTrack(esdtrack)){
89  // Temporary hack for TPC+TRD number of cluster cut which is not yet available in AliESDtrackCuts
90  bool isSelected = true;
91  auto tracklength = GetTPCTRDNumberOfClusters(esdtrack);
92  auto tracklengthcut = GetPtDepCutTPCTRDNumberOfClusters(esdtrack);
93  AliDebugStream(3) << "Global: Combined track length: " << tracklength << "(" << esdtrack->GetTPCCrossedRows() << "/" << static_cast<Int_t>(esdtrack->GetTRDncls()) << "), cut " << tracklengthcut << std::endl;
94  if(fRequireTPCTRDClusters && (static_cast<Double_t>(tracklength) < tracklengthcut)) isSelected = false;
95  if(isSelected){
96  AliDebugStream(2) << "Track selected as global hybrid track" << std::endl;
97  tracktype = AliEmcalTrackSelResultHybrid::kHybridGlobal;
98  }
99  } else {
100  if(fHybridTrackCutsConstrained && fHybridTrackCutsConstrained->AcceptTrack(esdtrack)){
101  // Temporary hack for TPC+TRD number of cluster cut which is not yet available in AliESDtrackCuts
102  bool isSelected = true;
103  auto tracklength = GetTPCTRDNumberOfClusters(esdtrack);
104  auto tracklengthcut = GetPtDepCutTPCTRDNumberOfClusters(esdtrack);
105  AliDebugStream(3) << "Constrained: Combined track length: " << tracklength << "(" << esdtrack->GetTPCCrossedRows() << "/" << static_cast<Int_t>(esdtrack->GetTRDncls()) << "), cut " << tracklengthcut << std::endl;
106  if(fRequireTPCTRDClusters && (tracklength < tracklengthcut)) isSelected = false;
107  if(isSelected){
108  AliDebugStream(2) << "Track selected as constrained hybrid track" << std::endl;
109  if(IsActiveITSModule(esdtrack, 0) || IsActiveITSModule(esdtrack, 1)) tracktype = AliEmcalTrackSelResultHybrid::kHybridConstrainedFake;
110  else tracktype = AliEmcalTrackSelResultHybrid::kHybridConstrainedTrue;
111  }
112  } else if(fHybridTrackCutsNoItsRefit && fHybridTrackCutsNoItsRefit->AcceptTrack(esdtrack)) {
113  // Temporary hack for TPC+TRD number of cluster cut which is not yet available in AliESDtrackCuts
114  bool isSelected = true;
115  if(fRequireTPCTRDClusters && (GetTPCTRDNumberOfClusters(esdtrack) < GetPtDepCutTPCTRDNumberOfClusters(esdtrack))) isSelected = false;
116  if(isSelected){
117  AliDebugStream(2) << "Track selected as non-refit hybrid track" << std::endl;
118  tracktype = AliEmcalTrackSelResultHybrid::kHybridConstrainedNoITSrefit;
119  }
120  } else {
121  AliDebugStream(2) << "Track not selected as hybrid track" << std::endl;
122  }
123  }
124  AliEmcalTrackSelResultPtr result(esdtrack, tracktype != AliEmcalTrackSelResultHybrid::kUndefined);
125  if(result) result.SetUserInfo(new AliEmcalTrackSelResultHybrid(tracktype));
126 
127  return result;
128  }
129  AliErrorStream() << "No ESD track" << std::endl;
130  return AliEmcalTrackSelResultPtr(nullptr, kFALSE);
131 }
132 
133 void AliEmcalESDHybridTrackCuts::Init(){
134  switch(fHybridTrackDefinition){
135  case kDef2010: InitHybridTracks2010(); break;
136  case kDef2011: InitHybridTracks2011(); break;
137  case kDef2018TRD: InitHybridTracks2018TRD(); break;
138  default:
139  AliErrorStream() << "No matching initialization found for requested hybrid track definition" <<std::endl;
140  };
141  fLocalInitialized = true;
142 }
143 
144 Int_t AliEmcalESDHybridTrackCuts::GetTPCTRDNumberOfClusters(const AliVTrack *const trk) const {
145  auto esdtrack = static_cast<const AliESDtrack *>(trk);
146  return static_cast<Int_t>(trk->GetTPCCrossedRows()) + static_cast<Int_t>(esdtrack->GetTRDntracklets() * 20);
147 }
148 
149 Double_t AliEmcalESDHybridTrackCuts::GetPtDepCutTPCTRDNumberOfClusters(const AliVTrack *trk) const {
150  return std::min(static_cast<Double_t>(fMinClustersTPCTRD), static_cast<Double_t>(fMinClustersTPCTRD) - fPtDepParamClusterCut / trk->Pt());
151 }
152 
153 Bool_t AliEmcalESDHybridTrackCuts::IsActiveITSModule(const AliESDtrack *const trk, int layer) const {
154  int det, status;
155  Float_t xloc, zloc;
156  trk->GetITSModuleIndexInfo(layer, det, status, xloc, zloc);
157  // dead status:
158  // - dead (2)
159  // - skipped (3)
160  // - outinz (4)
161  // - holeinz (7)
162  return !(status == 2 || status == 3 || status == 4 || status == 7);
163 }
164 
165 void AliEmcalESDHybridTrackCuts::InitHybridTracks2010() {
166  std::cout << "Initializing hybrid track cuts based on the 2010 definition" << std::endl;
167  auto baseCutsFactory = [](std::string cutsname) -> AliESDtrackCuts * {
168  auto trackcuts = new AliESDtrackCuts(cutsname.data());
169  auto f1NClustersTPCLinearPtDep = new TFormula("f1NClustersTPCLinearPtDep","70.+30./20.*x");
170  trackcuts->SetMinNClustersTPCPtDep(f1NClustersTPCLinearPtDep,20.);
171  trackcuts->SetMinNClustersTPC(70);
172  trackcuts->SetMaxChi2PerClusterTPC(4);
173  trackcuts->SetRequireTPCStandAlone(kTRUE); //cut on NClustersTPC and chi2TPC Iter1
174  trackcuts->SetAcceptKinkDaughters(kFALSE);
175  trackcuts->SetRequireTPCRefit(kTRUE);
176  trackcuts->SetMaxFractionSharedTPCClusters(0.4);
177  // ITS
178  trackcuts->SetRequireITSRefit(kTRUE);
179  //accept secondaries
180  trackcuts->SetMaxDCAToVertexXY(2.4);
181  trackcuts->SetMaxDCAToVertexZ(3.2);
182  trackcuts->SetDCAToVertex2D(kTRUE);
183  //reject fakes
184  trackcuts->SetMaxChi2PerClusterITS(36);
185  trackcuts->SetMaxChi2TPCConstrainedGlobal(36);
186 
187  trackcuts->SetRequireSigmaToVertex(kFALSE);
188 
189  trackcuts->SetEtaRange(-0.9,0.9);
190  trackcuts->SetPtRange(0.15, 1E+15);
191 
192  return trackcuts;
193  };
194 
195  fHybridTrackCutsGlobal = baseCutsFactory("JetCuts10001006");
196  fHybridTrackCutsGlobal->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
197 
198  // the complement to the one with SPD requirement: tracks with ITS refit but no SPD hit
199  // AliESDtrackCuts* esdTrackCutsHG1 = CreateTrackCutsPWGJE(10011006);
200  fHybridTrackCutsConstrained = baseCutsFactory("JetCuts10011006");
201  fHybridTrackCutsConstrained->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kNone);
202 
203  if(this->fSelectNonRefitTracks) {
204  // all complementary hybrid tracks: no SPD requirement, no ITS refit requirement
205  // AliESDtrackCuts* esdTrackCutsGCOnly = CreateTrackCutsPWGJE(10041006);
206  AliInfoStream() << "Create selection for non-refit tracks" << std::endl;
207  fHybridTrackCutsNoItsRefit = baseCutsFactory("JetCuts10041006");
208  fHybridTrackCutsConstrained->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kNone);
209  fHybridTrackCutsNoItsRefit->SetRequireITSRefit(kFALSE);
210  }
211 }
212 
213 void AliEmcalESDHybridTrackCuts::InitHybridTracks2011() {
214  std::cout << "Initialiing hybrid tracks based on the 2011 definition" <<std::endl;
215  // first the global tracks we want to take
216  fHybridTrackCutsGlobal = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kFALSE);
217  fHybridTrackCutsGlobal->SetName("Global Hybrid tracks, loose DCA");
218  fHybridTrackCutsGlobal->SetMaxDCAToVertexXY(2.4);
219  fHybridTrackCutsGlobal->SetMaxDCAToVertexZ(3.2);
220  fHybridTrackCutsGlobal->SetDCAToVertex2D(kTRUE);
221  fHybridTrackCutsGlobal->SetMaxChi2TPCConstrainedGlobal(36);
222  fHybridTrackCutsGlobal->SetMaxFractionSharedTPCClusters(0.4);
223 
224  // then the global constrainted tracks
225  fHybridTrackCutsConstrained = new AliESDtrackCuts(*fHybridTrackCutsGlobal);
226  fHybridTrackCutsConstrained->SetName("Global Constraint Hybrid tracks, loose DCA no it requirement");
227  fHybridTrackCutsConstrained->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kOff);
228  fHybridTrackCutsConstrained->SetRequireITSRefit(kTRUE);
229 
230  if(fSelectNonRefitTracks){
231  AliInfoStream() << "Create selection for non-refit tracks" << std::endl;
232  fHybridTrackCutsNoItsRefit = new AliESDtrackCuts(*fHybridTrackCutsConstrained);
233  fHybridTrackCutsNoItsRefit->SetRequireITSRefit(kFALSE);
234  }
235 }
236 
237 void AliEmcalESDHybridTrackCuts::InitHybridTracks2018TRD(){
238  std::cout << "Initialiing hybrid tracks based on the 2018 definition" <<std::endl;
239  InitHybridTracks2011();
240 
241  // Deactivate TPC crossed rows cut
242  if(fHybridTrackCutsGlobal) fHybridTrackCutsGlobal->SetMinNCrossedRowsTPC(30);
243  if(fHybridTrackCutsConstrained) fHybridTrackCutsConstrained->SetMinNCrossedRowsTPC(30);
244  if(fHybridTrackCutsNoItsRefit) fHybridTrackCutsNoItsRefit->SetMinNCrossedRowsTPC(30);
245 
246  // Set min. number of TPC+TRD clusters cut
247  fRequireTPCTRDClusters = true;
248  fMinClustersTPCTRD = 120;
249  fPtDepParamClusterCut = 10.;
250 }
double Double_t
Definition: External.C:58
Structure containing the result of a given track selection step.
Namespace for EMCAL framework classes and task.
int Int_t
Definition: External.C:63
float Float_t
Definition: External.C:68
Namespace for PWG framework classes.
Selection result of the hybrid track selection.
Interface for a cut class returning selection status and user information.
bool Bool_t
Definition: External.C:53