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

[PF] Add fillDescription to RecoParticleFlow producers #45212

Merged
merged 7 commits into from
Jun 21, 2024
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
18 changes: 14 additions & 4 deletions RecoParticleFlow/Configuration/plugins/HepMCCopy.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "FWCore/Framework/interface/one/EDProducer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
Expand All @@ -10,19 +12,27 @@ class HepMCCopy : public edm::one::EDProducer<> {
explicit HepMCCopy(edm::ParameterSet const& p);
~HepMCCopy() override = default;
void produce(edm::Event& e, const edm::EventSetup& c) override;
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:
const edm::EDGetTokenT<edm::HepMCProduct> hepMCToken_;
};

HepMCCopy::HepMCCopy(edm::ParameterSet const& p) {
void HepMCCopy::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("src", {"generatorSmeared"});
descriptions.addWithDefaultLabel(desc);
}

HepMCCopy::HepMCCopy(edm::ParameterSet const& p)
: hepMCToken_(consumes<edm::HepMCProduct>(p.getParameter<edm::InputTag>("src"))) {
// This producer produces a HepMCProduct, a copy of the original one
produces<edm::HepMCProduct>();
}

void HepMCCopy::produce(edm::Event& iEvent, const edm::EventSetup& es) {
edm::Handle<edm::HepMCProduct> theHepMCProduct;
bool source = iEvent.getByLabel("generatorSmeared", theHepMCProduct);
if (!source) {
const auto& theHepMCProduct = iEvent.getHandle(hepMCToken_);
if (theHepMCProduct.isValid()) {
auto pu_product = std::make_unique<edm::HepMCProduct>();
iEvent.put(std::move(pu_product));
} else {
Expand Down
3 changes: 2 additions & 1 deletion RecoParticleFlow/Configuration/python/HepMCCopy_cfi.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import FWCore.ParameterSet.Config as cms

generator = cms.EDProducer("HepMCCopy")
from RecoParticleFlow.Configuration.modules import HepMCCopy
generator = HepMCCopy()
stahlleiton marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 0 additions & 3 deletions RecoParticleFlow/Configuration/python/RecoParticleFlow_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@
pt_min_prim = 999999.0,
dxy = 999999.0)
)

e.toModify(particleFlowBlock, useNuclear = cms.bool(False))

e.toModify(pfNoPileUpIso, enable = False)
e.toModify(pfPileUpIso, enable = False)
e.toModify(pfNoPileUp, enable = False)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,21 @@ class HGCRecHitNavigator : public PFRecHitNavigatorBase {
}

HGCRecHitNavigator(const edm::ParameterSet& iConfig, edm::ConsumesCollector& cc) {
if (iConfig.exists("hgcee")) {
eeNav_ = new hgcee(iConfig.getParameter<edm::ParameterSet>("hgcee"), cc);
const auto& pset_hgcee = iConfig.getParameter<edm::ParameterSet>("hgcee");
if (!pset_hgcee.empty() && !pset_hgcee.getParameter<std::string>("name").empty()) {
eeNav_ = new hgcee(pset_hgcee, cc);
} else {
eeNav_ = nullptr;
}
if (iConfig.exists("hgchef")) {
hefNav_ = new hgchef(iConfig.getParameter<edm::ParameterSet>("hgchef"), cc);
const auto& pset_hgchef = iConfig.getParameter<edm::ParameterSet>("hgchef");
if (!pset_hgchef.empty() && !pset_hgchef.getParameter<std::string>("name").empty()) {
hefNav_ = new hgchef(pset_hgchef, cc);
} else {
hefNav_ = nullptr;
}
if (iConfig.exists("hgcheb")) {
hebNav_ = new hgcheb(iConfig.getParameter<edm::ParameterSet>("hgcheb"), cc);
const auto& pset_hgcheb = iConfig.getParameter<edm::ParameterSet>("hgcheb");
if (!pset_hgcheb.empty() && !pset_hgcheb.getParameter<std::string>("name").empty()) {
hebNav_ = new hgcheb(pset_hgcheb, cc);
} else {
hebNav_ = nullptr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ class PFClusterBuilderBase {
_nClustersFound(0),
_minFractionToKeep(conf.getParameter<double>("minFractionToKeep")),
_algoName(conf.getParameter<std::string>("algoName")) {
if (conf.exists("positionCalc")) {
const edm::ParameterSet& pcConf = conf.getParameterSet("positionCalc");
const auto& pcConf = conf.getParameterSet("positionCalc");
if (!pcConf.empty()) {
const std::string& algo = pcConf.getParameter<std::string>("algoName");
_positionCalc = PFCPositionCalculatorFactory::get()->create(algo, pcConf, cc);
if (!algo.empty())
_positionCalc = PFCPositionCalculatorFactory::get()->create(algo, pcConf, cc);
}
}
virtual ~PFClusterBuilderBase() = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,18 @@ Basic2DGenericPFlowClusterizer::Basic2DGenericPFlowClusterizer(const edm::Parame
_recHitEnergyNorms.emplace(_layerMap.find(det)->second, std::make_pair(depths, rhE_norm));
}

if (conf.exists("allCellsPositionCalc")) {
const edm::ParameterSet& acConf = conf.getParameterSet("allCellsPositionCalc");
const auto& acConf = conf.getParameterSet("allCellsPositionCalc");
if (!acConf.empty()) {
const std::string& algoac = acConf.getParameter<std::string>("algoName");
_allCellsPosCalc = PFCPositionCalculatorFactory::get()->create(algoac, acConf, cc);
if (!algoac.empty())
_allCellsPosCalc = PFCPositionCalculatorFactory::get()->create(algoac, acConf, cc);
}
// if necessary a third pos calc for convergence testing
if (conf.exists("positionCalcForConvergence")) {
const edm::ParameterSet& convConf = conf.getParameterSet("positionCalcForConvergence");
const auto& convConf = conf.getParameterSet("positionCalcForConvergence");
if (!convConf.empty()) {
const std::string& algoconv = convConf.getParameter<std::string>("algoName");
_convergencePosCalc = PFCPositionCalculatorFactory::get()->create(algoconv, convConf, cc);
if (!algoconv.empty())
_convergencePosCalc = PFCPositionCalculatorFactory::get()->create(algoconv, convConf, cc);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,14 @@ class Basic2DGenericPFlowPositionCalc : public PFCPositionCalculatorBase {
std::vector<double> logWeightDenom;
std::vector<float> logWeightDenomInv;

if (conf.exists("logWeightDenominatorByDetector")) {
const std::vector<edm::ParameterSet>& logWeightDenominatorByDetectorPSet =
conf.getParameterSetVector("logWeightDenominatorByDetector");

const auto& logWeightDenominatorByDetectorPSet = conf.getParameterSetVector("logWeightDenominatorByDetector");
if (!logWeightDenominatorByDetectorPSet.empty()) {
for (const auto& pset : logWeightDenominatorByDetectorPSet) {
if (!pset.exists("detector")) {
const auto& det = pset.getParameter<std::string>("detector");
if (det.empty()) {
throw cms::Exception("logWeightDenominatorByDetectorPSet") << "logWeightDenominator : detector not specified";
}

const std::string& det = pset.getParameter<std::string>("detector");

if (det == std::string("HCAL_BARREL1") || det == std::string("HCAL_ENDCAP")) {
std::vector<int> depthsT = pset.getParameter<std::vector<int> >("depths");
std::vector<double> logWeightDenomT = pset.getParameter<std::vector<double> >("logWeightDenominator");
Expand Down Expand Up @@ -70,15 +67,13 @@ class Basic2DGenericPFlowPositionCalc : public PFCPositionCalculatorBase {
_logWeightDenom = std::make_tuple(detectorEnum, depths, logWeightDenomInv);

_timeResolutionCalcBarrel.reset(nullptr);
if (conf.exists("timeResolutionCalcBarrel")) {
const edm::ParameterSet& timeResConf = conf.getParameterSet("timeResolutionCalcBarrel");
_timeResolutionCalcBarrel = std::make_unique<CaloRecHitResolutionProvider>(timeResConf);
}
const auto& timeResConfBarrel = conf.getParameterSet("timeResolutionCalcBarrel");
if (!timeResConfBarrel.empty() && timeResConfBarrel.getParameter<double>("threshHighE") >= 0)
_timeResolutionCalcBarrel = std::make_unique<CaloRecHitResolutionProvider>(timeResConfBarrel);
_timeResolutionCalcEndcap.reset(nullptr);
if (conf.exists("timeResolutionCalcEndcap")) {
const edm::ParameterSet& timeResConf = conf.getParameterSet("timeResolutionCalcEndcap");
_timeResolutionCalcEndcap = std::make_unique<CaloRecHitResolutionProvider>(timeResConf);
}
const auto& timeResConfEndcap = conf.getParameterSet("timeResolutionCalcEndcap");
if (!timeResConfEndcap.empty() && timeResConfEndcap.getParameter<double>("threshHighE") >= 0)
_timeResolutionCalcEndcap = std::make_unique<CaloRecHitResolutionProvider>(timeResConfEndcap);

switch (_posCalcNCrystals) {
case 5:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ class ECAL2DPositionCalcWithDepthCorr : public PFCPositionCalculatorBase {
_esMinus(false),
_geomToken(cc.esConsumes<edm::Transition::BeginRun>()) {
_timeResolutionCalc.reset(nullptr);
if (conf.exists("timeResolutionCalc")) {
const edm::ParameterSet& timeResConf = conf.getParameterSet("timeResolutionCalc");
const auto& timeResConf = conf.getParameterSet("timeResolutionCalc");
if (!timeResConf.empty())
_timeResolutionCalc = std::make_unique<CaloRecHitResolutionProvider>(timeResConf);
}
}
ECAL2DPositionCalcWithDepthCorr(const ECAL2DPositionCalcWithDepthCorr&) = delete;
ECAL2DPositionCalcWithDepthCorr& operator=(const ECAL2DPositionCalcWithDepthCorr&) = delete;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,18 @@ class LegacyPFClusterProducer : public edm::stream::EDProducer<> {
//setup pf cluster builder if requested
const edm::ParameterSet& pfcConf = config.getParameterSet("pfClusterBuilder");
if (!pfcConf.empty()) {
if (pfcConf.exists("positionCalc")) {
const edm::ParameterSet& acConf = pfcConf.getParameterSet("positionCalc");
const auto& acConf = pfcConf.getParameterSet("positionCalc");
if (!acConf.empty()) {
const std::string& algoac = acConf.getParameter<std::string>("algoName");
positionCalc_ = PFCPositionCalculatorFactory::get()->create(algoac, acConf, cc);
if (!algoac.empty())
positionCalc_ = PFCPositionCalculatorFactory::get()->create(algoac, acConf, cc);
}

if (pfcConf.exists("allCellsPositionCalc")) {
const edm::ParameterSet& acConf = pfcConf.getParameterSet("allCellsPositionCalc");
const std::string& algoac = acConf.getParameter<std::string>("algoName");
allCellsPositionCalc_ = PFCPositionCalculatorFactory::get()->create(algoac, acConf, cc);
const auto& acConf2 = pfcConf.getParameterSet("allCellsPositionCalc");
if (!acConf2.empty()) {
const std::string& algoac = acConf2.getParameter<std::string>("algoName");
if (!algoac.empty())
allCellsPositionCalc_ = PFCPositionCalculatorFactory::get()->create(algoac, acConf2, cc);
}
}
}
Expand All @@ -82,6 +84,7 @@ class LegacyPFClusterProducer : public edm::stream::EDProducer<> {
pfClusterBuilder.add<double>("minChi2Prob", 0.);
pfClusterBuilder.add<bool>("clusterTimeResFromSeed", false);
pfClusterBuilder.add<std::string>("algoName", "");
pfClusterBuilder.add<edm::ParameterSetDescription>("positionCalcForConvergence", {});
{
edm::ParameterSetDescription validator;
validator.add<std::string>("detector", "");
Expand Down Expand Up @@ -116,6 +119,8 @@ class LegacyPFClusterProducer : public edm::stream::EDProducer<> {
bar.addVPSet("logWeightDenominatorByDetector", validator, vDefaults);
}
bar.add<double>("minAllowedNormalization", 1e-9);
bar.add<edm::ParameterSetDescription>("timeResolutionCalcBarrel", {});
bar.add<edm::ParameterSetDescription>("timeResolutionCalcEndcap", {});
pfClusterBuilder.add("positionCalc", bar);
}
{
Expand All @@ -138,6 +143,8 @@ class LegacyPFClusterProducer : public edm::stream::EDProducer<> {
bar.addVPSet("logWeightDenominatorByDetector", validator, vDefaults);
}
bar.add<double>("minAllowedNormalization", 1e-9);
bar.add<edm::ParameterSetDescription>("timeResolutionCalcBarrel", {});
bar.add<edm::ParameterSetDescription>("timeResolutionCalcEndcap", {});
pfClusterBuilder.add("allCellsPositionCalc", bar);
}
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@
class PFClusterCollectionMerger : public edm::global::EDProducer<> {
public:
PFClusterCollectionMerger(const edm::ParameterSet& conf) {
const std::vector<edm::InputTag>& inputs = conf.getParameter<std::vector<edm::InputTag> >("inputs");
const std::vector<edm::InputTag>& inputs = conf.getParameter<std::vector<edm::InputTag>>("inputs");
for (const auto& input : inputs) {
_inputs.push_back(consumes<reco::PFClusterCollection>(input));
}
produces<reco::PFClusterCollection>();
}

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<std::vector<edm::InputTag>>("inputs", {});
descriptions.addWithDefaultLabel(desc);
}

void produce(edm::StreamID, edm::Event& e, const edm::EventSetup& es) const override {
auto output = std::make_unique<reco::PFClusterCollection>();
for (const auto& input : _inputs) {
Expand All @@ -34,7 +40,7 @@ class PFClusterCollectionMerger : public edm::global::EDProducer<> {
}

private:
std::vector<edm::EDGetTokenT<reco::PFClusterCollection> > _inputs;
std::vector<edm::EDGetTokenT<reco::PFClusterCollection>> _inputs;
};

DEFINE_FWK_MODULE(PFClusterCollectionMerger);
Expand Down
Loading