Skip to content

Commit 1313262

Browse files
authored
Merge pull request cms-sw#25982 from mariadalfonso/MahiCPUcleanup
HBHE: mahi speed up
2 parents 40d2157 + 4b3a7c4 commit 1313262

File tree

7 files changed

+105
-108
lines changed

7 files changed

+105
-108
lines changed

CalibCalorimetry/HcalAlgos/interface/HcalTimeSlew.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ class HcalTimeSlew {
2121
class HcalTimeSlewM2Parameters{
2222
public:
2323
//M2 Parameters
24-
double tzero;
25-
double slope;
26-
double tmax;
24+
float tzero;
25+
float slope;
26+
float tmax;
2727

28-
HcalTimeSlewM2Parameters(double t0, double m, double tmaximum):tzero(t0), slope(m), tmax(tmaximum){}
28+
HcalTimeSlewM2Parameters(float t0, float m, float tmaximum):tzero(t0), slope(m), tmax(tmaximum){}
2929
};
3030

3131
class HcalTimeSlewM3Parameters{
@@ -45,15 +45,15 @@ class HcalTimeSlew {
4545
HcalTimeSlew() {};
4646
~HcalTimeSlew() {}
4747

48-
void addM2ParameterSet(double tzero, double slope, double tmax);
48+
void addM2ParameterSet(float tzero, float slope, float tmax);
4949
void addM3ParameterSet(double cap, double tspar0, double tspar1, double tspar2, double tspar0_siPM, double tspar1_siPM, double tspar2_siPM);
5050

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

5959
private:

CalibCalorimetry/HcalAlgos/src/HcalTimeSlew.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <cmath>
33
#include <iostream>
44

5-
void HcalTimeSlew::addM2ParameterSet(double tzero, double slope, double tmax){
5+
void HcalTimeSlew::addM2ParameterSet(float tzero, float slope, float tmax){
66
parametersM2_.emplace_back(tzero,slope,tmax);
77
}
88

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

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

@@ -24,7 +24,7 @@ double HcalTimeSlew::delay(double fC, ParaSource source, BiasSetting bias, bool
2424
}
2525
else if(isHPD){
2626
rawDelay = std::fmin( parametersM3_[source].cap,
27-
parametersM3_[source].tspar0+parametersM3_[source].tspar1*log(fC+parametersM3_[source].tspar2 ));
27+
parametersM3_[source].tspar0+parametersM3_[source].tspar1*std::log(fC+parametersM3_[source].tspar2 ));
2828
}
2929
else{
3030
rawDelay = parametersM3_[source].cap+parametersM3_[source].tspar0_siPM;

CalibCalorimetry/HcalPlugins/src/HcalTimeSlewEP.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ HcalTimeSlewEP::produce(const HcalTimeSlewRecord& iRecord){
6060

6161
//loop over the VPSets
6262
for(const auto& p_timeslew : p_TimeSlewM2){
63-
double t0 = p_timeslew.getParameter<double>("tzero");
64-
double m = p_timeslew.getParameter<double>("slope");
65-
double tmaximum = p_timeslew.getParameter<double>("tmax");
63+
float t0 = p_timeslew.getParameter<double>("tzero");
64+
float m = p_timeslew.getParameter<double>("slope");
65+
float tmaximum = p_timeslew.getParameter<double>("tmax");
6666
hcalTimeSlew->addM2ParameterSet(t0, m, tmaximum);
6767
}
6868

RecoLocalCalo/HcalRecAlgos/interface/MahiFit.h

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ struct MahiNnlsWorkspace {
3030
//holds data samples
3131
SampleVector amplitudes;
3232

33-
//holds inverse covariance matrix
34-
SampleMatrix invCovMat;
35-
3633
//holds diagonal noise terms
3734
SampleVector noiseTerms;
3835

@@ -43,36 +40,19 @@ struct MahiNnlsWorkspace {
4340
//varied in time
4441
std::array<FullSampleMatrix, MaxPVSize> pulseCovArray;
4542

46-
//holds full pulse shape template
47-
std::array<FullSampleVector, MaxPVSize> pulseShapeArray;
48-
49-
//holds full pulse shape derivatives
50-
std::array<FullSampleVector, MaxPVSize> pulseDerivArray;
51-
52-
//holders for calculating pulse shape & covariance matrices
53-
std::array<double, MaxSVSize> pulseN;
54-
std::array<double, MaxSVSize> pulseM;
55-
std::array<double, MaxSVSize> pulseP;
56-
5743
//holds matrix of pulse shape templates for each BX
5844
SamplePulseMatrix pulseMat;
5945

6046
//holds matrix of pulse shape derivatives for each BX
6147
SamplePulseMatrix pulseDerivMat;
6248

63-
//holds residual vector
64-
PulseVector residuals;
65-
6649
//for FNNLS algorithm
6750
unsigned int nP;
6851
PulseVector ampVec;
6952

70-
PulseVector ampvecpermtest;
71-
7253
SamplePulseMatrix invcovp;
7354
PulseMatrix aTaMat; // A-transpose A (matrix)
7455
PulseVector aTbVec; // A-transpose b (vector)
75-
PulseVector updateWork; // w (vector)
7656

7757
SampleDecompLLT covDecomp;
7858
PulseDecompLDLT pulseDecomp;
@@ -154,7 +134,7 @@ class MahiFit
154134
FullSampleVector &pulseDeriv,
155135
FullSampleMatrix &pulseCov) const;
156136

157-
double calculateArrivalTime() const;
137+
float calculateArrivalTime() const;
158138
double calculateChiSq() const;
159139
void nnls() const;
160140
void resetWorkspace() const;
@@ -183,7 +163,7 @@ class MahiFit
183163

184164
bool applyTimeSlew_;
185165
HcalTimeSlew::BiasSetting slewFlavor_;
186-
double tsDelay1GeV_=0;
166+
float tsDelay1GeV_=0.f;
187167

188168
float meanTime_;
189169
float timeSigmaHPD_;

RecoLocalCalo/HcalRecAlgos/interface/PulseShapeFunctor.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ namespace FitterFuncs{
2323
unsigned int nSamplesToFit);
2424
~PulseShapeFunctor();
2525

26-
double EvalPulse(const double *pars, const unsigned nPar);
26+
void EvalPulse(const double *pars);
27+
double EvalPulseM2(const double *pars, const unsigned nPar);
2728

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

41+
void singlePulseShapeFuncMahi( const double *x );
4042
double singlePulseShapeFunc( const double *x );
4143
double doublePulseShapeFunc( const double *x );
4244
double triplePulseShapeFunc( const double *x );
@@ -52,6 +54,7 @@ namespace FitterFuncs{
5254
std::vector<float> acc25nsVec, diff25nsItvlVec;
5355
std::vector<float> accVarLenIdxZEROVec, diffVarItvlIdxZEROVec;
5456
std::vector<float> accVarLenIdxMinusOneVec, diffVarItvlIdxMinusOneVec;
57+
5558
void funcShape(std::array<double,HcalConst::maxSamples> & ntmpbin, const double pulseTime, const double pulseHeight,const double slew);
5659
double psFit_x[HcalConst::maxSamples], psFit_y[HcalConst::maxSamples], psFit_erry[HcalConst::maxSamples], psFit_erry2[HcalConst::maxSamples], psFit_slew[HcalConst::maxSamples];
5760

0 commit comments

Comments
 (0)