00001 // -*- C++ -*- 00002 // 00003 // Package: NTuplingDevice 00004 // Class: NTuplingDevice 00005 // 00013 // 00014 // Original Author: Jean-Roch Vlimant 00015 // Created: Sun May 11 21:12:46 CEST 2008 00016 // $Id: NTuplingDevice.cc,v 1.4 2009/12/18 17:52:25 wmtan Exp $ 00017 // 00018 // 00019 00020 00021 // system include files 00022 #include <memory> 00023 00024 // user include files 00025 #include "FWCore/Framework/interface/Frameworkfwd.h" 00026 #include "FWCore/Framework/interface/EDProducer.h" 00027 00028 #include "FWCore/Framework/interface/Event.h" 00029 #include "FWCore/Framework/interface/MakerMacros.h" 00030 00031 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00032 00033 #include "PhysicsTools/UtilAlgos/interface/NTupler.h" 00034 00035 // 00036 // class decleration 00037 // 00038 00039 class NTuplingDevice : public edm::EDProducer { 00040 public: 00041 explicit NTuplingDevice(const edm::ParameterSet&); 00042 ~NTuplingDevice(); 00043 00044 private: 00045 virtual void beginJob() ; 00046 virtual void produce(edm::Event&, const edm::EventSetup&); 00047 virtual void endJob() ; 00048 00049 // ----------member data --------------------------- 00050 NTupler * ntupler_; 00051 }; 00052 00053 // 00054 // constants, enums and typedefs 00055 // 00056 00057 // 00058 // static data member definitions 00059 // 00060 00061 // 00062 // constructors and destructor 00063 // 00064 NTuplingDevice::NTuplingDevice(const edm::ParameterSet& iConfig) 00065 { 00066 //this Ntupler can work with the InputTagDistributor, but should not be configured as such. 00067 edm::ParameterSet ntPset = iConfig.getParameter<edm::ParameterSet>("Ntupler"); 00068 std::string ntuplerName=ntPset.getParameter<std::string>("ComponentName"); 00069 ntupler_ = NTuplerFactory::get()->create(ntuplerName, ntPset); 00070 00071 //register the leaves from the ntupler 00072 ntupler_->registerleaves(this); 00073 00074 //put a dummy product if the ntupler does not output on edm 00075 produces<double>("dummy"); 00076 } 00077 00078 00079 NTuplingDevice::~NTuplingDevice(){} 00080 00081 // ------------ method called to produce the data ------------ 00082 void 00083 NTuplingDevice::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) 00084 { 00085 ntupler_->fill(iEvent); 00086 std::auto_ptr<double> v(new double(0)); 00087 iEvent.put(v,"dummy"); 00088 } 00089 00090 // ------------ method called once each job just before starting event loop ------------ 00091 void 00092 NTuplingDevice::beginJob() 00093 { 00094 } 00095 00096 // ------------ method called once each job just after ending the event loop ------------ 00097 void 00098 NTuplingDevice::endJob() { 00099 } 00100 00101 //define this as a plug-in 00102 DEFINE_FWK_MODULE(NTuplingDevice);