|
|
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 + noisePhoto * noisePhoto + pedWidth * pedWidth;
82 tsTOT *= channelData.
tsGain(0);
83 tstrig *= channelData.
tsGain(0);
95 doFit(reconstructedVals, 1);
97 doFit(reconstructedVals, 0);
101 doFit(reconstructedVals, 0);
105 reconstructedVals.at(0) = 0.f;
106 reconstructedVals.at(1) = -9999.f;
107 reconstructedVals.at(2) = -9999.f;
110 reconstructedEnergy = reconstructedVals[0] * channelData.
tsGain(0);
111 reconstructedTime = reconstructedVals[1];
112 chi2 = reconstructedVals[2];
116 unsigned int bxSize = 1;
134 for (
unsigned int iBX = 0; iBX < bxSize; ++iBX) {
180 bool foundintime =
false;
181 unsigned int ipulseintime = 0;
193 if (correctedOutput.at(0) != 0) {
195 float arrivalTime = 0.f;
198 correctedOutput.at(1) = arrivalTime;
200 correctedOutput.at(1) = -9999.f;
202 correctedOutput.at(2) = chiSq;
214 float oldChiSq = 9999;
215 float chiSq = oldChiSq;
227 const float deltaChiSq = newChiSq - chiSq;
229 if (newChiSq == oldChiSq && newChiSq < chiSq) {
255 std::array<double, HcalConst::maxSamples> pulseN;
256 std::array<double, HcalConst::maxSamples> pulseM;
257 std::array<double, HcalConst::maxSamples> pulseP;
264 psfPtr_->getPulseShape(pulseN);
266 psfPtr_->singlePulseShapeFuncMahi(&xxm);
267 psfPtr_->getPulseShape(pulseM);
269 psfPtr_->singlePulseShapeFuncMahi(&xxp);
270 psfPtr_->getPulseShape(pulseP);
288 for (
unsigned int jTS = 0; jTS < iTS + 1; ++jTS) {
289 auto const tmp = 0.5 * (pulseP[iTS +
delta] * pulseP[jTS +
delta] + pulseM[iTS +
delta] * pulseM[jTS +
delta]);
311 auto const ampsq = amp * amp;
359 const unsigned int nActive = npulse -
nnlsWork_.
nP;
366 Index idxwmaxprev = idxwmax;
367 float wmaxprev =
wmax;
368 wmax = updateWork.tail(nActive).maxCoeff(&idxwmax);
392 if (ampvecpermtest.head(
nnlsWork_.
nP).minCoeff() > 0.f) {
398 Index minratioidx = 0;
402 for (
unsigned int ipulse = 0; ipulse <
nnlsWork_.
nP; ++ipulse) {
403 if (ampvecpermtest.coeff(ipulse) <= 0.f) {
405 const float ratio = c_ampvec / (c_ampvec - ampvecpermtest.coeff(ipulse));
406 if (
ratio < minratio) {
408 minratioidx = ipulse;
425 if (iter % 10 == 0) {
499 float recoEnergy, recoTime,
chi2;
504 mdi.
soi = channelData.
soi();
515 for (
unsigned int iTS = 0; iTS < channelData.
nSamples(); ++iTS) {
544 mdi.
count[iTS] = iTS;
565 using namespace Eigen;
568 Matrix<float, 10, 10>
temp = mat;
569 outvec.head<10>() =
temp.ldlt().solve(invec.head<10>());
572 Matrix<float, 9, 9>
temp = mat.topLeftCorner<9, 9>();
573 outvec.head<9>() =
temp.ldlt().solve(invec.head<9>());
576 Matrix<float, 8, 8>
temp = mat.topLeftCorner<8, 8>();
577 outvec.head<8>() =
temp.ldlt().solve(invec.head<8>());
580 Matrix<float, 7, 7>
temp = mat.topLeftCorner<7, 7>();
581 outvec.head<7>() =
temp.ldlt().solve(invec.head<7>());
584 Matrix<float, 6, 6>
temp = mat.topLeftCorner<6, 6>();
585 outvec.head<6>() =
temp.ldlt().solve(invec.head<6>());
588 Matrix<float, 5, 5>
temp = mat.topLeftCorner<5, 5>();
589 outvec.head<5>() =
temp.ldlt().solve(invec.head<5>());
592 Matrix<float, 4, 4>
temp = mat.topLeftCorner<4, 4>();
593 outvec.head<4>() =
temp.ldlt().solve(invec.head<4>());
596 Matrix<float, 3, 3>
temp = mat.topLeftCorner<3, 3>();
597 outvec.head<3>() =
temp.ldlt().solve(invec.head<3>());
600 Matrix<float, 2, 2>
temp = mat.topLeftCorner<2, 2>();
601 outvec.head<2>() =
temp.ldlt().solve(invec.head<2>());
604 Matrix<float, 1, 1>
temp = mat.topLeftCorner<1, 1>();
605 outvec.head<1>() =
temp.ldlt().solve(invec.head<1>());
609 <<
"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 setPulseShapeTemplate(const HcalPulseShapes::Shape &ps, bool hasTimeInfo, const HcalTimeSlew *hcalTimeSlewDelay, unsigned int nSamples)
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)
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
std::unique_ptr< FitterFuncs::PulseShapeFunctor > psfPtr_
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)
float inNoisePhoto[MaxSVSize]
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_
void resetPulseShapeTemplate(const HcalPulseShapes::Shape &ps, bool hasTimeInfo, unsigned int nSamples)
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, 0, PulseVectorSize, PulseVectorSize > PulseMatrix
const HcalPulseShapes::Shape * currentPulseShape_
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
Abs< T >::type abs(const T &t)
constexpr unsigned soi() const
std::vector< int > activeBXs_
float inPedestal[MaxSVSize]
float calculateArrivalTime(unsigned int iBX) const
SamplePulseMatrix pulseDerivMat
void nnlsUnconstrainParameter(Index idxp) const