ATLAS Offline Software
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | List of all members
PixelChargeCalib::LUTChargeCalibParser Class Reference

#include <LUTChargeCalibParser.h>

Inheritance diagram for PixelChargeCalib::LUTChargeCalibParser:
Collaboration diagram for PixelChargeCalib::LUTChargeCalibParser:

Public Member Functions

 LUTChargeCalibParser (const PixelModuleData *pModData, const InDetDD::SiDetectorElementCollection *pElements, const PixelID *pId)
 
template<class T >
ChargeCalibrationBundle parse (unsigned int hash, const T &data)
 
template<class T >
ChargeCalibrationBundle parse (unsigned int hash, const T &data, int inputSource)
 

Protected Member Functions

template<typename T , typename b = std::is_integral<T>>
std::function< T(size_t)> getFunc (const std::vector< std::string > &data)
 Return function converting a string to number type T at index i of data vector. More...
 
template<typename T >
std::function< T(size_t)> getFunc (const nlohmann::json &data)
 Return function converting an item to number type T at index i of json data. More...
 

Protected Attributes

const PixelModuleDatam_configData {}
 
const InDetDD::SiDetectorElementCollectionm_elements {}
 
const PixelIDm_pixelID {}
 

Static Protected Attributes

static constexpr float m_chargeLimit = 1e5
 If the calculated charge exceeds this limit, a linear extrapolation is used at this point. More...
 

Private Member Functions

virtual ChargeCalibrationBundle parseImpl (unsigned int moduleHash, const nlohmann::json &data, int inputSource) override final
 
virtual ChargeCalibrationBundle parseImpl (unsigned int, const nlohmann::json &) override final
 
virtual ChargeCalibrationBundle parseImpl (unsigned int, const std::string &) override final
 

Detailed Description

Definition at line 23 of file LUTChargeCalibParser.h.

Constructor & Destructor Documentation

◆ LUTChargeCalibParser()

PixelChargeCalib::LUTChargeCalibParser::LUTChargeCalibParser ( const PixelModuleData pModData,
const InDetDD::SiDetectorElementCollection pElements,
const PixelID pId 
)
inline

Definition at line 25 of file LUTChargeCalibParser.h.

27  :IChargeCalibrationParser(pModData,pElements, pId){
28  //nop
29  }

Member Function Documentation

◆ getFunc() [1/2]

template<typename T >
std::function<T(size_t)> PixelChargeCalib::IChargeCalibrationParser::getFunc ( const nlohmann::json data)
inlineprotectedinherited

Return function converting an item to number type T at index i of json data.

Definition at line 69 of file IChargeCalibrationParser.h.

69  {
70  auto f = [&data](size_t i)->T {
71  return data[i].get<T>();
72  };
73  return f;
74  }

◆ getFunc() [2/2]

template<typename T , typename b = std::is_integral<T>>
std::function<T(size_t)> PixelChargeCalib::IChargeCalibrationParser::getFunc ( const std::vector< std::string > &  data)
inlineprotectedinherited

Return function converting a string to number type T at index i of data vector.

Definition at line 59 of file IChargeCalibrationParser.h.

59  {
60  auto f = [&data](size_t i)->T {
61  return b::value ? std::stoi(data[i]) : std::stof(data[i]);
62  };
63  return f;
64  }

◆ parse() [1/2]

template<class T >
ChargeCalibrationBundle PixelChargeCalib::IChargeCalibrationParser::parse ( unsigned int  hash,
const T &  data 
)
inlineinherited

Definition at line 41 of file IChargeCalibrationParser.h.

41  {
42  return parseImpl(hash, data);
43  }

◆ parse() [2/2]

template<class T >
ChargeCalibrationBundle PixelChargeCalib::IChargeCalibrationParser::parse ( unsigned int  hash,
const T &  data,
int  inputSource 
)
inlineinherited

Definition at line 45 of file IChargeCalibrationParser.h.

45  {
46  return parseImpl(hash, data, inputSource);
47  }

◆ parseImpl() [1/3]

ChargeCalibrationBundle PixelChargeCalib::LUTChargeCalibParser::parseImpl ( unsigned int  moduleHash,
const nlohmann::json data,
int  inputSource 
)
finaloverrideprivatevirtual

Implements PixelChargeCalib::IChargeCalibrationParser.

Definition at line 23 of file LUTChargeCalibParser.cxx.

23  {
24  IdentifierHash wafer_hash = IdentifierHash(moduleHash);
25  const InDetDD::SiDetectorElement *element = m_elements->getDetectorElement(wafer_hash);
26  const auto & [numFE, technology] = numChipsAndTechnology(element);
27  bool isLUTEnabled = (inputSource == 1);
28  bool isChargeCalibrationFromJson = (inputSource == 2);
29  //
30  ChargeCalibrationBundle b(numFE,isLUTEnabled,isChargeCalibrationFromJson);
31  //
32  for (unsigned int j{}; j < numFE; j++) {
33  //Retrieve calibArrays in different formats for Run4 (based on ITKPixV2 chip settings) and Run3
34  const auto &calibArray = (isLUTEnabled || isChargeCalibrationFromJson) ? data.at(0) : data.at(j);
35  if (!calibArray.empty()) {
36  // new charge calibration for RUN-3
37  if ((technology == InDetDD::PixelReadoutTechnology::FEI4 && !(element->isDBM())) || ((b.useLUT || b.useTXT) && technology == InDetDD::PixelReadoutTechnology::RD53)) {
38  if (calibArray.size() != FEStringSize) {
39  std::cout<<"Parameter size is not consistent(" << FEStringSize << ") " << calibArray.size() << " at (i,j)=(" << moduleHash << "," << j << ")\n";
40  b.isValid = false;
41  return b;
42  }
43  auto getInt = getFunc<int>(calibArray);
44  auto getFloat = getFunc<float>(calibArray);
45  auto &charges = b.tot2Charges.emplace_back(PixelChargeCalibCondData::IBLCalibration());
46  for (size_t k{}; k < PixelChargeCalibCondData::IBLCalibrationSize; k++) {
47  charges[k] = getFloat(k + 4ul);
48  }
50  b.threshold.emplace_back(getInt(0), 0.f, getInt(1), 0.f);
51  b.thresholdLong.emplace_back(getInt(2), 0.f, getInt(3), 0.f);
52  b.thresholdGanged.emplace_back(getInt(2), 0.f, getInt(3), 0.f);
53  b.params.emplace_back(0.f, 0.f, 0.f);
54  b.paramsGanged.emplace_back(0.f, 0.f, 0.f);
55  b.totRes.emplace_back(0.f, 0.f);
56  } else { //normal CalibrationStrategy
57  if (calibArray.size() != FEStringSize) {
58  std::cout<<"Parameter size is not consistent(" << FEStringSize << ") " << calibArray.size() << " at (i,j)=(" << moduleHash << "," << j << ")\n";
59  b.isValid = false;
60  return b;
61  }
62  auto getInt = getFunc<int>(calibArray);
63  auto getFloat = getFunc<float>(calibArray);
64  b.threshold.emplace_back(getInt(0), getInt(1), getInt(2), getInt(3));
65  b.thresholdLong.emplace_back(getInt(4), getInt(5), getInt(6), getInt(7));
66  b.thresholdGanged.emplace_back(getInt(8), getInt(9), getInt(10), getInt(11));
67  b.params.emplace_back(getFloat(12), getFloat(13), getFloat(14));
68  b.paramsGanged.emplace_back(getFloat(15), getFloat(16), getFloat(17));
69  b.totRes.emplace_back(getFloat(18), getFloat(19));
70 
71  // Linear extrapolation above large charge
74  const auto & [barrel_ec, layer] = getBecAndLayer(m_pixelID, wafer_hash);
75  // search for ToT when charge exceeds threshold
76  if (!(element->isDBM())) {
77  //charge threshold beyond which linear fit will be used
78  const int totIdxStart = m_configData->getToTThreshold(barrel_ec,layer);
79  const int totIdxEnd = m_configData->getFEI3Latency(barrel_ec,layer);
80  // Normal pixels
81  int totlimit = b.idxAtChargeLimit(m_chargeLimit, InDetDD::PixelDiodeType::NORMAL, totIdxStart, totIdxEnd);
82  b.insertLinearParams( InDetDD::PixelDiodeType::NORMAL, totlimit);
83  // Ganged pixels
84  totlimit = b.idxAtChargeLimit(m_chargeLimit, InDetDD::PixelDiodeType::GANGED, totIdxStart, totIdxEnd);
85  b.insertLinearParams( InDetDD::PixelDiodeType::GANGED, totlimit);
86  } else { // DBM
87  b.lin.emplace_back(0.f, 0.f);
88  b.linGanged.emplace_back(0.f, 0.f);
89  }
90  } else {
92  b.lin.emplace_back(0.f, 0.f);
93  b.linGanged.emplace_back(0.f, 0.f);
94  }
95  }
96  } else {
97  std::cout<<"Array size is zero in " << calibArray << " at (i,j)=(" << moduleHash << "," << j << ")\n";
98  b.isValid = false;
99  return b;
100  }
101  }
102  return b;
103  }

◆ parseImpl() [2/3]

virtual ChargeCalibrationBundle PixelChargeCalib::LUTChargeCalibParser::parseImpl ( unsigned int  ,
const nlohmann::json  
)
inlinefinaloverrideprivatevirtual

Implements PixelChargeCalib::IChargeCalibrationParser.

Definition at line 36 of file LUTChargeCalibParser.h.

36  {
38  b.isValid=false;
39  return b;
40  }

◆ parseImpl() [3/3]

virtual ChargeCalibrationBundle PixelChargeCalib::LUTChargeCalibParser::parseImpl ( unsigned int  ,
const std::string &   
)
inlinefinaloverrideprivatevirtual

Implements PixelChargeCalib::IChargeCalibrationParser.

Definition at line 43 of file LUTChargeCalibParser.h.

43  {
45  b.isValid=false;
46  return b;
47  }

Member Data Documentation

◆ m_chargeLimit

constexpr float PixelChargeCalib::IChargeCalibrationParser::m_chargeLimit = 1e5
staticconstexprprotectedinherited

If the calculated charge exceeds this limit, a linear extrapolation is used at this point.

Definition at line 55 of file IChargeCalibrationParser.h.

◆ m_configData

const PixelModuleData* PixelChargeCalib::IChargeCalibrationParser::m_configData {}
protectedinherited

Definition at line 51 of file IChargeCalibrationParser.h.

◆ m_elements

const InDetDD::SiDetectorElementCollection* PixelChargeCalib::IChargeCalibrationParser::m_elements {}
protectedinherited

Definition at line 52 of file IChargeCalibrationParser.h.

◆ m_pixelID

const PixelID* PixelChargeCalib::IChargeCalibrationParser::m_pixelID {}
protectedinherited

Definition at line 53 of file IChargeCalibrationParser.h.


The documentation for this class was generated from the following files:
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
PixelChargeCalib::IChargeCalibrationParser::IChargeCalibrationParser
IChargeCalibrationParser(const PixelModuleData *pModData, const InDetDD::SiDetectorElementCollection *pElements, const PixelID *pId)
Definition: IChargeCalibrationParser.h:33
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
athena.value
value
Definition: athena.py:124
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
InDetDD::PixelReadoutTechnology::RD53
@ RD53
PixelChargeCalibCondData::CalibrationStrategy::RUN3PIX
@ RUN3PIX
PixelChargeCalib::IChargeCalibrationParser::parseImpl
virtual ChargeCalibrationBundle parseImpl(unsigned int, const nlohmann::json &, int)=0
lumiFormat.i
int i
Definition: lumiFormat.py:85
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
PixelChargeCalibCondData::CalibrationStrategy::LUTFEI4
@ LUTFEI4
PixelChargeCalib::IChargeCalibrationParser::m_configData
const PixelModuleData * m_configData
Definition: IChargeCalibrationParser.h:51
hist_file_dump.f
f
Definition: hist_file_dump.py:135
detail::ul
unsigned long ul
Definition: PrimitiveHelpers.h:45
PixelModuleData::getFEI3Latency
int getFEI3Latency(int barrel_ec, int layer) const
Definition: PixelModuleData.cxx:238
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
PixelChargeCalib::IChargeCalibrationParser::m_elements
const InDetDD::SiDetectorElementCollection * m_elements
Definition: IChargeCalibrationParser.h:52
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
InDetDD::PixelReadoutTechnology::FEI4
@ FEI4
PixelChargeCalib::IChargeCalibrationParser::m_pixelID
const PixelID * m_pixelID
Definition: IChargeCalibrationParser.h:53
PixelChargeCalibCondData::CalibrationStrategy::RUN1PIX
@ RUN1PIX
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
InDetDD::SiDetectorElement::isDBM
bool isDBM() const
PixelChargeCalibCondData::IBLCalibrationSize
static constexpr size_t IBLCalibrationSize
Definition: PixelChargeCalibCondData.h:29
PixelChargeCalib::ChargeCalibrationBundle
bundles of parameters used together in the PixelChargeCalibCondAlg
Definition: ChargeCalibrationBundle.h:24
InDetDD::PixelDiodeType::NORMAL
@ NORMAL
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::SiDetectorElementCollection::getDetectorElement
const SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
Definition: SiDetectorElementCollection.cxx:15
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
fitman.k
k
Definition: fitman.py:528
PixelChargeCalibCondData::IBLCalibration
std::array< float, IBLCalibrationSize > IBLCalibration
Definition: PixelChargeCalibCondData.h:30