ATLAS Offline Software
Loading...
Searching...
No Matches
PixelChargeCalib::Run2ChargeCalibParser Class Reference

#include <Run2ChargeCalibParser.h>

Inheritance diagram for PixelChargeCalib::Run2ChargeCalibParser:
Collaboration diagram for PixelChargeCalib::Run2ChargeCalibParser:

Public Member Functions

 Run2ChargeCalibParser (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.
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.

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.

Private Member Functions

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

Detailed Description

Definition at line 22 of file Run2ChargeCalibParser.h.

Constructor & Destructor Documentation

◆ Run2ChargeCalibParser()

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

Definition at line 24 of file Run2ChargeCalibParser.h.

26 :IChargeCalibrationParser(pModData,pElements, pId){
27 //nop
28 }
IChargeCalibrationParser(const PixelModuleData *pModData, const InDetDD::SiDetectorElementCollection *pElements, const PixelID *pId)

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 }
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
unsigned long long T

◆ 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 }
virtual ChargeCalibrationBundle parseImpl(unsigned int, const nlohmann::json &, int)=0

◆ 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::Run2ChargeCalibParser::parseImpl ( unsigned int hash,
const std::string & data )
finaloverrideprivatevirtual

Implements PixelChargeCalib::IChargeCalibrationParser.

Definition at line 22 of file Run2ChargeCalibParser.cxx.

22 {
23 IdentifierHash wafer_hash = IdentifierHash(moduleHash);
24 const InDetDD::SiDetectorElement *element = m_elements->getDetectorElement(wafer_hash);
25 const auto & [numChips, technology] = PixelChargeCalib::numChipsAndTechnology(element);
26 //
27 std::stringstream ss(data);
28 std::vector<std::string> component;
29 std::string buffer;
30 std::getline(ss, buffer, '\n'); // skip first line
31 while (std::getline(ss, buffer, '\n')) { component.push_back(buffer); }
32 const size_t numFE = component.size();
33 if (numFE != numChips){
34 std::cout << "Warning that the number of chips in the DB string and the number of chips according to readout technology are not equal\n";
35 }
36 //
37 ChargeCalibrationBundle b(numFE);
38 //
39 // loop over FEs
40 for (size_t i{}; i < numFE; i++) {
41 std::stringstream checkFE(component[i]);
42 std::vector<std::string> FEString;
43 while (std::getline(checkFE, buffer, ' ')) { FEString.push_back(buffer); }
44
45 if (FEString.size() < FEStringSize) {
46 b.isValid=false;
47 return b;
48 }
49
50 auto getInt = getFunc<int>(FEString);
51 auto getFloat = getFunc<float>(FEString);
52 //
53 b.threshold.emplace_back(getInt(1), getInt(2), getInt(3), getInt(4));
54 b.thresholdLong.emplace_back(getInt(5), getInt(6), getInt(7), getInt(8));
55 b.thresholdGanged.emplace_back(getInt(9), getInt(10), getInt(11), getInt(12));
56 b.params.emplace_back(getFloat(13), getFloat(14), getFloat(15), LegacyFitParameters::defaultOverflow);
57 b.paramsGanged.emplace_back(getFloat(16), getFloat(17), getFloat(18), LegacyFitParameters::defaultOverflow);
58 b.totRes.emplace_back(getFloat(19), getFloat(20));
59
60 // Linear extrapolation above large charge
61 if (m_configData->getPIXLinearExtrapolation() && technology==InDetDD::PixelReadoutTechnology::FEI3) {
63 const auto & [barrel_ec, layer] = getBecAndLayer(m_pixelID, wafer_hash);
64 // search for ToT when charge exceeds threshold
65 int totlimit = -1;
66 int start = m_configData->getToTThreshold(barrel_ec,layer);
67 int end = m_configData->getFEI3Latency(barrel_ec,layer);
68 // Normal pixels
69 totlimit = b.idxAtChargeLimit(m_chargeLimit, InDetDD::PixelDiodeType::NORMAL, start, end);
70 b.insertLinearParams(InDetDD::PixelDiodeType::NORMAL, totlimit);
71 // Ganged pixels
72 totlimit = b.idxAtChargeLimit(m_chargeLimit, InDetDD::PixelDiodeType::GANGED, start, end);
73 b.insertLinearParams(InDetDD::PixelDiodeType::GANGED, totlimit);
74 } else {
75 b.lin.emplace_back(0.f, 0.f);
76 b.linGanged.emplace_back(0.f, 0.f);
77 }
78 }
79 return b;
80 }
static Double_t ss
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.
static constexpr float m_chargeLimit
If the calculated charge exceeds this limit, a linear extrapolation is used at this point.
const InDetDD::SiDetectorElementCollection * m_elements
std::pair< size_t, InDetDD::PixelReadoutTechnology > numChipsAndTechnology(const InDetDD::SiDetectorElement *element)
std::pair< int, int > getBecAndLayer(const PixelID *pPixelId, IdentifierHash hash)
@ layer
Definition HitInfo.h:79

◆ parseImpl() [2/3]

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

Implements PixelChargeCalib::IChargeCalibrationParser.

Definition at line 35 of file Run2ChargeCalibParser.h.

35 {
36 PixelChargeCalib::ChargeCalibrationBundle b(0);
37 b.isValid=false;
38 return b;
39 }

◆ parseImpl() [3/3]

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

Implements PixelChargeCalib::IChargeCalibrationParser.

Definition at line 42 of file Run2ChargeCalibParser.h.

42 {
43 PixelChargeCalib::ChargeCalibrationBundle b(0);
44 b.isValid=false;
45 return b;
46 }

Member Data Documentation

◆ m_chargeLimit

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.

51{};

◆ m_elements

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

Definition at line 52 of file IChargeCalibrationParser.h.

52{};

◆ m_pixelID

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

Definition at line 53 of file IChargeCalibrationParser.h.

53{};

The documentation for this class was generated from the following files: