Skip to content
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

HBHE: mahi speed up #25982

Merged
merged 9 commits into from Mar 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions CalibCalorimetry/HcalAlgos/interface/HcalTimeSlew.h
Expand Up @@ -21,11 +21,11 @@ class HcalTimeSlew {
class HcalTimeSlewM2Parameters{
public:
//M2 Parameters
double tzero;
double slope;
double tmax;
float tzero;
float slope;
float tmax;

HcalTimeSlewM2Parameters(double t0, double m, double tmaximum):tzero(t0), slope(m), tmax(tmaximum){}
HcalTimeSlewM2Parameters(float t0, float m, float tmaximum):tzero(t0), slope(m), tmax(tmaximum){}
};

class HcalTimeSlewM3Parameters{
Expand All @@ -45,15 +45,15 @@ class HcalTimeSlew {
HcalTimeSlew() {};
~HcalTimeSlew() {}

void addM2ParameterSet(double tzero, double slope, double tmax);
void addM2ParameterSet(float tzero, float slope, float tmax);
void addM3ParameterSet(double cap, double tspar0, double tspar1, double tspar2, double tspar0_siPM, double tspar1_siPM, double tspar2_siPM);

enum ParaSource { TestStand=0, Data=1, MC=2, HBHE=3 };
enum BiasSetting { Slow=0, Medium=1, Fast=2 };
/** \brief Returns the amount (ns) by which a pulse of the given
number of fC will be delayed by the timeslew effect, for the
specified bias setting. */
double delay(double fC, BiasSetting bias=Medium) const;
float delay(float fC, BiasSetting bias=Medium) const;
double delay(double fC, ParaSource source=HBHE, BiasSetting bias=Medium, bool isHPD=true) const;

private:
Expand Down
8 changes: 4 additions & 4 deletions CalibCalorimetry/HcalAlgos/src/HcalTimeSlew.cc
Expand Up @@ -2,7 +2,7 @@
#include <cmath>
#include <iostream>

void HcalTimeSlew::addM2ParameterSet(double tzero, double slope, double tmax){
void HcalTimeSlew::addM2ParameterSet(float tzero, float slope, float tmax){
parametersM2_.emplace_back(tzero,slope,tmax);
}

Expand All @@ -11,8 +11,8 @@ void HcalTimeSlew::addM3ParameterSet(double cap, double tspar0, double tspar1, d
}

// Used by M2/Simulation
double HcalTimeSlew::delay(double fC, BiasSetting bias) const {
double rawDelay = parametersM2_[bias].tzero + parametersM2_[bias].slope*log(fC);
float HcalTimeSlew::delay(float fC, BiasSetting bias) const {
float rawDelay = parametersM2_[bias].tzero + parametersM2_[bias].slope*std::log(fC);
return (rawDelay < 0)?(0):((rawDelay > parametersM2_[bias].tmax)?(parametersM2_[bias].tmax):(rawDelay));
}

Expand All @@ -24,7 +24,7 @@ double HcalTimeSlew::delay(double fC, ParaSource source, BiasSetting bias, bool
}
else if(isHPD){
rawDelay = std::fmin( parametersM3_[source].cap,
parametersM3_[source].tspar0+parametersM3_[source].tspar1*log(fC+parametersM3_[source].tspar2 ));
parametersM3_[source].tspar0+parametersM3_[source].tspar1*std::log(fC+parametersM3_[source].tspar2 ));
}
else{
rawDelay = parametersM3_[source].cap+parametersM3_[source].tspar0_siPM;
Expand Down
6 changes: 3 additions & 3 deletions CalibCalorimetry/HcalPlugins/src/HcalTimeSlewEP.cc
Expand Up @@ -60,9 +60,9 @@ HcalTimeSlewEP::produce(const HcalTimeSlewRecord& iRecord){

//loop over the VPSets
for(const auto& p_timeslew : p_TimeSlewM2){
double t0 = p_timeslew.getParameter<double>("tzero");
double m = p_timeslew.getParameter<double>("slope");
double tmaximum = p_timeslew.getParameter<double>("tmax");
float t0 = p_timeslew.getParameter<double>("tzero");
float m = p_timeslew.getParameter<double>("slope");
float tmaximum = p_timeslew.getParameter<double>("tmax");
hcalTimeSlew->addM2ParameterSet(t0, m, tmaximum);
}

Expand Down
24 changes: 2 additions & 22 deletions RecoLocalCalo/HcalRecAlgos/interface/MahiFit.h
Expand Up @@ -30,9 +30,6 @@ struct MahiNnlsWorkspace {
//holds data samples
SampleVector amplitudes;

//holds inverse covariance matrix
SampleMatrix invCovMat;

//holds diagonal noise terms
SampleVector noiseTerms;

Expand All @@ -43,36 +40,19 @@ struct MahiNnlsWorkspace {
//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 ampvecpermtest;

SamplePulseMatrix invcovp;
PulseMatrix aTaMat; // A-transpose A (matrix)
PulseVector aTbVec; // A-transpose b (vector)
PulseVector updateWork; // w (vector)

SampleDecompLLT covDecomp;
PulseDecompLDLT pulseDecomp;
Expand Down Expand Up @@ -154,7 +134,7 @@ class MahiFit
FullSampleVector &pulseDeriv,
FullSampleMatrix &pulseCov) const;

double calculateArrivalTime() const;
float calculateArrivalTime() const;
double calculateChiSq() const;
void nnls() const;
void resetWorkspace() const;
Expand Down Expand Up @@ -183,7 +163,7 @@ class MahiFit

bool applyTimeSlew_;
HcalTimeSlew::BiasSetting slewFlavor_;
double tsDelay1GeV_=0;
float tsDelay1GeV_=0.f;

float meanTime_;
float timeSigmaHPD_;
Expand Down
5 changes: 4 additions & 1 deletion RecoLocalCalo/HcalRecAlgos/interface/PulseShapeFunctor.h
Expand Up @@ -23,7 +23,8 @@ namespace FitterFuncs{
unsigned int nSamplesToFit);
~PulseShapeFunctor();

double EvalPulse(const double *pars, const unsigned nPar);
void EvalPulse(const double *pars);
double EvalPulseM2(const double *pars, const unsigned nPar);

void setDefaultcntNANinfit(){ cntNANinfit =0; }
int getcntNANinfit(){ return cntNANinfit; }
Expand All @@ -37,6 +38,7 @@ namespace FitterFuncs{
void setinvertpedSig2(double x) { invertpedSig2_ = x; }
void setinverttimeSig2(double x) { inverttimeSig2_ = x; }

void singlePulseShapeFuncMahi( const double *x );
double singlePulseShapeFunc( const double *x );
double doublePulseShapeFunc( const double *x );
double triplePulseShapeFunc( const double *x );
Expand All @@ -52,6 +54,7 @@ namespace FitterFuncs{
std::vector<float> acc25nsVec, diff25nsItvlVec;
std::vector<float> accVarLenIdxZEROVec, diffVarItvlIdxZEROVec;
std::vector<float> accVarLenIdxMinusOneVec, diffVarItvlIdxMinusOneVec;

void funcShape(std::array<double,HcalConst::maxSamples> & ntmpbin, const double pulseTime, const double pulseHeight,const double slew);
double psFit_x[HcalConst::maxSamples], psFit_y[HcalConst::maxSamples], psFit_erry[HcalConst::maxSamples], psFit_erry2[HcalConst::maxSamples], psFit_slew[HcalConst::maxSamples];

Expand Down