CMS 3D CMS Logo

RecoDiMuon.cc
Go to the documentation of this file.
1 
11 //-ap #include "Configuration/CSA06Skimming/interface/RecoDiMuon.h"
13 
16 
17 #include <iostream>
18 
20 
21 using namespace edm;
22 using namespace std;
23 
24 RecoDiMuon::RecoDiMuon(const edm::ParameterSet& iConfig) : nEvents_(0), nAccepted_(0) {
25  muonLabel_ = iConfig.getParameter<InputTag>("MuonLabel");
26  singleMuonPtMin_ = iConfig.getUntrackedParameter<double>("SingleMuonPtMin", 20.);
27  diMuonPtMin_ = iConfig.getUntrackedParameter<double>("DiMuonPtMin", 5.);
28 }
29 
31 
33  edm::LogVerbatim("RecoDiMuon") << "Events read " << nEvents_ << " Events accepted " << nAccepted_ << "\nEfficiency "
34  << ((double)nAccepted_) / ((double)nEvents_) << std::endl;
35 }
36 
37 // ------------ method called to skim the data ------------
39  nEvents_++;
40  bool accepted = false;
41  using namespace edm;
42 
44 
45  iEvent.getByLabel(muonLabel_, muons);
46  if (!muons.isValid()) {
47  edm::LogError("RecoDiMuon") << "FAILED to get Muon Track Collection. ";
48  return false;
49  }
50 
51  if (muons->empty()) {
52  return false;
53  }
54 
55  // at least one muons above a pt threshold singleMuonPtMin
56  // or at least 2 muons above a pt threshold diMuonPtMin
57  int nMuonOver2ndCut = 0;
58  for (reco::TrackCollection::const_iterator muon = muons->begin(); muon != muons->end(); ++muon) {
59  if (muon->pt() > singleMuonPtMin_)
60  accepted = true;
61  if (muon->pt() > diMuonPtMin_)
62  nMuonOver2ndCut++;
63  }
64  if (nMuonOver2ndCut >= 2)
65  accepted = true;
66 
67  if (accepted)
68  nAccepted_++;
69 
70  return accepted;
71 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
RecoDiMuon(const edm::ParameterSet &)
Definition: RecoDiMuon.cc:24
unsigned int nAccepted_
Definition: RecoDiMuon.h:39
edm::InputTag muonLabel_
Definition: RecoDiMuon.h:35
int iEvent
Definition: GenABIO.cc:224
unsigned int nEvents_
Definition: RecoDiMuon.h:38
void endJob() override
Definition: RecoDiMuon.cc:32
bool isValid() const
Definition: HandleBase.h:70
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:488
~RecoDiMuon() override
Definition: RecoDiMuon.cc:30
bool accepted(std::vector< std::string_view > const &, std::string_view)
HLT enums.
double singleMuonPtMin_
Definition: RecoDiMuon.h:36
double diMuonPtMin_
Definition: RecoDiMuon.h:37
bool filter(edm::Event &, const edm::EventSetup &) override
Definition: RecoDiMuon.cc:38