New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[HCAL] Mahi for HBHE local reconstruction #21664
Changes from 26 commits
9958112
abe1ca8
160b1e9
5041bd9
b61f6ba
c273552
b06b7b5
a149252
0022d97
538915c
9b72eed
f65bb94
9c6cf0d
617e6f0
4a8c929
9574222
314d16f
2738ad9
d5f6a61
a9bdfa9
c188729
6e1ef7d
f440c0d
860ffb0
2472ed0
dd984bd
69cb8d5
a94b00a
0827068
b4ded0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef RecoLocalCalo_HcalRecAlgos_EigenMatrixTypes_h | ||
#define RecoLocalCalo_HcalRecAlgos_EigenMatrixTypes_h | ||
|
||
#include <Eigen/Dense> | ||
|
||
constexpr int MaxSVSize=10; | ||
constexpr int MaxFSVSize=19; | ||
constexpr int MaxPVSize=10; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these are too simple to be in the global space. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. on a second thought, this namespace fold requirement is not essential in this context. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for example, at least one other definition of BXVector exists in CMSSW (for example) - a namespace (or equivalent) is needed for all of this if it needs to be in the interface directory |
||
typedef Eigen::Matrix<double,Eigen::Dynamic,1,0,MaxSVSize,1> SampleVector; | ||
typedef Eigen::Matrix<double,Eigen::Dynamic,1,0,MaxPVSize,1> PulseVector; | ||
typedef Eigen::Matrix<int,Eigen::Dynamic,1,0,MaxPVSize,1> BXVector; | ||
|
||
typedef Eigen::Matrix<double,MaxFSVSize,1> FullSampleVector; | ||
typedef Eigen::Matrix<double,MaxFSVSize,MaxFSVSize> FullSampleMatrix; | ||
|
||
typedef Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic,0,MaxSVSize,MaxSVSize> SampleMatrix; | ||
typedef Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic,0,MaxPVSize,MaxPVSize> PulseMatrix; | ||
typedef Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic,0,MaxSVSize,MaxPVSize> SamplePulseMatrix; | ||
|
||
typedef Eigen::LLT<SampleMatrix> SampleDecompLLT; | ||
typedef Eigen::LLT<PulseMatrix> PulseDecompLLT; | ||
typedef Eigen::LDLT<PulseMatrix> PulseDecompLDLT; | ||
|
||
typedef Eigen::Matrix<double,1,1> SingleMatrix; | ||
typedef Eigen::Matrix<double,1,1> SingleVector; | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
#ifndef RecoLocalCalo_HcalRecAlgos_MahiFit_HH | ||
#define RecoLocalCalo_HcalRecAlgos_MahiFit_HH | ||
|
||
#include "DataFormats/HcalDetId/interface/HcalSubdetector.h" | ||
#include "DataFormats/HcalDetId/interface/HcalDetId.h" | ||
#include "CalibFormats/HcalObjects/interface/HcalCalibrations.h" | ||
#include "CalibFormats/HcalObjects/interface/HcalCoder.h" | ||
#include "RecoLocalCalo/HcalRecAlgos/interface/EigenMatrixTypes.h" | ||
#include "DataFormats/HcalRecHit/interface/HBHEChannelInfo.h" | ||
|
||
#include "CalibCalorimetry/HcalAlgos/interface/HcalPulseShapes.h" | ||
#include "CalibCalorimetry/HcalAlgos/interface/HcalTimeSlew.h" | ||
#include "RecoLocalCalo/HcalRecAlgos/interface/PulseShapeFunctor.h" | ||
|
||
#include <Math/Functor.h> | ||
|
||
struct MahiNnlsWorkspace { | ||
|
||
unsigned int nPulseTot; | ||
unsigned int tsSize; | ||
unsigned int tsOffset; | ||
unsigned int fullTSOffset; | ||
int bxOffset; | ||
double dt; | ||
|
||
//holds active bunch crossings | ||
BXVector bxs; | ||
|
||
//holds data samples | ||
SampleVector amplitudes; | ||
|
||
//holds inverse covariance matrix | ||
SampleMatrix invCovMat; | ||
|
||
//holds diagonal noise terms | ||
SampleVector noiseTerms; | ||
|
||
//holds flat pedestal uncertainty | ||
SampleMatrix pedConstraint; | ||
|
||
//holds full covariance matrix for a pulse shape | ||
//varied in time | ||
std::array<FullSampleMatrix, MaxPVSize> pulseCovArray; | ||
|
||
//holds full pulse shape template | ||
std::array<FullSampleVector, MaxPVSize> pulseShapeArray; | ||
|
||
//holds full pulse shape derivatives | ||
std::array<FullSampleVector, MaxPVSize> pulseDerivArray; | ||
|
||
//holders for calculating pulse shape & covariance matrices | ||
std::array<double, MaxSVSize> pulseN; | ||
std::array<double, MaxSVSize> pulseM; | ||
std::array<double, MaxSVSize> pulseP; | ||
|
||
//holds matrix of pulse shape templates for each BX | ||
SamplePulseMatrix pulseMat; | ||
|
||
//holds matrix of pulse shape derivatives for each BX | ||
SamplePulseMatrix pulseDerivMat; | ||
|
||
//holds residual vector | ||
PulseVector residuals; | ||
|
||
//for FNNLS algorithm | ||
unsigned int nP; | ||
PulseVector ampVec; | ||
|
||
PulseVector errVec; | ||
PulseVector ampvecpermtest; | ||
|
||
SamplePulseMatrix invcovp; | ||
PulseMatrix aTaMat; // A-transpose A (matrix) | ||
PulseVector aTbVec; // A-transpose b (vector) | ||
PulseVector updateWork; // w (vector) | ||
|
||
SampleDecompLLT covDecomp; | ||
SampleMatrix covDecompLinv; | ||
PulseMatrix topleft_work; | ||
PulseDecompLDLT pulseDecomp; | ||
|
||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to follow up on #21664 (comment)
I do not see a reset method in the current implementation.
This implied that the struct is passed by argument There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah,I may have misinterpreted this request.This is what i did to reset everything: https://github.com/jaylawhorn/cmssw/blob/314d16ffe353ff1e6719567a146dde12c92747b9/RecoLocalCalo/HcalRecAlgos/src/MahiFit.cc#L600 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah, it's kind of covered then, I should have read the implementation in .cc |
||
|
||
class MahiFit | ||
{ | ||
public: | ||
MahiFit(); | ||
~MahiFit() { }; | ||
|
||
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); | ||
|
||
void phase1Apply(const HBHEChannelInfo& channelData, | ||
float& reconstructedEnergy, | ||
float& reconstructedTime, | ||
bool& useTriple, | ||
float& chi2) const; | ||
|
||
void doFit(std::array<float,3> &correctedOutput, int nbx) const; | ||
|
||
void setPulseShapeTemplate (const HcalPulseShapes::Shape& ps); | ||
void resetPulseShapeTemplate(const HcalPulseShapes::Shape& ps); | ||
|
||
typedef BXVector::Index Index; | ||
const HcalPulseShapes::Shape* currentPulseShape_=nullptr; | ||
|
||
private: | ||
|
||
double minimize() const; | ||
void onePulseMinimize() const; | ||
void updateCov() const; | ||
void updatePulseShape(double itQ, FullSampleVector &pulseShape, | ||
FullSampleVector &pulseDeriv, | ||
FullSampleMatrix &pulseCov) const; | ||
double calculateArrivalTime() const; | ||
double calculateChiSq() const; | ||
void nnls() const; | ||
void resetWorkspace() const; | ||
|
||
void nnlsUnconstrainParameter(Index idxp) const; | ||
void nnlsConstrainParameter(Index minratioidx) const; | ||
|
||
void solveSubmatrix(PulseMatrix& mat, PulseVector& invec, PulseVector& outvec, unsigned nP) const; | ||
|
||
double getSiPMDarkCurrent(double darkCurrent, double fcByPE, double lambda) const; | ||
|
||
mutable MahiNnlsWorkspace nnlsWork_; | ||
|
||
//hard coded in initializer | ||
const unsigned int fullTSSize_; | ||
const unsigned int fullTSofInterest_; | ||
|
||
static constexpr int pedestalBX_ = 100; | ||
|
||
// Python-configurables | ||
bool dynamicPed_; | ||
float ts4Thresh_; | ||
float chiSqSwitch_; | ||
|
||
bool applyTimeSlew_; | ||
HcalTimeSlew::BiasSetting slewFlavor_; | ||
|
||
float meanTime_; | ||
float timeSigmaHPD_; | ||
float timeSigmaSiPM_; | ||
|
||
std::vector <int> activeBXs_; | ||
|
||
int nMaxItersMin_; | ||
int nMaxItersNNLS_; | ||
|
||
float deltaChiSqThresh_; | ||
float nnlsThresh_; | ||
|
||
unsigned int bxSizeConf_; | ||
int bxOffsetConf_; | ||
|
||
//for pulse shapes | ||
int cntsetPulseShape_; | ||
std::unique_ptr<FitterFuncs::PulseShapeFunctor> psfPtr_; | ||
std::unique_ptr<ROOT::Math::Functor> pfunctor_; | ||
|
||
}; | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a header guard is missing