Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:24:17

0001 // -*- C++ -*-
0002 //
0003 // Package:    PlottingDevice
0004 // Class:      PlottingDevice
0005 //
0006 /**\class PlottingDevice PlottingDevice.cc Workspace/PlottingDevice/src/PlottingDevice.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Jean-Roch Vlimant
0015 //         Created:  Thu May 15 14:37:59 CEST 2008
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 
0022 // user include files
0023 #include "FWCore/Framework/interface/Frameworkfwd.h"
0024 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0025 
0026 #include "FWCore/Framework/interface/Event.h"
0027 #include "FWCore/Framework/interface/MakerMacros.h"
0028 
0029 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0030 //
0031 // class decleration
0032 //
0033 
0034 #include "PhysicsTools/UtilAlgos/interface/Plotter.h"
0035 #include "PhysicsTools/UtilAlgos/interface/VariableHelper.h"
0036 
0037 class PlottingDevice : public edm::one::EDAnalyzer<> {
0038 public:
0039   explicit PlottingDevice(const edm::ParameterSet&);
0040 
0041 private:
0042   void analyze(const edm::Event&, const edm::EventSetup&) override;
0043 
0044   // ----------member data ---------------------------
0045   std::string vHelperInstance_;
0046   std::string plotDirectoryName_;
0047   std::unique_ptr<Plotter> plotter_;
0048 };
0049 
0050 //
0051 // constants, enums and typedefs
0052 //
0053 
0054 //
0055 // static data member definitions
0056 //
0057 
0058 //
0059 // constructors and destructor
0060 //
0061 PlottingDevice::PlottingDevice(const edm::ParameterSet& iConfig) {
0062   vHelperInstance_ = iConfig.getParameter<std::string>("@module_label");
0063   plotDirectoryName_ = "PlottingDevice";
0064 
0065   //configure the inputtag distributor
0066   if (iConfig.exists("InputTags"))
0067     edm::Service<InputTagDistributorService>()->init(
0068         vHelperInstance_, iConfig.getParameter<edm::ParameterSet>("InputTags"), consumesCollector());
0069 
0070   //configure the variable helper
0071   edm::Service<VariableHelperService>()->init(
0072       vHelperInstance_, iConfig.getParameter<edm::ParameterSet>("Variables"), consumesCollector());
0073 
0074   //configure the plotting device
0075   edm::ParameterSet plotPset = iConfig.getParameter<edm::ParameterSet>("Plotter");
0076   std::string plotterName = plotPset.getParameter<std::string>("ComponentName");
0077   plotter_ = PlotterFactory::get()->create(plotterName, plotPset);
0078 }
0079 
0080 //
0081 // member functions
0082 //
0083 
0084 // ------------ method called to for each event  ------------
0085 void PlottingDevice::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0086   plotter_->setDir(plotDirectoryName_);
0087 
0088   plotter_->fill(plotDirectoryName_, iEvent);
0089 }
0090 //define this as a plug-in
0091 DEFINE_FWK_MODULE(PlottingDevice);