CMS 3D CMS Logo

NTuplingDevice.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: NTuplingDevice
4 // Class: NTuplingDevice
5 //
13 //
14 // Original Author: Jean-Roch Vlimant
15 // Created: Sun May 11 21:12:46 CEST 2008
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
25 
28 
30 
32 
33 //
34 // class decleration
35 //
36 
38 public:
39  explicit NTuplingDevice(const edm::ParameterSet&);
40  ~NTuplingDevice() override;
41 
42 private:
43  void beginJob() override;
44  void produce(edm::Event&, const edm::EventSetup&) override;
45  void endJob() override;
46 
47  // ----------member data ---------------------------
48  std::unique_ptr<NTupler> ntupler_;
49 };
50 
51 //
52 // constants, enums and typedefs
53 //
54 
55 //
56 // static data member definitions
57 //
58 
59 //
60 // constructors and destructor
61 //
63  //this Ntupler can work with the InputTagDistributor, but should not be configured as such.
64  edm::ParameterSet ntPset = iConfig.getParameter<edm::ParameterSet>("Ntupler");
65  std::string ntuplerName = ntPset.getParameter<std::string>("ComponentName");
66  ntupler_ = NTuplerFactory::get()->create(ntuplerName, ntPset);
67 
68  //register the leaves from the ntupler
69  ntupler_->registerleaves(producesCollector());
70 
71  //put a dummy product if the ntupler does not output on edm
72  produces<double>("dummy");
73 }
74 
76 
77 // ------------ method called to produce the data ------------
79  ntupler_->fill(iEvent);
80  iEvent.put(std::make_unique<double>(0.), "dummy");
81 }
82 
83 // ------------ method called once each job just before starting event loop ------------
85 
86 // ------------ method called once each job just after ending the event loop ------------
88 
89 //define this as a plug-in
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
void beginJob() override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
NTuplingDevice(const edm::ParameterSet &)
void produce(edm::Event &, const edm::EventSetup &) override
~NTuplingDevice() override
int iEvent
Definition: GenABIO.cc:224
ProducesCollector producesCollector()
std::unique_ptr< NTupler > ntupler_
void endJob() override
#define get