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

Optional use of Max-Sample algorithm for gain-switch cases #17279

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class EcalUncalibRecHitMultiFitAlgo
void setSelectiveBadSampleCriteria(bool b) { _selectiveBadSampleCriteria = b; }
void setAddPedestalUncertainty(double x) { _addPedestalUncertainty = x; }
void setSimplifiedNoiseModelForGainSwitch(bool b) { _simplifiedNoiseModelForGainSwitch = b; }
void setGainSwitchUseMaxSample(bool b) { _gainSwitchUseMaxSample = b; }

private:
PulseChiSqSNNLS _pulsefunc;
Expand All @@ -46,6 +47,7 @@ class EcalUncalibRecHitMultiFitAlgo
bool _selectiveBadSampleCriteria;
double _addPedestalUncertainty;
bool _simplifiedNoiseModelForGainSwitch;
bool _gainSwitchUseMaxSample;
BXVector _singlebx;

};
Expand Down
26 changes: 20 additions & 6 deletions RecoLocalCalo/EcalRecAlgos/src/EcalUncalibRecHitMultiFitAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ EcalUncalibRecHitMultiFitAlgo::EcalUncalibRecHitMultiFitAlgo() :
_mitigateBadSamples(false),
_selectiveBadSampleCriteria(false),
_addPedestalUncertainty(0.),
_simplifiedNoiseModelForGainSwitch(true) {
_simplifiedNoiseModelForGainSwitch(true),
_gainSwitchUseMaxSample(false){

_singlebx.resize(1);
_singlebx << 0;
Expand Down Expand Up @@ -105,20 +106,33 @@ EcalUncalibratedRecHit EcalUncalibRecHitMultiFitAlgo::makeRecHit(const EcalDataF
}

}


double amplitude, amperr, chisq;
bool status = false;

//special handling for gain switch, where sample before maximum is potentially affected by slew rate limitation
//optionally apply a stricter criteria, assuming slew rate limit is only reached in case where maximum sample has gain switched but previous sample has not
//A floating negative single-sample offset is added to the fit
//option 1: use simple max-sample algorithm
if (hasGainSwitch && _gainSwitchUseMaxSample) {
EcalUncalibratedRecHit rh( dataFrame.id(), maxamplitude, pedval, 0., 0., flags );
rh.setAmplitudeError(0.);
for (unsigned int ipulse=0; ipulse<_pulsefunc.BXs().rows(); ++ipulse) {
int bx = _pulsefunc.BXs().coeff(ipulse);
if (bx!=0) {
rh.setOutOfTimeAmplitude(bx+5, 0.0);
}
}
return rh;
}

//option2: A floating negative single-sample offset is added to the fit
//such that the affected sample is treated only as a lower limit for the true amplitude
bool mitigateBadSample = _mitigateBadSamples && hasGainSwitch && iSampleMax>0;
mitigateBadSample &= (!_selectiveBadSampleCriteria || (gainsNoise.coeff(iSampleMax-1)!=gainsNoise.coeff(iSampleMax)) );
if (mitigateBadSample) {
badSamples[iSampleMax-1] = 1;
}

double amplitude, amperr, chisq;
bool status = false;

//compute noise covariance matrix, which depends on the sample gains
SampleMatrix noisecov;
if (hasGainSwitch) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ EcalUncalibRecHitWorkerMultiFit::EcalUncalibRecHitWorkerMultiFit(const edm::Para
dynamicPedestalsEE_ = ps.getParameter<bool>("dynamicPedestalsEE");
mitigateBadSamplesEB_ = ps.getParameter<bool>("mitigateBadSamplesEB");
mitigateBadSamplesEE_ = ps.getParameter<bool>("mitigateBadSamplesEE");
gainSwitchUseMaxSampleEB_ = ps.getParameter<bool>("gainSwitchUseMaxSampleEB");
gainSwitchUseMaxSampleEE_ = ps.getParameter<bool>("gainSwitchUseMaxSampleEE");
selectiveBadSampleCriteriaEB_ = ps.getParameter<bool>("selectiveBadSampleCriteriaEB");
selectiveBadSampleCriteriaEE_ = ps.getParameter<bool>("selectiveBadSampleCriteriaEE");
addPedestalUncertaintyEB_ = ps.getParameter<double>("addPedestalUncertaintyEB");
Expand Down Expand Up @@ -281,6 +283,7 @@ EcalUncalibRecHitWorkerMultiFit::run( const edm::Event & evt,
multiFitMethod_.setPrefitMaxChiSq(prefitMaxChiSqEE_);
multiFitMethod_.setDynamicPedestals(dynamicPedestalsEE_);
multiFitMethod_.setMitigateBadSamples(mitigateBadSamplesEE_);
multiFitMethod_.setGainSwitchUseMaxSample(gainSwitchUseMaxSampleEE_);
multiFitMethod_.setSelectiveBadSampleCriteria(selectiveBadSampleCriteriaEE_);
multiFitMethod_.setAddPedestalUncertainty(addPedestalUncertaintyEE_);
offsetTime = offtime->getEEValue();
Expand All @@ -293,11 +296,12 @@ EcalUncalibRecHitWorkerMultiFit::run( const edm::Event & evt,
aPulseCov = &pulsecovariances->barrel(hashedIndex);
multiFitMethod_.setDoPrefit(doPrefitEB_);
multiFitMethod_.setPrefitMaxChiSq(prefitMaxChiSqEB_);
offsetTime = offtime->getEBValue();
multiFitMethod_.setDynamicPedestals(dynamicPedestalsEB_);
multiFitMethod_.setMitigateBadSamples(mitigateBadSamplesEB_);
multiFitMethod_.setGainSwitchUseMaxSample(gainSwitchUseMaxSampleEB_);
multiFitMethod_.setSelectiveBadSampleCriteria(selectiveBadSampleCriteriaEB_);
multiFitMethod_.setAddPedestalUncertainty(addPedestalUncertaintyEB_);
offsetTime = offtime->getEBValue();
}

double pedVec[3] = { aped->mean_x12, aped->mean_x6, aped->mean_x1 };
Expand Down Expand Up @@ -598,6 +602,8 @@ EcalUncalibRecHitWorkerMultiFit::getAlgoDescription() {
edm::ParameterDescription<bool>("dynamicPedestalsEE", false, true) and
edm::ParameterDescription<bool>("mitigateBadSamplesEB", false, true) and
edm::ParameterDescription<bool>("mitigateBadSamplesEE", false, true) and
edm::ParameterDescription<bool>("gainSwitchUseMaxSampleEB", false, true) and
edm::ParameterDescription<bool>("gainSwitchUseMaxSampleEE", false, true) and
edm::ParameterDescription<bool>("selectiveBadSampleCriteriaEB", false, true) and
edm::ParameterDescription<bool>("selectiveBadSampleCriteriaEE", false, true) and
edm::ParameterDescription<double>("addPedestalUncertaintyEB", 0., true) and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ class EcalUncalibRecHitWorkerMultiFit final : public EcalUncalibRecHitWorkerBase
bool dynamicPedestalsEE_;
bool mitigateBadSamplesEB_;
bool mitigateBadSamplesEE_;
bool gainSwitchUseMaxSampleEB_;
bool gainSwitchUseMaxSampleEE_;
bool selectiveBadSampleCriteriaEB_;
bool selectiveBadSampleCriteriaEE_;
double addPedestalUncertaintyEB_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
dynamicPedestalsEE = cms.bool(False),
mitigateBadSamplesEB = cms.bool(False),
mitigateBadSamplesEE = cms.bool(False),
gainSwitchUseMaxSampleEB = cms.bool(False),
gainSwitchUseMaxSampleEE = cms.bool(False),
selectiveBadSampleCriteriaEB = cms.bool(False),
selectiveBadSampleCriteriaEE = cms.bool(False),
simplifiedNoiseModelForGainSwitch = cms.bool(True),
Expand Down