ATLAS Offline Software
ChargeCalibrationBundle.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
12 #ifndef ChargeCalibrationBundle_h
13 #define ChargeCalibrationBundle_h
14 
16 #include "PixelConditionsData/ChargeCalibParameters.h" //Thresholds, LegacyFitParameters etc
18 #include "CxxUtils/trapping_fp.h"
19 #include <vector>
20 #include <map> //also has std::pair
21 
22 namespace PixelChargeCalib{
25  bool isValid=true;
26  bool useLUT = false;
27  bool useTXT = false;
28 
29  std::vector<PixelChargeCalib::Thresholds> threshold;
30  std::vector<PixelChargeCalib::Thresholds> thresholdLong;
31  std::vector<PixelChargeCalib::Thresholds> thresholdGanged;
32  std::vector<PixelChargeCalib::LegacyFitParameters> params;
33  std::vector<PixelChargeCalib::LegacyFitParameters> paramsGanged;
34  std::vector<PixelChargeCalib::LinearFitParameters> lin;
35  std::vector<PixelChargeCalib::LinearFitParameters> linGanged;
36  std::vector<PixelChargeCalib::Resolutions> totRes;
39  //
41  ChargeCalibrationBundle(size_t n, bool lut = false, bool txt = false):useLUT(lut),useTXT(txt){
42  threshold.reserve(n);
43  thresholdLong.reserve(n);
44  thresholdGanged.reserve(n);
45  params.reserve(n);
46  paramsGanged.reserve(n);
47  lin.reserve(n);
48  linGanged.reserve(n);
49  totRes.reserve(n);
50  }
51  //return the index, within range (start, end), where the charge threshold is exceeded
52  //or -1 if it is not
53  int
54  idxAtChargeLimit(float chargeLimit, InDetDD::PixelDiodeType type, int start, int end) const {
55  const auto &relevantArray = (type == InDetDD::PixelDiodeType::NORMAL) ? params : paramsGanged;
56  int idx=-1;
57  for (int i = start;i!=end;++i){
58  const float tmpcharge = relevantArray.back().Q(i);
59  if (tmpcharge > chargeLimit){
60  idx = i;
61  break;
62  }
63  }
64  return idx;
65  }
66 
67  void
69  // Tell clang to optimize assuming that FP exceptions can trap.
70  // Otherwise, it can vectorize the division, which can lead to
71  // spurious division-by-zero traps from unused vector lanes.
73  auto &targetArray = (type == InDetDD::PixelDiodeType::NORMAL) ? lin : linGanged;
74  if (idxLimit <= 0){ //duplicates original logic
75  targetArray.emplace_back(0.f,0.f);
76  return;
77  }
78  //not entirely satisfactory, the fit derivatives are not continuous
79  //and a difference of 5 seems a bit arbitrary
80  const auto &readArray = (type == InDetDD::PixelDiodeType::NORMAL) ? params : paramsGanged;
81  static constexpr int dx = 5;
82  const float x1 = idxLimit;
83  const float x2 = idxLimit-dx;
84  const float y1 = readArray.back().Q(x1);
85  const float y2 = readArray.back().Q(x2);
86  targetArray.emplace_back((y1-y2)/dx, (y2*x1-y1*x2)/dx);
87  }
88  };
89 }
90 
91 #endif
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
CXXUTILS_TRAPPING_FP
#define CXXUTILS_TRAPPING_FP
Definition: trapping_fp.h:24
PixelChargeCalib::ChargeCalibrationBundle::idxAtChargeLimit
int idxAtChargeLimit(float chargeLimit, InDetDD::PixelDiodeType type, int start, int end) const
Definition: ChargeCalibrationBundle.h:54
PixelChargeCalib::ChargeCalibrationBundle::linGanged
std::vector< PixelChargeCalib::LinearFitParameters > linGanged
Definition: ChargeCalibrationBundle.h:35
PixelChargeCalib::ChargeCalibrationBundle::useTXT
bool useTXT
Definition: ChargeCalibrationBundle.h:27
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
plotBeamSpotCompare.x2
x2
Definition: plotBeamSpotCompare.py:218
InDetDD::PixelDiodeType
PixelDiodeType
Definition: PixelReadoutDefinitions.h:25
ChargeCalibParameters.h
Structs for holding charge calibration parameterisation and data.
PixelChargeCalib::ChargeCalibrationBundle::tot2Charges
PixelChargeCalibCondData::IBLModule tot2Charges
Definition: ChargeCalibrationBundle.h:37
PixelChargeCalib::ChargeCalibrationBundle::threshold
std::vector< PixelChargeCalib::Thresholds > threshold
Definition: ChargeCalibrationBundle.h:29
makeTRTBarrelCans.y1
tuple y1
Definition: makeTRTBarrelCans.py:15
ITkPixEncoding::lut
constexpr auto lut(Generator &&f)
Definition: ITkPixQCoreEncodingLUT.h:19
PixelChargeCalib::ChargeCalibrationBundle::lin
std::vector< PixelChargeCalib::LinearFitParameters > lin
Definition: ChargeCalibrationBundle.h:34
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
PixelChargeCalib::ChargeCalibrationBundle::insertLinearParams
void insertLinearParams(InDetDD::PixelDiodeType type, int idxLimit)
Definition: ChargeCalibrationBundle.h:68
PixelChargeCalib::ChargeCalibrationBundle::thresholdLong
std::vector< PixelChargeCalib::Thresholds > thresholdLong
Definition: ChargeCalibrationBundle.h:30
PixelChargeCalib::ChargeCalibrationBundle::totRes
std::vector< PixelChargeCalib::Resolutions > totRes
Definition: ChargeCalibrationBundle.h:36
PixelChargeCalib::ChargeCalibrationBundle::thresholdGanged
std::vector< PixelChargeCalib::Thresholds > thresholdGanged
Definition: ChargeCalibrationBundle.h:31
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
PixelChargeCalib::ChargeCalibrationBundle::params
std::vector< PixelChargeCalib::LegacyFitParameters > params
Definition: ChargeCalibrationBundle.h:32
makeTRTBarrelCans.y2
tuple y2
Definition: makeTRTBarrelCans.py:18
PixelChargeCalibCondData::CalibrationStrategy
CalibrationStrategy
Definition: PixelChargeCalibCondData.h:34
hist_file_dump.f
f
Definition: hist_file_dump.py:135
PixelChargeCalib::ChargeCalibrationBundle::isValid
bool isValid
Definition: ChargeCalibrationBundle.h:25
PixelChargeCalib::ChargeCalibrationBundle::paramsGanged
std::vector< PixelChargeCalib::LegacyFitParameters > paramsGanged
Definition: ChargeCalibrationBundle.h:33
trapping_fp.h
Tell the compiler to optimize assuming that FP may trap.
PixelChargeCalib::ChargeCalibrationBundle::calibrationType
PixelChargeCalibCondData::CalibrationStrategy calibrationType
Definition: ChargeCalibrationBundle.h:38
PixelChargeCalibCondData::IBLModule
std::vector< IBLCalibration > IBLModule
Definition: PixelChargeCalibCondData.h:31
threshold
Definition: chainparser.cxx:74
PixelChargeCalibCondData::CalibrationStrategy::RUN1PIX
@ RUN1PIX
PixelReadoutDefinitions.h
PixelChargeCalib::ChargeCalibrationBundle::useLUT
bool useLUT
Definition: ChargeCalibrationBundle.h:26
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
makeTRTBarrelCans.dx
tuple dx
Definition: makeTRTBarrelCans.py:20
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
PixelChargeCalib
Definition: IChargeCalibrationParser.h:30
PixelChargeCalib::ChargeCalibrationBundle
bundles of parameters used together in the PixelChargeCalibCondAlg
Definition: ChargeCalibrationBundle.h:24
InDetDD::PixelDiodeType::NORMAL
@ NORMAL
PixelChargeCalib::ChargeCalibrationBundle::ChargeCalibrationBundle
ChargeCalibrationBundle(size_t n, bool lut=false, bool txt=false)
constructor with reserve for the vectors, n = number of frontends
Definition: ChargeCalibrationBundle.h:41
PixelChargeCalibCondData.h