CMS 3D CMS Logo

BasicMuonAnalyzer.cc
Go to the documentation of this file.
4 
7  : edm::BasicAnalyzer::BasicAnalyzer(cfg, fs), muons_(cfg.getParameter<edm::InputTag>("muons")) {
8  hists_["muonPt"] = fs.make<TH1F>("muonPt", "pt", 100, 0., 300.);
9  hists_["muonEta"] = fs.make<TH1F>("muonEta", "eta", 100, -3., 3.);
10  hists_["muonPhi"] = fs.make<TH1F>("muonPhi", "phi", 100, -5., 5.);
11  hists_["mumuMass"] = fs.make<TH1F>("mumuMass", "mass", 90, 30., 120.);
12 }
15  muons_(cfg.getParameter<edm::InputTag>("muons")),
16  muonsToken_(iC.consumes<std::vector<reco::Muon> >(muons_)) {
17  hists_["muonPt"] = fs.make<TH1F>("muonPt", "pt", 100, 0., 300.);
18  hists_["muonEta"] = fs.make<TH1F>("muonEta", "eta", 100, -3., 3.);
19  hists_["muonPhi"] = fs.make<TH1F>("muonPhi", "phi", 100, -5., 5.);
20  hists_["mumuMass"] = fs.make<TH1F>("mumuMass", "mass", 90, 30., 120.);
21 }
22 
25  // define what muon you are using; this is necessary as FWLite is not
26  // capable of reading edm::Views
27  using reco::Muon;
28 
29  // Handle to the muon collection
31  event.getByLabel(muons_, muons);
32 
33  // loop muon collection and fill histograms
34  for (std::vector<Muon>::const_iterator mu1 = muons->begin(); mu1 != muons->end(); ++mu1) {
35  hists_["muonPt"]->Fill(mu1->pt());
36  hists_["muonEta"]->Fill(mu1->eta());
37  hists_["muonPhi"]->Fill(mu1->phi());
38  if (mu1->pt() > 20 && fabs(mu1->eta()) < 2.1) {
39  for (std::vector<Muon>::const_iterator mu2 = muons->begin(); mu2 != muons->end(); ++mu2) {
40  if (mu2 > mu1) { // prevent double conting
41  if (mu1->charge() * mu2->charge() < 0) { // check only muon pairs of unequal charge
42  if (mu2->pt() > 20 && fabs(mu2->eta()) < 2.1) {
43  hists_["mumuMass"]->Fill((mu1->p4() + mu2->p4()).mass());
44  }
45  }
46  }
47  }
48  }
49  }
50 }
std::map< std::string, TH1 * > hists_
histograms
BasicMuonAnalyzer(const edm::ParameterSet &cfg, TFileDirectory &fs)
default constructor
Abstract base class for FWLite and EDM friendly analyzers.
Definition: Muon.py:1
void analyze(const edm::EventBase &event) override
everything that needs to be done during the event loop
fixed size matrix
HLT enums.
Definition: event.py:1
edm::InputTag muons_
input tag for mouns