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 Allnoise += tool[CurrentTS];
150 if(noiseslices != 0) {
151 noise = (Allnoise)/
double(noiseslices);
155 for(
unsigned int ivs = 0; ivs<mySignalTS.size(); ++ivs)
157 CurrentTS = mySignalTS[ivs];
158 int capid=digi[CurrentTS].capid();
164 ta = tool[CurrentTS]-noise;
174 for(
unsigned int iLGvs = 0; iLGvs<mySignalTS.size(); ++iLGvs)
177 int capid=digi[CurrentTS].capid();
178 TempLGAmp = tool[CurrentTS]-noise;
179 lowGfc_ampl+=TempLGAmp;
182 lowGEnergy+=TempLGAmp;
191 if(maxI==0 || maxI==(tool.
size()-1)) {
192 LogDebug(
"HCAL Pulse") <<
"ZdcSimpleRecAlgo::reco2 :" 193 <<
" Invalid max amplitude position, " 194 <<
" max Amplitude: "<< maxI
195 <<
" first: "<<ifirst
196 <<
" last: "<<(tool.
size()-1)
199 int capid=digi[maxI-1].capid();
200 double Energy0 = ((tool[maxI-1])*calibs.
respcorrgain(capid) );
203 if(Energy0<0){Energy0=0.;}
204 capid=digi[
maxI].capid();
206 if(Energy1<0){Energy1=0.;}
207 capid=digi[maxI+1].capid();
208 double Energy2 = ((tool[maxI+1])*calibs.
respcorrgain(capid) );
209 if(Energy2<0){Energy2=0.;}
211 double TSWeightEnergy = ((maxI-1)*Energy0 + maxI*Energy1 + (maxI+1)*Energy2);
212 double EnergySum=Energy0+Energy1+Energy2;
214 if (EnergySum!=0) AvgTSPos=TSWeightEnergy/ EnergySum;
220 time = (AvgTSPos*25.0);
227 return RecHit(digi.id(),ampl,
time,lowGEnergy);
234 return ZdcSimpleRecAlgoImpl::reco1<ZDCDataFrame,ZDCRecHit>(digi,coder,calibs,
239 return ZdcSimpleRecAlgoImpl::reco2<ZDCDataFrame,ZDCRecHit>(digi,coder,calibs,
243 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)