1 #ifndef UtilAlgos_UniqueMerger_h 2 #define UtilAlgos_UniqueMerger_h 37 typedef std::set<typename OutputCollection::value_type>
set_type;
47 typedef std::vector<edm::EDGetTokenT<InputCollection> >
vtoken;
56 template <
typename InputCollection,
typename OutputCollection,
typename P>
60 skipNulls_(par.getParameter<
bool>(
"skipNulls")),
61 warnOnSkip_(par.getParameter<
bool>(
"warnOnSkip")) {
62 produces<OutputCollection>();
65 template <
typename InputCollection,
typename OutputCollection,
typename P>
68 template <
typename InputCollection,
typename OutputCollection,
typename P>
73 for (
auto const&
s : srcToken_) {
74 for (
auto const&
c : evt.
get(
s)) {
75 if (!skipNulls_ || (
c.isNonnull() &&
c.isAvailable())) {
77 }
else if (warnOnSkip_) {
78 edm::LogWarning(
"InvalidPointer") <<
"Found an invalid pointer. Will not merge to collection.";
82 std::unique_ptr<OutputCollection> coll(
new OutputCollection(coll_set.size()));
83 std::copy(coll_set.begin(), coll_set.end(), coll->begin());
UniqueMerger(const edm::ParameterSet &)
constructor from parameter set
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool get(ProductID const &oid, Handle< PROD > &result) const
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
bool skipNulls_
choose whether to skip null/invalid pointers
bool warnOnSkip_
choose whether to warn when skipping pointers
vtoken srcToken_
labels of the collections to be merged
def template(fileName, svg, replaceme="REPLACEME")
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
process an event
std::set< typename OutputCollection::value_type > set_type
std::pair< OmniClusterRef, TrackingParticleRef > P
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
~UniqueMerger() override
destructor
std::vector< edm::EDGetTokenT< InputCollection > > vtoken
vector of strings
Log< level::Warning, false > LogWarning