13 recoMethod_(recoMethod),
14 correctForTimeslew_(correctForTimeslew),
15 correctForPulse_(correctForPulse),
17 lowGainOffset_(lowGainOffset),
18 lowGainFrac_(lowGainFrac)
35 template<
class Digi,
class RecHit>
40 int ifirst = mySignalTS[0];
41 int n = mySignalTS.size();
42 double ampl=0;
int maxI = -1;
double maxA = -1e10;
double ta=0;
44 double lowGEnergy=0;
double lowGfc_ampl=0;
double TempLGAmp=0;
52 for (
int i=ifirst;
i<tool.
size() &&
i<n+ifirst;
i++) {
53 int capid=digi[
i].capid();
65 if((n+ifirst+lowGainOffset)<=10){
70 for (
int iLG=(ifirst+lowGainOffset); iLG<tool.
size() && iLG<topLowGain; iLG++) {
71 int capid=digi[iLG].capid();
72 TempLGAmp = (tool[iLG]-calibs.
pedestal(capid));
73 lowGfc_ampl+=TempLGAmp;
76 lowGEnergy+=TempLGAmp;
81 if(maxI==0 || maxI==(tool.
size()-1)) {
82 LogDebug(
"HCAL Pulse") <<
"ZdcSimpleRecAlgo::reco1 :" 83 <<
" Invalid max amplitude position, " 84 <<
" max Amplitude: "<< maxI
86 <<
" last: "<<(tool.
size()-1)
89 int capid=digi[maxI-1].capid();
90 double Energy0 = ((tool[maxI-1])*calibs.
respcorrgain(capid) );
93 if(Energy0<0){Energy0=0.;}
94 capid=digi[
maxI].capid();
96 if(Energy1<0){Energy1=0.;}
97 capid=digi[maxI+1].capid();
98 double Energy2 = ((tool[maxI+1])*calibs.
respcorrgain(capid) );
99 if(Energy2<0){Energy2=0.;}
101 double TSWeightEnergy = ((maxI-1)*Energy0 + maxI*Energy1 + (maxI+1)*Energy2);
102 double EnergySum=Energy0+Energy1+Energy2;
104 if (EnergySum!=0) AvgTSPos=TSWeightEnergy/ EnergySum;
110 time = (AvgTSPos*25.0);
117 return RecHit(digi.id(),ampl,
time,lowGEnergy);
122 template<
class Digi,
class RecHit>
128 int ifirst = mySignalTS[0];
130 double ampl=0;
int maxI = -1;
double maxA = -1e10;
double ta=0;
132 double lowGEnergy=0;
double lowGfc_ampl=0;
double TempLGAmp=0;
144 for(
unsigned int iv = 0; iv<myNoiseTS.size(); ++iv)
146 CurrentTS = myNoiseTS[iv];
147 if ( CurrentTS >= digi.size() )
continue;
148 Allnoise += tool[CurrentTS];
151 if(noiseslices != 0) {
152 noise = (Allnoise)/
double(noiseslices);
156 for(
unsigned int ivs = 0; ivs<mySignalTS.size(); ++ivs)
158 CurrentTS = mySignalTS[ivs];
159 if ( CurrentTS >= digi.size() )
continue;
160 int capid=digi[CurrentTS].capid();
166 ta = tool[CurrentTS]-noise;
176 for(
unsigned int iLGvs = 0; iLGvs<mySignalTS.size(); ++iLGvs)
179 if ( CurrentTS >= digi.size() )
continue;
180 int capid=digi[CurrentTS].capid();
181 TempLGAmp = tool[CurrentTS]-noise;
182 lowGfc_ampl+=TempLGAmp;
185 lowGEnergy+=TempLGAmp;
194 if(maxI==0 || maxI==(tool.
size()-1)) {
195 LogDebug(
"HCAL Pulse") <<
"ZdcSimpleRecAlgo::reco2 :" 196 <<
" Invalid max amplitude position, " 197 <<
" max Amplitude: "<< maxI
198 <<
" first: "<<ifirst
199 <<
" last: "<<(tool.
size()-1)
202 int capid=digi[maxI-1].capid();
203 double Energy0 = ((tool[maxI-1])*calibs.
respcorrgain(capid) );
206 if(Energy0<0){Energy0=0.;}
207 capid=digi[
maxI].capid();
209 if(Energy1<0){Energy1=0.;}
210 capid=digi[maxI+1].capid();
211 double Energy2 = ((tool[maxI+1])*calibs.
respcorrgain(capid) );
212 if(Energy2<0){Energy2=0.;}
214 double TSWeightEnergy = ((maxI-1)*Energy0 + maxI*Energy1 + (maxI+1)*Energy2);
215 double EnergySum=Energy0+Energy1+Energy2;
217 if (EnergySum!=0) AvgTSPos=TSWeightEnergy/ EnergySum;
223 time = (AvgTSPos*25.0);
230 return RecHit(digi.id(),ampl,
time,lowGEnergy);
237 return ZdcSimpleRecAlgoImpl::reco1<ZDCDataFrame,ZDCRecHit>(digi,coder,calibs,
242 return ZdcSimpleRecAlgoImpl::reco2<ZDCDataFrame,ZDCRecHit>(digi,coder,calibs,
246 edm::LogError(
"ZDCSimpleRecAlgoImpl::reconstruct, recoMethod was not declared");
RecHit reco1(const Digi &digi, const HcalCoder &coder, const HcalCalibrations &calibs, const std::vector< unsigned int > &myNoiseTS, const std::vector< unsigned int > &mySignalTS, int lowGainOffset, double lowGainFrac, bool slewCorrect, const HcalPulseContainmentCorrection *corr, HcalTimeSlew::BiasSetting slewFlavor)
double respcorrgain(int fCapId) const
get response corrected gain for capid=0..3
void initPulseCorr(int toadd, const HcalTimeSlew *hcalTimeSlew_delay)
double getCorrection(double fc_ampl) const
double pedestal(int fCapId) const
get pedestal for capid=0..3
std::tuple< unsigned int, int, int, DigiType, int, int, int, float > Digi
ZDCRecHit reconstruct(const ZDCDataFrame &digi, const std::vector< unsigned int > &myNoiseTS, const std::vector< unsigned int > &mySignalTS, const HcalCoder &coder, const HcalCalibrations &calibs) const
ZdcSimpleRecAlgo(bool correctForTimeslew, bool correctForContainment, float fixedPhaseNs, int recoMethod, int lowGainOffset, double lowGainFrac)
double MaximumFractionalError
virtual void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const =0
std::unique_ptr< HcalPulseContainmentCorrection > pulseCorr_
int size() const
get the size
RecHit reco2(const Digi &digi, const HcalCoder &coder, const HcalCalibrations &calibs, const std::vector< unsigned int > &myNoiseTS, const std::vector< unsigned int > &mySignalTS, int lowGainOffset, double lowGainFrac, bool slewCorrect, const HcalPulseContainmentCorrection *corr, HcalTimeSlew::BiasSetting slewFlavor)