11 firstSample_(firstSample),
12 samplesToAdd_(samplesToAdd),
13 correctForTimeslew_(correctForTimeslew) {
36 template<
class Digi,
class RecHit>
42 double ampl=0;
int maxI = -1;
double maxA = -1e10;
float ta=0;
44 for (
int i=ifirst;
i<tool.
size() &&
i<n+ifirst;
i++) {
45 int capid=digi[
i].capid();
48 ta*=calibs.
gain(capid);
58 if(maxI==0 || maxI==(tool.
size()-1)) {
70 int capid=digi[maxI-1].capid();
71 float t0 = fabs((tool[maxI-1]-calibs.
pedestal(capid))*calibs.
gain(capid));
72 capid=digi[maxI+1].capid();
73 float t2 = fabs((tool[maxI+1]-calibs.
pedestal(capid))*calibs.
gain(capid));
74 float wpksamp = (t0 + maxA + t2);
75 if (wpksamp!=0) wpksamp=(maxA + 2.0*t2) / wpksamp;
87 return RecHit(digi.id(),ampl,
time);
93 for (
int i=ifirst;
i<digi.size() &&
i<n+ifirst;
i++) {
102 template<
class Digi,
class RecHit>
104 const Digi& digi,
const int&
maxADCvalue,
const double& satCorrConst,
int ifirst,
int n)
107 if(n != 2)
return false;
110 if(ifirst+n > digi.size())
return false;
114 if(digi[ifirst].
adc() >= maxADCvalue && digi[ifirst+1].adc() <
maxADCvalue) {
121 int capid = digi[ifirst].capid();
122 float ta = tool[ifirst]-calibs.
pedestal(capid);
123 float ta1 = ta*calibs.
gain(capid);
126 capid = digi[ifirst+1].capid();
127 ta = tool[ifirst+1]-calibs.
pedestal(capid);
128 float ta2 = ta*calibs.
gain(capid);
133 if(ta2 / satCorrConst <= ta1)
return false;
137 ampl = ta2 + ta2 / satCorrConst;
140 rechit.setEnergy(ampl);
150 return CastorSimpleRecAlgoImpl::reco<CastorDataFrame,CastorRecHit>(digi,coder,calibs,
164 if(CastorSimpleRecAlgoImpl::corrSaturation<CastorDataFrame,CastorRecHit>(rechit,coder,calibs,digi,
165 maxADCvalue,satCorrConst,
297 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...
double MaximumFractionalError
CastorSimpleRecAlgo(int firstSample, int samplesToAdd, bool correctForTimeslew, bool correctForContainment, float fixedPhaseNs)
std::tuple< unsigned int, int, int, DigiType, int, int, int, float > Digi
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]
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
virtual void adc2fC(const CastorDataFrame &df, CaloSamples &lf) const =0
static const float scale_hf
double pedestal(int fCapId) const
get pedestal for capid=0..3
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)