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

Mustache SuperCluster Regression for 800 #13000

Merged
merged 7 commits into from Feb 3, 2016
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
24 changes: 12 additions & 12 deletions Configuration/AlCa/python/autoCond.py
Expand Up @@ -2,35 +2,35 @@

### NEW KEYS ###
# GlobalTag for MC production with perfectly aligned and calibrated detector for Run1
'run1_design' : '80X_mcRun1_design_v3',
'run1_design' : '80X_mcRun1_design_v4',
# GlobalTag for MC production (pp collisions) with realistic alignment and calibrations for Run1
'run1_mc' : '80X_mcRun1_realistic_v3',
'run1_mc' : '80X_mcRun1_realistic_v4',
# GlobalTag for MC production (Heavy Ions collisions) with realistic alignment and calibrations for Run1
'run1_mc_hi' : '80X_mcRun1_HeavyIon_v3',
'run1_mc_hi' : '80X_mcRun1_HeavyIon_v4',
# GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run1
'run1_mc_pa' : '80X_mcRun1_pA_v3',
'run1_mc_pa' : '80X_mcRun1_pA_v4',
# GlobalTag for MC production with perfectly aligned and calibrated detector for Run2
'run2_design' : '80X_mcRun2_design_v2',
'run2_design' : '80X_mcRun2_design_v4',
# GlobalTag for MC production with pessimistic alignment and calibrations for Run2
'run2_mc_50ns' : '80X_mcRun2_startup_v2',
'run2_mc_50ns' : '80X_mcRun2_startup_v4',
#GlobalTag for MC production with optimistic alignment and calibrations for Run2
'run2_mc' : '80X_mcRun2_asymptotic_v2',
'run2_mc' : '80X_mcRun2_asymptotic_v4',
# GlobalTag for MC production (cosmics) with starup-like alignment and calibrations for Run2, Strip tracker in peak mode
'run2_mc_cosmics' : '80X_mcRun2cosmics_startup_peak_v1',
'run2_mc_cosmics' : '80X_mcRun2cosmics_startup_peak_v2',
# GlobalTag for MC production (Heavy Ions collisions) with optimistic alignment and calibrations for Run2
'run2_mc_hi' : '80X_mcRun2_HeavyIon_v2',
'run2_mc_hi' : '80X_mcRun2_HeavyIon_v3',
# GlobalTag for Run1 data reprocessing
'run1_data' : '80X_dataRun2_v3',
'run1_data' : '80X_dataRun2_v4',
# GlobalTag for Run2 data reprocessing
'run2_data' : '80X_dataRun2_v3',
'run2_data' : '80X_dataRun2_v4',
# GlobalTag for Run1 HLT: it points to the online GT
'run1_hlt' : '80X_dataRun2_HLT_frozen_v2',
# GlobalTag for Run2 HLT: it points to the online GT
'run2_hlt' : '80X_dataRun2_HLT_frozen_v2',
# GlobalTag for Run2 HLT for HI: it points to the online GT
'run2_hlt_hi' : '80X_dataRun2_HLTHI_frozen_v2',
# GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2017
'phase1_2017_design' : '80X_upgrade2017_design_v2',
'phase1_2017_design' : '80X_upgrade2017_design_v3',
# GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2019
'phase1_2019_design' : 'DES19_70_V2', # placeholder (GT not meant for standard RelVal)
# GlobalTag for MC production with perfectly aligned and calibrated detector for Phase2
Expand Down
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