Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-03-26 00:00:19

0001 // -*- C++ -*-
0002 //
0003 // Package:    Validation/RecoVertex
0004 // Class:      AnotherBeamSpotAnalyzer
0005 //
0006 /**\class AnotherBeamSpotAnalyzer BeamSpotAnalyzer.cc Validation/RecoVertex/plugins/BeamSpotAnalyzer.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Andrea Venturi
0015 //         Created:  Mon Oct 27 17:37:53 CET 2008
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 
0022 // user include files
0023 
0024 #include <vector>
0025 #include <map>
0026 #include <limits>
0027 
0028 #include "FWCore/Framework/interface/Frameworkfwd.h"
0029 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0030 
0031 #include "FWCore/Framework/interface/Event.h"
0032 #include "FWCore/Framework/interface/Run.h"
0033 #include "FWCore/Framework/interface/MakerMacros.h"
0034 
0035 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0036 
0037 #include "FWCore/Utilities/interface/InputTag.h"
0038 
0039 #include "Validation/RecoVertex/interface/BeamSpotHistogramMaker.h"
0040 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
0041 
0042 //
0043 // class decleration
0044 //
0045 
0046 class AnotherBeamSpotAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::SharedResources> {
0047 public:
0048   explicit AnotherBeamSpotAnalyzer(const edm::ParameterSet&);
0049   ~AnotherBeamSpotAnalyzer() override;
0050 
0051 private:
0052   void beginJob() override;
0053   void analyze(const edm::Event&, const edm::EventSetup&) override;
0054   void beginRun(const edm::Run&, const edm::EventSetup&) override;
0055   void endRun(const edm::Run&, const edm::EventSetup&) override;
0056   void endJob() override;
0057 
0058   // ----------member data ---------------------------
0059 
0060   BeamSpotHistogramMaker _bshm;
0061   edm::EDGetTokenT<reco::BeamSpot> _recoBeamSpotToken;
0062 };
0063 
0064 //
0065 // constants, enums and typedefs
0066 //
0067 
0068 //
0069 // static data member definitions
0070 //
0071 
0072 //
0073 // constructors and destructor
0074 //
0075 AnotherBeamSpotAnalyzer::AnotherBeamSpotAnalyzer(const edm::ParameterSet& iConfig)
0076     : _bshm(iConfig.getParameter<edm::ParameterSet>("bsHistogramMakerPSet"), consumesCollector()),
0077       _recoBeamSpotToken(consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("bsCollection"))) {
0078   //now do what ever initialization is needed
0079   usesResource(TFileService::kSharedResource);
0080   //
0081 
0082   _bshm.book();
0083 }
0084 
0085 AnotherBeamSpotAnalyzer::~AnotherBeamSpotAnalyzer() {
0086   // do anything here that needs to be done at desctruction time
0087   // (e.g. close files, deallocate resources etc.)
0088 }
0089 
0090 //
0091 // member functions
0092 //
0093 
0094 // ------------ method called to for each event  ------------
0095 void AnotherBeamSpotAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0096   // get BS
0097 
0098   edm::Handle<reco::BeamSpot> bs;
0099   iEvent.getByToken(_recoBeamSpotToken, bs);
0100   _bshm.fill(iEvent.orbitNumber(), *bs);
0101 }
0102 
0103 // ------------ method called once each job just before starting event loop  ------------
0104 void AnotherBeamSpotAnalyzer::beginJob() {}
0105 
0106 void AnotherBeamSpotAnalyzer::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
0107   _bshm.beginRun(iRun.run());
0108 }
0109 
0110 void AnotherBeamSpotAnalyzer::endRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {}
0111 // ------------ method called once each job just after ending the event loop  ------------
0112 void AnotherBeamSpotAnalyzer::endJob() {}
0113 
0114 //define this as a plug-in
0115 DEFINE_FWK_MODULE(AnotherBeamSpotAnalyzer);