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,
48 : soiPhase_(i_soiPhase),
49 timeShift_(i_timeShift),
50 triseIfNoTDC_(i_triseIfNoTDC),
51 tfallIfNoTDC_(i_tfallIfNoTDC),
52 minChargeForUndershoot_(i_minChargeForUndershoot),
53 minChargeForOvershoot_(i_minChargeForOvershoot),
54 rejectAllFailures_(rejectAllFailures)
64 const unsigned ianode,
const HFQIE10Info& anode,
bool*)
const 84 eStates[0] = states[0];
85 eStates[1] = states[1];
87 for (
unsigned i=0;
i<2; ++
i)
101 const bool flaggedBadInDB[2],
102 const bool expectSingleAnodePMT)
108 if (expectSingleAnodePMT)
111 bool isTimingReliable[2] = {
true,
true};
112 for (
unsigned ianode=0; ianode<2; ++ianode)
114 if (flaggedBadInDB[ianode])
121 &isTimingReliable[ianode]);
127 if (lookupInd != UINT_MAX)
133 float energy = 0.f, tfallWeightedEnergySum = 0.f, triseWeightedEnergySum = 0.f;
134 float tfallWeightedSum = 0.f, triseWeightedSum = 0.f;
135 float tfallSum = 0.f, triseSum = 0.f;
136 unsigned tfallCount = 0, triseCount = 0;
138 for (
unsigned ianode=0; ianode<2; ++ianode)
141 if (anodeInfo && weights[ianode] > 0.
f)
143 const float weightedEnergy = weights[ianode]*anodeInfo->
energy();
144 energy += weightedEnergy;
146 if (isTimingReliable[ianode] &&
155 if (weightedEnergy > 0.
f)
157 triseWeightedSum += trise*weightedEnergy;
158 triseWeightedEnergySum += weightedEnergy;
168 if (weightedEnergy > 0.
f)
170 tfallWeightedSum += tfall*weightedEnergy;
171 tfallWeightedEnergySum += weightedEnergy;
178 bool triseFromTDC =
false;
179 const float trise = build_rechit_time(
180 triseWeightedEnergySum, triseWeightedSum, triseSum,
183 bool tfallFromTDC =
false;
184 const float tfall = build_rechit_time(
185 tfallWeightedEnergySum, tfallWeightedSum, tfallSum,
188 rh =
HFRecHit(prehit.
id(), energy, trise, tfall);
192 const uint32_t
flag = triseFromTDC ? 1
U : 0
U;
std::pair< float, float > tlimits_[2]
bool isDataframeOK(bool checkAllTimeSlices=false) const
void setFlagField(uint32_t value, int base, int width=1)
virtual unsigned determineAnodeStatus(unsigned anodeNumber, const HFQIE10Info &anode, bool *isTimingReliable) const
const HFQIE10Info * getHFQIE10Info(unsigned index) const
U second(std::pair< T, U > const &p)
bool isSpecial(const float t)
unsigned mapStatusIntoIndex(const unsigned states[2]) const
virtual HFRecHit reconstruct(const HFPreRecHit &prehit, const HcalCalibrations &calibs, const bool flaggedBadInDB[2], bool expectSingleAnodePMT) override
float energyWeights_[2 *HFAnodeStatus::N_POSSIBLE_STATES-1][2]
static void setAux(const HFPreRecHit &prehit, const unsigned anodeStates[2], unsigned soiPhase, HFRecHit *rechit)
float timeFalling() 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)