From 4ae9e396511b01b4315cea942cff6048aecc6599 Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Thu, 22 Oct 2015 11:28:55 +0200 Subject: [PATCH] add a label to indentify the PFProducer calibrations --- .../python/customizeHLTforCMSSW.py | 19 ++++++++++++++++--- .../PFProducer/plugins/PFProducer.cc | 13 ++++++++----- .../PFProducer/plugins/PFProducer.h | 2 +- .../python/particleFlowEGamma_cfi.py | 1 + .../PFProducer/python/particleFlow_cfi.py | 1 + 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/HLTrigger/Configuration/python/customizeHLTforCMSSW.py b/HLTrigger/Configuration/python/customizeHLTforCMSSW.py index b52818228639b..84c71d3ae8518 100644 --- a/HLTrigger/Configuration/python/customizeHLTforCMSSW.py +++ b/HLTrigger/Configuration/python/customizeHLTforCMSSW.py @@ -1,5 +1,10 @@ import FWCore.ParameterSet.Config as cms +# reusable functions +def producers_by_type(process, type): + return (module for module in process._Process__producers.values() if module._TypedParameterizable__type == type) + + # Update to replace old jet corrector mechanism from HLTrigger.Configuration.customizeHLTforNewJetCorrectors import customizeHLTforNewJetCorrectors @@ -55,9 +60,6 @@ def customiseFor8356(process): input = cms.InputTag( 'hltL2Muons','UpdatedAtVtx' ) ) - def producers_by_type(process, type): - return (module for module in process._Process__producers.values() if module._TypedParameterizable__type == type) - for l3MPModule in producers_by_type(process, 'L3MuonProducer'): if hasattr(l3MPModule, 'GlbRefitterParameters'): l3MPModule.GlbRefitterParameters.RefitFlag = cms.bool(True) @@ -175,12 +177,22 @@ def replaceInPSet(pset, moduleLabel): return process + def customiseFor11497(process): # Take care of CaloTowerTopology if not hasattr(process,'CaloTowerTopologyEP'): process.CaloTowerTopologyEP = cms.ESProducer( 'CaloTowerTopologyEP' ) return process + +def customiseFor12044(process): + # add a label to indentify the PFProducer calibrations + for module in producers_by_type(process, 'PFProducer'): + if not 'calibrationsLabel' in module.__dict__: + module.calibrationsLabel = cms.string('') + return process + + # CMSSW version specific customizations def customiseHLTforCMSSW(process, menuType="GRun", fastSim=False): import os @@ -192,6 +204,7 @@ def customiseHLTforCMSSW(process, menuType="GRun", fastSim=False): process = customiseFor10911(process) process = customiseFor11183(process) process = customiseFor11497(process) + process = customiseFor12044(process) if cmsswVersion >= "CMSSW_7_5": process = customiseFor10927(process) process = customiseFor9232(process) diff --git a/RecoParticleFlow/PFProducer/plugins/PFProducer.cc b/RecoParticleFlow/PFProducer/plugins/PFProducer.cc index 77ea1d7b1a4d9..301da06daffd5 100644 --- a/RecoParticleFlow/PFProducer/plugins/PFProducer.cc +++ b/RecoParticleFlow/PFProducer/plugins/PFProducer.cc @@ -263,7 +263,10 @@ PFProducer::PFProducer(const edm::ParameterSet& iConfig) { // fToRead = iConfig.getUntrackedParameter >("toRead"); useCalibrationsFromDB_ - = iConfig.getParameter("useCalibrationsFromDB"); + = iConfig.getParameter("useCalibrationsFromDB"); + + if (useCalibrationsFromDB_) + calibrationsLabel_ = iConfig.getParameter("calibrationsLabel"); boost::shared_ptr calibration( new PFEnergyCalibration() ); @@ -424,11 +427,11 @@ PFProducer::beginRun(const edm::Run & run, */ if ( useCalibrationsFromDB_ ) { - // Read the PFCalibration functions from the global tags. + // read the PFCalibration functions from the global tags edm::ESHandle perfH; - es.get().get(perfH); - - const PerformancePayloadFromTFormula *pfCalibrations = static_cast< const PerformancePayloadFromTFormula *>(perfH.product()); + es.get().get(calibrationsLabel_, perfH); + + PerformancePayloadFromTFormula const * pfCalibrations = static_cast< const PerformancePayloadFromTFormula *>(perfH.product()); pfAlgo_->thePFEnergyCalibration()->setCalibrationFunctions(pfCalibrations); } diff --git a/RecoParticleFlow/PFProducer/plugins/PFProducer.h b/RecoParticleFlow/PFProducer/plugins/PFProducer.h index 99976e2cebabe..0586eeb889c86 100644 --- a/RecoParticleFlow/PFProducer/plugins/PFProducer.h +++ b/RecoParticleFlow/PFProducer/plugins/PFProducer.h @@ -102,7 +102,7 @@ class PFProducer : public edm::stream::EDProducer<> { // Take PF cluster calibrations from Global Tag ? bool useCalibrationsFromDB_; - + std::string calibrationsLabel_; bool postHFCleaning_; // Name of the calibration functions to read from the database diff --git a/RecoParticleFlow/PFProducer/python/particleFlowEGamma_cfi.py b/RecoParticleFlow/PFProducer/python/particleFlowEGamma_cfi.py index 8d9e7a974451b..ec5b7ba15ac75 100644 --- a/RecoParticleFlow/PFProducer/python/particleFlowEGamma_cfi.py +++ b/RecoParticleFlow/PFProducer/python/particleFlowEGamma_cfi.py @@ -176,6 +176,7 @@ # ECAL/HCAL PF cluster calibration : take it from global tag ? useCalibrationsFromDB = cms.bool(True), + calibrationsLabel = cms.string(''), # calibration parameters for HF: calibHF_use = cms.bool(False), diff --git a/RecoParticleFlow/PFProducer/python/particleFlow_cfi.py b/RecoParticleFlow/PFProducer/python/particleFlow_cfi.py index 9273ce87c4b4d..5093cbab42e19 100644 --- a/RecoParticleFlow/PFProducer/python/particleFlow_cfi.py +++ b/RecoParticleFlow/PFProducer/python/particleFlow_cfi.py @@ -215,6 +215,7 @@ # ECAL/HCAL PF cluster calibration : take it from global tag ? useCalibrationsFromDB = cms.bool(True), + calibrationsLabel = cms.string(''), # calibration parameters for HF: calibHF_use = cms.bool(False),