ATLAS Offline Software
EmulatedDefects.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3  */
4 /* Dear emacs, this is -*-c++-*- */
5 #ifndef INDET_EMULATEDDEFECTS_H
6 #define INDET_EMULATEDDEFECTS_H
7 
8 #include <vector>
9 #include <algorithm>
10 #include <utility>
11 
12 namespace InDetDD {
13  class SiDetectorElementCollection;
14 }
15 
16 namespace InDet {
26  template <class T_ModuleHelper>
27  class EmulatedDefects : public std::vector<std::vector<unsigned int> >
28  {
29  public:
30  static constexpr unsigned int MASK_FOR_COMPARISON = T_ModuleHelper::CHIP_MASK | T_ModuleHelper::ROW_MASK | T_ModuleHelper::COL_MASK;
33  class greater {
34  public:
35  /*static (c++23) */ bool operator()(unsigned int key_a, unsigned int key_b) {
36  return (key_a & MASK_FOR_COMPARISON)
37  > (key_b & MASK_FOR_COMPARISON);
38  }
39  };
47  unsigned int key) {
48  return std::make_pair( std::lower_bound( module_defects.begin(),module_defects.end(), key, greater()),
49  module_defects.end());
50  }
51 
59  std::pair< std::vector<unsigned int>::const_iterator, std::vector<unsigned int>::const_iterator> lower_bound(unsigned int id_hash, unsigned int key) const {
60  const std::vector<unsigned int> &module_defects = this->at(id_hash);
61  return std::make_pair( std::lower_bound( module_defects.begin(),module_defects.end(), key, greater()),
62  module_defects.end());
63  }
64 
72  bool isDefect(const T_ModuleHelper &helper, unsigned int id_hash, unsigned int key) const {
73  auto [defect_iter, end_iter] =lower_bound(id_hash, key);
74  return (defect_iter != end_iter && helper.isSameDefectWithGroups( *defect_iter, key) );
75  }
76 
85  bool isDefect(const T_ModuleHelper &helper, unsigned int id_hash, unsigned int row_idx_aka_phi, unsigned int col_idx_aka_eta) const {
86  unsigned int key = helper.hardwareCoordinates(row_idx_aka_phi, col_idx_aka_eta);
87  return isDefect(helper, id_hash, key);
88  }
89 
90  const InDetDD::SiDetectorElementCollection *m_detectorElements = nullptr; // pointer to the detector element collection these defects are for
91  };
92 }
93 
94 #endif
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
InDet::EmulatedDefects::isDefect
bool isDefect(const T_ModuleHelper &helper, unsigned int id_hash, unsigned int key) const
Test whether a pixel on a certain module is marked as defect.
Definition: EmulatedDefects.h:72
InDet::EmulatedDefects::greater
Special greater operator which ignores the column group flag in the comparison.
Definition: EmulatedDefects.h:33
InDetDD::SiDetectorElementCollection
Definition: SiDetectorElementCollection.h:30
InDet
Primary Vertex Finder.
Definition: VP1ErrorUtils.h:36
InDet::EmulatedDefects::lower_bound
std::pair< std::vector< unsigned int >::const_iterator, std::vector< unsigned int >::const_iterator > lower_bound(unsigned int id_hash, unsigned int key) const
Convenience method to find the preceding defect.
Definition: EmulatedDefects.h:59
CxxUtils::fpcompare::greater
bool greater(double a, double b)
Compare two FP numbers, working around x87 precision issues.
Definition: fpcompare.h:140
runBeamSpotCalibration.helper
helper
Definition: runBeamSpotCalibration.py:112
InDet::EmulatedDefects::MASK_FOR_COMPARISON
static constexpr unsigned int MASK_FOR_COMPARISON
Definition: EmulatedDefects.h:30
InDet::EmulatedDefects::isDefect
bool isDefect(const T_ModuleHelper &helper, unsigned int id_hash, unsigned int row_idx_aka_phi, unsigned int col_idx_aka_eta) const
Test whether a pixel on a certain module is marked as defect.
Definition: EmulatedDefects.h:85
InDet::EmulatedDefects
Data structure do mark e.g.
Definition: EmulatedDefects.h:28
InDet::EmulatedDefects::greater::operator()
bool operator()(unsigned int key_a, unsigned int key_b)
Definition: EmulatedDefects.h:35
InDet::EmulatedDefects::m_detectorElements
const InDetDD::SiDetectorElementCollection * m_detectorElements
Definition: EmulatedDefects.h:90
InDet::EmulatedDefects::lower_bound
static std::pair< std::vector< unsigned int >::iterator, std::vector< unsigned int >::iterator > lower_bound(std::vector< unsigned int > &module_defects, unsigned int key)
Convenience method to find the preceding defect.
Definition: EmulatedDefects.h:46
InDetDD
Message Stream Member.
Definition: FakeTrackBuilder.h:8
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37