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(0
U, 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)) {
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.unwrappedType().typeInfo() ==
typeid(Collection)) {
164 if (
desc.produced() &&
desc.moduleLabel() == moduleDescription().moduleLabel() &&
165 desc.productInstanceName().empty()) {
166 thinnedCollectionID =
desc.branchID();
170 if (!
desc.produced()) {
171 parentCollectionIDs.push_back(
desc.branchID());
173 }
else if (inputTag_.
process().empty() || inputTag_.
process() ==
desc.processName()) {
174 if (
desc.produced()) {
175 parentCollectionIDs.push_back(
desc.originalBranchID());
177 parentCollectionIDs.push_back(
desc.branchID());
183 desc.moduleLabel() == moduleDescription().moduleLabel() &&
desc.productInstanceName().empty()) {
184 associationID =
desc.branchID();
187 if (parentCollectionIDs.empty()) {
193 for (
auto const& parentCollectionID : parentCollectionIDs) {
194 thinnedAssociationsHelper.
addAssociation(parentCollectionID, associationID, thinnedCollectionID, isSlimming);