23 fTimeSlewBias_ = bias;
24 applyTimeSlew_ = iApplyTimeSlew;
25 frespCorr_ = respCorr;
34 if (
std::abs(tStart - tEnd - tsWidth) < 0.1
f) {
38 sum = landauFrac[
int(
ceil(tStart + tsWidth))];
44 if (
std::abs(tStart - tEnd - tsWidth) < 0.1
f) {
48 sum = siPM205Frac[
int(
ceil(tStart + tsWidth))];
54 if (
std::abs(tStart - tEnd - tsWidth) < 0.1
f) {
58 sum = siPM206Frac[
int(
ceil(tStart + tsWidth))];
64 if (
std::abs(tStart - tEnd - tsWidth) < 0.1
f) {
68 sum = siPM207Frac[
int(
ceil(tStart + tsWidth))];
75 get205Frac(tStart, tEnd, sum);
78 get206Frac(tStart, tEnd, sum);
81 get207Frac(tStart, tEnd, sum);
84 getLandauFrac(tStart, tEnd, sum);
90 float &reconstructedEnergy,
91 float &reconstructedTime,
93 unsigned int soi = channelData.
soi();
95 std::vector<double> corrCharge;
96 corrCharge.reserve(channelData.
nSamples());
97 std::vector<double> inputCharge;
98 inputCharge.reserve(channelData.
nSamples());
99 std::vector<double> inputPedestal;
100 inputPedestal.reserve(channelData.
nSamples());
101 std::vector<double> inputNoise;
102 inputNoise.reserve(channelData.
nSamples());
107 for (
unsigned int ip = 0; ip < channelData.
nSamples(); ip++) {
114 inputCharge.push_back(
charge);
115 inputPedestal.push_back(
ped);
116 inputNoise.push_back(
noise);
119 fPedestalSubFxn_.calculate(inputCharge, inputPedestal, inputNoise, corrCharge, soi, channelData.
nSamples());
123 else if (fTimeSlew_ == 1)
124 channelData.
hasTimeInfo() ? respCorr = rCorrSiPM[0] : respCorr = rCorr[0];
125 else if (fTimeSlew_ == 2)
126 channelData.
hasTimeInfo() ? respCorr = rCorrSiPM[1] : respCorr = rCorr[1];
127 else if (fTimeSlew_ == 3)
128 respCorr = frespCorr_;
130 float tsShift3, tsShift4, tsShift5;
131 tsShift3 = 0.f, tsShift4 = 0.f, tsShift5 = 0.f;
133 if (applyTimeSlew_) {
134 tsShift3 = hcalTimeSlew_delay->
delay(inputCharge[soi - 1], fTimeSlew_, fTimeSlewBias_, !channelData.
hasTimeInfo());
135 tsShift4 = hcalTimeSlew_delay->
delay(inputCharge[soi], fTimeSlew_, fTimeSlewBias_, !channelData.
hasTimeInfo());
136 tsShift5 = hcalTimeSlew_delay->
delay(inputCharge[soi + 1], fTimeSlew_, fTimeSlewBias_, !channelData.
hasTimeInfo());
139 float ch3, ch4, ch5,
i3, n3, nn3, i4, n4, i5, n5;
140 ch4 = 0.f,
i3 = 0.f, n3 = 0.f, nn3 = 0.f, i4 = 0.f, n4 = 0.f, i5 = 0.f, n5 = 0.f;
152 getFrac(-tsShift3, -tsShift3 + tsWidth,
i3, fType);
153 getFrac(-tsShift3 + tsWidth, -tsShift3 + tsWidth * 2, n3, fType);
154 getFrac(-tsShift3 + tsWidth * 2, -tsShift3 + tsWidth * 3, nn3, fType);
156 getFrac(-tsShift4, -tsShift4 + tsWidth, i4, fType);
157 getFrac(-tsShift4 + tsWidth, -tsShift4 + tsWidth * 2, n4, fType);
159 getFrac(-tsShift5, -tsShift5 + tsWidth, i5, fType);
160 getFrac(-tsShift5 + tsWidth, -tsShift5 + tsWidth * 2, n5, fType);
162 if (
i3 != 0 && i4 != 0 && i5 != 0) {
163 ch3 = corrCharge[soi - 1] /
i3;
164 ch4 = (
i3 * corrCharge[soi] - n3 * corrCharge[soi - 1]) / (
i3 * i4);
165 ch5 = (n3 * n4 * corrCharge[soi - 1] - i4 * nn3 * corrCharge[soi - 1] -
i3 * n4 * corrCharge[soi] +
166 i3 * i4 * corrCharge[soi + 1]) /
169 if (ch3 < negThresh[0]) {
171 ch4 = corrCharge[soi] / i4;
172 ch5 = (i4 * corrCharge[soi + 1] - n4 * corrCharge[soi]) / (i4 * i5);
174 if (ch5 < negThresh[0] && ch4 > negThresh[1]) {
175 double ratio = (corrCharge[soi] - ch3 *
i3) / (corrCharge[soi + 1] - negThresh[0] * i5);
176 if (ratio < 5 && ratio > 0.5) {
177 double invG = invGpar[0] + invGpar[1] *
std::sqrt(2 *
std::log(invGpar[2] / ratio));
179 getFrac(-invG, -invG + tsWidth, iG, fType);
181 ch4 = (corrCharge[soi] - ch3 * n3) / (iG);
192 reconstructedEnergy = ch4 * gainCorr * respCorr;
193 reconstructedTime = tsShift4;
constexpr int32_t ceil(float num)
void phase1Apply(const HBHEChannelInfo &channelData, float &reconstructedEnergy, float &reconstructedTime, const HcalTimeSlew *hcalTimeSlew_delay) const
static constexpr float rCorr[2]
constexpr int recoShape() const
static constexpr float rCorrSiPM[2]
constexpr double tsRawCharge(const unsigned ts) const
static constexpr int HcalRegion[2]
void get207Frac(float tStart, float tEnd, float &sum) const
constexpr double tsPedestalWidth(const unsigned ts) const
static constexpr float siPM206Frac[125]
float delay(float fC, BiasSetting bias=Medium) const
Returns the amount (ns) by which a pulse of the given number of fC will be delayed by the timeslew ef...
constexpr double tsGain(const unsigned ts) const
Abs< T >::type abs(const T &t)
static constexpr float siPM205Frac[125]
constexpr unsigned soi() const
void init(HcalTimeSlew::ParaSource tsParam, HcalTimeSlew::BiasSetting bias, bool iApplyTimeSlew, double respCorr)
static constexpr float landauFrac[125]
void get205Frac(float tStart, float tEnd, float &sum) const
constexpr bool hasTimeInfo() const
constexpr unsigned nSamples() const
static constexpr float siPM207Frac[125]
constexpr double tsPedestal(const unsigned ts) const
void get206Frac(float tStart, float tEnd, float &sum) const
static constexpr float negThresh[2]
static constexpr float invGpar[3]
void getFrac(float, float, float &, FType) const
void getLandauFrac(float tStart, float tEnd, float &sum) const