CMS 3D CMS Logo

badGlobalMuonTaggerFWLite.py
Go to the documentation of this file.
1 from builtins import range
2 import ROOT
3 ROOT.gInterpreter.ProcessLine("#include <DataFormats/MuonReco/interface/MuonSelectors.h>")
4 
6 
7 
9  def __init__(self,selectClones,muonPtCut):
10  self.selectClones_ = selectClones
11  self.ptCut_ = muonPtCut
12 
13  def outInOnly(self,mu):
14  tk = mu.innerTrack().get();
15  return tk.algoMask().count() == 1 and tk.isAlgoInMask(tk.muonSeededStepOutIn);
16  def preselection(self, mu):
17  return (not(self.selectClones_) or self.outInOnly(mu));
18  def tighterId(self, mu):
19  return mu.isMediumMuon() and mu.numberOfMatchedStations() >= 2;
20  def tightGlobal(self, mu):
21  return mu.isGlobalMuon() and (mu.globalTrack().hitPattern().muonStationsWithValidHits() >= 3 and mu.globalTrack().normalizedChi2() <= 20);
22  def safeId(self, mu):
23  if (mu.muonBestTrack().ptError() > 0.2 * mu.muonBestTrack().pt()): return False;
24  return mu.numberOfMatchedStations() >= 1 or self.tightGlobal(mu);
25  def partnerId(self, mu):
26  return mu.pt() >= 10 and mu.numberOfMatchedStations() >= 1;
27 
28  def badMuons(self, allmuons, allvertices):
29  """Returns the list of bad muons in an event"""
30 
31  muons = list(m for m in allmuons) # make it a python list
32  goodMuon = []
33 
34  if len(allvertices) < 1: raise RuntimeError
35  PV = allvertices[0].position()
36 
37  out = []
38  for mu in muons:
39  if (not(mu.isPFMuon()) or mu.innerTrack().isNull()):
40  goodMuon.append(-1); # bad but we don't care
41  continue;
42  if (self.preselection(mu)):
43  dxypv = abs(mu.innerTrack().dxy(PV));
44  dzpv = abs(mu.innerTrack().dz(PV));
45  if (self.tighterId(mu)):
46  ipLoose = ((dxypv < 0.5 and dzpv < 2.0) or mu.innerTrack().hitPattern().pixelLayersWithMeasurement() >= 2);
47  goodMuon.append(ipLoose or (not(self.selectClones_) and self.tightGlobal(mu)));
48  elif (self.safeId(mu)):
49  ipTight = (dxypv < 0.2 and dzpv < 0.5);
50  goodMuon.append(ipTight);
51  else:
52  goodMuon.append(0);
53  else:
54  goodMuon.append(3); # maybe good, maybe bad, but we don't care
55 
56  n = len(muons)
57  for i in range(n):
58  if (muons[i].pt() < self.ptCut_ or goodMuon[i] != 0): continue;
59  bad = True;
60  if (self.selectClones_):
61  bad = False; # unless proven otherwise
62  n1 = muons[i].numberOfMatches(ROOT.reco.Muon.SegmentArbitration);
63  for j in range(n):
64  if (j == i or goodMuon[j] <= 0 or not(self.partnerId(muons[j]))): continue
65  n2 = muons[j].numberOfMatches(ROOT.reco.Muon.SegmentArbitration);
66  if (deltaR(muons[i],muons[j]) < 0.4 or (n1 > 0 and n2 > 0 and ROOT.muon.sharedSegments(muons[i],muons[j]) >= 0.5*min(n1,n2))):
67  bad = True;
68  break;
69  if (bad):
70  out.append(muons[i]);
71  return out
72 
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T min(T a, T b)
Definition: MathUtil.h:58
static int position[264][3]
Definition: ReadPGInfo.cc:509
T get(const Candidate &c)
Definition: component.h:55
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