ATLAS Offline Software
InDetEtaDependentCutsSvc.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 // InDetEtaDependentCutsSvc includes
8 
9 #include <algorithm>
10 #include <cmath>
11 #include <functional>
12 #include <variant>
13 
14 namespace InDet {
15 
17  // Constructors
20  ISvcLocator* sl):
21  base_class(name, sl)
22  {}
23 
25  // Destructor
28 
29 
31  // Initialize
33  StatusCode
35  ATH_MSG_DEBUG ("Initializing " << name() << "...");
36  if (m_etaBins.empty()) {
37  ATH_MSG_ERROR( "Wrong initialisation of eta bins. Check the eta bin values in " << name() );
38  return StatusCode::FAILURE;
39  }
40 
41  // expecting eta bins in ascending order
42  if (not std::is_sorted(m_etaBins.value().begin(), m_etaBins.value().end())) {
43  ATH_MSG_ERROR( "Wrong initialisation of eta bins in " << name() << ". Values are not sorted!" );
44  return StatusCode::FAILURE;
45  }
46 
47  using setOfCuts = std::variant< std::reference_wrapper<std::vector <double>>, std::reference_wrapper<std::vector <int>> >;
48 
49  std::vector < setOfCuts> allCuts { m_etaWidthBrem.value() ,
50  m_maxdImpactSSSSeeds.value() ,
51  m_maxPrimaryImpact.value() ,
52  m_maxZImpact.value() ,
53  m_minPT.value() ,
54  m_minPTBrem.value() ,
55  m_phiWidthBrem.value() ,
56  m_Xi2max.value() ,
57  m_Xi2maxNoAdd.value() ,
58  m_maxDoubleHoles.value() ,
59  m_maxHoles.value() ,
60  m_maxPixelHoles.value() ,
61  m_maxSctHoles.value() ,
62  m_maxShared.value() ,
63  m_minClusters.value() ,
64  m_minPixelHits.value() ,
65  m_minSiNotShared.value() ,
66  m_maxHolesGapPattern.value() ,
67  m_maxHolesPattern.value() ,
68  m_nWeightedClustersMin.value(),
69  m_minInPixelHits.value(),
70  m_minStripHits.value()};
71 
72  // checking if the set of cuts makes sense
73  size_t noOfEtaBins = m_etaBins.size();
74 
75  for (setOfCuts& cuts : allCuts) {
76  auto sCode = std::visit([noOfEtaBins] (auto & testingCuts) -> StatusCode {
77 
78  if (testingCuts.get().size() == noOfEtaBins)
79  return StatusCode::SUCCESS;
80 
81  if (testingCuts.get().size() > noOfEtaBins)
82  return StatusCode::FAILURE;
83 
84  if (testingCuts.get().size() < noOfEtaBins)
85  testingCuts.get().resize(noOfEtaBins, testingCuts.get().back());
86 
87  return StatusCode::SUCCESS;
88  } , cuts);
89 
90  if (sCode.isFailure()) {
91  ATH_MSG_ERROR( "No. of cut values bigger than eta bins");
92  return sCode;
93  }
94  }
95 
96  // printing all the cuts
97  ATH_MSG_DEBUG ("--- Dynamic cuts ---");
98  ATH_MSG_DEBUG ("Eta bins (size=" << (m_etaBins.size()) << "): " << m_etaBins);
99  ATH_MSG_DEBUG ("etaWidthBrem: " << m_etaWidthBrem);
100  ATH_MSG_DEBUG ("maxdImpactSSSSeeds: " << m_maxdImpactSSSSeeds);
101  ATH_MSG_DEBUG ("maxDoubleHoles: " << m_maxDoubleHoles);
102  ATH_MSG_DEBUG ("maxHoles: " << m_maxHoles);
103  ATH_MSG_DEBUG ("maxPixelHoles: " << m_maxPixelHoles);
104  ATH_MSG_DEBUG ("maxPrimaryImpact: " << m_maxPrimaryImpact);
105  ATH_MSG_DEBUG ("maxSctHoles: " << m_maxSctHoles);
106  ATH_MSG_DEBUG ("maxShared: " << m_maxShared);
107  ATH_MSG_DEBUG ("maxZImpact: " << m_maxZImpact);
108  ATH_MSG_DEBUG ("minClusters: " << m_minClusters);
109  ATH_MSG_DEBUG ("minInnermostPixelHits: " << m_minInPixelHits);
110  ATH_MSG_DEBUG ("minPixelHits: " << m_minPixelHits);
111  ATH_MSG_DEBUG ("minStripHits: " << m_minStripHits);
112  ATH_MSG_DEBUG ("minPT: " << m_minPT);
113  ATH_MSG_DEBUG ("minPTBrem: " << m_minPTBrem);
114  ATH_MSG_DEBUG ("minSiNotShared: " << m_minSiNotShared);
115  ATH_MSG_DEBUG ("nHolesGapMax: " << m_maxHolesGapPattern);
116  ATH_MSG_DEBUG ("nHolesMax: " << m_maxHolesPattern);
117  ATH_MSG_DEBUG ("nWeightedClustersMin: " << m_nWeightedClustersMin);
118  ATH_MSG_DEBUG ("phiWidthBrem: " << m_phiWidthBrem);
119  ATH_MSG_DEBUG ("Xi2max: " << m_Xi2max);
120  ATH_MSG_DEBUG ("Xi2maxNoAdd: " << m_Xi2maxNoAdd);
121 
122  // Initialize maps for navigation
124  m_mapDoubleCuts[InDet::CutName::minPT] = m_minPT;
125  m_mapDoubleCuts[InDet::CutName::maxPrimaryImpact] = m_maxPrimaryImpact;
126  m_mapDoubleCuts[InDet::CutName::maxZImpact] = m_maxZImpact;
128  m_mapDoubleCuts[InDet::CutName::Xi2maxNoAdd] = m_Xi2maxNoAdd;
129  m_mapDoubleCuts[InDet::CutName::maxdImpactSSSSeeds] = m_maxdImpactSSSSeeds;
130  m_mapDoubleCuts[InDet::CutName::minPTBrem] = m_minPTBrem;
131  m_mapDoubleCuts[InDet::CutName::etaWidthBrem] = m_etaWidthBrem;
132  m_mapDoubleCuts[InDet::CutName::phiWidthBrem] = m_phiWidthBrem;
133 
134  m_mapIntCuts[InDet::CutName::minClusters] = m_minClusters;
135  m_mapIntCuts[InDet::CutName::minSiNotShared] = m_minSiNotShared;
136  m_mapIntCuts[InDet::CutName::maxShared] = m_maxShared;
137  m_mapIntCuts[InDet::CutName::minPixelHits] = m_minPixelHits;
138  m_mapIntCuts[InDet::CutName::maxHoles] = m_maxHoles;
139  m_mapIntCuts[InDet::CutName::maxPixelHoles] = m_maxPixelHoles;
140  m_mapIntCuts[InDet::CutName::maxSctHoles] = m_maxSctHoles;
141  m_mapIntCuts[InDet::CutName::maxDoubleHoles] = m_maxDoubleHoles;
142  m_mapIntCuts[InDet::CutName::maxHolesPattern] = m_maxHolesPattern;
143  m_mapIntCuts[InDet::CutName::maxHolesGapPattern] = m_maxHolesGapPattern;
144  m_mapIntCuts[InDet::CutName::nWeightedClustersMin] = m_nWeightedClustersMin;
145  m_mapIntCuts[InDet::CutName::minInPixelHits] = m_minInPixelHits;
146  m_mapIntCuts[InDet::CutName::minStripHits] = m_minStripHits;
147 
148  return StatusCode::SUCCESS;
149  }
150 
152  // Finalize
155  return StatusCode::SUCCESS;
156  }
157 
158  int
159  InDetEtaDependentCutsSvc::getIndexByEta(const double eta) const {
160  double absEta = std::abs(eta);
161  if (absEta > m_etaBins.value().back() || absEta < m_etaBins.value().front()) {
162  ATH_MSG_INFO("Requesting cut value outside of configured eta range: clamping eta="
163  << absEta << " to eta="
164  << std::clamp(absEta, m_etaBins.value().front(), m_etaBins.value().back()));
165  }
166  absEta = std::clamp(absEta, m_etaBins.value().front(), m_etaBins.value().back());
167  const auto pVal = std::lower_bound(m_etaBins.value().begin(), m_etaBins.value().end(), absEta);
168  const int bin = std::distance(m_etaBins.value().begin(), pVal) - 1;
169  ATH_MSG_DEBUG("Checking (abs(eta)/bin) = (" << absEta << "," << bin << ")");
170  return bin;
171  }
172 
173 
174  void InDetEtaDependentCutsSvc::getValue(const InDet::CutName cutName, std::vector < double >& cuts) {
175  // getting the number of eta bins
176  size_t noOfEtaBins = m_etaBins.size();
177 
178  // resize the cuts vector before setting it
179  cuts.resize(noOfEtaBins);
180 
181  std::unordered_map< InDet::CutName, std::vector<double> >::iterator it = m_mapDoubleCuts.find(cutName);
182 
183  if(it!=m_mapDoubleCuts.end()) cuts = it->second;
184  else ATH_MSG_ERROR("CutName not recognized. Cuts will remain unchanged.");
185 
186  }
187 
188  void InDetEtaDependentCutsSvc::getValue(const InDet::CutName cutName, std::vector < int >& cuts) {
189 
190  // getting the number of eta bins
191  size_t noOfEtaBins = m_etaBins.size();
192 
193  // resize the cuts vector before setting it
194  cuts.resize(noOfEtaBins);
195 
196  std::unordered_map< InDet::CutName, std::vector<int> >::iterator it = m_mapIntCuts.find(cutName);
197 
198  if(it!=m_mapIntCuts.end()) cuts = it->second;
199  else ATH_MSG_ERROR("CutName not recognized. Cuts will remain unchanged.");
200 
201  }
202 
203 
205  return m_etaBins.value().back();
206  }
207 
208  double InDetEtaDependentCutsSvc::getMinPtAtEta(const double eta) const {
209  return getValueAtEta<double>(m_minPT,eta);
210  }
211 
212  double InDetEtaDependentCutsSvc::getMaxZImpactAtEta (const double eta) const {
213  return getValueAtEta<double>(m_maxZImpact, eta);
214  }
215 
216  double InDetEtaDependentCutsSvc::getMaxPrimaryImpactAtEta(const double eta) const {
217  return getValueAtEta<double>(m_maxPrimaryImpact, eta);
218  }
219 
220  double InDetEtaDependentCutsSvc::getMaxChi2AtEta(const double eta) const {
221  return getValueAtEta<double>(m_Xi2max, eta);
222  }
223 
224  int InDetEtaDependentCutsSvc::getMinSiHitsAtEta (const double eta) const {
225  return getValueAtEta<int>(m_minClusters, eta);
226  }
227 
228  int InDetEtaDependentCutsSvc::getMinPixelHitsAtEta (const double eta) const {
229  return getValueAtEta<int>(m_minPixelHits, eta);
230  }
231 
232  int InDetEtaDependentCutsSvc::getMaxSiHolesAtEta (const double eta) const {
233  return getValueAtEta<int>(m_maxHoles, eta);
234  }
235 
236  int InDetEtaDependentCutsSvc::getMaxPixelHolesAtEta (const double eta) const {
237  return getValueAtEta<int>(m_maxPixelHoles, eta);
238  }
239 
240  int InDetEtaDependentCutsSvc::getMaxSctHolesAtEta (const double eta) const {
241  return getValueAtEta<int>(m_maxSctHoles, eta);
242  }
243 
245  return getValueAtEta<int>(m_maxDoubleHoles, eta);
246  }
247 
249  return getValueAtEta<int>(m_minSiNotShared, eta);
250  }
251 
252  int InDetEtaDependentCutsSvc::getMaxSharedAtEta (const double eta) const {
253  return getValueAtEta<int>(m_maxShared, eta);
254  }
255 
257  return getValueAtEta<int>(m_minInPixelHits, eta);
258  }
259 
260  int InDetEtaDependentCutsSvc::getMinStripHitsAtEta (const double eta) const {
261  return getValueAtEta<int>(m_minStripHits, eta);
262  }
263 
264 } // end namespace
InDet::InDetEtaDependentCutsSvc::getMaxEta
double getMaxEta() const override final
Definition: InDetEtaDependentCutsSvc.cxx:204
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
InDet::InDetEtaDependentCutsSvc::m_maxdImpactSSSSeeds
DoubleArrayProperty m_maxdImpactSSSSeeds
Definition: InDetEtaDependentCutsSvc.h:74
InDet::InDetEtaDependentCutsSvc::m_Xi2maxNoAdd
DoubleArrayProperty m_Xi2maxNoAdd
Definition: InDetEtaDependentCutsSvc.h:79
InDet::InDetEtaDependentCutsSvc::m_maxPixelHoles
IntegerArrayProperty m_maxPixelHoles
Definition: InDetEtaDependentCutsSvc.h:85
InDet::InDetEtaDependentCutsSvc::m_minPTBrem
DoubleArrayProperty m_minPTBrem
Definition: InDetEtaDependentCutsSvc.h:77
InDet::InDetEtaDependentCutsSvc::m_Xi2max
DoubleArrayProperty m_Xi2max
Definition: InDetEtaDependentCutsSvc.h:78
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
InDet::InDetEtaDependentCutsSvc::m_minSiNotShared
IntegerArrayProperty m_minSiNotShared
Definition: InDetEtaDependentCutsSvc.h:82
InDet::InDetEtaDependentCutsSvc::getValue
void getValue(const InDet::CutName cutName, std::vector< double > &cut) override final
Definition: InDetEtaDependentCutsSvc.cxx:174
InDet
Primary Vertex Finder.
Definition: VP1ErrorUtils.h:36
ConvertOldUJHistosToNewHistos.etaBins
list etaBins
Definition: ConvertOldUJHistosToNewHistos.py:145
InDet::cuts
Definition: TrackStatHelper.h:83
skel.it
it
Definition: skel.GENtoEVGEN.py:396
bin
Definition: BinsDiffFromStripMedian.h:43
InDet::InDetEtaDependentCutsSvc::getMaxPixelHolesAtEta
int getMaxPixelHolesAtEta(const double eta) const override final
Definition: InDetEtaDependentCutsSvc.cxx:236
InDetEtaDependentCutsSvc.h
InDet::InDetEtaDependentCutsSvc::m_maxZImpact
DoubleArrayProperty m_maxZImpact
Definition: InDetEtaDependentCutsSvc.h:73
IDTrig_MC23a_preInclude.Xi2max
Xi2max
Definition: IDTrig_MC23a_preInclude.py:15
InDet::InDetEtaDependentCutsSvc::getMinInnermostPixelHitsAtEta
int getMinInnermostPixelHitsAtEta(const double eta) const override final
Definition: InDetEtaDependentCutsSvc.cxx:256
InDet::InDetEtaDependentCutsSvc::getMinPtAtEta
double getMinPtAtEta(const double eta) const override final
Definition: InDetEtaDependentCutsSvc.cxx:208
InDet::InDetEtaDependentCutsSvc::m_maxDoubleHoles
IntegerArrayProperty m_maxDoubleHoles
Definition: InDetEtaDependentCutsSvc.h:87
InDet::InDetEtaDependentCutsSvc::getMaxSctHolesAtEta
int getMaxSctHolesAtEta(const double eta) const override final
Definition: InDetEtaDependentCutsSvc.cxx:240
InDet::InDetEtaDependentCutsSvc::m_maxHolesGapPattern
IntegerArrayProperty m_maxHolesGapPattern
Definition: InDetEtaDependentCutsSvc.h:89
InDet::InDetEtaDependentCutsSvc::getMaxZImpactAtEta
double getMaxZImpactAtEta(const double eta) const override final
Definition: InDetEtaDependentCutsSvc.cxx:212
InDet::InDetEtaDependentCutsSvc::m_minClusters
IntegerArrayProperty m_minClusters
Definition: InDetEtaDependentCutsSvc.h:80
InDet::InDetEtaDependentCutsSvc::getMaxChi2AtEta
double getMaxChi2AtEta(const double eta) const override final
Definition: InDetEtaDependentCutsSvc.cxx:220
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
InDet::InDetEtaDependentCutsSvc::m_minPT
DoubleArrayProperty m_minPT
Definition: InDetEtaDependentCutsSvc.h:71
InDet::InDetEtaDependentCutsSvc::~InDetEtaDependentCutsSvc
virtual ~InDetEtaDependentCutsSvc() override final
Destructor:
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
InDet::InDetEtaDependentCutsSvc::m_maxPrimaryImpact
DoubleArrayProperty m_maxPrimaryImpact
Definition: InDetEtaDependentCutsSvc.h:72
InDet::InDetEtaDependentCutsSvc::getMinStripHitsAtEta
int getMinStripHitsAtEta(const double eta) const override final
Definition: InDetEtaDependentCutsSvc.cxx:260
plotBeamSpotVert.cuts
string cuts
Definition: plotBeamSpotVert.py:93
InDet::InDetEtaDependentCutsSvc::getMinSiHitsAtEta
int getMinSiHitsAtEta(const double eta) const override final
Definition: InDetEtaDependentCutsSvc.cxx:224
InDet::InDetEtaDependentCutsSvc::getMaxSharedAtEta
int getMaxSharedAtEta(const double eta) const override final
Definition: InDetEtaDependentCutsSvc.cxx:252
InDet::InDetEtaDependentCutsSvc::m_etaBins
DoubleArrayProperty m_etaBins
Definition: InDetEtaDependentCutsSvc.h:70
InDet::InDetEtaDependentCutsSvc::getMaxDoubleHolesAtEta
int getMaxDoubleHolesAtEta(const double eta) const override final
Definition: InDetEtaDependentCutsSvc.cxx:244
InDet::InDetEtaDependentCutsSvc::m_nWeightedClustersMin
IntegerArrayProperty m_nWeightedClustersMin
Definition: InDetEtaDependentCutsSvc.h:90
InDet::InDetEtaDependentCutsSvc::getMaxSiHolesAtEta
int getMaxSiHolesAtEta(const double eta) const override final
Definition: InDetEtaDependentCutsSvc.cxx:232
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
InDet::InDetEtaDependentCutsSvc::m_maxHolesPattern
IntegerArrayProperty m_maxHolesPattern
Definition: InDetEtaDependentCutsSvc.h:88
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
InDet::InDetEtaDependentCutsSvc::getIndexByEta
int getIndexByEta(const double eta) const
Definition: InDetEtaDependentCutsSvc.cxx:159
InDet::InDetEtaDependentCutsSvc::m_minPixelHits
IntegerArrayProperty m_minPixelHits
Definition: InDetEtaDependentCutsSvc.h:81
InDet::InDetEtaDependentCutsSvc::m_mapIntCuts
std::unordered_map< InDet::CutName, std::vector< int > > m_mapIntCuts
Definition: InDetEtaDependentCutsSvc.h:95
InDet::InDetEtaDependentCutsSvc::m_minInPixelHits
IntegerArrayProperty m_minInPixelHits
Definition: InDetEtaDependentCutsSvc.h:91
InDet::InDetEtaDependentCutsSvc::m_maxShared
IntegerArrayProperty m_maxShared
Definition: InDetEtaDependentCutsSvc.h:83
InDet::InDetEtaDependentCutsSvc::m_mapDoubleCuts
std::unordered_map< InDet::CutName, std::vector< double > > m_mapDoubleCuts
Definition: InDetEtaDependentCutsSvc.h:94
InDet::InDetEtaDependentCutsSvc::m_minStripHits
IntegerArrayProperty m_minStripHits
Definition: InDetEtaDependentCutsSvc.h:92
InDet::InDetEtaDependentCutsSvc::m_etaWidthBrem
DoubleArrayProperty m_etaWidthBrem
Definition: InDetEtaDependentCutsSvc.h:75
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567
TauGNNUtils::Variables::absEta
bool absEta(const xAOD::TauJet &tau, double &out)
Definition: TauGNNUtils.cxx:234
InDet::InDetEtaDependentCutsSvc::getMinPixelHitsAtEta
int getMinPixelHitsAtEta(const double eta) const override final
Definition: InDetEtaDependentCutsSvc.cxx:228
InDet::CutName
CutName
Definition: IInDetEtaDependentCutsSvc.h:12
InDet::InDetEtaDependentCutsSvc::m_phiWidthBrem
DoubleArrayProperty m_phiWidthBrem
Definition: InDetEtaDependentCutsSvc.h:76
InDet::InDetEtaDependentCutsSvc::m_maxSctHoles
IntegerArrayProperty m_maxSctHoles
Definition: InDetEtaDependentCutsSvc.h:86
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
InDet::InDetEtaDependentCutsSvc::initialize
StatusCode initialize() override final
Definition: InDetEtaDependentCutsSvc.cxx:34
InDet::InDetEtaDependentCutsSvc::getMaxPrimaryImpactAtEta
double getMaxPrimaryImpactAtEta(const double eta) const override final
Definition: InDetEtaDependentCutsSvc.cxx:216
InDet::InDetEtaDependentCutsSvc::m_maxHoles
IntegerArrayProperty m_maxHoles
Definition: InDetEtaDependentCutsSvc.h:84
InDet::InDetEtaDependentCutsSvc::finalize
StatusCode finalize() override final
Definition: InDetEtaDependentCutsSvc.cxx:154
InDet::InDetEtaDependentCutsSvc::InDetEtaDependentCutsSvc
InDetEtaDependentCutsSvc(const std::string &name, ISvcLocator *sl)
Constructor with parameters:
Definition: InDetEtaDependentCutsSvc.cxx:19
InDet::InDetEtaDependentCutsSvc::getMinSiNotSharedAtEta
int getMinSiNotSharedAtEta(const double eta) const override final
Definition: InDetEtaDependentCutsSvc.cxx:248