ATLAS Offline Software
Run3ChargeCalibParser.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
6 #include "Identifier/Identifier.h"
12 
15 
16 namespace{
17  constexpr size_t FEStringSize{21};
18 } // namespace
19 
20 
21 namespace PixelChargeCalib{
22  ChargeCalibrationBundle
23  Run3ChargeCalibParser::parseImpl(unsigned int moduleHash, const nlohmann::json & data){
24  IdentifierHash wafer_hash = IdentifierHash(moduleHash);
25  const InDetDD::SiDetectorElement *element = m_elements->getDetectorElement(wafer_hash);
26  const auto & [numFE, technology] = numChipsAndTechnology(element);
27  //
29  //
30  for (unsigned int j{}; j < numFE; j++) {
31  const auto &calibArray = data.at(j);
32  if (!calibArray.empty()) {
33  // conventional calibration
34  if (calibArray.size() != FEStringSize-1) {
35  std::cout<<"Parameter size is not consistent(" << FEStringSize << ") " << calibArray.size() << " at (i,j)=(" << moduleHash << "," << j << ")\n";
36  b.isValid = false;
37  return b;
38  }
39  auto getInt = getFunc<int>(calibArray);
40  auto getFloat = getFunc<float>(calibArray);
41  b.threshold.emplace_back(getInt(0), getInt(1), getInt(2), getInt(3));
42  b.thresholdLong.emplace_back(getInt(4), getInt(5), getInt(6), getInt(7));
43  b.thresholdGanged.emplace_back(getInt(8), getInt(9), getInt(10), getInt(11));
44  b.params.emplace_back(getFloat(12), getFloat(13), getFloat(14));
45  b.paramsGanged.emplace_back(getFloat(15), getFloat(16), getFloat(17));
46  b.totRes.emplace_back(getFloat(18), getFloat(19));
47 
48  // Linear extrapolation above large charge
51  const auto & [barrel_ec, layer] = getBecAndLayer(m_pixelID, wafer_hash);
52  // search for ToT when charge exceeds threshold
53  if (!(element->isDBM())) {
54  //charge threshold beyond which linear fit will be used
55  const int totIdxStart = m_configData->getToTThreshold(barrel_ec,layer);
56  const int totIdxEnd = m_configData->getFEI3Latency(barrel_ec,layer);
57  // Normal pixels
58  int totlimit = b.idxAtChargeLimit(m_chargeLimit, InDetDD::PixelDiodeType::NORMAL, totIdxStart, totIdxEnd);
59  b.insertLinearParams( InDetDD::PixelDiodeType::NORMAL, totlimit);
60  // Ganged pixels
61  totlimit = b.idxAtChargeLimit(m_chargeLimit, InDetDD::PixelDiodeType::GANGED, totIdxStart, totIdxEnd);
62  b.insertLinearParams( InDetDD::PixelDiodeType::GANGED, totlimit);
63  } else { // DBM
64  b.lin.emplace_back(0.f, 0.f);
65  b.linGanged.emplace_back(0.f, 0.f);
66  }
67  } else {
68  b.lin.emplace_back(0.f, 0.f);
69  b.linGanged.emplace_back(0.f, 0.f);
70  }
71  } else {
72  std::cout<<"Array size is zero in " << calibArray << " at (i,j)=(" << moduleHash << "," << j << ")\n";
73  b.isValid = false;
74  return b;
75  }
76  }
77  return b;
78  }
79 }
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
json
nlohmann::json json
Definition: HistogramDef.cxx:9
PixelModuleData::getPIXLinearExtrapolation
bool getPIXLinearExtrapolation() const
Definition: PixelModuleData.cxx:332
PixelChargeCalib::getBecAndLayer
std::pair< int, int > getBecAndLayer(const PixelID *pPixelId, IdentifierHash hash)
Definition: PixelChargeCalibUtils.cxx:13
Run3ChargeCalibParser.h
Parses a database run3 format string to a ChargeCalibrationBundle.
InDetDD::PixelReadoutTechnology::FEI3
@ FEI3
PixelChargeCalib::numChipsAndTechnology
std::pair< size_t, InDetDD::PixelReadoutTechnology > numChipsAndTechnology(const InDetDD::SiDetectorElement *element)
Definition: PixelChargeCalibUtils.cxx:19
InDetDD::PixelDiodeType::GANGED
@ GANGED
PixelModuleData::getToTThreshold
int getToTThreshold(int barrel_ec, int layer) const
Definition: PixelModuleData.cxx:107
PixelChargeCalibCondData::CalibrationStrategy::RUN3PIX
@ RUN3PIX
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
ChargeCalibrationBundle.h
Struct for holding vectors of charge calibration constants, with utility methods.
PixelChargeCalib::IChargeCalibrationParser::m_configData
const PixelModuleData * m_configData
Definition: IChargeCalibrationParser.h:51
PixelModuleData::getFEI3Latency
int getFEI3Latency(int barrel_ec, int layer) const
Definition: PixelModuleData.cxx:238
PixelChargeCalibUtils.h
PixelChargeCalib::IChargeCalibrationParser::m_chargeLimit
static constexpr float m_chargeLimit
If the calculated charge exceeds this limit, a linear extrapolation is used at this point.
Definition: IChargeCalibrationParser.h:55
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
IdentifierHash.h
PixelChargeCalib::IChargeCalibrationParser::m_elements
const InDetDD::SiDetectorElementCollection * m_elements
Definition: IChargeCalibrationParser.h:52
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
SiDetectorElement.h
PixelChargeCalib::IChargeCalibrationParser::m_pixelID
const PixelID * m_pixelID
Definition: IChargeCalibrationParser.h:53
PixelModuleDesign.h
InDetDD::SiDetectorElement::isDBM
bool isDBM() const
PixelChargeCalib
Definition: IChargeCalibrationParser.h:30
PixelModuleData.h
Store pixel constant parameters in PixelModuleData.
PixelChargeCalib::ChargeCalibrationBundle
bundles of parameters used together in the PixelChargeCalibCondAlg
Definition: ChargeCalibrationBundle.h:24
InDetDD::PixelDiodeType::NORMAL
@ NORMAL
IdentifierHash
Definition: IdentifierHash.h:38
PixelChargeCalib::Run3ChargeCalibParser::parseImpl
virtual ChargeCalibrationBundle parseImpl(unsigned int moduleHash, const nlohmann::json &data) override final
Definition: Run3ChargeCalibParser.cxx:23
InDetDD::SiDetectorElementCollection::getDetectorElement
const SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
Definition: SiDetectorElementCollection.cxx:15