13 inline float build_rechit_time(
const float weightedEnergySum,
14 const float weightedSum,
17 const float valueIfNothingWorks,
18 bool* resultComesFromTDC) {
19 if (weightedEnergySum > 0.
f) {
20 *resultComesFromTDC =
true;
21 return weightedSum / weightedEnergySum;
23 *resultComesFromTDC =
true;
26 *resultComesFromTDC =
false;
27 return valueIfNothingWorks;
34 const unsigned i_soiPhase,
35 const float i_timeShift,
36 const float i_triseIfNoTDC,
37 const float i_tfallIfNoTDC,
38 const float i_minChargeForUndershoot,
39 const float i_minChargeForOvershoot,
42 : soiPhase_(i_soiPhase),
43 timeShift_(i_timeShift),
44 triseIfNoTDC_(i_triseIfNoTDC),
45 tfallIfNoTDC_(i_tfallIfNoTDC),
46 minChargeForUndershoot_(i_minChargeForUndershoot),
47 minChargeForOvershoot_(i_minChargeForOvershoot),
74 eStates[0] = states[0];
75 eStates[1] = states[1];
77 for (
unsigned i = 0;
i < 2; ++
i)
90 const bool flaggedBadInDB[2],
91 const bool expectSingleAnodePMT) {
96 if (expectSingleAnodePMT)
99 bool isTimingReliable[2] = {
true,
true};
100 for (
unsigned ianode = 0; ianode < 2; ++ianode) {
101 if (flaggedBadInDB[ianode])
112 if (lookupInd != UINT_MAX) {
117 float energy = 0.f, tfallWeightedEnergySum = 0.f, triseWeightedEnergySum = 0.f;
118 float tfallWeightedSum = 0.f, triseWeightedSum = 0.f;
119 float tfallSum = 0.f, triseSum = 0.f;
120 unsigned tfallCount = 0, triseCount = 0;
122 for (
unsigned ianode = 0; ianode < 2; ++ianode) {
124 if (anodeInfo &&
weights[ianode] > 0.
f) {
125 const float weightedEnergy =
weights[ianode] * anodeInfo->
energy();
134 if (weightedEnergy > 0.
f) {
135 triseWeightedSum += trise * weightedEnergy;
136 triseWeightedEnergySum += weightedEnergy;
145 if (weightedEnergy > 0.
f) {
146 tfallWeightedSum += tfall * weightedEnergy;
147 tfallWeightedEnergySum += weightedEnergy;
154 bool triseFromTDC =
false;
156 build_rechit_time(triseWeightedEnergySum, triseWeightedSum, triseSum, triseCount,
triseIfNoTDC_, &triseFromTDC);
158 bool tfallFromTDC =
false;
160 build_rechit_time(tfallWeightedEnergySum, tfallWeightedSum, tfallSum, tfallCount,
tfallIfNoTDC_, &tfallFromTDC);
166 const uint32_t
flag = triseFromTDC ? 1
U : 0
U;
constexpr float energy() const
constexpr void setFlagField(uint32_t value, int base, int width=1)
constexpr HFQIE10Info const * getHFQIE10Info(unsigned index) const
unsigned mapStatusIntoIndex(const unsigned states[2]) const
U second(std::pair< T, U > const &p)
constexpr float timeFalling() const
constexpr float timeRising() const
std::pair< float, float > tlimits_[2]
constexpr bool isSpecial(const float t)
float energyWeights_[2 *HFAnodeStatus::N_POSSIBLE_STATES - 1][2]
HFSimpleTimeCheck(const std::pair< float, float > tlimits[2], const float energyWeights[2 *HFAnodeStatus::N_POSSIBLE_STATES - 1][2], unsigned soiPhase, float timeShift, float triseIfNoTDC, float tfallIfNoTDC, float minChargeForUndershoot, float minChargeForOvershoot, bool rejectAllFailures=true, bool alwaysCalculateChargeAsymmetry=true)
HFRecHit reconstruct(const HFPreRecHit &prehit, const HcalCalibrations &calibs, const bool flaggedBadInDB[2], bool expectSingleAnodePMT) override
constexpr HcalDetId id() const
static void setAux(const HFPreRecHit &prehit, const unsigned anodeStates[2], unsigned soiPhase, HFRecHit *rechit)
bool isDataframeOK(bool checkAllTimeSlices=false) const
virtual unsigned determineAnodeStatus(unsigned anodeNumber, const HFQIE10Info &anode, bool *isTimingReliable) const
alwaysCalculateQAsymmetry