ATLAS Offline Software
Loading...
Searching...
No Matches
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
27class PixelModuleData;
28
29
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:
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)>
69 getFunc(const nlohmann::json & data){
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
Struct for holding vectors of charge calibration constants, with utility methods.
This is an Identifier helper class for the Pixel subdetector.
Class to hold the SiDetectorElement objects to be put in the detector store.
virtual ChargeCalibrationBundle parseImpl(unsigned int, const nlohmann::json &)=0
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.
IChargeCalibrationParser(const PixelModuleData *pModData, const InDetDD::SiDetectorElementCollection *pElements, const PixelID *pId)
ChargeCalibrationBundle parse(unsigned int hash, const T &data, int inputSource)
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.
virtual ChargeCalibrationBundle parseImpl(unsigned int, const std::string &)=0
virtual ChargeCalibrationBundle parseImpl(unsigned int, const nlohmann::json &, int)=0
ChargeCalibrationBundle parse(unsigned int hash, const T &data)
const InDetDD::SiDetectorElementCollection * m_elements
This is an Identifier helper class for the Pixel subdetector.
Definition PixelID.h:69
bundles of parameters used together in the PixelChargeCalibCondAlg