1 #ifndef FWCore_Framework_ThinningProducer_h
2 #define FWCore_Framework_ThinningProducer_h
26 #include <type_traits>
35 static constexpr
bool value =
false;
39 static constexpr
bool value =
true;
42 template <
typename Item,
typename Selector,
typename Collection>
48 using SelectorChooseReturnType = decltype(selector.choose(0U, std::declval<Item const&>()));
50 if constexpr (isSlimming) {
51 std::optional<typename SelectorChooseReturnType::value_type>
obj = selector.choose(iIndex, item);
52 if (obj.has_value()) {
58 if (selector.choose(iIndex, item)) {
59 output.push_back(item);
67 template <
typename Collection,
typename Selector>
91 std::is_same_v<SelectorChooseReturnType, bool> ||
isSlimming,
92 "Selector::choose() must return bool (for pure thinning) or std::optional<ElementType> (for slimming)");
95 template <
typename Collection,
typename Selector>
97 : selector_(new
Selector(pset, consumesCollector())) {
105 template <
typename Collection,
typename Selector>
108 template <
typename Collection,
typename Selector>
111 desc.
setComment(
"Produces thinned collections and associations to them");
117 template <
typename Collection,
typename Selector>
124 Collection thinnedCollection;
127 unsigned int iIndex = 0;
129 using namespace detail;
138 event.emplace(thinnedOutToken_,
std::move(thinnedAssociation));
141 template <
typename Collection,
typename Selector>
158 std::vector<BranchID> parentCollectionIDs;
161 for (
auto const& product : productList) {
166 thinnedCollectionID = desc.
branchID();
169 if (inputTag_.willSkipCurrentProcess()) {
171 parentCollectionIDs.push_back(desc.
branchID());
173 }
else if (inputTag_.process().empty() || inputTag_.process() == desc.
processName()) {
177 parentCollectionIDs.push_back(desc.
branchID());
187 if (parentCollectionIDs.empty()) {
193 for (
auto const& parentCollectionID : parentCollectionIDs) {
194 thinnedAssociationsHelper.
addAssociation(parentCollectionID, associationID, thinnedCollectionID, isSlimming);
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
void setThinnedCollectionID(ProductID const &v)
void fillCollectionForThinning(Item const &item, Selector &selector, unsigned int iIndex, Collection &output, ThinnedAssociation &association)
std::map< BranchKey, BranchDescription > ProductList
std::string const & processName() const
decltype(selector_->choose(0U, std::declval< typename detail::ElementType< Collection >::type const >())) SelectorChooseReturnType
edm::propagate_const< std::unique_ptr< Selector > > selector_
edm::EDPutTokenT< Collection > outputToken_
ProductList const & productList() const
void setComment(std::string const &value)
typename std::remove_reference< decltype(*std::declval< Collection >().begin())>::type type
std::tuple< layerClusterToCaloParticle, caloParticleToLayerCluster > association
std::string const & moduleLabel() const
std::string const & productInstanceName() const
ThinningProducer(ParameterSet const &pset)
edm::EDGetTokenT< Collection > inputToken_
edm::EDPutTokenT< ThinnedAssociation > thinnedOutToken_
void produce(Event &event, EventSetup const &eventSetup) override
BranchID const & branchID() const
TypeWithDict const & unwrappedType() const
void addAssociation(BranchID const &, BranchID const &, BranchID const &, bool slimmed)
std::type_info const & typeInfo() const
virtual void push_back(std::string const &s)
This is the registration of an individual cut string.
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Functor that operates on <T>
void push_back(unsigned int index)
void registerThinnedAssociations(ProductRegistry const &productRegistry, ThinnedAssociationsHelper &thinnedAssociationsHelper) override
static constexpr bool value
~ThinningProducer() override
void fillPSetDescription(edm::ParameterSetDescription &desc)
void setParentCollectionID(ProductID const &v)
T getParameter(std::string const &) const
static constexpr bool isSlimming
BranchID const & originalBranchID() const
static void fillDescriptions(ConfigurationDescriptions &descriptions)