ATLAS Offline Software
PixelFEUtils.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 #ifndef PIXELFEUTILS_H
5 #define PIXELFEUTILS_H
6 
10 #include <algorithm>
11 #include <tuple>
12 #include <limits>
13 #include <cassert>
14 
15 namespace Pixel {
16 
19  template <typename T>
20  inline std::tuple<T,T> sorted_tuple(T a, T b) {
21  return (a<b ? std::make_tuple(a,b) : std::make_tuple(b,a) );
22  }
23 
32  inline double getGoodFraction(const InDet::SiDetectorElementStatus &pixelDetElStatus,
33  const InDetDD::PixelModuleDesign &design,
34  const PixelID &pixelID,
35  const IdentifierHash &modulIdHash,
36  const Identifier &startId,
37  const Identifier &endId) {
38  auto [phiStart,phiEnd] = sorted_tuple( pixelID.phi_index(startId), pixelID.phi_index(endId) );
39  auto [etaStart,etaEnd] = sorted_tuple( pixelID.eta_index(startId), pixelID.eta_index(endId) );
40 
41  double nTotal = (phiEnd-phiStart+1.0)*(etaEnd-etaStart+1.0);
42 
43  unsigned int nGood=0;
44  for (int i=phiStart; i<=phiEnd; i++) {
45  for (int j=etaStart; j<=etaEnd; j++) {
46 
47  std::array<InDetDD::PixelDiodeTree::CellIndexType,2> diode_idx
49  InDetDD::PixelDiodeTree::DiodeProxy si_param ( design.diodeProxyFromIdx(diode_idx));
50  std::uint32_t feValue = design.getFE(si_param);
51 
52  if (pixelDetElStatus.isChipGood(modulIdHash,feValue)) {++nGood;}
53  }
54  }
55  return nGood/nTotal;
56  }
57 
63  inline unsigned int makeReadoutTechnologyBit( InDetDD::PixelReadoutTechnology technology, unsigned int bit_val=1 ) {
64  assert(static_cast<unsigned int>(technology) < 31);
65  return bit_val << static_cast<unsigned int>(technology);
66  }
67 
74  const IdentifierHash &moduleIdHash,
75  unsigned int readOutTechnologyMask = ( Pixel::makeReadoutTechnologyBit(InDetDD::PixelReadoutTechnology::FEI4)
77  {
78  const InDetDD::SiDetectorElement *element = elementStatus.getDetectorElement(moduleIdHash);
79  const InDetDD::PixelModuleDesign &p_design = dynamic_cast<const InDetDD::PixelModuleDesign &>(element->design());
80  return ( static_cast<uint64_t>(p_design.getReadoutTechnology()) < 31ul && readOutTechnologyMask & Pixel::makeReadoutTechnologyBit(p_design.getReadoutTechnology()) );
81  }
82 
83 }
84 #endif
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
Pixel::matchingReadoutTechnology
bool matchingReadoutTechnology(const InDet::SiDetectorElementStatus &elementStatus, const IdentifierHash &moduleIdHash, unsigned int readOutTechnologyMask=(Pixel::makeReadoutTechnologyBit(InDetDD::PixelReadoutTechnology::FEI4)|(Pixel::makeReadoutTechnologyBit(InDetDD::PixelReadoutTechnology::FEI3))))
Check whether the readout technology of the specified module is contained in the given readout techno...
Definition: PixelFEUtils.h:73
PixelID::phi_index
int phi_index(const Identifier &id) const
Definition: PixelID.h:639
InDetDD::PixelReadoutTechnology
PixelReadoutTechnology
Definition: PixelReadoutDefinitions.h:37
InDetDD::PixelModuleDesign
Definition: PixelModuleDesign.h:45
Pixel
Definition: PixelFEUtils.h:15
SiDetectorElementStatus.h
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
InDet::SiDetectorElementStatus::isChipGood
bool isChipGood(IdentifierHash hash, unsigned int chip) const
Definition: SiDetectorElementStatus.h:100
Pixel::getGoodFraction
double getGoodFraction(const InDet::SiDetectorElementStatus &pixelDetElStatus, const InDetDD::PixelModuleDesign &design, const PixelID &pixelID, const IdentifierHash &modulIdHash, const Identifier &startId, const Identifier &endId)
Get The fraction of good chips the pixel of a pixel array is connected to.
Definition: PixelFEUtils.h:32
InDet::SiDetectorElementStatus::getDetectorElement
const InDetDD::SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
Definition: SiDetectorElementStatus.h:91
Pixel::makeReadoutTechnologyBit
unsigned int makeReadoutTechnologyBit(InDetDD::PixelReadoutTechnology technology, unsigned int bit_val=1)
Create a word with a bit representing the given readout technology to the given value.
Definition: PixelFEUtils.h:63
InDetDD::PixelReadoutTechnology::FEI3
@ FEI3
InDetDD::PixelModuleDesign::getFE
static unsigned int getFE(const PixelDiodeTree::DiodeProxy &diode_proxy)
Definition: PixelModuleDesign.h:258
InDetDD::PixelModuleDesign::diodeProxyFromIdx
PixelDiodeTree::DiodeProxy diodeProxyFromIdx(const std::array< PixelDiodeTree::IndexType, 2 > &idx) const
Definition: PixelModuleDesign.h:248
lumiFormat.i
int i
Definition: lumiFormat.py:85
InDet::SiDetectorElementStatus
Definition: SiDetectorElementStatus.h:62
PixelID::eta_index
int eta_index(const Identifier &id) const
Definition: PixelID.h:645
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
detail::ul
unsigned long ul
Definition: PrimitiveHelpers.h:47
python.compareNtuple.nGood
nGood
Definition: compareNtuple.py:55
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:76
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
InDetDD::PixelReadoutTechnology::FEI4
@ FEI4
InDetDD::PixelModuleDesign::getReadoutTechnology
PixelReadoutTechnology getReadoutTechnology() const
Definition: PixelModuleDesign.h:391
a
TList * a
Definition: liststreamerinfos.cxx:10
InDetDD::PixelDiodeTree::DiodeProxy
Helper class to access parameters of a diode.
Definition: PixelDiodeTree.h:183
PixelModuleDesign.h
InDetDD::PixelDiodeTree::makeCellIndex
static constexpr std::array< PixelDiodeTree::CellIndexType, 2 > makeCellIndex(T local_x_idx, T local_y_idx)
Create a 2D cell index from the indices in local-x (phi, row) and local-y (eta, column) direction.
Definition: PixelDiodeTree.h:320
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
InDetDD::SiDetectorElement::design
virtual const SiDetectorDesign & design() const override final
access to the local description (inline):
PixelID
Definition: PixelID.h:67
Pixel::sorted_tuple
std::tuple< T, T > sorted_tuple(T a, T b)
Create a tuple of the given values in increasing order.
Definition: PixelFEUtils.h:20
Identifier
Definition: IdentifierFieldParser.cxx:14