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 
33 
34 //
35 // class decleration
36 //
37 
38 class NTuplingDevice : public edm::one::EDProducer<edm::one::SharedResources> {
39 public:
40  explicit NTuplingDevice(const edm::ParameterSet&);
41  ~NTuplingDevice() override;
42 
43 private:
44  void produce(edm::Event&, const edm::EventSetup&) override;
45 
46  // ----------member data ---------------------------
47  std::unique_ptr<NTupler> ntupler_;
48 };
49 
50 //
51 // constants, enums and typedefs
52 //
53 
54 //
55 // static data member definitions
56 //
57 
58 //
59 // constructors and destructor
60 //
62  usesResource(TFileService::kSharedResource);
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 //define this as a plug-in
static const std::string kSharedResource
Definition: TFileService.h:76
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
NTuplingDevice(const edm::ParameterSet &)
void produce(edm::Event &, const edm::EventSetup &) override
~NTuplingDevice() override
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ProducesCollector producesCollector()
std::unique_ptr< NTupler > ntupler_
#define get