11 double iMeanTime,
double iTimeSigmaHPD,
double iTimeSigmaSiPM,
12 const std::vector <int> &iActiveBXs,
int iNMaxItersMin,
int iNMaxItersNNLS,
13 double iDeltaChiSqThresh,
double iNnlsThresh) {
41 float& reconstructedEnergy,
42 float& reconstructedTime,
69 std::array<float,3> reconstructedVals {{ 0.0, -9999, -9999 }};
71 double tsTOT = 0, tstrig = 0;
82 double noisePhoto = 0;
84 noisePhoto =
sqrt((charge-ped)*channelData.
fcByPE());
91 nnlsWork_.
noiseTerms.coeffRef(iTS) = noiseADC*noiseADC + noisePhoto*noisePhoto + pedWidth*pedWidth;
93 tsTOT += (charge - ped)*channelData.
tsGain(0);
95 tstrig += (charge - ped)*channelData.
tsGain(0);
105 doFit(reconstructedVals,1);
107 doFit(reconstructedVals,0);
112 doFit(reconstructedVals,0);
117 reconstructedVals.at(0) = 0.;
118 reconstructedVals.at(1) = -9999.;
119 reconstructedVals.at(2) = -9999.;
122 reconstructedEnergy = reconstructedVals[0]*channelData.
tsGain(0);
123 reconstructedTime = reconstructedVals[1];
124 chi2 = reconstructedVals[2];
130 unsigned int bxSize=1;
149 for (
unsigned int iBX=0; iBX<bxSize; ++iBX) {
192 bool foundintime =
false;
193 unsigned int ipulseintime = 0;
204 if (correctedOutput.at(0)!=0) {
206 correctedOutput.at(1) = arrivalTime;
208 else correctedOutput.at(1) = -9999;
210 correctedOutput.at(2) = chiSq;
218 double oldChiSq=9999;
219 double chiSq=oldChiSq;
233 double deltaChiSq = newChiSq - chiSq;
235 if (newChiSq==oldChiSq && newChiSq<chiSq) {
263 const double xx[4]={
t0, 1.0, 0.0, 3};
267 (*pfunctor_)(&xx[0]);
270 (*pfunctor_)(&xxm[0]);
273 (*pfunctor_)(&xxp[0]);
290 for (
unsigned int jTS=0; jTS<iTS+1; ++jTS) {
335 if (offset==0) itIndex=iBX;
373 const unsigned int nActive = npulse -
nnlsWork_.
nP;
376 Index idxwmaxprev = idxwmax;
377 double wmaxprev = wmax;
380 if (wmax<threshold || (idxwmax==idxwmaxprev && wmax==wmaxprev)) {
402 bool positive =
true;
415 for (
unsigned int ipulse=0; ipulse<
nnlsWork_.
nP; ++ipulse) {
419 if (ratio<minratio) {
421 minratioidx = ipulse;
512 float recoEnergy, recoTime,
chi2;
514 phase1Apply(channelData, recoEnergy, recoTime, use3, chi2);
518 mdi.
soi = channelData.
soi();
529 for (
unsigned int iTS=0; iTS<channelData.
nSamples(); ++iTS) {
558 mdi.
count[iTS] = iTS;
583 using namespace Eigen;
587 Matrix<double,10,10>
temp = mat;
588 outvec.head<10>() = temp.ldlt().solve(invec.head<10>());
593 Matrix<double,9,9>
temp = mat.topLeftCorner<9,9>();
594 outvec.head<9>() = temp.ldlt().solve(invec.head<9>());
599 Matrix<double,8,8>
temp = mat.topLeftCorner<8,8>();
600 outvec.head<8>() = temp.ldlt().solve(invec.head<8>());
605 Matrix<double,7,7>
temp = mat.topLeftCorner<7,7>();
606 outvec.head<7>() = temp.ldlt().solve(invec.head<7>());
611 Matrix<double,6,6>
temp = mat.topLeftCorner<6,6>();
612 outvec.head<6>() = temp.ldlt().solve(invec.head<6>());
617 Matrix<double,5,5>
temp = mat.topLeftCorner<5,5>();
618 outvec.head<5>() = temp.ldlt().solve(invec.head<5>());
623 Matrix<double,4,4>
temp = mat.topLeftCorner<4,4>();
624 outvec.head<4>() = temp.ldlt().solve(invec.head<4>());
629 Matrix<double,3,3>
temp = mat.topLeftCorner<3,3>();
630 outvec.head<3>() = temp.ldlt().solve(invec.head<3>());
635 Matrix<double,2,2>
temp = mat.topLeftCorner<2,2>();
636 outvec.head<2>() = temp.ldlt().solve(invec.head<2>());
641 Matrix<double,1,1>
temp = mat.topLeftCorner<1,1>();
642 outvec.head<1>() = temp.ldlt().solve(invec.head<1>());
647 <<
"Weird number of pulses encountered in Mahi, module is configured incorrectly!";
void phase1Apply(const HBHEChannelInfo &channelData, float &reconstructedEnergy, float &reconstructedTime, bool &useTriple, float &chi2) const
SamplePulseMatrix invcovp
HcalTimeSlew::BiasSetting slewFlavor_
double tsGain(const unsigned ts) const
void nnlsConstrainParameter(Index minratioidx) const
MahiNnlsWorkspace nnlsWork_
double singlePulseShapeFunc(const double *x)
void solveSubmatrix(PulseMatrix &mat, PulseVector &invec, PulseVector &outvec, unsigned nP) const
double delay(double fC, BiasSetting bias=Medium) const
Returns the amount (ns) by which a pulse of the given number of fC will be delayed by the timeslew ef...
void resetPulseShapeTemplate(const HcalPulseShapes::Shape &ps)
SampleDecompLLT covDecomp
PulseVector ampvecpermtest
std::array< FullSampleVector, MaxPVSize > pulseShapeArray
void nnlsUnconstrainParameter(Index idxp) const
std::array< double, MaxSVSize > pulseM
double tsPedestal(const unsigned ts) const
float totalUCNoise[MaxSVSize]
float inNoiseADC[MaxSVSize]
SamplePulseMatrix pulseDerivMat
std::array< double, MaxSVSize > pulseN
double tsRawCharge(const unsigned ts) const
float inPedestal[MaxSVSize]
void onePulseMinimize() const
std::unique_ptr< FitterFuncs::PulseShapeFunctor > psfPtr_
Eigen::Matrix< double, FullSampleVectorSize, 1 > FullSampleVector
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
void doFit(std::array< float, 3 > &correctedOutput, const int nbx) const
Eigen::Matrix< double, 1, 1 > SingleVector
Abs< T >::type abs(const T &t)
double calculateArrivalTime() const
SampleMatrix pedConstraint
std::vector< int > activeBXs_
std::array< FullSampleVector, MaxPVSize > pulseDerivArray
const unsigned int fullTSofInterest_
void updatePulseShape(double itQ, FullSampleVector &pulseShape, FullSampleVector &pulseDeriv, FullSampleMatrix &pulseCov) const
void resetWorkspace() const
void phase1Debug(const HBHEChannelInfo &channelData, MahiDebugInfo &mdi) const
std::unique_ptr< ROOT::Math::Functor > pfunctor_
Eigen::Matrix< double, FullSampleVectorSize, FullSampleVectorSize > FullSampleMatrix
float tsRiseTime(const unsigned ts) const
double tsPedestalWidth(const unsigned ts) const
double calculateChiSq() const
unsigned int fullTSOffset
Eigen::Matrix< double, Eigen::Dynamic, 1, 0, PulseVectorSize, 1 > PulseVector
SamplePulseMatrix pulseMat
std::array< FullSampleMatrix, MaxPVSize > pulseCovArray
float inNoisePhoto[MaxSVSize]
std::vector< std::vector< double > > tmp
void setParameters(bool iDynamicPed, double iTS4Thresh, double chiSqSwitch, bool iApplyTimeSlew, HcalTimeSlew::BiasSetting slewFlavor, double iMeanTime, double iTimeSigmaHPD, double iTimeSigmaSiPM, const std::vector< int > &iActiveBXs, int iNMaxItersMin, int iNMaxItersNNLS, double iDeltaChiSqThresh, double iNnlsThresh)
const HcalTimeSlew * hcalTimeSlewDelay_
const HcalPulseShapes::Shape * currentPulseShape_
unsigned nSamples() const
std::array< double, MaxSVSize > pulseP
Eigen::Matrix< double, 1, 1 > SingleMatrix
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, 0, PulseVectorSize, PulseVectorSize > PulseMatrix
float tsDFcPerADC(const unsigned ts) const
void setPulseShapeTemplate(const HcalPulseShapes::Shape &ps, const HcalTimeSlew *hcalTimeSlewDelay)