ATLAS Offline Software
IChargeCalibrationParser.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
11 #ifndef IChargeCalibrationParser_h
12 #define IChargeCalibrationParser_h
13 
16 #include <nlohmann/json.hpp>
18 #include "Identifier/Identifier.h"
20 
21 #include <string>
22 #include <utility> //for std::pair
23 #include <functional> //std::function
24 #include <type_traits>
25 
26 
27 class PixelModuleData;
28 
29 
30 namespace PixelChargeCalib{
32  public:
34  const InDetDD::SiDetectorElementCollection * pElements, const PixelID * pId): m_configData(pModData),
35  m_elements(pElements), m_pixelID(pId){
36 
37  }
38 
39  //the interface dispatches to one of the implementations in derived classes
40  template<class T>
41  ChargeCalibrationBundle parse(unsigned int hash, const T & data){
42  return parseImpl(hash, data);
43  }
44  template<class T>
45  ChargeCalibrationBundle parse(unsigned int hash, const T & data, int inputSource){
46  return parseImpl(hash, data, inputSource);
47  }
48  virtual ~IChargeCalibrationParser() = default;
49 
50  protected:
53  const PixelID* m_pixelID{};
55  static constexpr float m_chargeLimit = 1e5;
57  template<typename T, typename b = std::is_integral<T>>
58  std::function<T(size_t)>
59  getFunc(const std::vector<std::string> & data){
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  }
65 
67  template<typename T>
68  std::function<T(size_t)>
70  auto f = [&data](size_t i)->T {
71  return data[i].get<T>();
72  };
73  return f;
74  }
75 
76 
77  private:
79  parseImpl(unsigned int /*hash*/, const nlohmann::json & /*data*/, int /*inputSource*/) = 0;
81  parseImpl(unsigned int /*hash*/, const nlohmann::json & /*data*/) = 0;
83  parseImpl(unsigned int /*hash*/, const std::string & /*data*/) = 0;
84  };
85 }
86 
87 #endif
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
InDetDD::SiDetectorElementCollection
Definition: SiDetectorElementCollection.h:30
PixelChargeCalib::IChargeCalibrationParser::IChargeCalibrationParser
IChargeCalibrationParser(const PixelModuleData *pModData, const InDetDD::SiDetectorElementCollection *pElements, const PixelID *pId)
Definition: IChargeCalibrationParser.h:33
json
nlohmann::json json
Definition: HistogramDef.cxx:9
PixelChargeCalib::IChargeCalibrationParser::getFunc
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.
Definition: IChargeCalibrationParser.h:59
PixelModuleData
Definition: PixelModuleData.h:22
PixelChargeCalib::IChargeCalibrationParser::~IChargeCalibrationParser
virtual ~IChargeCalibrationParser()=default
athena.value
value
Definition: athena.py:124
PixelChargeCalib::IChargeCalibrationParser::parseImpl
virtual ChargeCalibrationBundle parseImpl(unsigned int, const nlohmann::json &, int)=0
PixelChargeCalib::IChargeCalibrationParser::parseImpl
virtual ChargeCalibrationBundle parseImpl(unsigned int, const std::string &)=0
lumiFormat.i
int i
Definition: lumiFormat.py:85
PixelChargeCalib::IChargeCalibrationParser::getFunc
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.
Definition: IChargeCalibrationParser.h:69
PixelChargeCalib::IChargeCalibrationParser
Definition: IChargeCalibrationParser.h:31
PixelChargeCalib::IChargeCalibrationParser::parse
ChargeCalibrationBundle parse(unsigned int hash, const T &data)
Definition: IChargeCalibrationParser.h:41
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
hist_file_dump.f
f
Definition: hist_file_dump.py:135
PixelChargeCalib::IChargeCalibrationParser::parseImpl
virtual ChargeCalibrationBundle parseImpl(unsigned int, const nlohmann::json &)=0
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
PixelChargeCalib::IChargeCalibrationParser::parse
ChargeCalibrationBundle parse(unsigned int hash, const T &data, int inputSource)
Definition: IChargeCalibrationParser.h:45
IdentifierHash.h
PixelChargeCalib::IChargeCalibrationParser::m_elements
const InDetDD::SiDetectorElementCollection * m_elements
Definition: IChargeCalibrationParser.h:52
SiDetectorElementCollection.h
PixelChargeCalib::IChargeCalibrationParser::m_pixelID
const PixelID * m_pixelID
Definition: IChargeCalibrationParser.h:53
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
PixelChargeCalib
Definition: IChargeCalibrationParser.h:30
PixelChargeCalib::ChargeCalibrationBundle
bundles of parameters used together in the PixelChargeCalibCondAlg
Definition: ChargeCalibrationBundle.h:24
PixelID
Definition: PixelID.h:67