AliPhysics  59e0e03 (59e0e03)
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  return static_cast<Int_t>(trk->GetTPCCrossedRows()) + static_cast<Int_t>(trk->GetTRDncls());
146 }
147 
148 Double_t AliEmcalESDHybridTrackCuts::GetPtDepCutTPCTRDNumberOfClusters(const AliVTrack *trk) const {
149  return std::min(static_cast<Double_t>(fMinClustersTPCTRD), static_cast<Double_t>(fMinClustersTPCTRD) - fPtDepParamClusterCut / trk->Pt());
150 }
151 
152 Bool_t AliEmcalESDHybridTrackCuts::IsActiveITSModule(const AliESDtrack *const trk, int layer) const {
153  int det, status;
154  Float_t xloc, zloc;
155  trk->GetITSModuleIndexInfo(layer, det, status, xloc, zloc);
156  // dead status:
157  // - dead (2)
158  // - skipped (3)
159  // - outinz (4)
160  // - holeinz (7)
161  return !(status == 2 || status == 3 || status == 4 || status == 7);
162 }
163 
164 void AliEmcalESDHybridTrackCuts::InitHybridTracks2010() {
165  std::cout << "Initializing hybrid track cuts based on the 2010 definition" << std::endl;
166  auto baseCutsFactory = [](std::string cutsname) -> AliESDtrackCuts * {
167  auto trackcuts = new AliESDtrackCuts(cutsname.data());
168  auto f1NClustersTPCLinearPtDep = new TFormula("f1NClustersTPCLinearPtDep","70.+30./20.*x");
169  trackcuts->SetMinNClustersTPCPtDep(f1NClustersTPCLinearPtDep,20.);
170  trackcuts->SetMinNClustersTPC(70);
171  trackcuts->SetMaxChi2PerClusterTPC(4);
172  trackcuts->SetRequireTPCStandAlone(kTRUE); //cut on NClustersTPC and chi2TPC Iter1
173  trackcuts->SetAcceptKinkDaughters(kFALSE);
174  trackcuts->SetRequireTPCRefit(kTRUE);
175  trackcuts->SetMaxFractionSharedTPCClusters(0.4);
176  // ITS
177  trackcuts->SetRequireITSRefit(kTRUE);
178  //accept secondaries
179  trackcuts->SetMaxDCAToVertexXY(2.4);
180  trackcuts->SetMaxDCAToVertexZ(3.2);
181  trackcuts->SetDCAToVertex2D(kTRUE);
182  //reject fakes
183  trackcuts->SetMaxChi2PerClusterITS(36);
184  trackcuts->SetMaxChi2TPCConstrainedGlobal(36);
185 
186  trackcuts->SetRequireSigmaToVertex(kFALSE);
187 
188  trackcuts->SetEtaRange(-0.9,0.9);
189  trackcuts->SetPtRange(0.15, 1E+15);
190 
191  return trackcuts;
192  };
193 
194  fHybridTrackCutsGlobal = baseCutsFactory("JetCuts10001006");
195  fHybridTrackCutsGlobal->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
196 
197  // the complement to the one with SPD requirement: tracks with ITS refit but no SPD hit
198  // AliESDtrackCuts* esdTrackCutsHG1 = CreateTrackCutsPWGJE(10011006);
199  fHybridTrackCutsConstrained = baseCutsFactory("JetCuts10011006");
200  fHybridTrackCutsConstrained->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kNone);
201 
202  if(this->fSelectNonRefitTracks) {
203  // all complementary hybrid tracks: no SPD requirement, no ITS refit requirement
204  // AliESDtrackCuts* esdTrackCutsGCOnly = CreateTrackCutsPWGJE(10041006);
205  AliInfoStream() << "Create selection for non-refit tracks" << std::endl;
206  fHybridTrackCutsNoItsRefit = baseCutsFactory("JetCuts10041006");
207  fHybridTrackCutsConstrained->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kNone);
208  fHybridTrackCutsNoItsRefit->SetRequireITSRefit(kFALSE);
209  }
210 }
211 
212 void AliEmcalESDHybridTrackCuts::InitHybridTracks2011() {
213  std::cout << "Initialiing hybrid tracks based on the 2011 definition" <<std::endl;
214  // first the global tracks we want to take
215  fHybridTrackCutsGlobal = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kFALSE);
216  fHybridTrackCutsGlobal->SetName("Global Hybrid tracks, loose DCA");
217  fHybridTrackCutsGlobal->SetMaxDCAToVertexXY(2.4);
218  fHybridTrackCutsGlobal->SetMaxDCAToVertexZ(3.2);
219  fHybridTrackCutsGlobal->SetDCAToVertex2D(kTRUE);
220  fHybridTrackCutsGlobal->SetMaxChi2TPCConstrainedGlobal(36);
221  fHybridTrackCutsGlobal->SetMaxFractionSharedTPCClusters(0.4);
222 
223  // then the global constrainted tracks
224  fHybridTrackCutsConstrained = new AliESDtrackCuts(*fHybridTrackCutsGlobal);
225  fHybridTrackCutsConstrained->SetName("Global Constraint Hybrid tracks, loose DCA no it requirement");
226  fHybridTrackCutsConstrained->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kOff);
227  fHybridTrackCutsConstrained->SetRequireITSRefit(kTRUE);
228 
229  if(fSelectNonRefitTracks){
230  AliInfoStream() << "Create selection for non-refit tracks" << std::endl;
231  fHybridTrackCutsNoItsRefit = new AliESDtrackCuts(*fHybridTrackCutsConstrained);
232  fHybridTrackCutsNoItsRefit->SetRequireITSRefit(kFALSE);
233  }
234 }
235 
236 void AliEmcalESDHybridTrackCuts::InitHybridTracks2018TRD(){
237  std::cout << "Initialiing hybrid tracks based on the 2018 definition" <<std::endl;
238  InitHybridTracks2011();
239 
240  // Deactivate TPC crossed rows cut
241  if(fHybridTrackCutsGlobal) fHybridTrackCutsGlobal->SetMinNCrossedRowsTPC(30);
242  if(fHybridTrackCutsConstrained) fHybridTrackCutsConstrained->SetMinNCrossedRowsTPC(30);
243  if(fHybridTrackCutsNoItsRefit) fHybridTrackCutsNoItsRefit->SetMinNCrossedRowsTPC(30);
244 
245  // Set min. number of TPC+TRD clusters cut
246  fRequireTPCTRDClusters = true;
247  fMinClustersTPCTRD = 120;
248 }
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