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  AthService(name, sl)
22  {}
23 
25  // Destructor
28 
29 
31  // queryInterface
33  StatusCode InDetEtaDependentCutsSvc::queryInterface(const InterfaceID& riid, void** ppvIF) {
34  if( IID_IInDetEtaDependentCutsSvc == riid ) {
35  *ppvIF = dynamic_cast< IInDetEtaDependentCutsSvc* >(this);
36  } else{
37  return AthService::queryInterface(riid, ppvIF);
38  }
39  addRef();
40  return StatusCode::SUCCESS;
41  }
42 
44  // Initialize
46  StatusCode
48  ATH_MSG_DEBUG ("Initializing " << name() << "...");
49  if (m_etaBins.empty()) {
50  ATH_MSG_ERROR( "Wrong initialisation of eta bins. Check the eta bin values in " << name() );
51  return StatusCode::FAILURE;
52  }
53 
54  // expecting eta bins in ascending order
55  if (not std::is_sorted(m_etaBins.value().begin(), m_etaBins.value().end())) {
56  ATH_MSG_ERROR( "Wrong initialisation of eta bins in " << name() << ". Values are not sorted!" );
57  return StatusCode::FAILURE;
58  }
59 
60  using setOfCuts = std::variant< std::reference_wrapper<std::vector <double>>, std::reference_wrapper<std::vector <int>> >;
61 
62  std::vector < setOfCuts> allCuts { m_etaWidthBrem.value() ,
63  m_maxdImpactSSSSeeds.value() ,
64  m_maxPrimaryImpact.value() ,
65  m_maxZImpact.value() ,
66  m_minPT.value() ,
67  m_minPTBrem.value() ,
68  m_phiWidthBrem.value() ,
69  m_Xi2max.value() ,
70  m_Xi2maxNoAdd.value() ,
71  m_maxDoubleHoles.value() ,
72  m_maxHoles.value() ,
73  m_maxPixelHoles.value() ,
74  m_maxSctHoles.value() ,
75  m_maxShared.value() ,
76  m_minClusters.value() ,
77  m_minPixelHits.value() ,
78  m_minSiNotShared.value() ,
79  m_maxHolesGapPattern.value() ,
80  m_maxHolesPattern.value() ,
81  m_nWeightedClustersMin.value(),
82  m_minInPixelHits.value(),
83  m_minStripHits.value()};
84 
85  // checking if the set of cuts makes sense
86  size_t noOfEtaBins = m_etaBins.size();
87 
88  for (setOfCuts& cuts : allCuts) {
89  auto sCode = std::visit([noOfEtaBins] (auto & testingCuts) -> StatusCode {
90 
91  if (testingCuts.get().size() == noOfEtaBins)
92  return StatusCode::SUCCESS;
93 
94  if (testingCuts.get().size() > noOfEtaBins)
95  return StatusCode::FAILURE;
96 
97  if (testingCuts.get().size() < noOfEtaBins)
98  testingCuts.get().resize(noOfEtaBins, testingCuts.get().back());
99 
100  return StatusCode::SUCCESS;
101  } , cuts);
102 
103  if (sCode.isFailure()) {
104  ATH_MSG_ERROR( "No. of cut values bigger than eta bins");
105  return sCode;
106  }
107  }
108 
109  // printing all the cuts
110  ATH_MSG_DEBUG ("--- Dynamic cuts ---");
111  ATH_MSG_DEBUG ("Eta bins (size=" << (m_etaBins.size()) << "): " << m_etaBins);
112  ATH_MSG_DEBUG ("etaWidthBrem: " << m_etaWidthBrem);
113  ATH_MSG_DEBUG ("maxdImpactSSSSeeds: " << m_maxdImpactSSSSeeds);
114  ATH_MSG_DEBUG ("maxDoubleHoles: " << m_maxDoubleHoles);
115  ATH_MSG_DEBUG ("maxHoles: " << m_maxHoles);
116  ATH_MSG_DEBUG ("maxPixelHoles: " << m_maxPixelHoles);
117  ATH_MSG_DEBUG ("maxPrimaryImpact: " << m_maxPrimaryImpact);
118  ATH_MSG_DEBUG ("maxSctHoles: " << m_maxSctHoles);
119  ATH_MSG_DEBUG ("maxShared: " << m_maxShared);
120  ATH_MSG_DEBUG ("maxZImpact: " << m_maxZImpact);
121  ATH_MSG_DEBUG ("minClusters: " << m_minClusters);
122  ATH_MSG_DEBUG ("minInnermostPixelHits: " << m_minInPixelHits);
123  ATH_MSG_DEBUG ("minPixelHits: " << m_minPixelHits);
124  ATH_MSG_DEBUG ("minStripHits: " << m_minStripHits);
125  ATH_MSG_DEBUG ("minPT: " << m_minPT);
126  ATH_MSG_DEBUG ("minPTBrem: " << m_minPTBrem);
127  ATH_MSG_DEBUG ("minSiNotShared: " << m_minSiNotShared);
128  ATH_MSG_DEBUG ("nHolesGapMax: " << m_maxHolesGapPattern);
129  ATH_MSG_DEBUG ("nHolesMax: " << m_maxHolesPattern);
130  ATH_MSG_DEBUG ("nWeightedClustersMin: " << m_nWeightedClustersMin);
131  ATH_MSG_DEBUG ("phiWidthBrem: " << m_phiWidthBrem);
132  ATH_MSG_DEBUG ("Xi2max: " << m_Xi2max);
133  ATH_MSG_DEBUG ("Xi2maxNoAdd: " << m_Xi2maxNoAdd);
134 
135  // Initialize maps for navigation
137  m_mapDoubleCuts[InDet::CutName::minPT] = m_minPT;
138  m_mapDoubleCuts[InDet::CutName::maxPrimaryImpact] = m_maxPrimaryImpact;
139  m_mapDoubleCuts[InDet::CutName::maxZImpact] = m_maxZImpact;
141  m_mapDoubleCuts[InDet::CutName::Xi2maxNoAdd] = m_Xi2maxNoAdd;
142  m_mapDoubleCuts[InDet::CutName::maxdImpactSSSSeeds] = m_maxdImpactSSSSeeds;
143  m_mapDoubleCuts[InDet::CutName::minPTBrem] = m_minPTBrem;
144  m_mapDoubleCuts[InDet::CutName::etaWidthBrem] = m_etaWidthBrem;
145  m_mapDoubleCuts[InDet::CutName::phiWidthBrem] = m_phiWidthBrem;
146 
147  m_mapIntCuts[InDet::CutName::minClusters] = m_minClusters;
148  m_mapIntCuts[InDet::CutName::minSiNotShared] = m_minSiNotShared;
149  m_mapIntCuts[InDet::CutName::maxShared] = m_maxShared;
150  m_mapIntCuts[InDet::CutName::minPixelHits] = m_minPixelHits;
151  m_mapIntCuts[InDet::CutName::maxHoles] = m_maxHoles;
152  m_mapIntCuts[InDet::CutName::maxPixelHoles] = m_maxPixelHoles;
153  m_mapIntCuts[InDet::CutName::maxSctHoles] = m_maxSctHoles;
154  m_mapIntCuts[InDet::CutName::maxDoubleHoles] = m_maxDoubleHoles;
155  m_mapIntCuts[InDet::CutName::maxHolesPattern] = m_maxHolesPattern;
156  m_mapIntCuts[InDet::CutName::maxHolesGapPattern] = m_maxHolesGapPattern;
157  m_mapIntCuts[InDet::CutName::nWeightedClustersMin] = m_nWeightedClustersMin;
158  m_mapIntCuts[InDet::CutName::minInPixelHits] = m_minInPixelHits;
159  m_mapIntCuts[InDet::CutName::minStripHits] = m_minStripHits;
160 
161  return StatusCode::SUCCESS;
162  }
163 
165  // Finalize
168  return StatusCode::SUCCESS;
169  }
170 
171  int
173  double absEta = std::abs(eta);
174  if (absEta > m_etaBins.value().back() || absEta < m_etaBins.value().front()) {
175  ATH_MSG_INFO("Requesting cut value outside of configured eta range: clamping eta="
176  << absEta << " to eta="
177  << std::clamp(absEta, m_etaBins.value().front(), m_etaBins.value().back()));
178  }
179  absEta = std::clamp(absEta, m_etaBins.value().front(), m_etaBins.value().back());
180  const auto pVal = std::lower_bound(m_etaBins.value().begin(), m_etaBins.value().end(), absEta);
181  const int bin = std::distance(m_etaBins.value().begin(), pVal) - 1;
182  ATH_MSG_DEBUG("Checking (abs(eta)/bin) = (" << absEta << "," << bin << ")");
183  return bin;
184  }
185 
186 
187  void InDetEtaDependentCutsSvc::getValue(const InDet::CutName cutName, std::vector < double >& cuts) {
188  // getting the number of eta bins
189  size_t noOfEtaBins = m_etaBins.size();
190 
191  // resize the cuts vector before setting it
192  cuts.resize(noOfEtaBins);
193 
194  std::unordered_map< InDet::CutName, std::vector<double> >::iterator it = m_mapDoubleCuts.find(cutName);
195 
196  if(it!=m_mapDoubleCuts.end()) cuts = it->second;
197  else ATH_MSG_ERROR("CutName not recognized. Cuts will remain unchanged.");
198 
199  }
200 
201  void InDetEtaDependentCutsSvc::getValue(const InDet::CutName cutName, std::vector < int >& cuts) {
202 
203  // getting the number of eta bins
204  size_t noOfEtaBins = m_etaBins.size();
205 
206  // resize the cuts vector before setting it
207  cuts.resize(noOfEtaBins);
208 
209  std::unordered_map< InDet::CutName, std::vector<int> >::iterator it = m_mapIntCuts.find(cutName);
210 
211  if(it!=m_mapIntCuts.end()) cuts = it->second;
212  else ATH_MSG_ERROR("CutName not recognized. Cuts will remain unchanged.");
213 
214  }
215 
216 
218  return m_etaBins.value().back();
219  }
220 
221  double InDetEtaDependentCutsSvc::getMinPtAtEta(const double eta) const {
222  return getValueAtEta<double>(m_minPT,eta);
223  }
224 
225  double InDetEtaDependentCutsSvc::getMaxZImpactAtEta (const double eta) const {
226  return getValueAtEta<double>(m_maxZImpact, eta);
227  }
228 
230  return getValueAtEta<double>(m_maxPrimaryImpact, eta);
231  }
232 
233  double InDetEtaDependentCutsSvc::getMaxChi2AtEta(const double eta) const {
234  return getValueAtEta<double>(m_Xi2max, eta);
235  }
236 
238  return getValueAtEta<int>(m_minClusters, eta);
239  }
240 
242  return getValueAtEta<int>(m_minPixelHits, eta);
243  }
244 
246  return getValueAtEta<int>(m_maxHoles, eta);
247  }
248 
250  return getValueAtEta<int>(m_maxPixelHoles, eta);
251  }
252 
254  return getValueAtEta<int>(m_maxSctHoles, eta);
255  }
256 
258  return getValueAtEta<int>(m_maxDoubleHoles, eta);
259  }
260 
262  return getValueAtEta<int>(m_minSiNotShared, eta);
263  }
264 
266  return getValueAtEta<int>(m_maxShared, eta);
267  }
268 
270  return getValueAtEta<int>(m_minInPixelHits, eta);
271  }
272 
274  return getValueAtEta<int>(m_minStripHits, eta);
275  }
276 
277 } // end namespace
InDet::InDetEtaDependentCutsSvc::getMaxEta
double getMaxEta() const override final
Definition: InDetEtaDependentCutsSvc.cxx:217
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
InDet::InDetEtaDependentCutsSvc::m_maxdImpactSSSSeeds
DoubleArrayProperty m_maxdImpactSSSSeeds
Definition: InDetEtaDependentCutsSvc.h:76
InDet::InDetEtaDependentCutsSvc::m_Xi2maxNoAdd
DoubleArrayProperty m_Xi2maxNoAdd
Definition: InDetEtaDependentCutsSvc.h:81
InDet::InDetEtaDependentCutsSvc::m_maxPixelHoles
IntegerArrayProperty m_maxPixelHoles
Definition: InDetEtaDependentCutsSvc.h:87
InDet::InDetEtaDependentCutsSvc::m_minPTBrem
DoubleArrayProperty m_minPTBrem
Definition: InDetEtaDependentCutsSvc.h:79
InDet::InDetEtaDependentCutsSvc::m_Xi2max
DoubleArrayProperty m_Xi2max
Definition: InDetEtaDependentCutsSvc.h:80
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
InDet::InDetEtaDependentCutsSvc::m_minSiNotShared
IntegerArrayProperty m_minSiNotShared
Definition: InDetEtaDependentCutsSvc.h:84
InDet::InDetEtaDependentCutsSvc::getValue
void getValue(const InDet::CutName cutName, std::vector< double > &cut) override final
Definition: InDetEtaDependentCutsSvc.cxx:187
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
InDet
DUMMY 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:423
bin
Definition: BinsDiffFromStripMedian.h:43
InDet::InDetEtaDependentCutsSvc::getMaxPixelHolesAtEta
int getMaxPixelHolesAtEta(const double eta) const override final
Definition: InDetEtaDependentCutsSvc.cxx:249
InDetEtaDependentCutsSvc.h
InDet::InDetEtaDependentCutsSvc::m_maxZImpact
DoubleArrayProperty m_maxZImpact
Definition: InDetEtaDependentCutsSvc.h:75
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:269
InDet::InDetEtaDependentCutsSvc::getMinPtAtEta
double getMinPtAtEta(const double eta) const override final
Definition: InDetEtaDependentCutsSvc.cxx:221
InDet::InDetEtaDependentCutsSvc::m_maxDoubleHoles
IntegerArrayProperty m_maxDoubleHoles
Definition: InDetEtaDependentCutsSvc.h:89
InDet::InDetEtaDependentCutsSvc::getMaxSctHolesAtEta
int getMaxSctHolesAtEta(const double eta) const override final
Definition: InDetEtaDependentCutsSvc.cxx:253
InDet::InDetEtaDependentCutsSvc::m_maxHolesGapPattern
IntegerArrayProperty m_maxHolesGapPattern
Definition: InDetEtaDependentCutsSvc.h:91
InDet::InDetEtaDependentCutsSvc::getMaxZImpactAtEta
double getMaxZImpactAtEta(const double eta) const override final
Definition: InDetEtaDependentCutsSvc.cxx:225
InDet::InDetEtaDependentCutsSvc::m_minClusters
IntegerArrayProperty m_minClusters
Definition: InDetEtaDependentCutsSvc.h:82
InDet::InDetEtaDependentCutsSvc::getMaxChi2AtEta
double getMaxChi2AtEta(const double eta) const override final
Definition: InDetEtaDependentCutsSvc.cxx:233
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
InDet::InDetEtaDependentCutsSvc::m_minPT
DoubleArrayProperty m_minPT
Definition: InDetEtaDependentCutsSvc.h:73
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
AthService
Definition: AthService.h:32
InDet::InDetEtaDependentCutsSvc::m_maxPrimaryImpact
DoubleArrayProperty m_maxPrimaryImpact
Definition: InDetEtaDependentCutsSvc.h:74
InDet::InDetEtaDependentCutsSvc::getMinStripHitsAtEta
int getMinStripHitsAtEta(const double eta) const override final
Definition: InDetEtaDependentCutsSvc.cxx:273
plotBeamSpotVert.cuts
string cuts
Definition: plotBeamSpotVert.py:93
InDet::InDetEtaDependentCutsSvc::getMinSiHitsAtEta
int getMinSiHitsAtEta(const double eta) const override final
Definition: InDetEtaDependentCutsSvc.cxx:237
InDet::InDetEtaDependentCutsSvc::getMaxSharedAtEta
int getMaxSharedAtEta(const double eta) const override final
Definition: InDetEtaDependentCutsSvc.cxx:265
InDet::IInDetEtaDependentCutsSvc
Definition: IInDetEtaDependentCutsSvc.h:23
InDet::InDetEtaDependentCutsSvc::m_etaBins
DoubleArrayProperty m_etaBins
Definition: InDetEtaDependentCutsSvc.h:72
InDet::InDetEtaDependentCutsSvc::getMaxDoubleHolesAtEta
int getMaxDoubleHolesAtEta(const double eta) const override final
Definition: InDetEtaDependentCutsSvc.cxx:257
InDet::InDetEtaDependentCutsSvc::m_nWeightedClustersMin
IntegerArrayProperty m_nWeightedClustersMin
Definition: InDetEtaDependentCutsSvc.h:92
InDet::InDetEtaDependentCutsSvc::getMaxSiHolesAtEta
int getMaxSiHolesAtEta(const double eta) const override final
Definition: InDetEtaDependentCutsSvc.cxx:245
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
InDet::InDetEtaDependentCutsSvc::m_maxHolesPattern
IntegerArrayProperty m_maxHolesPattern
Definition: InDetEtaDependentCutsSvc.h:90
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
InDet::InDetEtaDependentCutsSvc::getIndexByEta
int getIndexByEta(const double eta) const
Definition: InDetEtaDependentCutsSvc.cxx:172
InDet::InDetEtaDependentCutsSvc::m_minPixelHits
IntegerArrayProperty m_minPixelHits
Definition: InDetEtaDependentCutsSvc.h:83
InDet::InDetEtaDependentCutsSvc::m_mapIntCuts
std::unordered_map< InDet::CutName, std::vector< int > > m_mapIntCuts
Definition: InDetEtaDependentCutsSvc.h:97
InDet::InDetEtaDependentCutsSvc::m_minInPixelHits
IntegerArrayProperty m_minInPixelHits
Definition: InDetEtaDependentCutsSvc.h:93
InDet::InDetEtaDependentCutsSvc::queryInterface
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvIF) final
Definition: InDetEtaDependentCutsSvc.cxx:33
InDet::InDetEtaDependentCutsSvc::m_maxShared
IntegerArrayProperty m_maxShared
Definition: InDetEtaDependentCutsSvc.h:85
InDet::InDetEtaDependentCutsSvc::m_mapDoubleCuts
std::unordered_map< InDet::CutName, std::vector< double > > m_mapDoubleCuts
Definition: InDetEtaDependentCutsSvc.h:96
InDet::InDetEtaDependentCutsSvc::m_minStripHits
IntegerArrayProperty m_minStripHits
Definition: InDetEtaDependentCutsSvc.h:94
InDet::InDetEtaDependentCutsSvc::m_etaWidthBrem
DoubleArrayProperty m_etaWidthBrem
Definition: InDetEtaDependentCutsSvc.h:77
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:569
TauGNNUtils::Variables::absEta
bool absEta(const xAOD::TauJet &tau, double &out)
Definition: TauGNNUtils.cxx:232
InDet::InDetEtaDependentCutsSvc::getMinPixelHitsAtEta
int getMinPixelHitsAtEta(const double eta) const override final
Definition: InDetEtaDependentCutsSvc.cxx:241
InDet::CutName
CutName
Definition: IInDetEtaDependentCutsSvc.h:14
InDet::InDetEtaDependentCutsSvc::m_phiWidthBrem
DoubleArrayProperty m_phiWidthBrem
Definition: InDetEtaDependentCutsSvc.h:78
InDet::InDetEtaDependentCutsSvc::m_maxSctHoles
IntegerArrayProperty m_maxSctHoles
Definition: InDetEtaDependentCutsSvc.h:88
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:47
InDet::InDetEtaDependentCutsSvc::getMaxPrimaryImpactAtEta
double getMaxPrimaryImpactAtEta(const double eta) const override final
Definition: InDetEtaDependentCutsSvc.cxx:229
InDet::InDetEtaDependentCutsSvc::m_maxHoles
IntegerArrayProperty m_maxHoles
Definition: InDetEtaDependentCutsSvc.h:86
InDet::InDetEtaDependentCutsSvc::finalize
StatusCode finalize() override final
Definition: InDetEtaDependentCutsSvc.cxx:167
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:261