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) {
190 bool foundintime =
false;
191 unsigned int ipulseintime = 0;
202 if (correctedOutput.at(0)!=0) {
204 correctedOutput.at(1) = arrivalTime;
206 else correctedOutput.at(1) = -9999;
208 correctedOutput.at(2) = chiSq;
216 double oldChiSq=9999;
217 double chiSq=oldChiSq;
231 double deltaChiSq = newChiSq - chiSq;
233 if (newChiSq==oldChiSq && newChiSq<chiSq) {
261 const double xx[4]={
t0, 1.0, 0.0, 3};
265 (*pfunctor_)(&xx[0]);
268 (*pfunctor_)(&xxm[0]);
271 (*pfunctor_)(&xxp[0]);
288 for (
unsigned int jTS=0; jTS<iTS+1; ++jTS) {
333 if (offset==0) itIndex=iBX;
371 const unsigned int nActive = npulse -
nnlsWork_.
nP;
374 Index idxwmaxprev = idxwmax;
375 double wmaxprev = wmax;
378 if (wmax<threshold || (idxwmax==idxwmaxprev && wmax==wmaxprev)) {
400 bool positive =
true;
413 for (
unsigned int ipulse=0; ipulse<
nnlsWork_.
nP; ++ipulse) {
417 if (ratio<minratio) {
419 minratioidx = ipulse;
510 float recoEnergy, recoTime,
chi2;
512 phase1Apply(channelData, recoEnergy, recoTime, use3, chi2);
516 mdi.
soi = channelData.
soi();
527 for (
unsigned int iTS=0; iTS<channelData.
nSamples(); ++iTS) {
556 mdi.
count[iTS] = iTS;
581 using namespace Eigen;
585 Matrix<double,10,10>
temp = mat;
586 outvec.head<10>() = temp.ldlt().solve(invec.head<10>());
591 Matrix<double,9,9>
temp = mat.topLeftCorner<9,9>();
592 outvec.head<9>() = temp.ldlt().solve(invec.head<9>());
597 Matrix<double,8,8>
temp = mat.topLeftCorner<8,8>();
598 outvec.head<8>() = temp.ldlt().solve(invec.head<8>());
603 Matrix<double,7,7>
temp = mat.topLeftCorner<7,7>();
604 outvec.head<7>() = temp.ldlt().solve(invec.head<7>());
609 Matrix<double,6,6>
temp = mat.topLeftCorner<6,6>();
610 outvec.head<6>() = temp.ldlt().solve(invec.head<6>());
615 Matrix<double,5,5>
temp = mat.topLeftCorner<5,5>();
616 outvec.head<5>() = temp.ldlt().solve(invec.head<5>());
621 Matrix<double,4,4>
temp = mat.topLeftCorner<4,4>();
622 outvec.head<4>() = temp.ldlt().solve(invec.head<4>());
627 Matrix<double,3,3>
temp = mat.topLeftCorner<3,3>();
628 outvec.head<3>() = temp.ldlt().solve(invec.head<3>());
633 Matrix<double,2,2>
temp = mat.topLeftCorner<2,2>();
634 outvec.head<2>() = temp.ldlt().solve(invec.head<2>());
639 Matrix<double,1,1>
temp = mat.topLeftCorner<1,1>();
640 outvec.head<1>() = temp.ldlt().solve(invec.head<1>());
645 <<
"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)