11 bool correctForTimeslew,
bool correctForPulse,
float phaseNS,
int recoMethod,
int lowGainOffset,
double lowGainFrac)
12 : recoMethod_(recoMethod),
13 correctForTimeslew_(correctForTimeslew),
14 correctForPulse_(correctForPulse),
16 lowGainOffset_(lowGainOffset),
17 lowGainFrac_(lowGainFrac) {}
23 pulseCorr_ = std::make_unique<HcalPulseContainmentCorrection>(
29 namespace ZdcSimpleRecAlgoImpl {
30 template <
class Digi,
class RecHit>
31 inline RecHit
reco1(
const Digi& digi,
34 const std::vector<unsigned int>& myNoiseTS,
35 const std::vector<unsigned int>& mySignalTS,
43 int ifirst = mySignalTS[0];
44 int n = mySignalTS.size();
50 double lowGEnergy = 0;
51 double lowGfc_ampl = 0;
60 for (
int i = ifirst;
i < tool.
size() &&
i < n + ifirst;
i++) {
61 int capid = digi[
i].capid();
73 if ((n + ifirst + lowGainOffset) <= 10) {
74 topLowGain = n + ifirst + lowGainOffset;
78 for (
int iLG = (ifirst + lowGainOffset); iLG < tool.
size() && iLG < topLowGain; iLG++) {
79 int capid = digi[iLG].capid();
80 TempLGAmp = (tool[iLG] - calibs.
pedestal(capid));
81 lowGfc_ampl += TempLGAmp;
83 TempLGAmp *= lowGainFrac;
84 lowGEnergy += TempLGAmp;
89 if (maxI == 0 || maxI == (tool.
size() - 1)) {
90 LogDebug(
"HCAL Pulse") <<
"ZdcSimpleRecAlgo::reco1 :"
91 <<
" Invalid max amplitude position, "
92 <<
" max Amplitude: " << maxI <<
" first: " << ifirst <<
" last: " << (tool.
size() - 1)
95 int capid = digi[maxI - 1].capid();
96 double Energy0 = ((tool[maxI - 1]) * calibs.
respcorrgain(capid));
102 capid = digi[
maxI].capid();
107 capid = digi[maxI + 1].capid();
108 double Energy2 = ((tool[maxI + 1]) * calibs.
respcorrgain(capid));
113 double TSWeightEnergy = ((maxI - 1) * Energy0 + maxI * Energy1 + (maxI + 1) * Energy2);
114 double EnergySum = Energy0 + Energy1 + Energy2;
115 double AvgTSPos = 0.;
117 AvgTSPos = TSWeightEnergy / EnergySum;
123 time = (AvgTSPos * 25.0);
125 if (corr !=
nullptr) {
130 return RecHit(digi.id(), ampl, time, lowGEnergy);
134 namespace ZdcSimpleRecAlgoImpl {
135 template <
class Digi,
class RecHit>
136 inline RecHit
reco2(
const Digi& digi,
139 const std::vector<unsigned int>& myNoiseTS,
140 const std::vector<unsigned int>& mySignalTS,
149 int ifirst = mySignalTS[0];
156 double lowGEnergy = 0;
157 double lowGfc_ampl = 0;
158 double TempLGAmp = 0;
170 for (
unsigned int iv = 0;
iv < myNoiseTS.size(); ++
iv) {
171 CurrentTS = myNoiseTS[
iv];
172 if (CurrentTS >= digi.size())
174 Allnoise += tool[CurrentTS];
177 if (noiseslices != 0) {
178 noise = (Allnoise) /
double(noiseslices);
182 for (
unsigned int ivs = 0; ivs < mySignalTS.size(); ++ivs) {
183 CurrentTS = mySignalTS[ivs];
184 if (CurrentTS >= digi.size())
186 int capid = digi[CurrentTS].capid();
192 ta = tool[CurrentTS] -
noise;
202 for (
unsigned int iLGvs = 0; iLGvs < mySignalTS.size(); ++iLGvs) {
203 CurrentTS = mySignalTS[iLGvs] + lowGainOffset;
204 if (CurrentTS >= digi.size())
206 int capid = digi[CurrentTS].capid();
207 TempLGAmp = tool[CurrentTS] -
noise;
208 lowGfc_ampl += TempLGAmp;
210 TempLGAmp *= lowGainFrac;
211 lowGEnergy += TempLGAmp;
220 if (maxI == 0 || maxI == (tool.
size() - 1)) {
221 LogDebug(
"HCAL Pulse") <<
"ZdcSimpleRecAlgo::reco2 :"
222 <<
" Invalid max amplitude position, "
223 <<
" max Amplitude: " << maxI <<
" first: " << ifirst <<
" last: " << (tool.
size() - 1)
226 int capid = digi[maxI - 1].capid();
227 double Energy0 = ((tool[maxI - 1]) * calibs.
respcorrgain(capid));
233 capid = digi[
maxI].capid();
238 capid = digi[maxI + 1].capid();
239 double Energy2 = ((tool[maxI + 1]) * calibs.
respcorrgain(capid));
244 double TSWeightEnergy = ((maxI - 1) * Energy0 + maxI * Energy1 + (maxI + 1) * Energy2);
245 double EnergySum = Energy0 + Energy1 + Energy2;
246 double AvgTSPos = 0.;
248 AvgTSPos = TSWeightEnergy / EnergySum;
254 time = (AvgTSPos * 25.0);
256 if (corr !=
nullptr) {
261 return RecHit(digi.id(), ampl, time, lowGEnergy);
266 const std::vector<unsigned int>& myNoiseTS,
267 const std::vector<unsigned int>& mySignalTS,
271 return ZdcSimpleRecAlgoImpl::reco1<ZDCDataFrame, ZDCRecHit>(
274 return ZdcSimpleRecAlgoImpl::reco2<ZDCDataFrame, ZDCRecHit>(
277 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)
void initPulseCorr(int toadd, const HcalTimeSlew *hcalTimeSlew_delay)
double getCorrection(double fc_ampl) const
Log< level::Error, false > LogError
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)
constexpr double MaximumFractionalError
constexpr double pedestal(int fCapId) const
get pedestal for capid=0..3
std::unique_ptr< HcalPulseContainmentCorrection > pulseCorr_
int size() const
get the size
virtual void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const =0
constexpr double respcorrgain(int fCapId) const
get response corrected gain for capid=0..3
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)