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 
11 #include <algorithm>
12 #include <tuple>
13 #include <limits>
14 #include <cassert>
15 
16 namespace Pixel {
17 
20  template <typename T>
21  inline std::tuple<T,T> sorted_tuple(T a, T b) {
22  return (a<b ? std::make_tuple(a,b) : std::make_tuple(b,a) );
23  }
24 
33  inline double getGoodFraction(const InDet::SiDetectorElementStatus &pixelDetElStatus,
34  const InDetDD::IPixelReadoutManager &pixelReadout,
35  const PixelID &pixelID,
36  const Identifier &moduleId,
37  const IdentifierHash &moudlIdHash,
38  const Identifier &startId,
39  const Identifier &endId) {
40  auto [phiStart,phiEnd] = sorted_tuple( pixelID.phi_index(startId), pixelID.phi_index(endId) );
41  auto [etaStart,etaEnd] = sorted_tuple( pixelID.eta_index(startId), pixelID.eta_index(endId) );
42 
43  double nTotal = (phiEnd-phiStart+1.0)*(etaEnd-etaStart+1.0);
44 
45  unsigned int nGood=0;
46  for (int i=phiStart; i<=phiEnd; i++) {
47  for (int j=etaStart; j<=etaEnd; j++) {
48  int chFE = pixelReadout.getFE(pixelID.pixel_id(moduleId,i,j), moduleId);
49  if (pixelDetElStatus.isChipGood(moudlIdHash,chFE)) {++nGood;}
50  }
51  }
52  return nGood/nTotal;
53  }
54 
60  inline unsigned int makeReadoutTechnologyBit( InDetDD::PixelReadoutTechnology technology, unsigned int bit_val=1 ) {
61  assert(static_cast<unsigned int>(technology) < 31);
62  return bit_val << static_cast<unsigned int>(technology);
63  }
64 
71  const IdentifierHash &moduleIdHash,
72  unsigned int readOutTechnologyMask = ( Pixel::makeReadoutTechnologyBit(InDetDD::PixelReadoutTechnology::FEI4)
74  {
75  const InDetDD::SiDetectorElement *element = elementStatus.getDetectorElement(moduleIdHash);
76  const InDetDD::PixelModuleDesign &p_design = dynamic_cast<const InDetDD::PixelModuleDesign &>(element->design());
77  return ( static_cast<uint64_t>(p_design.getReadoutTechnology()) < 31ul && readOutTechnologyMask & Pixel::makeReadoutTechnologyBit(p_design.getReadoutTechnology()) );
78  }
79 
80 }
81 #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:70
PixelID::phi_index
int phi_index(const Identifier &id) const
Definition: PixelID.h:658
InDetDD::PixelReadoutTechnology
PixelReadoutTechnology
Definition: PixelReadoutDefinitions.h:34
InDetDD::PixelModuleDesign
Definition: PixelModuleDesign.h:48
Pixel
Definition: PixelFEUtils.h:16
SiDetectorElementStatus.h
InDet::SiDetectorElementStatus::isChipGood
bool isChipGood(IdentifierHash hash, unsigned int chip) const
Definition: SiDetectorElementStatus.h:100
InDetDD::IPixelReadoutManager
Definition: IPixelReadoutManager.h:21
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:60
InDetDD::PixelReadoutTechnology::FEI3
@ FEI3
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:664
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
detail::ul
unsigned long ul
Definition: PrimitiveHelpers.h:46
python.compareNtuple.nGood
nGood
Definition: compareNtuple.py:55
IPixelReadoutManager.h
InDetDD::IPixelReadoutManager::getFE
virtual uint32_t getFE(Identifier diodeId, Identifier offlineId) const =0
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
InDetDD::PixelReadoutTechnology::FEI4
@ FEI4
InDetDD::PixelModuleDesign::getReadoutTechnology
PixelReadoutTechnology getReadoutTechnology() const
Definition: PixelModuleDesign.h:386
a
TList * a
Definition: liststreamerinfos.cxx:10
PixelModuleDesign.h
PixelID::pixel_id
Identifier pixel_id(int barrel_ec, int layer_disk, int phi_module, int eta_module, int phi_index, int eta_index) const
For an individual pixel.
Definition: PixelID.h:432
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:21
Pixel::getGoodFraction
double getGoodFraction(const InDet::SiDetectorElementStatus &pixelDetElStatus, const InDetDD::IPixelReadoutManager &pixelReadout, const PixelID &pixelID, const Identifier &moduleId, const IdentifierHash &moudlIdHash, const Identifier &startId, const Identifier &endId)
Get The fraction of good chips the pixel of a pixel array is connected to.
Definition: PixelFEUtils.h:33
Identifier
Definition: IdentifierFieldParser.cxx:14