13 inline float build_rechit_time(
const float weightedEnergySum,
14 const float weightedSum,
17 const float valueIfNothingWorks,
18 bool* resultComesFromTDC)
20 if (weightedEnergySum > 0.
f)
22 *resultComesFromTDC =
true;
23 return weightedSum/weightedEnergySum;
27 *resultComesFromTDC =
true;
32 *resultComesFromTDC =
false;
33 return valueIfNothingWorks;
41 const unsigned i_soiPhase,
42 const float i_timeShift,
43 const float i_triseIfNoTDC,
44 const float i_tfallIfNoTDC,
45 const float i_minChargeForUndershoot,
46 const float i_minChargeForOvershoot,
49 : soiPhase_(i_soiPhase),
50 timeShift_(i_timeShift),
51 triseIfNoTDC_(i_triseIfNoTDC),
52 tfallIfNoTDC_(i_tfallIfNoTDC),
53 minChargeForUndershoot_(i_minChargeForUndershoot),
54 minChargeForOvershoot_(i_minChargeForOvershoot),
55 rejectAllFailures_(rejectAllFailures),
56 alwaysQAsym_(alwaysCalculateQAsymmetry)
66 const unsigned ianode,
const HFQIE10Info& anode,
bool*)
const 86 eStates[0] = states[0];
87 eStates[1] = states[1];
89 for (
unsigned i=0;
i<2; ++
i)
103 const bool flaggedBadInDB[2],
104 const bool expectSingleAnodePMT)
110 if (expectSingleAnodePMT)
113 bool isTimingReliable[2] = {
true,
true};
114 for (
unsigned ianode=0; ianode<2; ++ianode)
116 if (flaggedBadInDB[ianode])
123 &isTimingReliable[ianode]);
129 if (lookupInd != UINT_MAX)
135 float energy = 0.f, tfallWeightedEnergySum = 0.f, triseWeightedEnergySum = 0.f;
136 float tfallWeightedSum = 0.f, triseWeightedSum = 0.f;
137 float tfallSum = 0.f, triseSum = 0.f;
138 unsigned tfallCount = 0, triseCount = 0;
140 for (
unsigned ianode=0; ianode<2; ++ianode)
143 if (anodeInfo && weights[ianode] > 0.
f)
145 const float weightedEnergy = weights[ianode]*anodeInfo->
energy();
146 energy += weightedEnergy;
148 if (isTimingReliable[ianode] &&
157 if (weightedEnergy > 0.
f)
159 triseWeightedSum += trise*weightedEnergy;
160 triseWeightedEnergySum += weightedEnergy;
170 if (weightedEnergy > 0.
f)
172 tfallWeightedSum += tfall*weightedEnergy;
173 tfallWeightedEnergySum += weightedEnergy;
180 bool triseFromTDC =
false;
181 const float trise = build_rechit_time(
182 triseWeightedEnergySum, triseWeightedSum, triseSum,
185 bool tfallFromTDC =
false;
186 const float tfall = build_rechit_time(
187 tfallWeightedEnergySum, tfallWeightedSum, tfallSum,
190 rh =
HFRecHit(prehit.
id(), energy, trise, tfall);
194 const uint32_t
flag = triseFromTDC ? 1
U : 0
U;
std::pair< float, float > tlimits_[2]
bool isDataframeOK(bool checkAllTimeSlices=false) const
virtual unsigned determineAnodeStatus(unsigned anodeNumber, const HFQIE10Info &anode, bool *isTimingReliable) const
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)
constexpr void setFlagField(uint32_t value, int base, int width=1)
U second(std::pair< T, U > const &p)
unsigned mapStatusIntoIndex(const unsigned states[2]) const
constexpr bool isSpecial(const float t)
HFQIE10Info const * getHFQIE10Info(unsigned index) const
HFRecHit reconstruct(const HFPreRecHit &prehit, const HcalCalibrations &calibs, const bool flaggedBadInDB[2], bool expectSingleAnodePMT) override
float energyWeights_[2 *HFAnodeStatus::N_POSSIBLE_STATES-1][2]
alwaysCalculateQAsymmetry
static void setAux(const HFPreRecHit &prehit, const unsigned anodeStates[2], unsigned soiPhase, HFRecHit *rechit)
float timeFalling() const