CMS 3D CMS Logo

TrackOfDSVThingsProducer.cc
Go to the documentation of this file.
3 #include "DataFormats/TestObjects/interface/Thing.h"
4 #include "DataFormats/TestObjects/interface/TrackOfDSVThings.h"
10 
11 namespace edm {
12  class EventSetup;
13 }
14 
15 namespace edmtest {
16 
18  public:
20 
21  void produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const override;
22 
23  private:
24  void incrementKey(std::vector<unsigned int>::const_iterator& key) const;
25 
28  const std::vector<unsigned int> keysToReference_;
29  const unsigned int nTracks_;
30  };
31 
33  : inputToken_(consumes<edmNew::DetSetVector<Thing>>(pset.getParameter<edm::InputTag>("inputTag"))),
34  outputToken_(produces<TrackOfDSVThingsCollection>()),
35  keysToReference_(pset.getParameter<std::vector<unsigned int>>("keysToReference")),
36  nTracks_(pset.getParameter<unsigned int>("nTracks")) {}
37 
38  void TrackOfDSVThingsProducer::incrementKey(std::vector<unsigned int>::const_iterator& key) const {
39  ++key;
40  if (key == keysToReference_.end())
41  key = keysToReference_.begin();
42  }
43 
46 
47  TrackOfDSVThingsCollection result;
48 
49  // Arbitrarily fabricate some fake data with TrackOfThings pointing to
50  // Thing objects in products written to the event by a different module.
51  // The numbers in the keys here are made up, passed in via the configuration
52  // and have no meaning other than that we will later check that we can
53  // read out what we put in here.
54  std::vector<unsigned int>::const_iterator key = keysToReference_.begin();
55  for (unsigned int i = 0; i < nTracks_; ++i) {
56  edmtest::TrackOfDSVThings trackOfThings;
57 
58  trackOfThings.ref1 = edm::Ref<edmNew::DetSetVector<Thing>, Thing>(inputCollection, *key);
60 
61  trackOfThings.ref2 = edm::Ref<edmNew::DetSetVector<Thing>, Thing>(inputCollection, *key);
63 
64  for (auto iKey : keysToReference_) {
65  trackOfThings.refVector1.push_back(edm::Ref<edmNew::DetSetVector<Thing>, Thing>(inputCollection, iKey));
66  }
67 
68  result.push_back(trackOfThings);
69  }
70 
71  event.emplace(outputToken_, std::move(result));
72  }
73 } // namespace edmtest
void incrementKey(std::vector< unsigned int >::const_iterator &key) const
TrackOfDSVThingsProducer(edm::ParameterSet const &)
void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const override
const edm::EDGetTokenT< edmNew::DetSetVector< Thing > > inputToken_
const std::vector< unsigned int > keysToReference_
key
prepare the HTCondor submission files and eventually submit them
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const edm::EDPutTokenT< TrackOfDSVThingsCollection > outputToken_
HLT enums.
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1