ATLAS Offline Software
Loading...
Searching...
No Matches
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
11
12#ifndef ChargeCalibrationBundle_h
13#define ChargeCalibrationBundle_h
14
16#include "PixelConditionsData/ChargeCalibParameters.h" //Thresholds, LegacyFitParameters etc
19#include <vector>
20#include <map> //also has std::pair
21
22namespace 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
Structs for holding charge calibration parameterisation and data.
std::vector< IBLCalibration > IBLModule
std::vector< PixelChargeCalib::LinearFitParameters > linGanged
std::vector< PixelChargeCalib::Thresholds > thresholdGanged
std::vector< PixelChargeCalib::Thresholds > threshold
PixelChargeCalibCondData::CalibrationStrategy calibrationType
ChargeCalibrationBundle(size_t n, bool lut=false, bool txt=false)
constructor with reserve for the vectors, n = number of frontends
std::vector< PixelChargeCalib::LinearFitParameters > lin
std::vector< PixelChargeCalib::LegacyFitParameters > paramsGanged
int idxAtChargeLimit(float chargeLimit, InDetDD::PixelDiodeType type, int start, int end) const
void insertLinearParams(InDetDD::PixelDiodeType type, int idxLimit)
std::vector< PixelChargeCalib::Thresholds > thresholdLong
std::vector< PixelChargeCalib::Resolutions > totRes
PixelChargeCalibCondData::IBLModule tot2Charges
std::vector< PixelChargeCalib::LegacyFitParameters > params
Tell the compiler to optimize assuming that FP may trap.
#define CXXUTILS_TRAPPING_FP
Definition trapping_fp.h:24