|
|
Go to the documentation of this file. 1 #define EIGEN_NO_DEBUG // kill throws in eigen code
12 bool iCalculateArrivalTime,
15 double iTimeSigmaSiPM,
16 const std::vector<int>& iActiveBXs,
19 double iDeltaChiSqThresh,
47 float& reconstructedEnergy,
48 float& reconstructedTime,
57 std::array<float, 3> reconstructedVals{{0.0f, -9999.f, -9999.f}};
59 double tsTOT = 0, tstrig = 0;
75 nnlsWork_.
noiseTerms.coeffRef(iTS) = noiseADC * noiseADC + noisePhotoSq + pedWidth * pedWidth;
83 tsTOT *= channelData.
tsGain(0);
84 tstrig *= channelData.
tsGain(0);
102 doFit(reconstructedVals, 1);
104 doFit(reconstructedVals, 0);
108 doFit(reconstructedVals, 0);
112 reconstructedVals.at(0) = 0.f;
113 reconstructedVals.at(1) = -9999.f;
114 reconstructedVals.at(2) = -9999.f;
117 reconstructedEnergy = reconstructedVals[0] * channelData.
tsGain(0);
118 reconstructedTime = reconstructedVals[1];
119 chi2 = reconstructedVals[2];
123 unsigned int bxSize = 1;
141 for (
unsigned int iBX = 0; iBX < bxSize; ++iBX) {
187 bool foundintime =
false;
188 unsigned int ipulseintime = 0;
200 if (correctedOutput.at(0) != 0) {
202 float arrivalTime = 0.f;
205 correctedOutput.at(1) = arrivalTime;
207 correctedOutput.at(1) = -9999.f;
209 correctedOutput.at(2) = chiSq;
225 invCovMat(
i - 1,
i) += noiseCorrTerm;
226 invCovMat(
i,
i - 1) += noiseCorrTerm;
230 float oldChiSq = 9999;
231 float chiSq = oldChiSq;
243 const float deltaChiSq = newChiSq - chiSq;
245 if (newChiSq == oldChiSq && newChiSq < chiSq) {
275 std::array<double, hcal::constants::maxSamples> pulseN;
276 std::array<double, hcal::constants::maxSamples> pulseM;
277 std::array<double, hcal::constants::maxSamples> pulseP;
308 for (
unsigned int jTS = 0; jTS < iTS + 1; ++jTS) {
309 auto const tmp = 0.5 * (pulseP[iTS +
delta] * pulseP[jTS +
delta] + pulseM[iTS +
delta] * pulseM[jTS +
delta]);
380 const unsigned int nActive = npulse -
nnlsWork_.
nP;
387 Index idxwmaxprev = idxwmax;
388 float wmaxprev =
wmax;
389 wmax = updateWork.tail(nActive).maxCoeff(&idxwmax);
413 if (ampvecpermtest.head(
nnlsWork_.
nP).minCoeff() > 0.f) {
419 Index minratioidx = 0;
423 for (
unsigned int ipulse = 0; ipulse <
nnlsWork_.
nP; ++ipulse) {
424 if (ampvecpermtest.coeff(ipulse) <= 0.f) {
426 const float ratio = c_ampvec / (c_ampvec - ampvecpermtest.coeff(ipulse));
427 if (
ratio < minratio) {
429 minratioidx = ipulse;
446 if (iter % 10 == 0) {
469 const bool hasTimeInfo,
473 assert(hcalTimeSlewDelay);
495 const unsigned int ) {
500 if (elem.first == pulseShapeId) {
509 auto p = std::make_shared<FitterFuncs::PulseShapeFunctor>(
543 float recoEnergy, recoTime,
chi2;
548 mdi.
soi = channelData.
soi();
559 for (
unsigned int iTS = 0; iTS < channelData.
nSamples(); ++iTS) {
588 mdi.
count[iTS] = iTS;
609 using namespace Eigen;
612 Matrix<float, 10, 10>
temp = mat;
613 outvec.head<10>() =
temp.ldlt().solve(invec.head<10>());
616 Matrix<float, 9, 9>
temp = mat.topLeftCorner<9, 9>();
617 outvec.head<9>() =
temp.ldlt().solve(invec.head<9>());
620 Matrix<float, 8, 8>
temp = mat.topLeftCorner<8, 8>();
621 outvec.head<8>() =
temp.ldlt().solve(invec.head<8>());
624 Matrix<float, 7, 7>
temp = mat.topLeftCorner<7, 7>();
625 outvec.head<7>() =
temp.ldlt().solve(invec.head<7>());
628 Matrix<float, 6, 6>
temp = mat.topLeftCorner<6, 6>();
629 outvec.head<6>() =
temp.ldlt().solve(invec.head<6>());
632 Matrix<float, 5, 5>
temp = mat.topLeftCorner<5, 5>();
633 outvec.head<5>() =
temp.ldlt().solve(invec.head<5>());
636 Matrix<float, 4, 4>
temp = mat.topLeftCorner<4, 4>();
637 outvec.head<4>() =
temp.ldlt().solve(invec.head<4>());
640 Matrix<float, 3, 3>
temp = mat.topLeftCorner<3, 3>();
641 outvec.head<3>() =
temp.ldlt().solve(invec.head<3>());
644 Matrix<float, 2, 2>
temp = mat.topLeftCorner<2, 2>();
645 outvec.head<2>() =
temp.ldlt().solve(invec.head<2>());
648 Matrix<float, 1, 1>
temp = mat.topLeftCorner<1, 1>();
649 outvec.head<1>() =
temp.ldlt().solve(invec.head<1>());
653 <<
"Weird number of pulses encountered in Mahi, module is configured incorrectly!";
constexpr float tsDFcPerADC(const unsigned ts) const
void updatePulseShape(const float itQ, FullSampleVector &pulseShape, FullSampleVector &pulseDeriv, FullSampleMatrix &pulseCov) const
MahiNnlsWorkspace nnlsWork_
constexpr bool hasTimeInfo() const
constexpr float tsRiseTime(const unsigned ts) const
constexpr unsigned nSamples() const
float totalUCNoise[MaxSVSize]
void singlePulseShapeFuncMahi(const float *x)
Eigen::Matrix< double, FullSampleVectorSize, FullSampleVectorSize > FullSampleMatrix
Eigen::Matrix< double, SampleVectorSize, SampleVectorSize > SampleMatrix
constexpr double tsPedestalWidth(const unsigned ts) const
void swap(Association< C > &lhs, Association< C > &rhs)
void resetPulseShapeTemplate(int pulseShapeId, const HcalPulseShapes &ps, unsigned int nSamples)
constexpr double tsGain(const unsigned ts) const
void phase1Apply(const HBHEChannelInfo &channelData, float &reconstructedEnergy, float &reconstructedTime, bool &useTriple, float &chi2) const
void resetWorkspace() const
void nnlsConstrainParameter(Index minratioidx) const
float delay(float 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...
float calculateChiSq() const
Eigen::Matrix< double, Eigen::Dynamic, 1, 0, PulseVectorSize, 1 > PulseVector
static constexpr float timeLimit_
constexpr double fcByPE() const
void setParameters(bool iDynamicPed, double iTS4Thresh, double chiSqSwitch, bool iApplyTimeSlew, HcalTimeSlew::BiasSetting slewFlavor, bool iCalculateArrivalTime, double iMeanTime, double iTimeSigmaHPD, double iTimeSigmaSiPM, const std::vector< int > &iActiveBXs, int iNMaxItersMin, int iNMaxItersNNLS, double iDeltaChiSqThresh, double iNnlsThresh)
const Shape & getShape(int shapeType) const
float inNoisePhoto[MaxSVSize]
std::vector< ShapeWithId > knownPulseShapes_
void getPulseShape(std::array< double, hcal::constants::maxSamples > &fillPulseShape)
constexpr double tsPedestal(const unsigned ts) const
bool calculateArrivalTime_
float ootPulse[7][MaxSVSize]
SamplePulseMatrix invcovp
static constexpr int pedestalBX_
void solveSubmatrix(PulseMatrix &mat, PulseVector &invec, PulseVector &outvec, unsigned nP) const
const float minimize() const
void phase1Debug(const HBHEChannelInfo &channelData, MahiDebugInfo &mdi) const
std::array< SampleMatrix, MaxPVSize > pulseCovArray
void updateCov(const SampleMatrix &invCovMat) const
Eigen::Matrix< double, SampleVectorSize, Eigen::Dynamic, 0, SampleVectorSize, PulseVectorSize > SamplePulseMatrix
SamplePulseMatrix pulseMat
void onePulseMinimize() const
Eigen::Matrix< double, SampleVectorSize, 1 > SampleVector
Eigen::Matrix< double, FullSampleVectorSize, 1 > FullSampleVector
const HcalTimeSlew * hcalTimeSlewDelay_
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, 0, PulseVectorSize, PulseVectorSize > PulseMatrix
void setPulseShapeTemplate(int pulseShapeId, const HcalPulseShapes &ps, bool hasTimeInfo, const HcalTimeSlew *hcalTimeSlewDelay, unsigned int nSamples)
SampleDecompLLT covDecomp
HcalTimeSlew::BiasSetting slewFlavor_
constexpr double tsRawCharge(const unsigned ts) const
float inNoiseADC[MaxSVSize]
void doFit(std::array< float, 3 > &correctedOutput, const int nbx) const
FitterFuncs::PulseShapeFunctor * psfPtr_
Abs< T >::type abs(const T &t)
constexpr unsigned soi() const
float calculateArrivalTime(const unsigned int iBX) const
std::vector< int > activeBXs_
constexpr double noisecorr() const
float inPedestal[MaxSVSize]
SamplePulseMatrix pulseDerivMat
void nnlsUnconstrainParameter(Index idxp) const