CMS 3D CMS Logo

ZtoMMEventSelector.cc
Go to the documentation of this file.
9 #include "TLorentzVector.h"
10 
13 #include "TH1.h"
15 
16 using namespace std;
17 using namespace edm;
18 
20  : verbose_(ps.getUntrackedParameter<bool>("verbose", false)),
21  muonTag_(ps.getUntrackedParameter<edm::InputTag>("muonInputTag", edm::InputTag("muons"))),
22  bsTag_(ps.getUntrackedParameter<edm::InputTag>("offlineBeamSpot", edm::InputTag("offlineBeamSpot"))),
23  muonToken_(consumes<reco::MuonCollection>(muonTag_)),
24  bsToken_(consumes<reco::BeamSpot>(bsTag_)),
25  maxEta_(ps.getUntrackedParameter<double>("maxEta", 2.1)),
26  minPt_(ps.getUntrackedParameter<double>("minPt", 5)),
27  maxNormChi2_(ps.getUntrackedParameter<double>("maxNormChi2", 10)),
28  maxD0_(ps.getUntrackedParameter<double>("maxD0", 0.02)),
29  maxDz_(ps.getUntrackedParameter<double>("maxDz", 20.)),
30  minPixelHits_(ps.getUntrackedParameter<uint32_t>("minPixelHits", 1)),
31  minStripHits_(ps.getUntrackedParameter<uint32_t>("minStripHits", 8)),
32  minChambers_(ps.getUntrackedParameter<uint32_t>("minChambers", 2)),
33  minMatches_(ps.getUntrackedParameter<uint32_t>("minMatches", 2)),
34  minMatchedStations_(ps.getUntrackedParameter<double>("minMatchedStations", 2)),
35  maxIso_(ps.getUntrackedParameter<double>("maxIso", 0.3)),
36  minPtHighest_(ps.getUntrackedParameter<double>("minPtHighest", 24)),
37  minInvMass_(ps.getUntrackedParameter<double>("minInvMass", 60)),
38  maxInvMass_(ps.getUntrackedParameter<double>("maxInvMass", 120)) {}
40  // Read Muon Collection
42  iEvent.getByToken(muonToken_, muonColl);
43 
44  // and the beamspot
46  iEvent.getByToken(bsToken_, beamSpot);
47 
48  std::vector<TLorentzVector> list;
49  if (muonColl.isValid()) {
50  for (auto const& mu : *muonColl) {
51  if (!mu.isGlobalMuon())
52  continue;
53  if (!mu.isPFMuon())
54  continue;
55  if (std::fabs(mu.eta()) >= maxEta_)
56  continue;
57  if (mu.pt() < minPt_)
58  continue;
59 
60  reco::TrackRef gtk = mu.globalTrack();
61  double chi2 = gtk->chi2();
62  double ndof = gtk->ndof();
63  double chbyndof = (ndof > 0) ? chi2 / ndof : 0;
64  if (chbyndof >= maxNormChi2_)
65  continue;
66 
67  reco::TrackRef tk = mu.innerTrack();
68  double trkd0 = tk->d0();
69  double trkdz = tk->dz();
70  if (beamSpot.isValid()) {
71  trkd0 = -(tk->dxy(beamSpot->position()));
72  if (std::fabs(trkd0) >= maxD0_)
73  continue;
74  trkdz = tk->dz(beamSpot->position());
75  if (std::fabs(trkdz) >= maxDz_)
76  continue;
77  } else {
78  edm::LogError("ZtoMMEventSelector") << "Error >> Failed to get BeamSpot for label: " << bsTag_;
79  }
80 
81  const reco::HitPattern& hitp = gtk->hitPattern();
83  continue;
85  continue;
86 
87  // Hits/section in the muon chamber
88  if (mu.numberOfChambers() < minChambers_)
89  continue;
90  if (mu.numberOfMatches() < minMatches_)
91  continue;
92  if (mu.numberOfMatchedStations() < minMatchedStations_)
93  continue;
95  continue;
96 
97  // PF Isolation
98  const reco::MuonPFIsolation& pfIso04 = mu.pfIsolationR04();
99  double absiso = pfIso04.sumChargedParticlePt +
100  std::max(0.0, pfIso04.sumNeutralHadronEt + pfIso04.sumPhotonEt - 0.5 * pfIso04.sumPUPt);
101  if (absiso / mu.pt() > maxIso_)
102  continue;
103 
104  TLorentzVector lv;
105  lv.SetPtEtaPhiE(mu.pt(), mu.eta(), mu.phi(), mu.energy());
106  list.push_back(lv);
107  }
108  } else {
109  edm::LogError("ZtoMMEventSelector") << "Error >> Failed to get MuonCollection for label: " << muonTag_;
110  return false;
111  }
112 
113  if (list.size() < 2)
114  return false;
115  if (list[0].Pt() < minPtHighest_)
116  return false;
117  TLorentzVector zv = list[0] + list[1];
118  double mass = zv.M();
119  if (mass < minInvMass_ || mass > maxInvMass_)
120  return false;
121 
122  return true;
123 }
124 
125 // Define this as a plug-in
const edm::InputTag muonTag_
const double maxNormChi2_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
int numberOfValidStripHits() const
Definition: HitPattern.h:813
float sumPhotonEt
sum pt of PF photons
const double minPtHighest_
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
float sumNeutralHadronEt
sum pt of neutral hadrons
float sumChargedParticlePt
sum-pt of charged Particles(inludes e/mu)
float sumPUPt
sum pt of charged Particles not from PV (for Pu corrections)
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const edm::EDGetTokenT< reco::MuonCollection > muonToken_
bool isValid() const
Definition: HandleBase.h:70
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
ZtoMMEventSelector(const edm::ParameterSet &)
const edm::InputTag bsTag_
const edm::EDGetTokenT< reco::BeamSpot > bsToken_
bool filter(edm::Event &, edm::EventSetup const &) override
fixed size matrix
HLT enums.
int numberOfValidPixelHits() const
Definition: HitPattern.h:801
const Point & position() const
position
Definition: BeamSpot.h:59
const double maxInvMass_
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run