Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-22 06:26:40

0001 // -*- C++ -*-
0002 //
0003 // Package:    CSCOverlapsBeamSplashCut
0004 // Class:      CSCOverlapsBeamSplashCut
0005 //
0006 /**\class CSCOverlapsBeamSplashCut CSCOverlapsBeamSplashCut.cc Alignment/CSCOverlapsBeamSplashCut/src/CSCOverlapsBeamSplashCut.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Jim Pivarski
0015 //         Created:  Sat Nov 21 21:18:04 CET 2009
0016 //
0017 
0018 // system include files
0019 #include <memory>
0020 
0021 // user include files
0022 #include "FWCore/Framework/interface/Frameworkfwd.h"
0023 #include "FWCore/Framework/interface/one/EDFilter.h"
0024 #include "FWCore/Framework/interface/Event.h"
0025 #include "FWCore/Framework/interface/EventSetup.h"
0026 #include "FWCore/Framework/interface/ESHandle.h"
0027 #include "FWCore/Framework/interface/MakerMacros.h"
0028 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0029 
0030 // references
0031 #include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h"
0032 #include "FWCore/ServiceRegistry/interface/Service.h"
0033 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0034 #include "TH1F.h"
0035 
0036 //
0037 // class decleration
0038 //
0039 
0040 class CSCOverlapsBeamSplashCut : public edm::one::EDFilter<edm::one::SharedResources> {
0041 public:
0042   explicit CSCOverlapsBeamSplashCut(const edm::ParameterSet&);
0043   ~CSCOverlapsBeamSplashCut() override = default;
0044 
0045 private:
0046   bool filter(edm::Event&, const edm::EventSetup&) override;
0047   // ----------member data ---------------------------
0048   edm::InputTag m_src;
0049   int m_maxSegments;
0050   TH1F* m_numSegments;
0051 };
0052 
0053 //
0054 // constructors and destructor
0055 //
0056 CSCOverlapsBeamSplashCut::CSCOverlapsBeamSplashCut(const edm::ParameterSet& iConfig)
0057     : m_src(iConfig.getParameter<edm::InputTag>("src")), m_maxSegments(iConfig.getParameter<int>("maxSegments")) {
0058   usesResource(TFileService::kSharedResource);
0059   edm::Service<TFileService> tFileService;
0060   m_numSegments = tFileService->make<TH1F>("numSegments", "", 201, -0.5, 200.5);
0061 }
0062 
0063 //
0064 // member functions
0065 //
0066 
0067 // ------------ method called to produce the data  ------------
0068 bool CSCOverlapsBeamSplashCut::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0069   edm::Handle<CSCSegmentCollection> cscSegments;
0070   iEvent.getByLabel(m_src, cscSegments);
0071 
0072   m_numSegments->Fill(cscSegments->size());
0073 
0074   if (m_maxSegments < 0)
0075     return true;
0076 
0077   else if (int(cscSegments->size()) <= m_maxSegments)
0078     return true;
0079 
0080   else
0081     return false;
0082 }
0083 
0084 //define this as a plug-in
0085 DEFINE_FWK_MODULE(CSCOverlapsBeamSplashCut);