CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/Alignment/MuonAlignmentAlgorithms/plugins/CSCOverlapsBeamSplashCut.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    CSCOverlapsBeamSplashCut
00004 // Class:      CSCOverlapsBeamSplashCut
00005 // 
00013 //
00014 // Original Author:  Jim Pivarski
00015 //         Created:  Sat Nov 21 21:18:04 CET 2009
00016 //
00017 
00018 // system include files
00019 #include <memory>
00020 
00021 // user include files
00022 #include "FWCore/Framework/interface/Frameworkfwd.h"
00023 #include "FWCore/Framework/interface/EDFilter.h"
00024 #include "FWCore/Framework/interface/Event.h"
00025 #include "FWCore/Framework/interface/EventSetup.h"
00026 #include "FWCore/Framework/interface/ESHandle.h"
00027 #include "FWCore/Framework/interface/MakerMacros.h"
00028 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00029 
00030 // references
00031 #include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h"
00032 #include "FWCore/ServiceRegistry/interface/Service.h"
00033 #include "CommonTools/UtilAlgos/interface/TFileService.h"
00034 #include "TH1F.h"
00035 
00036 //
00037 // class decleration
00038 //
00039 
00040 class CSCOverlapsBeamSplashCut : public edm::EDFilter {
00041    public:
00042       explicit CSCOverlapsBeamSplashCut(const edm::ParameterSet&);
00043       ~CSCOverlapsBeamSplashCut();
00044 
00045    private:
00046       virtual void beginJob() ;
00047       virtual bool filter(edm::Event&, const edm::EventSetup&);
00048       virtual void endJob() ;
00049       
00050       // ----------member data ---------------------------
00051       edm::InputTag m_src;
00052       int m_maxSegments;
00053       TH1F *m_numSegments;
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 CSCOverlapsBeamSplashCut::CSCOverlapsBeamSplashCut(const edm::ParameterSet& iConfig)
00068    : m_src(iConfig.getParameter<edm::InputTag>("src"))
00069    , m_maxSegments(iConfig.getParameter<int>("maxSegments"))
00070 {
00071    edm::Service<TFileService> tFileService;
00072    m_numSegments = tFileService->make<TH1F>("numSegments", "", 201, -0.5, 200.5);
00073 }
00074 
00075 
00076 CSCOverlapsBeamSplashCut::~CSCOverlapsBeamSplashCut()
00077 {
00078    // do anything here that needs to be done at desctruction time
00079    // (e.g. close files, deallocate resources etc.)
00080 }
00081 
00082 
00083 //
00084 // member functions
00085 //
00086 
00087 // ------------ method called to produce the data  ------------
00088 bool
00089 CSCOverlapsBeamSplashCut::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
00090    edm::Handle<CSCSegmentCollection> cscSegments;
00091    iEvent.getByLabel(m_src, cscSegments);
00092 
00093    m_numSegments->Fill(cscSegments->size());
00094 
00095    if (m_maxSegments < 0) return true;
00096 
00097    else if (int(cscSegments->size()) <= m_maxSegments) return true;
00098 
00099    else return false;
00100 }
00101 
00102 // ------------ method called once each job just before starting event loop  ------------
00103 void CSCOverlapsBeamSplashCut::beginJob() {}
00104 
00105 // ------------ method called once each job just after ending the event loop  ------------
00106 void CSCOverlapsBeamSplashCut::endJob() {}
00107 
00108 //define this as a plug-in
00109 DEFINE_FWK_MODULE(CSCOverlapsBeamSplashCut);