CMS 3D CMS Logo

UniqueMerger.h
Go to the documentation of this file.
1 #ifndef UtilAlgos_UniqueMerger_h
2 #define UtilAlgos_UniqueMerger_h
3 
27 #include <vector>
28 
29 template <typename InputCollection,
33 public:
34  typedef std::set<typename OutputCollection::value_type> set_type;
36  explicit UniqueMerger(const edm::ParameterSet&);
38  ~UniqueMerger() override;
39 
40 private:
42  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
44  typedef std::vector<edm::EDGetTokenT<InputCollection> > vtoken;
47 };
48 
49 template <typename InputCollection, typename OutputCollection, typename P>
51  : srcToken_(edm::vector_transform(par.template getParameter<std::vector<edm::InputTag> >("src"),
52  [this](edm::InputTag const& tag) { return consumes<InputCollection>(tag); })) {
53  produces<OutputCollection>();
54 }
55 
56 template <typename InputCollection, typename OutputCollection, typename P>
58 
59 template <typename InputCollection, typename OutputCollection, typename P>
61  edm::Event& evt,
62  const edm::EventSetup&) const {
63  set_type coll_set;
64  for (typename vtoken::const_iterator s = srcToken_.begin(); s != srcToken_.end(); ++s) {
66  evt.getByToken(*s, h);
67  for (typename InputCollection::const_iterator c = h->begin(); c != h->end(); ++c) {
68  coll_set.emplace(P::clone(*c));
69  }
70  }
71  std::unique_ptr<OutputCollection> coll(new OutputCollection(coll_set.size()));
72  std::copy(coll_set.begin(), coll_set.end(), coll->begin());
73  evt.put(std::move(coll));
74 }
75 
76 #endif
edm::StreamID
Definition: StreamID.h:30
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
edm
HLT enums.
Definition: AlignableModifier.h:19
h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition: L1TUtmAlgorithmRcd.h:4
watchdog.const
const
Definition: watchdog.py:83
edm::Handle
Definition: AssociativeIterator.h:50
UniqueMerger::UniqueMerger
UniqueMerger(const edm::ParameterSet &)
constructor from parameter set
Definition: UniqueMerger.h:50
alignCSCRings.s
s
Definition: alignCSCRings.py:92
CloneTrait.h
clone
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
edm::clonehelper::CloneTrait
Definition: CloneTrait.h:12
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
h
UniqueMerger::srcToken_
vtoken srcToken_
labels of the collections to be merged
Definition: UniqueMerger.h:46
edm::global::EDProducer
Definition: EDProducer.h:32
edm::vector_transform
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 >
Definition: transform.h:11
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
UniqueMerger::set_type
std::set< typename OutputCollection::value_type > set_type
Definition: UniqueMerger.h:34
UniqueMerger::~UniqueMerger
~UniqueMerger() override
destructor
Definition: UniqueMerger.h:57
UniqueMerger::vtoken
std::vector< edm::EDGetTokenT< InputCollection > > vtoken
vector of strings
Definition: UniqueMerger.h:44
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:132
edm::EventSetup
Definition: EventSetup.h:57
svgfig.template
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
UniqueMerger
Definition: UniqueMerger.h:32
InputTag.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
transform.h
UniqueMerger::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
process an event
Definition: UniqueMerger.h:60
SimL1EmulatorRepack_GT2_cff.InputCollection
InputCollection
Definition: SimL1EmulatorRepack_GT2_cff.py:16
ParameterSet.h
EDProducer.h
P
std::pair< OmniClusterRef, TrackingParticleRef > P
Definition: BDHadronTrackMonitoringAnalyzer.cc:202
edm::Event
Definition: Event.h:73
HLTTauReferences_cfi.OutputCollection
OutputCollection
Definition: HLTTauReferences_cfi.py:92