Skip to content

Commit

Permalink
Merge pull request #21430 from makortel/selectorFillDescriptions
Browse files Browse the repository at this point in the history
Add addWithDefaultLabel() to ConfigurationDescriptions to allow automatically deriving the module label from the plugin name, and make first step for fillDescriptions in generic selectors
  • Loading branch information
cmsbuild committed Dec 8, 2017
2 parents 623a831 + 4a59669 commit 1eed5e2
Show file tree
Hide file tree
Showing 30 changed files with 212 additions and 43 deletions.
5 changes: 5 additions & 0 deletions CommonTools/RecoAlgos/plugins/EtMinSuperClusterSelector.h
Expand Up @@ -2,6 +2,7 @@
#define UtilAlgos_FunctionMinSelector_h

#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "CommonTools/UtilAlgos/interface/ParameterAdapter.h"
#include "CommonTools/Utils/interface/FunctionMinSelector.h"
#include "CommonTools/RecoAlgos/plugins/SuperClusterEt.h"
Expand All @@ -16,6 +17,10 @@ namespace reco {
const edm::ParameterSet & cfg, edm::ConsumesCollector & iC ) {
return EtMinSuperClusterSelector( cfg.getParameter<double>( "etMin" ) );
}

static void fillPSetDescription(edm::ParameterSetDescription& desc) {
desc.add<double>("etMin", 0);
}
};

}
Expand Down

This file was deleted.

27 changes: 27 additions & 0 deletions CommonTools/UtilAlgos/interface/AndSelector.h
@@ -1,6 +1,7 @@
#ifndef UtilAlgos_AndSelector_h
#define UtilAlgos_AndSelector_h
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
#include "CommonTools/UtilAlgos/interface/ParameterAdapter.h"
#include "CommonTools/Utils/interface/AndSelector.h"

Expand Down Expand Up @@ -30,6 +31,14 @@ namespace reco {
modules::make<S4>( cfg, iC ),
modules::make<S5>( cfg, iC ) );
}

static void fillPSetDescription(edm::ParameterSetDescription& desc) {
modules::fillPSetDescription<S1>(desc);
modules::fillPSetDescription<S2>(desc);
modules::fillPSetDescription<S3>(desc);
modules::fillPSetDescription<S4>(desc);
modules::fillPSetDescription<S5>(desc);
}
};

template<typename S1, typename S2, typename S3, typename S4>
Expand All @@ -52,6 +61,13 @@ namespace reco {
modules::make<S3>( cfg, iC ),
modules::make<S4>( cfg, iC ) );
}

static void fillPSetDescription(edm::ParameterSetDescription& desc) {
modules::fillPSetDescription<S1>(desc);
modules::fillPSetDescription<S2>(desc);
modules::fillPSetDescription<S3>(desc);
modules::fillPSetDescription<S4>(desc);
}
};

template<typename S1, typename S2, typename S3>
Expand All @@ -71,6 +87,12 @@ namespace reco {
modules::make<S2>( cfg, iC ),
modules::make<S3>( cfg, iC ) );
}

static void fillPSetDescription(edm::ParameterSetDescription& desc) {
modules::fillPSetDescription<S1>(desc);
modules::fillPSetDescription<S2>(desc);
modules::fillPSetDescription<S3>(desc);
}
};

template<typename S1, typename S2>
Expand All @@ -87,6 +109,11 @@ namespace reco {
return AndSelector<S1, S2>( modules::make<S1>( cfg, iC ),
modules::make<S2>( cfg, iC ) );
}

static void fillPSetDescription(edm::ParameterSetDescription& desc) {
modules::fillPSetDescription<S1>(desc);
modules::fillPSetDescription<S2>(desc);
}
};

}
Expand Down
3 changes: 3 additions & 0 deletions CommonTools/UtilAlgos/interface/AnySelector.h
@@ -1,6 +1,7 @@
#ifndef UtilAlgos_AnySelector_h
#define UtilAlgos_AnySelector_h
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
#include "CommonTools/UtilAlgos/interface/ParameterAdapter.h"
#include "CommonTools/Utils/interface/AnySelector.h"

Expand All @@ -18,6 +19,8 @@ namespace reco {
static AnySelector make( const edm::ParameterSet & cfg, edm::ConsumesCollector & iC ) {
return AnySelector();
}

static void fillPSetDescription(edm::ParameterSetDescription& desc) {}
};

}
Expand Down
5 changes: 5 additions & 0 deletions CommonTools/UtilAlgos/interface/EtMinSelector.h
@@ -1,6 +1,7 @@
#ifndef UtilAlgos_EtMinSelector_h
#define UtilAlgos_EtMinSelector_h
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "CommonTools/UtilAlgos/interface/ParameterAdapter.h"
#include "CommonTools/Utils/interface/EtMinSelector.h"

Expand All @@ -12,6 +13,10 @@ namespace reco {
static EtMinSelector make( const edm::ParameterSet & cfg, edm::ConsumesCollector & iC ) {
return EtMinSelector( cfg.getParameter<double>( "etMin" ) );
}

static void fillPSetDescription(edm::ParameterSetDescription& desc) {
desc.add<double>("etMin", 0.);
}
};

}
Expand Down
5 changes: 5 additions & 0 deletions CommonTools/UtilAlgos/interface/EtaRangeSelector.h
Expand Up @@ -14,6 +14,11 @@ namespace reco {
EtaRangeSelector( cfg.getParameter<double>( "etaMin" ),
cfg.getParameter<double>( "etaMax" ) );
}

static void fillPSetDescription(edm::ParameterSetDescription& desc) {
desc.add<double>("etaMin", 0.);
desc.add<double>("etaMax", 0.);
}
};

}
Expand Down
8 changes: 8 additions & 0 deletions CommonTools/UtilAlgos/interface/EventSelectorAdapter.h
Expand Up @@ -17,6 +17,8 @@
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"

template<typename T>
class EventSelectorAdapter : public edm::global::EDFilter<>
Expand All @@ -30,6 +32,12 @@ class EventSelectorAdapter : public edm::global::EDFilter<>
// destructor
~EventSelectorAdapter() override {}

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
T::fillPSetDescription(desc);
descriptions.addWithDefaultLabel(desc);
}

private:
bool filter(edm::StreamID, edm::Event& evt, const edm::EventSetup& es) const override { return eventSelector_(evt, es); }

Expand Down
5 changes: 5 additions & 0 deletions CommonTools/UtilAlgos/interface/MaxNumberSelector.h
@@ -1,6 +1,7 @@
#ifndef UtilAlgos_MaxNumberSelector_h
#define UtilAlgos_MaxNumberSelector_h
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "CommonTools/UtilAlgos/interface/ParameterAdapter.h"
#include "CommonTools/Utils/interface/MaxNumberSelector.h"

Expand All @@ -12,6 +13,10 @@ namespace reco {
static MaxNumberSelector make(const edm::ParameterSet & cfg, edm::ConsumesCollector & iC) {
return MaxNumberSelector(cfg.getParameter<unsigned int>("maxNumber"));
}

static void fillPSetDescription(edm::ParameterSetDescription& desc) {
desc.add<unsigned int>("maxNumber", 0);
}
};

}
Expand Down
5 changes: 5 additions & 0 deletions CommonTools/UtilAlgos/interface/MinNumberSelector.h
@@ -1,6 +1,7 @@
#ifndef UtilAlgos_MinNumberSelector_h
#define UtilAlgos_MinNumberSelector_h
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "CommonTools/UtilAlgos/interface/ParameterAdapter.h"
#include "CommonTools/Utils/interface/MinNumberSelector.h"

Expand All @@ -12,6 +13,10 @@ namespace reco {
static MinNumberSelector make(const edm::ParameterSet & cfg, edm::ConsumesCollector & iC) {
return MinNumberSelector(cfg.getParameter<unsigned int>("minNumber"));
}

static void fillPSetDescription(edm::ParameterSetDescription& desc) {
desc.add<unsigned int>("minNumber", 0);
}
};

}
Expand Down
7 changes: 7 additions & 0 deletions CommonTools/UtilAlgos/interface/ObjectCountEventSelector.h
Expand Up @@ -16,6 +16,7 @@
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "CommonTools/UtilAlgos/interface/ParameterAdapter.h"
#include "CommonTools/UtilAlgos/interface/CollectionFilterTrait.h"
Expand All @@ -35,6 +36,12 @@ class ObjectCountEventSelector : public EventSelectorBase
sizeSelect_( reco::modules::make<N>( cfg, iC ) ) {
}

static void fillPSetDescription(edm::ParameterSetDescription& desc) {
desc.add<edm::InputTag>("src", edm::InputTag());
reco::modules::fillPSetDescription<S>(desc);
reco::modules::fillPSetDescription<N>(desc);
}

bool operator()(edm::Event& evt, const edm::EventSetup&) const override {
edm::Handle<C> source;
evt.getByToken( srcToken_, source );
Expand Down
10 changes: 10 additions & 0 deletions CommonTools/UtilAlgos/interface/ParameterAdapter.h
Expand Up @@ -2,6 +2,7 @@
#define UtilAlgos_ParameterAdapter_h

#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

namespace reco {
Expand All @@ -18,6 +19,10 @@ namespace reco {
static S make(const edm::ParameterSet & cfg, edm::ConsumesCollector & iC) {
return S(cfg, iC);
}

static void fillPSetDescription(edm::ParameterSetDescription& desc) {
S::template fillPSetDescription(desc);
}
};

template<typename S>
Expand All @@ -33,6 +38,10 @@ namespace reco {
return ParameterAdapter<S>::make(cfg, iC);
}

template <typename S>
void fillPSetDescription(edm::ParameterSetDescription& desc) {
ParameterAdapter<S>::fillPSetDescription(desc);
}
}
}

Expand All @@ -49,6 +58,7 @@ namespace reco { \
static TYPE make(const edm::ParameterSet & cfg, edm::ConsumesCollector & iC) { \
return TYPE(); \
} \
static void fillPSetDescription(edm::ParameterSetDescription& desc) {} \
}; \
} \
}
Expand Down
5 changes: 5 additions & 0 deletions CommonTools/UtilAlgos/interface/PtMinSelector.h
@@ -1,6 +1,7 @@
#ifndef UtilAlgos_PtMinSelector_h
#define UtilAlgos_PtMinSelector_h
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "CommonTools/UtilAlgos/interface/ParameterAdapter.h"
#include "CommonTools/Utils/interface/PtMinSelector.h"

Expand All @@ -12,6 +13,10 @@ namespace reco {
static PtMinSelector make( const edm::ParameterSet & cfg, edm::ConsumesCollector & iC ) {
return PtMinSelector( cfg.getParameter<double>( "ptMin" ) );
}

static void fillPSetDescription(edm::ParameterSetDescription& desc) {
desc.add<double>("ptMin", 0.);
}
};

}
Expand Down
5 changes: 5 additions & 0 deletions CommonTools/UtilAlgos/interface/StringCutObjectSelector.h
@@ -1,6 +1,7 @@
#ifndef UtilAlgos_StringCutObjectSelector_h
#define UtilAlgos_StringCutObjectSelector_h
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "CommonTools/UtilAlgos/interface/ParameterAdapter.h"
#include "CommonTools/Utils/interface/StringCutObjectSelector.h"

Expand All @@ -12,6 +13,10 @@ namespace reco {
static StringCutObjectSelector<T, Lazy> make( const edm::ParameterSet & cfg, edm::ConsumesCollector & iC ) {
return StringCutObjectSelector<T, Lazy>( cfg.template getParameter<std::string>( "cut" ) );
}

static void fillPSetDescription(edm::ParameterSetDescription& desc) {
desc.add<std::string>("cut", "");
}
};

}
Expand Down
1 change: 0 additions & 1 deletion Configuration/Skimming/python/PDWG_BPHSkim_cff.py
Expand Up @@ -52,7 +52,6 @@
onia2MuMuPATCounter = cms.EDFilter('CandViewCountFilter',
src = cms.InputTag('onia2MuMuPAT'),
minNumber = cms.uint32(1),
filter = cms.bool(True)
)

# make photon candidate conversions for P-wave studies
Expand Down
2 changes: 1 addition & 1 deletion FWCore/Framework/src/EventProcessor.cc
Expand Up @@ -130,7 +130,7 @@ namespace edm {

std::unique_ptr<ParameterSetDescriptionFillerBase> filler(
ParameterSetDescriptionFillerPluginFactory::get()->create(modtype));
ConfigurationDescriptions descriptions(filler->baseType());
ConfigurationDescriptions descriptions(filler->baseType(), modtype);
filler->fill(descriptions);

try {
Expand Down
2 changes: 1 addition & 1 deletion FWCore/Framework/src/EventSetupProviderMaker.cc
Expand Up @@ -150,7 +150,7 @@ namespace edm {

std::unique_ptr<ParameterSetDescriptionFillerBase> filler(
ParameterSetDescriptionFillerPluginFactory::get()->create(modtype));
ConfigurationDescriptions descriptions(filler->baseType());
ConfigurationDescriptions descriptions(filler->baseType(), modtype);
filler->fill(descriptions);
try {
edm::convertException::wrap([&]() {
Expand Down
2 changes: 1 addition & 1 deletion FWCore/Framework/src/WorkerMaker.cc
Expand Up @@ -65,7 +65,7 @@ namespace edm {
Maker::makeModule(MakeModuleParams const& p,
signalslot::Signal<void(ModuleDescription const&)>& pre,
signalslot::Signal<void(ModuleDescription const&)>& post) const {
ConfigurationDescriptions descriptions(baseType());
ConfigurationDescriptions descriptions(baseType(), p.pset_->getParameter<std::string>("@module_type"));
fillDescriptions(descriptions);
try {
convertException::wrap([&]() {
Expand Down
6 changes: 6 additions & 0 deletions FWCore/Integration/test/ProducerWithPSetDesc.cc
Expand Up @@ -1034,6 +1034,12 @@ namespace edmtest {
edm::ParameterSetDescription iDesc2;
iDesc2.add<int>("p_int", 2);
descriptions.addDefault(iDesc2);

// ------------------------------------------

edm::ParameterSetDescription iDesc3;
iDesc3.add<int>("p_int", 3);
descriptions.addWithDefaultLabel(iDesc3);
}
}
using edmtest::ProducerWithPSetDesc;
Expand Down
Expand Up @@ -726,6 +726,9 @@
noDefault22 untracked VLuminosityBlockRange none (do not write to cfi)
noDefault23 untracked EventRange none (do not write to cfi)
noDefault24 untracked VEventRange none (do not write to cfi)
1.3 description without a module label
1.3 producerWithPSetDesc
p_int int32 3
mightGet untracked vstring optional none (do not write to cfi)
1.4 description without a module label
p_int int32 2
mightGet untracked vstring optional none (do not write to cfi)
@@ -1,6 +1,6 @@
1 ProducerWithPSetDesc (EDProducer) "pluginTestProducerWithPSetDesc.so"

This plugin has 3 PSet descriptions. The description used to validate a
This plugin has 4 PSet descriptions. The description used to validate a
configuration is selected by matching the module labels. If none match, then
the last description, which has no label, is selected. A cfi file will be
generated for each configuration with a module label.
Expand Down Expand Up @@ -2174,7 +2174,23 @@ generated for each configuration with a module label.
type: untracked VEventRange
default: none (do not write to cfi)

1.3 description without a module label
1.3 module label: producerWithPSetDesc

p_int
type: int32
default: 3

mightGet
type: untracked vstring optional
default: none (do not write to cfi)
List contains the branch names for the EDProducts which
might be requested by the module.
The format for identifying the EDProduct is the same as
the one used for OutputModules, except no wild cards
are allowed. E.g.
Foos_foomodule_whichFoo_RECO

1.4 description without a module label

p_int
type: int32
Expand Down

0 comments on commit 1eed5e2

Please sign in to comment.