13 recoMethod_(recoMethod),
14 correctForTimeslew_(correctForTimeslew),
15 correctForPulse_(correctForPulse),
17 lowGainOffset_(lowGainOffset),
18 lowGainFrac_(lowGainFrac)
23 recoMethod_(recoMethod),
24 correctForTimeslew_(
false) {
33 namespace ZdcSimpleRecAlgoImpl {
34 template<
class Digi,
class RecHit>
39 int ifirst = mySignalTS[0];
40 int n = mySignalTS.size();
41 double ampl=0;
int maxI = -1;
double maxA = -1e10;
double ta=0;
43 double lowGEnergy=0;
double lowGfc_ampl=0;
double TempLGAmp=0;
51 for (
int i=ifirst;
i<tool.
size() &&
i<n+ifirst;
i++) {
52 int capid=digi[
i].capid();
64 if((n+ifirst+lowGainOffset)<=10){
65 topLowGain=n+ifirst+lowGainOffset;
69 for (
int iLG=(ifirst+lowGainOffset); iLG<tool.
size() && iLG<topLowGain; iLG++) {
70 int capid=digi[iLG].capid();
71 TempLGAmp = (tool[iLG]-calibs.
pedestal(capid));
72 lowGfc_ampl+=TempLGAmp;
74 TempLGAmp*= lowGainFrac ;
75 lowGEnergy+=TempLGAmp;
80 if(maxI==0 || maxI==(tool.
size()-1)) {
81 LogDebug(
"HCAL Pulse") <<
"ZdcSimpleRecAlgo::reco1 :"
82 <<
" Invalid max amplitude position, "
83 <<
" max Amplitude: "<< maxI
85 <<
" last: "<<(tool.
size()-1)
88 int capid=digi[maxI-1].capid();
89 double Energy0 = ((tool[maxI-1])*calibs.
respcorrgain(capid) );
92 if(Energy0<0){Energy0=0.;}
93 capid=digi[
maxI].capid();
95 if(Energy1<0){Energy1=0.;}
96 capid=digi[maxI+1].capid();
97 double Energy2 = ((tool[maxI+1])*calibs.
respcorrgain(capid) );
98 if(Energy2<0){Energy2=0.;}
100 double TSWeightEnergy = ((maxI-1)*Energy0 + maxI*Energy1 + (maxI+1)*Energy2);
101 double EnergySum=Energy0+Energy1+Energy2;
103 if (EnergySum!=0) AvgTSPos=TSWeightEnergy/ EnergySum;
109 time = (AvgTSPos*25.0);
116 return RecHit(digi.id(),ampl,time,lowGEnergy);
120 namespace ZdcSimpleRecAlgoImpl {
121 template<
class Digi,
class RecHit>
127 int ifirst = mySignalTS[0];
129 double ampl=0;
int maxI = -1;
double maxA = -1e10;
double ta=0;
131 double lowGEnergy=0;
double lowGfc_ampl=0;
double TempLGAmp=0;
143 for(
unsigned int iv = 0; iv<myNoiseTS.size(); ++iv)
145 CurrentTS = myNoiseTS[iv];
146 Allnoise += tool[CurrentTS];
149 if(noiseslices != 0) {
150 noise = (Allnoise)/
double(noiseslices);
154 for(
unsigned int ivs = 0; ivs<mySignalTS.size(); ++ivs)
156 CurrentTS = mySignalTS[ivs];
157 int capid=digi[CurrentTS].capid();
163 ta = tool[CurrentTS]-
noise;
173 for(
unsigned int iLGvs = 0; iLGvs<mySignalTS.size(); ++iLGvs)
175 CurrentTS = mySignalTS[iLGvs]+lowGainOffset;
176 int capid=digi[CurrentTS].capid();
177 TempLGAmp = tool[CurrentTS]-
noise;
178 lowGfc_ampl+=TempLGAmp;
180 TempLGAmp*= lowGainFrac ;
181 lowGEnergy+=TempLGAmp;
190 if(maxI==0 || maxI==(tool.
size()-1)) {
191 LogDebug(
"HCAL Pulse") <<
"ZdcSimpleRecAlgo::reco2 :"
192 <<
" Invalid max amplitude position, "
193 <<
" max Amplitude: "<< maxI
194 <<
" first: "<<ifirst
195 <<
" last: "<<(tool.
size()-1)
198 int capid=digi[maxI-1].capid();
199 double Energy0 = ((tool[maxI-1])*calibs.
respcorrgain(capid) );
202 if(Energy0<0){Energy0=0.;}
203 capid=digi[
maxI].capid();
205 if(Energy1<0){Energy1=0.;}
206 capid=digi[maxI+1].capid();
207 double Energy2 = ((tool[maxI+1])*calibs.
respcorrgain(capid) );
208 if(Energy2<0){Energy2=0.;}
210 double TSWeightEnergy = ((maxI-1)*Energy0 + maxI*Energy1 + (maxI+1)*Energy2);
211 double EnergySum=Energy0+Energy1+Energy2;
213 if (EnergySum!=0) AvgTSPos=TSWeightEnergy/ EnergySum;
219 time = (AvgTSPos*25.0);
226 return RecHit(digi.id(),ampl,time,lowGEnergy);
233 return ZdcSimpleRecAlgoImpl::reco1<ZDCDataFrame,ZDCRecHit>(digi,coder,calibs,
238 return ZdcSimpleRecAlgoImpl::reco2<ZDCDataFrame,ZDCRecHit>(digi,coder,calibs,
242 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
double MaximumFractionalError
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
std::auto_ptr< HcalPulseContainmentCorrection > pulseCorr_
void initPulseCorr(int toadd)
ZdcSimpleRecAlgo(bool correctForTimeslew, bool correctForContainment, float fixedPhaseNs, int recoMethod, int lowGainOffset, double lowGainFrac)
int size() const
get the size
virtual void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const =0
volatile std::atomic< bool > shutdown_flag false
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)