1 #ifndef FWCore_Framework_ThinningProducer_h 2 #define FWCore_Framework_ThinningProducer_h 26 #include <type_traits> 42 template <
typename Item,
typename Selector,
typename Collection>
48 using SelectorChooseReturnType = decltype(
selector.choose(0
U, std::declval<Item const&>()));
51 std::optional<typename SelectorChooseReturnType::value_type>
obj =
selector.choose(iIndex,
item);
52 if (
obj.has_value()) {
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>
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;
138 event.emplace(thinnedOutToken_,
std::move(thinnedAssociation));
141 template <
typename Collection,
typename Selector>
158 std::vector<BranchID> parentCollectionIDs;
161 for (
auto const& product : productList) {
163 if (
desc.dropped()) {
169 if (
desc.unwrappedType().typeInfo() ==
typeid(Collection)) {
170 if (
desc.produced() &&
desc.moduleLabel() == moduleDescription().moduleLabel() &&
171 desc.productInstanceName().empty()) {
172 thinnedCollectionID =
desc.branchID();
176 if (!
desc.produced()) {
177 parentCollectionIDs.push_back(
desc.branchID());
179 }
else if (inputTag_.
process().empty() || inputTag_.
process() ==
desc.processName()) {
180 if (
desc.produced()) {
181 parentCollectionIDs.push_back(
desc.originalBranchID());
183 parentCollectionIDs.push_back(
desc.branchID());
189 desc.moduleLabel() == moduleDescription().moduleLabel() &&
desc.productInstanceName().empty()) {
190 associationID =
desc.branchID();
193 if (parentCollectionIDs.empty()) {
199 for (
auto const& parentCollectionID : parentCollectionIDs) {
200 thinnedAssociationsHelper.
addAssociation(parentCollectionID, associationID, thinnedCollectionID, isSlimming);
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
void setThinnedCollectionID(ProductID const &v)
ProductList const & productList() const
void fillCollectionForThinning(Item const &item, Selector &selector, unsigned int iIndex, Collection &output, ThinnedAssociation &association)
std::map< BranchKey, BranchDescription > ProductList
decltype(selector_->choose(0U, std::declval< typename detail::ElementType< Collection >::type const >())) SelectorChooseReturnType
edm::propagate_const< std::unique_ptr< Selector > > selector_
std::tuple< layerClusterToCaloParticle, caloParticleToLayerCluster > association
edm::EDPutTokenT< Collection > outputToken_
typename std::remove_reference< decltype(*std::declval< Collection >().begin())>::type type
ThinningProducer(ParameterSet const &pset)
edm::EDGetTokenT< Collection > inputToken_
edm::EDPutTokenT< ThinnedAssociation > thinnedOutToken_
void produce(Event &event, EventSetup const &eventSetup) override
void addAssociation(BranchID const &, BranchID const &, BranchID const &, bool slimmed)
Functor that operates on <T>
void registerThinnedAssociations(ProductRegistry const &productRegistry, ThinnedAssociationsHelper &thinnedAssociationsHelper) override
~ThinningProducer() override
void fillPSetDescription(edm::ParameterSetDescription &desc)
void setParentCollectionID(ProductID const &v)
static constexpr bool isSlimming
static void fillDescriptions(ConfigurationDescriptions &descriptions)