20 const std::vector<double>& chargeRatios,
22 const int ZdcSection) {
23 int nRatios = chargeRatios.size();
24 int nBx = bxTs.size();
30 Eigen::MatrixXf
a(nTs, nCols);
31 for (
int j = 0;
j < nBx;
j++) {
32 timeslice = bxTs.at(
j);
33 for (
int i = 0;
i < nTs;
i++) {
41 for (
int i = 0;
i < nTs;
i++)
43 Eigen::MatrixXf
b =
a.transpose() *
a;
44 if (std::fabs(
b.determinant()) < 1E-8) {
49 Eigen::MatrixXf tfMatrix;
50 tfMatrix =
b.inverse() *
a.transpose();
51 for (
int i = 0;
i < nTs;
i++)
74 const float ootpuRatio,
75 const float ootpuFrac) {
76 if (energy0 >= ootpuRatio * energy1 || ootpuRatio < 0)
77 return (ootpuFrac * energy1);
88 const std::vector<unsigned int>& myNoiseTS,
89 const std::vector<unsigned int>& mySignalTS)
const {
93 int ifirst = mySignalTS[0];
98 double energySOIp1 = 0;
99 double ratioSOIp1 = -1.0;
100 double chargeWeightedTime = -99.0;
106 int digi_size = digi.
samples();
108 int zdcsection = cell.
section();
111 for (
unsigned int iv = 0;
iv < myNoiseTS.size(); ++
iv) {
112 CurrentTS = myNoiseTS[
iv];
113 int capid = digi[CurrentTS].capid();
117 if (CurrentTS >= digi_size)
122 capid = digi[CurrentTS - 1].capid();
131 if (noiseslices != 0) {
132 noise = (Allnoise) /
double(noiseslices);
136 for (
unsigned int ivs = 0; ivs < mySignalTS.size(); ++ivs) {
137 CurrentTS = mySignalTS[ivs];
138 if (CurrentTS >= digi_size)
141 int capid = digi[CurrentTS].capid();
147 if (CurrentTS < digi_size - 1) {
148 capid = digi[CurrentTS].capid();
154 ta = energy0 -
noise;
159 ratioSOIp1 = (energy0 > 0 && energy1 > 0) ? energy0 / energy1 : -1.0;
169 int capid = digi[
iv].capid();
184 LogDebug(
"HCAL Pulse") <<
"ZdcSimpleRecAlgo::reco2 :" 185 <<
" Invalid max amplitude position, " 186 <<
" max Amplitude: " <<
maxI <<
" first: " << ifirst <<
" last: " << (tool.
size() - 1)
189 int capid = digi[
maxI - 1].capid();
192 capid = digi[
maxI].capid();
194 capid = digi[
maxI + 1].capid();
197 double TSWeightEnergy = ((
maxI - 1) * Energy0 +
maxI * Energy1 + (
maxI + 1) * Energy2);
198 double EnergySum = Energy0 + Energy1 + Energy2;
199 double AvgTSPos = 0.;
201 AvgTSPos = TSWeightEnergy / EnergySum;
207 time = (AvgTSPos * 25.0);
212 for (
unsigned int ivs = 0; ivs < mySignalTS.size(); ++ivs) {
213 CurrentTS = mySignalTS[ivs] + 1;
214 if (CurrentTS >= digi_size)
216 int capid = digi[CurrentTS].capid();
218 ta = tool[CurrentTS];
224 double tmp_energy = 0;
225 double tmp_TSWeightedEnergy = 0;
226 for (
int ts = 0; ts < digi_size; ++ts) {
227 int capid = digi[ts].capid();
234 tmp_TSWeightedEnergy += (ts)*ta;
239 chargeWeightedTime = (tmp_TSWeightedEnergy / tmp_energy) * 25.0;
244 float tmp_tdctime = 0;
245 int le_tdc = digi[
maxI].le_tdc();
248 tmp_tdctime = -1 * (le_tdc - 59);
250 tmp_tdctime =
maxI * 25. + (le_tdc / 2.0);
251 rh.setTDCtime(tmp_tdctime);
254 rh.setChargeWeightedTime(chargeWeightedTime);
255 rh.setRatioSOIp1(ratioSOIp1);
260 const std::vector<unsigned int>& myNoiseTS,
261 const std::vector<unsigned int>& mySignalTS,
267 edm::LogError(
"ZDCSimpleRecAlgoImpl::reconstruct, recoMethod was not declared");
constexpr edm::DataFrame::id_type id() const
int size() const
get the size
ZDCRecHit reconstruct(const QIE10DataFrame &digi, const std::vector< unsigned int > &myNoiseTS, const std::vector< unsigned int > &mySignalTS, const HcalCoder &coder, const HcalCalibrations &calibs, const HcalPedestal &effPeds) const
double subPedestal(const float charge, const float ped, const float width)
float getValue(int fCapId) const
get value for capId = 0..3
Log< level::Error, false > LogError
std::map< int, std::vector< double > > templateFitValues_
void initRatioSubtraction(const float ratio, const float frac, const int ZdcSection)
std::map< int, bool > templateFitValid_
std::map< int, int > correctionMethod_
constexpr double respcorrgain(int fCapId) const
get response corrected gain for capid=0..3
ZdcSimpleRecAlgo_Run3(int recoMethod)
float getWidth(int fCapId) const
get width for capId = 0..3
constexpr void setEnergySOIp1(const float en)
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
constexpr Section section() const
get the section
virtual void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const =0
void initTemplateFit(const std::vector< unsigned int > &bxTs, const std::vector< double > &chargeRatios, const int nTs, const int ZdcSection)
std::map< int, float > ootpuRatio_
std::map< int, float > ootpuFrac_
void initCorrectionMethod(const int method, const int ZdcSection)
constexpr int samples() const
total number of samples in the digi
double getNoiseOOTPURatio(const float energy0, const float energy1, const float ootpuRatio, const float ootpuFrac)
ZDCRecHit reco0(const QIE10DataFrame &digi, const HcalCoder &coder, const HcalCalibrations &calibs, const HcalPedestal &effPeds, const std::vector< unsigned int > &myNoiseTS, const std::vector< unsigned int > &mySignalTS) const