11 firstSample_(firstSample),
12 samplesToAdd_(samplesToAdd),
13 correctForTimeslew_(correctForTimeslew) {
19 firstSample_(firstSample),
20 samplesToAdd_(samplesToAdd),
21 correctForTimeslew_(
false) {
35 namespace CastorSimpleRecAlgoImpl {
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);
92 inline bool isSaturated(
const Digi& digi,
const int& maxADCvalue,
int ifirst,
int n) {
93 for (
int i=ifirst;
i<digi.size() &&
i<n+ifirst;
i++) {
94 if(digi[
i].
adc() >= maxADCvalue)
return true;
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,
163 const CastorDataFrame& digi,
const int& maxADCvalue,
const double& satCorrConst)
const {
164 if(CastorSimpleRecAlgoImpl::corrSaturation<CastorDataFrame,CastorRecHit>(rechit,coder,calibs,digi,
165 maxADCvalue,satCorrConst,
284 int index = (int)flx;
297 yval = y1 + (y2-y1)*(flx-(
float)
index);
int adc(sample_type sample)
get the ADC sample (12 bits)
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)
void setFlagField(uint32_t value, int base, int width=1)
virtual void adc2fC(const CastorDataFrame &df, CaloSamples &lf) const =0
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)
static const float wpksamp0_hf
double getCorrection(double fc_ampl) const
const T & max(const T &a, const T &b)
auto const T2 &decltype(t1.eta()) t2
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
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
constexpr double MaximumFractionalError
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)
std::auto_ptr< CastorPulseContainmentCorrection > pulseCorr_