CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GeneratorSmearedProducer.cc
Go to the documentation of this file.
6 
11 
12 #include <memory>
13 
14 namespace edm {
15  class ParameterSet;
17  class Event;
18  class EventSetup;
19  class HepMCProduct;
20 } // namespace edm
21 
23 public:
25 
26  void produce(edm::StreamID, edm::Event& e, edm::EventSetup const& c) const override;
27  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
28 
29 private:
32 };
33 
35  : newToken_(consumes<edm::HepMCProduct>(ps.getUntrackedParameter<edm::InputTag>("currentTag"))),
36  oldToken_(consumes<edm::HepMCProduct>(ps.getUntrackedParameter<edm::InputTag>("previousTag"))) {
37  // This producer produces a HepMCProduct, a copy of the original one
38  // It is used for backwaerd compatibility
39  produces<edm::HepMCProduct>();
40 }
41 
43  edm::Handle<edm::HepMCProduct> theHepMCProduct;
44  bool found = iEvent.getByToken(newToken_, theHepMCProduct);
45  if (!found) {
46  found = iEvent.getByToken(oldToken_, theHepMCProduct);
47  }
48  if (found) {
49  std::unique_ptr<edm::HepMCProduct> theCopy(new edm::HepMCProduct(*theHepMCProduct));
50  iEvent.put(std::move(theCopy));
51  }
52 }
53 
56  desc.addUntracked<edm::InputTag>("currentTag", edm::InputTag("VtxSmeared"));
57  desc.addUntracked<edm::InputTag>("previousTag", edm::InputTag("generator"));
58  descriptions.add("generatorSmeared", desc);
59 }
60 
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
const edm::EventSetup & c
GeneratorSmearedProducer(edm::ParameterSet const &p)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::EDGetTokenT< edm::HepMCProduct > newToken_
int iEvent
Definition: GenABIO.cc:224
const edm::EDGetTokenT< edm::HepMCProduct > oldToken_
def move
Definition: eostools.py:511
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void produce(edm::StreamID, edm::Event &e, edm::EventSetup const &c) const override