Skip to content

Commit

Permalink
Merge pull request #11507 from igv4321/always-run-hcal-method3
Browse files Browse the repository at this point in the history
Permanently enabling method 3
  • Loading branch information
cmsbuild committed Oct 1, 2015
2 parents edd325e + bb4492a commit 3cca4f7
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 57 deletions.
13 changes: 6 additions & 7 deletions RecoLocalCalo/HcalRecAlgos/interface/HcalSimpleRecAlgo.h
Expand Up @@ -43,9 +43,6 @@ class HcalSimpleRecAlgo {
HcalSimpleRecAlgo(bool correctForTimeslew,
bool correctForContainment, float fixedPhaseNs);

/** Simple constructor for PMT-based detectors */
HcalSimpleRecAlgo();

void beginRun(edm::EventSetup const & es);
void endRun();

Expand Down Expand Up @@ -80,17 +77,17 @@ class HcalSimpleRecAlgo {
HcalCalibRecHit reconstruct(const HcalCalibDataFrame& digi, int first, int toadd, const HcalCoder& coder, const HcalCalibrations& calibs) const;

void setpuCorrMethod(int method){
puCorrMethod_ = method; if( puCorrMethod_ == 2 ) psFitOOTpuCorr_ = std::auto_ptr<PulseShapeFitOOTPileupCorrection>(new PulseShapeFitOOTPileupCorrection());
if( puCorrMethod_ == 3) hltOOTpuCorr_ = std::auto_ptr<HcalDeterministicFit>(new HcalDeterministicFit());
puCorrMethod_ = method;
if( puCorrMethod_ == 2 )
psFitOOTpuCorr_ = std::auto_ptr<PulseShapeFitOOTPileupCorrection>(new PulseShapeFitOOTPileupCorrection());
}

void setpuCorrParams(bool iPedestalConstraint, bool iTimeConstraint,bool iAddPulseJitter,bool iUnConstrainedFit,bool iApplyTimeSlew,
double iTS4Min, double iTS4Max, double iPulseJitter,double iTimeMean,double iTimeSig,double iPedMean,double iPedSig,
double iNoise,double iTMin,double iTMax,
double its3Chi2,double its4Chi2,double its345Chi2,double iChargeThreshold, int iFitTimes);
void setMeth3Params(int iPedSubMethod, float iPedSubThreshold, int iTimeSlewParsType, std::vector<double> iTimeSlewPars, double irespCorrM3);

std::auto_ptr<PedestalSub> pedSubFxn_= std::auto_ptr<PedestalSub>(new PedestalSub());

private:
bool correctForTimeslew_;
bool correctForPulse_;
Expand All @@ -111,6 +108,8 @@ class HcalSimpleRecAlgo {

std::auto_ptr<PulseShapeFitOOTPileupCorrection> psFitOOTpuCorr_;

std::auto_ptr<PedestalSub> pedSubFxn_;

// S.Brandt Feb19 : Add a pointer to the HLT algo
std::auto_ptr<HcalDeterministicFit> hltOOTpuCorr_;
};
Expand Down
79 changes: 42 additions & 37 deletions RecoLocalCalo/HcalRecAlgos/src/HcalSimpleRecAlgo.cc
Expand Up @@ -19,17 +19,10 @@ HcalSimpleRecAlgo::HcalSimpleRecAlgo(bool correctForTimeslew, bool correctForPul
correctForTimeslew_(correctForTimeslew),
correctForPulse_(correctForPulse),
phaseNS_(phaseNS), runnum_(0), setLeakCorrection_(false), puCorrMethod_(0)
{

pulseCorr_ = std::auto_ptr<HcalPulseContainmentManager>(
new HcalPulseContainmentManager(MaximumFractionalError)
);
}


HcalSimpleRecAlgo::HcalSimpleRecAlgo() :
correctForTimeslew_(false), runnum_(0), puCorrMethod_(0)
{
{
pulseCorr_ = std::auto_ptr<HcalPulseContainmentManager>(new HcalPulseContainmentManager(MaximumFractionalError));
pedSubFxn_ = std::auto_ptr<PedestalSub>(new PedestalSub());
hltOOTpuCorr_ = std::auto_ptr<HcalDeterministicFit>(new HcalDeterministicFit());
}


Expand Down Expand Up @@ -326,7 +319,7 @@ namespace HcalSimpleRecAlgoImpl {
const AbsOOTPileupCorrection* pileupCorrection,
const BunchXParameter* bxInfo, const unsigned lenInfo, const int puCorrMethod, const PulseShapeFitOOTPileupCorrection * psFitOOTpuCorr, HcalDeterministicFit * hltOOTpuCorr, PedestalSub * hltPedSub /* whatever don't know what to do with the pointer...*/)// const on end
{
double fc_ampl =0, ampl =0, uncorr_ampl =0, maxA = -1.e300;
double fc_ampl =0, ampl =0, uncorr_ampl =0, m3_ampl =0, maxA = -1.e300;
int nRead = 0, maxI = -1;
bool leakCorrApplied = false;
float t0 =0, t2 =0;
Expand Down Expand Up @@ -361,11 +354,11 @@ namespace HcalSimpleRecAlgoImpl {

// Note that uncorr_ampl is always set from outside of method 2!
if( puCorrMethod == 2 ){
std::vector<double> correctedOutput;
std::vector<double> correctedOutput;

CaloSamples cs;
coder.adc2fC(digi,cs);
std::vector<int> capidvec;
CaloSamples cs;
coder.adc2fC(digi,cs);
std::vector<int> capidvec;
for(int ip=0; ip<cs.size(); ip++){
const int capid = digi[ip].capid();
capidvec.push_back(capid);
Expand All @@ -377,10 +370,10 @@ namespace HcalSimpleRecAlgoImpl {
}

// S. Brandt - Feb 19th : Adding Section for HLT
// Turn on HLT here with puCorrMethod = 3
if ( puCorrMethod == 3){
// Run "Method 3" all the time.
{
std::vector<double> hltCorrOutput;

CaloSamples cs;
coder.adc2fC(digi,cs);
std::vector<int> capidvec;
Expand All @@ -390,7 +383,10 @@ namespace HcalSimpleRecAlgoImpl {
}
hltOOTpuCorr->apply(cs, capidvec, calibs, digi, hltCorrOutput);
if( hltCorrOutput.size() > 1 ){
time = hltCorrOutput[1]; ampl = hltCorrOutput[0];
m3_ampl = hltCorrOutput[0];
if (puCorrMethod == 3) {
time = hltCorrOutput[1]; ampl = hltCorrOutput[0];
}
}
}

Expand All @@ -400,33 +396,36 @@ namespace HcalSimpleRecAlgoImpl {
if (cell.subdet() == HcalBarrel) {
const int ieta = cell.ieta();
const int iphi = cell.iphi();
ampl *= eCorr(ieta, iphi, ampl, runnum);
uncorr_ampl *= eCorr(ieta, iphi, uncorr_ampl, runnum);
ampl *= eCorr(ieta, iphi, ampl, runnum);
m3_ampl *= eCorr(ieta, iphi, m3_ampl, runnum);
}
}

// Correction for a leak to pre-sample
if(useLeak && !leakCorrApplied) {
ampl *= leakCorr(ampl);
uncorr_ampl *= leakCorr(uncorr_ampl);
uncorr_ampl *= leakCorr(uncorr_ampl);
if (puCorrMethod < 2)
ampl *= leakCorr(ampl);
}

RecHit rh(digi.id(),ampl,time);
setRawEnergy(rh, static_cast<float>(uncorr_ampl));
setAuxEnergy(rh, static_cast<float>(m3_ampl));
return rh;
}

template<class Digi, class RecHit>
template<class Digi, class RecHit>
inline RecHit recoHBHE(const Digi& digi, const HcalCoder& coder,
const HcalCalibrations& calibs,
const int ifirst, const int n, const bool slewCorrect,
const bool pulseCorrect, const HcalPulseContainmentCorrection* corr,
const HcalTimeSlew::BiasSetting slewFlavor,
const int runnum, const bool useLeak,
const AbsOOTPileupCorrection* pileupCorrection,
const BunchXParameter* bxInfo, const unsigned lenInfo, const int puCorrMethod, const PulseShapeFitOOTPileupCorrection * psFitOOTpuCorr, HcalDeterministicFit * hltOOTpuCorr, PedestalSub * hltPedSub )// const on end
const BunchXParameter* bxInfo, const unsigned lenInfo, const int puCorrMethod, const PulseShapeFitOOTPileupCorrection * psFitOOTpuCorr, HcalDeterministicFit * hltOOTpuCorr, PedestalSub * hltPedSub)// const on end
{
double fc_ampl =0, ampl =0, uncorr_ampl =0, maxA = -1.e300;
double fc_ampl =0, ampl =0, uncorr_ampl =0, m3_ampl =0, maxA = -1.e300;
int nRead = 0, maxI = -1;
bool leakCorrApplied = false;
float t0 =0, t2 =0;
Expand Down Expand Up @@ -463,7 +462,7 @@ template<class Digi, class RecHit>
// Note that uncorr_ampl is always set from outside of method 2!
if( puCorrMethod == 2 ){
std::vector<double> correctedOutput;

CaloSamples cs;
coder.adc2fC(digi,cs);
std::vector<int> capidvec;
Expand All @@ -479,10 +478,10 @@ template<class Digi, class RecHit>
}

// S. Brandt - Feb 19th : Adding Section for HLT
// Turn on HLT here with puCorrMethod = 3
if ( puCorrMethod == 3){
// Run "Method 3" all the time.
{
std::vector<double> hltCorrOutput;

CaloSamples cs;
coder.adc2fC(digi,cs);
std::vector<int> capidvec;
Expand All @@ -491,34 +490,40 @@ template<class Digi, class RecHit>
capidvec.push_back(capid);
}
hltOOTpuCorr->apply(cs, capidvec, calibs, digi, hltCorrOutput);
if( hltCorrOutput.size() > 1 ){
time = hltCorrOutput[1]; ampl = hltCorrOutput[0];
if (hltCorrOutput.size() > 1) {
m3_ampl = hltCorrOutput[0];
if (puCorrMethod == 3) {
time = hltCorrOutput[1]; ampl = hltCorrOutput[0];
}
}
}

// Temporary hack to apply energy-dependent corrections to some HB- cells
if (runnum > 0) {
const HcalDetId& cell = digi.id();
if (cell.subdet() == HcalBarrel) {
const int ieta = cell.ieta();
const int iphi = cell.iphi();
ampl *= eCorr(ieta, iphi, ampl, runnum);
uncorr_ampl *= eCorr(ieta, iphi, uncorr_ampl, runnum);
ampl *= eCorr(ieta, iphi, ampl, runnum);
m3_ampl *= eCorr(ieta, iphi, m3_ampl, runnum);
}
}

// Correction for a leak to pre-sample
if(useLeak && !leakCorrApplied) {
ampl *= leakCorr(ampl);
uncorr_ampl *= leakCorr(uncorr_ampl);
if (puCorrMethod < 2)
ampl *= leakCorr(ampl);
}

HBHERecHit rh(digi.id(),ampl,time);
if(useTriple)
{
rh.setFlagField(1, HcalCaloFlagLabels::HBHEPulseFitBit);
}
setRawEnergy(rh, static_cast<float>(uncorr_ampl));
setAuxEnergy(rh, static_cast<float>(m3_ampl));
return rh;
}
}
Expand Down
23 changes: 10 additions & 13 deletions RecoLocalCalo/HcalRecProducers/src/HcalHitReconstructor.cc
Expand Up @@ -47,7 +47,7 @@ HcalHitReconstructor::HcalHitReconstructor(edm::ParameterSet const& conf):
mcOOTCorrectionCategory_("MC"),
setPileupCorrection_(0),
paramTS(0),
puCorrMethod_(conf.existsAs<int>("puCorrMethod") ? conf.getParameter<int>("puCorrMethod") : 0),
puCorrMethod_(conf.getParameter<int>("puCorrMethod")),
cntprtCorrMethod_(0),
first_(true)

Expand Down Expand Up @@ -163,12 +163,12 @@ HcalHitReconstructor::HcalHitReconstructor(edm::ParameterSet const& conf):
produces<HBHERecHitCollection>();
} else if (!strcasecmp(subd.c_str(),"HO")) {
subdet_=HcalOuter;
setPileupCorrection_ = &HcalSimpleRecAlgo::setHOPileupCorrection;
// setPileupCorrection_ = &HcalSimpleRecAlgo::setHOPileupCorrection;
setPileupCorrection_ = 0;
produces<HORecHitCollection>();
} else if (!strcasecmp(subd.c_str(),"HF")) {
subdet_=HcalForward;
setPileupCorrection_ = &HcalSimpleRecAlgo::setHFPileupCorrection;
// setPileupCorrection_ = &HcalSimpleRecAlgo::setHFPileupCorrection;
setPileupCorrection_ = 0;
digiTimeFromDB_=conf.getParameter<bool>("digiTimeFromDB");

Expand Down Expand Up @@ -270,16 +270,13 @@ HcalHitReconstructor::HcalHitReconstructor(edm::ParameterSet const& conf):
conf.getParameter<int> ("fitTimes")
);
}
if(puCorrMethod_ == 3) {
reco_.setMeth3Params(
conf.getParameter<int> ("pedestalSubtractionType"),
conf.getParameter<double> ("pedestalUpperLimit"),
conf.getParameter<int> ("timeSlewParsType"),
conf.getParameter<std::vector<double> >("timeSlewPars"),
conf.getParameter<double> ("respCorrM3")
);
}

reco_.setMeth3Params(
conf.getParameter<int> ("pedestalSubtractionType"),
conf.getParameter<double> ("pedestalUpperLimit"),
conf.getParameter<int> ("timeSlewParsType"),
conf.getParameter<std::vector<double> >("timeSlewPars"),
conf.getParameter<double> ("respCorrM3")
);
}

void HcalHitReconstructor::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
Expand Down

0 comments on commit 3cca4f7

Please sign in to comment.