Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-07 22:41:50

0001 #include "DPGAnalysis/Skims/interface/EcalTangentFilter.h"
0002 
0003 using namespace std;
0004 
0005 EcalTangentFilter::EcalTangentFilter(const edm::ParameterSet& iConfig) {
0006   fMuLabel = iConfig.getParameter<std::string>("MuLabel");
0007   fMuonD0Min = iConfig.getParameter<double>("MuD0Min");
0008   fMuonD0Max = iConfig.getParameter<double>("MuD0Max");
0009   fVerbose = iConfig.getParameter<bool>("Verbose");
0010   cout << "----------------------------------------------------------------------" << std::endl;
0011   cout << "--- EcalTangentFilter constructor" << std::endl;
0012   cout << "---  MuLabel:       " << fMuLabel << std::endl;
0013   cout << "---  MuonD0Min:     " << fMuonD0Min << std::endl;
0014   cout << "---  MuonD0Max:     " << fMuonD0Max << std::endl;
0015   cout << "---  Verbose:     " << fVerbose << std::endl;
0016   cout << "----------------------------------------------------------------------" << std::endl;
0017   fNgood = 0;
0018   fNtot = 0;
0019 }
0020 
0021 EcalTangentFilter::~EcalTangentFilter() {
0022   std::cout << "==> EcalTangentFilter> Number of accepted/total events = " << fNgood << "/" << fNtot << std::endl;
0023 }
0024 
0025 // ------------ method called on each new Event  ------------
0026 bool EcalTangentFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0027   ++fNtot;
0028   bool goodEvent(false);
0029   using namespace edm;
0030   using namespace reco;
0031   edm::Handle<reco::MuonCollection> Muons;
0032   iEvent.getByLabel(fMuLabel, Muons);
0033   for (MuonCollection::const_iterator muon = Muons->begin(); muon != Muons->end(); ++muon) {
0034     reco::TrackRef ref;
0035     if (muon->outerTrack().isNonnull()) {
0036       ref = muon->outerTrack();
0037       // Cut on impact parameter
0038       double d0 = ref->d0();
0039       if (fabs(d0) > fMuonD0Min && fabs(d0) < fMuonD0Max)
0040         goodEvent = true;
0041     }
0042   }
0043   if (goodEvent) {
0044     ++fNgood;
0045     if (fVerbose)
0046       std::cout << "==> EcalTangentFilter> new event r" << iEvent.id().run() << "/ev" << iEvent.id().event()
0047                 << " accepted, so far: " << fNgood << std::endl;
0048   }
0049   return goodEvent;
0050 }
0051 
0052 //define this as a plug-in
0053 DEFINE_FWK_MODULE(EcalTangentFilter);