Skip to content

Commit

Permalink
Merge pull request #13000 from matteosan1/mustacheRegression_800
Browse files Browse the repository at this point in the history
  • Loading branch information
cmsbuild committed Feb 3, 2016
2 parents b0d3d47 + 138bdc5 commit 243a743
Show file tree
Hide file tree
Showing 8 changed files with 472 additions and 103 deletions.
Expand Up @@ -16,6 +16,7 @@

#include "RecoParticleFlow/PFClusterTools/interface/PFEnergyCalibration.h"
#include "RecoEgamma/EgammaTools/interface/BaselinePFSCRegression.h"
#include "RecoEgamma/EgammaTools/interface/SCEnergyCorrectorSemiParm.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/ESHandle.h"
Expand Down Expand Up @@ -149,7 +150,7 @@ class PFECALSuperClusterAlgo {

// regression
bool useRegression_;
std::unique_ptr<PFSCRegressionCalc> regr_;
std::unique_ptr<SCEnergyCorrectorSemiParm> regr_;

double threshSuperClusterEt_;

Expand Down
13 changes: 6 additions & 7 deletions RecoEcal/EgammaClusterAlgos/src/PFECALSuperClusterAlgo.cc
Expand Up @@ -191,16 +191,16 @@ void PFECALSuperClusterAlgo::setTokens(const edm::ParameterSet &iConfig, edm::Co
if (useRegression_) {
const edm::ParameterSet &regconf = iConfig.getParameter<edm::ParameterSet>("regressionConfig");

regr_.reset(new PFSCRegressionCalc(regconf));
regr_->varCalc()->setTokens(regconf,std::move(cc));
regr_.reset(new SCEnergyCorrectorSemiParm());
regr_->setTokens(regconf, cc);
}

}

void PFECALSuperClusterAlgo::update(const edm::EventSetup& setup) {

if (useRegression_) {
regr_->update(setup);
regr_->setEventSetup(setup);
}

edm::ESHandle<ESEEIntercalibConstants> esEEInterCalibHandle_;
Expand Down Expand Up @@ -236,7 +236,7 @@ loadAndSortPFClusters(const edm::Event &iEvent) {

//initialize regression for this event
if (useRegression_) {
regr_->varCalc()->setEvent(iEvent);
regr_->setEvent(iEvent);
}

// reset the system for running
Expand Down Expand Up @@ -511,9 +511,8 @@ buildSuperCluster(CalibClusterPtr& seed,
new_sc.rawEnergy();

//apply regression energy corrections
if( useRegression_ ) {
double cor = regr_->getCorrection(new_sc);
new_sc.setEnergy(cor*new_sc.correctedEnergy());
if( useRegression_ ) {
regr_->modifyObject(new_sc);
}

// save the super cluster to the appropriate list (if it passes the final
Expand Down
Expand Up @@ -17,11 +17,7 @@
PFClusters = cms.InputTag("particleFlowClusterECAL"),
ESAssociation = cms.InputTag("particleFlowClusterECAL"),
BeamSpot = cms.InputTag("offlineBeamSpot"),
vertexCollection = cms.InputTag("offlinePrimaryVertices"),
#rechit collections for lazytools
ecalRecHitsEB = cms.InputTag('ecalRecHit','EcalRecHitsEB'),
ecalRecHitsEE = cms.InputTag('ecalRecHit','EcalRecHitsEE'),


PFBasicClusterCollectionBarrel = cms.string("particleFlowBasicClusterECALBarrel"),
PFSuperClusterCollectionBarrel = cms.string("particleFlowSuperClusterECALBarrel"),
PFBasicClusterCollectionEndcap = cms.string("particleFlowBasicClusterECALEndcap"),
Expand All @@ -37,9 +33,16 @@

# regression setup
useRegression = cms.bool(False), #regressions are mustache only
regressionKeyEB = cms.string('pfecalsc_EBCorrection'),
regressionKeyEE = cms.string('pfecalsc_EECorrection'),

regressionConfig = cms.PSet(
regressionKeyEB = cms.string('pfscecal_EBCorrection_offline_v2'),
uncertaintyKeyEB = cms.string('pfscecal_EBUncertainty_offline_v2'),
regressionKeyEE = cms.string('pfscecal_EECorrection_offline_v2'),
uncertaintyKeyEE = cms.string('pfscecal_EEUncertainty_offline_v2'),
vertexCollection = cms.InputTag("offlinePrimaryVertices"),
ecalRecHitsEB = cms.InputTag('ecalRecHit','EcalRecHitsEB'),
ecalRecHitsEE = cms.InputTag('ecalRecHit','EcalRecHitsEE')
),

#threshold for final SuperCluster Et
thresh_SCEt = cms.double(4.0),

Expand Down Expand Up @@ -105,8 +108,10 @@
# regression setup
useRegression = cms.bool(True),
regressionConfig = cms.PSet(
regressionKeyEB = cms.string('pfscecal_EBCorrection_offline_v1'),
regressionKeyEE = cms.string('pfscecal_EECorrection_offline_v1'),
regressionKeyEB = cms.string('pfscecal_EBCorrection_offline_v2'),
uncertaintyKeyEB = cms.string('pfscecal_EBUncertainty_offline_v2'),
regressionKeyEE = cms.string('pfscecal_EECorrection_offline_v2'),
uncertaintyKeyEE = cms.string('pfscecal_EEUncertainty_offline_v2'),
vertexCollection = cms.InputTag("offlinePrimaryVertices"),
ecalRecHitsEB = cms.InputTag('ecalRecHit','EcalRecHitsEB'),
ecalRecHitsEE = cms.InputTag('ecalRecHit','EcalRecHitsEE')
Expand Down
Expand Up @@ -324,11 +324,15 @@ void PFECALSuperClusterProducer::fillDescriptions(edm::ConfigurationDescriptions
desc.add<std::string>("PFSuperClusterCollectionBarrel","particleFlowSuperClusterECALBarrel");
{
edm::ParameterSetDescription psd0;
psd0.add<std::string>("regressionKeyEE","pfscecal_EECorrection_offline_v1");
psd0.add<bool>("isHLT", false);
psd0.add<edm::InputTag>("ecalRecHitsEE",edm::InputTag("ecalRecHit","EcalRecHitsEE"));
psd0.add<edm::InputTag>("ecalRecHitsEB",edm::InputTag("ecalRecHit","EcalRecHitsEB"));
psd0.add<std::string>("regressionKeyEB","pfscecal_EBCorrection_offline_v1");
psd0.add<edm::InputTag>("vertexCollection",edm::InputTag("offlinePrimaryVertices"));
psd0.add<std::string>("regressionKeyEE","pfscecal_EECorrection_offline_v1");
psd0.add<std::string>("uncertaintyKeyEB","pfscecal_EBUncertainty_offline_v1");
psd0.add<std::string>("uncertaintyKeyEE","pfscecal_EEUncertainty_offline_v1");
psd0.add<edm::InputTag>("vertexCollection",edm::InputTag("offlinePrimaryVertices"));
psd0.add<double>("etRecHitThreshold", 1.);
desc.add<edm::ParameterSetDescription>("regressionConfig",psd0);
}
desc.add<bool>("applyCrackCorrections",false);
Expand Down
75 changes: 75 additions & 0 deletions RecoEgamma/EgammaTools/interface/SCEnergyCorrectorSemiParm.h
@@ -0,0 +1,75 @@
//--------------------------------------------------------------------------------------------------
// $Id $
//
// SCEnergyCorrectorSemiParm
//
// Helper Class for applying regression-based energy corrections with optimized BDT implementation
//
// Authors: J.Bendavid
//--------------------------------------------------------------------------------------------------

#ifndef EGAMMATOOLS_SCEnergyCorrectorSemiParm_H
#define EGAMMATOOLS_SCEnergyCorrectorSemiParm_H

#include "FWCore/Framework/interface/EventSetup.h"

#include "DataFormats/VertexReco/interface/VertexFwd.h"
#include "CondFormats/EgammaObjects/interface/GBRForestD.h"
#include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
#include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h"
#include "Geometry/CaloTopology/interface/CaloTopology.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "DataFormats/EgammaReco/interface/SuperCluster.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

class SCEnergyCorrectorSemiParm {
public:
SCEnergyCorrectorSemiParm();
~SCEnergyCorrectorSemiParm();

void setTokens(const edm::ParameterSet &iConfig, edm::ConsumesCollector &cc);

void modifyObject(reco::SuperCluster &sc);

void setEventSetup(const edm::EventSetup &es);
void setEvent(const edm::Event &e);

protected:
const GBRForestD *foresteb_;
const GBRForestD *forestee_;
const GBRForestD *forestsigmaeb_;
const GBRForestD *forestsigmaee_;

edm::ESHandle<CaloTopology> calotopo_;
edm::ESHandle<CaloGeometry> calogeom_;
const CaloTopologyRecord* topo_record_;
const CaloGeometryRecord* geom_record_;

edm::EDGetTokenT<EcalRecHitCollection> tokenEBRecHits_;
edm::EDGetTokenT<EcalRecHitCollection> tokenEERecHits_;
edm::EDGetTokenT<reco::VertexCollection> tokenVertices_;

edm::Handle<reco::VertexCollection> vertices_;
edm::Handle<EcalRecHitCollection> rechitsEB_;
edm::Handle<EcalRecHitCollection> rechitsEE_;

edm::InputTag ecalHitsEBInputTag_;
edm::InputTag ecalHitsEEInputTag_;
edm::InputTag vertexInputTag_;

std::string regressionKeyEB_;
std::string uncertaintyKeyEB_;
std::string regressionKeyEE_;
std::string uncertaintyKeyEE_;

private:
bool isHLT_;
int nHitsAboveThreshold_;
float etThreshold_;
};
#endif

0 comments on commit 243a743

Please sign in to comment.