12 : firstSample_(firstSample), samplesToAdd_(samplesToAdd), correctForTimeslew_(correctForTimeslew) {
18 : firstSample_(firstSample), samplesToAdd_(samplesToAdd), correctForTimeslew_(
false) {}
30 namespace CastorSimpleRecAlgoImpl {
31 template <
class Digi,
class RecHit>
32 inline RecHit
reco(
const Digi& digi,
48 for (
int i = ifirst;
i < tool.
size() &&
i < n + ifirst;
i++) {
49 int capid = digi[
i].capid();
52 ta *= calibs.
gain(capid);
62 if (maxI == 0 || maxI == (tool.
size() - 1)) {
74 int capid = digi[maxI - 1].capid();
75 float t0 = fabs((tool[maxI - 1] - calibs.
pedestal(capid)) * calibs.
gain(capid));
76 capid = digi[maxI + 1].capid();
77 float t2 = fabs((tool[maxI + 1] - calibs.
pedestal(capid)) * calibs.
gain(capid));
78 float wpksamp = (t0 + maxA + t2);
80 wpksamp = (maxA + 2.0 * t2) / wpksamp;
83 if (corr !=
nullptr) {
92 return RecHit(digi.id(), ampl, time);
98 for (
int i = ifirst;
i < digi.size() &&
i < n + ifirst;
i++) {
108 template <
class Digi,
class RecHit>
114 const double& satCorrConst,
122 if (ifirst + n > digi.size())
127 if (digi[ifirst].
adc() >= maxADCvalue && digi[ifirst + 1].adc() <
maxADCvalue) {
134 int capid = digi[ifirst].capid();
135 float ta = tool[ifirst] - calibs.
pedestal(capid);
136 float ta1 = ta * calibs.
gain(capid);
139 capid = digi[ifirst + 1].capid();
140 ta = tool[ifirst + 1] - calibs.
pedestal(capid);
141 float ta2 = ta * calibs.
gain(capid);
146 if (ta2 / satCorrConst <= ta1)
151 ampl = ta2 + ta2 / satCorrConst;
154 rechit.setEnergy(ampl);
166 return CastorSimpleRecAlgoImpl::reco<CastorDataFrame, CastorRecHit>(
183 const double& satCorrConst)
const {
184 if (CastorSimpleRecAlgoImpl::corrSaturation<CastorDataFrame, CastorRecHit>(
302 int index = (int)flx;
317 yval = y1 + (y2 - y1) * (flx - (
float)
index);
static double delay(double fC, BiasSetting bias=Medium)
Returns the amount (ns) by which a pulse of the given number of fC will be delayed by the timeslew ef...
CastorSimpleRecAlgo(int firstSample, int samplesToAdd, bool correctForTimeslew, bool correctForContainment, float fixedPhaseNs)
virtual void adc2fC(const CastorDataFrame &df, CaloSamples &lf) const =0
constexpr void setFlagField(uint32_t value, int base, int width=1)
CastorRecHit reconstruct(const CastorDataFrame &digi, const CastorCoder &coder, const CastorCalibrations &calibs) const
bool corrSaturation(RecHit &rechit, const CastorCoder &coder, const CastorCalibrations &calibs, const Digi &digi, const int &maxADCvalue, const double &satCorrConst, int ifirst, int n)
std::unique_ptr< CastorPulseContainmentCorrection > pulseCorr_
static const float wpksamp0_hf
double getCorrection(double fc_ampl) const
static const float actual_ns_hf[num_bins_hf]
static const float scale_hf
double pedestal(int fCapId) const
get pedestal for capid=0..3
constexpr double MaximumFractionalError
void recoverADCSaturation(CastorRecHit &rechit, const CastorCoder &coder, const CastorCalibrations &calibs, const CastorDataFrame &digi, const int &maxADCvalue, const double &satCorrConst) const
double gain(int fCapId) const
get gain for capid=0..3
int size() const
get the size
static float timeshift_ns_hf(float wpksamp)
Same as above, but for the HF PMTs.
bool isSaturated(const Digi &digi, const int &maxADCvalue, int ifirst, int n)
static const int num_bins_hf
void checkADCSaturation(CastorRecHit &rechit, const CastorDataFrame &digi, const int &maxADCvalue) const
RecHit reco(const Digi &digi, const CastorCoder &coder, const CastorCalibrations &calibs, int ifirst, int n, bool slewCorrect, const CastorPulseContainmentCorrection *corr, CastorTimeSlew::BiasSetting slewFlavor)
uint16_t *__restrict__ uint16_t const *__restrict__ adc