File indexing completed on 2024-04-06 11:56:44
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #include <memory>
0020
0021
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
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
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
0050 const edm::InputTag m_src;
0051 const int m_maxSegments;
0052 edm::EDGetTokenT<CSCSegmentCollection> cscToken_;
0053 TH1F* m_numSegments;
0054 };
0055
0056
0057
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
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
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
0095 DEFINE_FWK_MODULE(CSCOverlapsBeamSplashCut);