CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/PhysicsTools/UtilAlgos/plugins/PlottingDevice.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    PlottingDevice
00004 // Class:      PlottingDevice
00005 // 
00013 //
00014 // Original Author:  Jean-Roch Vlimant
00015 //         Created:  Thu May 15 14:37:59 CEST 2008
00016 // $Id: PlottingDevice.cc,v 1.7 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/EDAnalyzer.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 // class decleration
00034 //
00035 
00036 #include "PhysicsTools/UtilAlgos/interface/Plotter.h"
00037 #include "PhysicsTools/UtilAlgos/interface/VariableHelper.h"
00038 
00039 class PlottingDevice : public edm::EDAnalyzer {
00040    public:
00041       explicit PlottingDevice(const edm::ParameterSet&);
00042       ~PlottingDevice();
00043 
00044 
00045    private:
00046       virtual void beginJob() ;
00047       virtual void analyze(const edm::Event&, const edm::EventSetup&);
00048       virtual void endJob() ;
00049 
00050       // ----------member data ---------------------------
00051   std::string vHelperInstance_;
00052   std::string plotDirectoryName_;
00053   Plotter * plotter_;
00054 };
00055 
00056 //
00057 // constants, enums and typedefs
00058 //
00059 
00060 //
00061 // static data member definitions
00062 //
00063 
00064 //
00065 // constructors and destructor
00066 //
00067 PlottingDevice::PlottingDevice(const edm::ParameterSet& iConfig)
00068 {
00069   vHelperInstance_ = iConfig.getParameter<std::string>("@module_label");
00070   plotDirectoryName_="PlottingDevice";
00071   
00072   //configure the inputtag distributor
00073   if (iConfig.exists("InputTags"))
00074     edm::Service<InputTagDistributorService>()->init(vHelperInstance_,iConfig.getParameter<edm::ParameterSet>("InputTags"));
00075   
00076   //configure the variable helper
00077   edm::Service<VariableHelperService>()->init(vHelperInstance_,iConfig.getParameter<edm::ParameterSet>("Variables"));
00078 
00079   //configure the plotting device
00080   edm::ParameterSet plotPset = iConfig.getParameter<edm::ParameterSet>("Plotter");
00081   std::string plotterName = plotPset.getParameter<std::string>("ComponentName");
00082   plotter_ = PlotterFactory::get()->create(plotterName, plotPset);
00083 }
00084 
00085 
00086 PlottingDevice::~PlottingDevice(){}
00087 
00088 
00089 //
00090 // member functions
00091 //
00092 
00093 // ------------ method called to for each event  ------------
00094 void
00095 PlottingDevice::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00096 {
00097   plotter_->setDir(plotDirectoryName_);
00098 
00099   plotter_->fill(plotDirectoryName_, iEvent);
00100 }
00101 
00102 
00103 void PlottingDevice::beginJob(){}
00104 void PlottingDevice::endJob() {}
00105 
00106 //define this as a plug-in
00107 DEFINE_FWK_MODULE(PlottingDevice);