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,
46 : soiPhase_(i_soiPhase),
47 timeShift_(i_timeShift),
48 triseIfNoTDC_(i_triseIfNoTDC),
49 tfallIfNoTDC_(i_tfallIfNoTDC),
50 rejectAllFailures_(rejectAllFailures)
60 const unsigned ianode,
const HFQIE10Info& anode,
bool*)
const 80 eStates[0] = states[0];
81 eStates[1] = states[1];
83 for (
unsigned i=0;
i<2; ++
i)
97 const bool flaggedBadInDB[2],
98 const bool expectSingleAnodePMT)
104 if (expectSingleAnodePMT)
107 bool isTimingReliable[2] = {
true,
true};
108 for (
unsigned ianode=0; ianode<2; ++ianode)
113 if (flaggedBadInDB[ianode])
117 &isTimingReliable[ianode]);
123 if (lookupInd != UINT_MAX)
129 float energy = 0.f, tfallWeightedEnergySum = 0.f, triseWeightedEnergySum = 0.f;
130 float tfallWeightedSum = 0.f, triseWeightedSum = 0.f;
131 float tfallSum = 0.f, triseSum = 0.f;
132 unsigned tfallCount = 0, triseCount = 0;
134 for (
unsigned ianode=0; ianode<2; ++ianode)
137 if (anodeInfo && weights[ianode] > 0.
f)
139 const float weightedEnergy = weights[ianode]*anodeInfo->
energy();
140 energy += weightedEnergy;
142 if (isTimingReliable[ianode] &&
151 if (weightedEnergy > 0.
f)
153 triseWeightedSum += trise*weightedEnergy;
154 triseWeightedEnergySum += weightedEnergy;
164 if (weightedEnergy > 0.
f)
166 tfallWeightedSum += tfall*weightedEnergy;
167 tfallWeightedEnergySum += weightedEnergy;
174 bool triseFromTDC =
false;
175 const float trise = build_rechit_time(
176 triseWeightedEnergySum, triseWeightedSum, triseSum,
179 bool tfallFromTDC =
false;
180 const float tfall = build_rechit_time(
181 tfallWeightedEnergySum, tfallWeightedSum, tfallSum,
184 rh =
HFRecHit(prehit.
id(), energy, trise, tfall);
188 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
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, bool rejectAllFailures=true)
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