Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:44

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 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0030 
0031 // references
0032 #include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h"
0033 #include "FWCore/ServiceRegistry/interface/Service.h"
0034 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0035 #include "TH1F.h"
0036 
0037 //
0038 // class decleration
0039 //
0040 
0041 class CSCOverlapsBeamSplashCut : public edm::one::EDFilter<edm::one::SharedResources> {
0042 public:
0043   explicit CSCOverlapsBeamSplashCut(const edm::ParameterSet&);
0044   ~CSCOverlapsBeamSplashCut() override = default;
0045   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0046 
0047 private:
0048   bool filter(edm::Event&, const edm::EventSetup&) override;
0049   // ----------member data ---------------------------
0050   const edm::InputTag m_src;
0051   const int m_maxSegments;
0052   edm::EDGetTokenT<CSCSegmentCollection> cscToken_;
0053   TH1F* m_numSegments;
0054 };
0055 
0056 //
0057 // constructors and destructor
0058 //
0059 CSCOverlapsBeamSplashCut::CSCOverlapsBeamSplashCut(const edm::ParameterSet& iConfig)
0060     : m_src(iConfig.getParameter<edm::InputTag>("src")),
0061       m_maxSegments(iConfig.getParameter<int>("maxSegments")),
0062       cscToken_(consumes<CSCSegmentCollection>(m_src)) {
0063   usesResource(TFileService::kSharedResource);
0064   edm::Service<TFileService> tFileService;
0065   m_numSegments = tFileService->make<TH1F>("numSegments", "", 201, -0.5, 200.5);
0066 }
0067 
0068 //
0069 // member functions
0070 //
0071 void CSCOverlapsBeamSplashCut::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0072   edm::ParameterSetDescription desc;
0073   desc.add<edm::InputTag>("src", edm::InputTag("ALCARECOMuAlBeamHaloOverlaps"));
0074   desc.add<int>("maxSegments", 4);
0075   descriptions.add("cscOverlapsBeamSplashCut", desc);
0076 }
0077 
0078 // ------------ method called to produce the data  ------------
0079 bool CSCOverlapsBeamSplashCut::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0080   const edm::Handle<CSCSegmentCollection>& cscSegments = iEvent.getHandle(cscToken_);
0081 
0082   m_numSegments->Fill(cscSegments->size());
0083 
0084   if (m_maxSegments < 0)
0085     return true;
0086 
0087   else if (static_cast<int>(cscSegments->size()) <= m_maxSegments)
0088     return true;
0089 
0090   else
0091     return false;
0092 }
0093 
0094 //define this as a plug-in
0095 DEFINE_FWK_MODULE(CSCOverlapsBeamSplashCut);