CMS 3D CMS Logo

DTSegmentSelector.cc
Go to the documentation of this file.
2 
8 
15 
17  : muonTags_(pset.getParameter<edm::InputTag>("Muons")),
18  checkNoisyChannels_(pset.getParameter<bool>("checkNoisyChannels")),
19  minHitsPhi_(pset.getParameter<int>("minHitsPhi")),
20  minHitsZ_(pset.getParameter<int>("minHitsZ")),
21  maxChi2_(pset.getParameter<double>("maxChi2")),
22  maxAnglePhi_(pset.getParameter<double>("maxAnglePhi")),
23  maxAngleZ_(pset.getParameter<double>("maxAngleZ")) {
25 }
26 
28  edm::Event const& event,
29  edm::EventSetup const& setup) {
30  bool result = true;
31 
32  /* get the muon collection if one is specified
33  (not specifying a muon collection switches off muon matching */
34  if (!muonTags_.label().empty()) {
36  event.getByToken(muonToken_, muonH);
37  const std::vector<reco::Muon>* muons = muonH.product();
38  //std::cout << " Muon collection size: " << muons->size() << std::endl;
39  if (muons->empty())
40  return false;
41 
42  DTChamberId segId(segment.rawId());
43 
44  bool matched = false;
45  for (auto& imuon : *muons)
46  for (const auto& ch : imuon.matches()) {
47  DetId chId(ch.id.rawId());
48  if (chId != segId)
49  continue;
50  if (imuon.pt() < 15 || !imuon.isGlobalMuon())
51  continue;
52 
53  int nsegs = ch.segmentMatches.size();
54  if (!nsegs)
55  continue;
56 
57  LocalPoint posHit = segment.localPosition();
58  float dx = (posHit.x() ? posHit.x() - ch.x : 0);
59  float dy = (posHit.y() ? posHit.y() - ch.y : 0);
60  float dr = sqrt(dx * dx + dy * dy);
61  if (dr < 5)
62  matched = true;
63  }
64 
65  if (!matched)
66  result = false;
67  }
68 
71  setup.get<DTStatusFlagRcd>().get(statusMap);
72 
73  // Get the Phi 2D segment
74  int nPhiHits = -1;
75  bool segmentNoisyPhi = false;
76  if (segment.hasPhi()) {
77  const DTChamberRecSegment2D* phiSeg = segment.phiSegment(); // phiSeg lives in the chamber RF
78  std::vector<DTRecHit1D> phiRecHits = phiSeg->specificRecHits();
79  nPhiHits = phiRecHits.size();
81  segmentNoisyPhi = checkNoisySegment(statusMap, phiRecHits);
82  //} else result = false;
83  }
84  // Get the Theta 2D segment
85  int nZHits = -1;
86  bool segmentNoisyZ = false;
87  if (segment.hasZed()) {
88  const DTSLRecSegment2D* zSeg = segment.zSegment(); // zSeg lives in the SL RF
89  std::vector<DTRecHit1D> zRecHits = zSeg->specificRecHits();
90  nZHits = zRecHits.size();
92  segmentNoisyZ = checkNoisySegment(statusMap, zRecHits);
93  }
94 
95  // Segment selection
96  // Discard segment if it has a noisy cell
97  if (segmentNoisyPhi || segmentNoisyZ)
98  result = false;
99 
100  // 2D-segment number of hits
101  if (segment.hasPhi() && nPhiHits < minHitsPhi_)
102  result = false;
103 
104  if (segment.hasZed() && nZHits < minHitsZ_)
105  result = false;
106 
107  // Segment chi2
108  double chiSquare = segment.chi2() / segment.degreesOfFreedom();
109  if (chiSquare > maxChi2_)
110  result = false;
111 
112  // Segment angle
113  LocalVector segment4DLocalDir = segment.localDirection();
114  double angleZ = fabs(atan(segment4DLocalDir.y() / segment4DLocalDir.z()) * 180. / Geom::pi());
115  if (angleZ > maxAngleZ_)
116  result = false;
117 
118  double anglePhi = fabs(atan(segment4DLocalDir.x() / segment4DLocalDir.z()) * 180. / Geom::pi());
119  if (anglePhi > maxAnglePhi_)
120  result = false;
121 
122  return result;
123 }
124 
126  std::vector<DTRecHit1D> const& dtHits) {
127  bool segmentNoisy = false;
128 
129  std::vector<DTRecHit1D>::const_iterator dtHit = dtHits.begin();
130  std::vector<DTRecHit1D>::const_iterator dtHits_end = dtHits.end();
131  for (; dtHit != dtHits_end; ++dtHit) {
132  DTWireId wireId = dtHit->wireId();
133  // Check for noisy channels to skip them
134  bool isNoisy = false, isFEMasked = false, isTDCMasked = false, isTrigMask = false, isDead = false, isNohv = false;
135  statusMap->cellStatus(wireId, isNoisy, isFEMasked, isTDCMasked, isTrigMask, isDead, isNohv);
136  if (isNoisy) {
137  LogTrace("Calibration") << "Wire: " << wireId << " is noisy, skipping!";
138  segmentNoisy = true;
139  break;
140  }
141  }
142  return segmentNoisy;
143 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
LocalPoint localPosition() const override
Local position in Chamber frame.
DTSegmentSelector(edm::ParameterSet const &pset, edm::ConsumesCollector &iC)
LocalVector localDirection() const override
Local direction in Chamber frame.
const DTChamberRecSegment2D * phiSegment() const
The superPhi segment: 0 if no phi projection available.
double chi2() const override
Chi2 of the segment fit.
T y() const
Definition: PV3DBase.h:60
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
bool operator()(DTRecSegment4D const &, edm::Event const &, edm::EventSetup const &)
T sqrt(T t)
Definition: SSEVec.h:19
T z() const
Definition: PV3DBase.h:61
bool hasPhi() const
Does it have the Phi projection?
#define LogTrace(id)
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
bool hasZed() const
Does it have the Z projection?
Definition: DetId.h:17
const DTSLRecSegment2D * zSegment() const
The Z segment: 0 if not zed projection available.
edm::EDGetTokenT< reco::MuonCollection > muonToken_
T const * product() const
Definition: Handle.h:69
int cellStatus(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool &noiseFlag, bool &feMask, bool &tdcMask, bool &trigMask, bool &deadFlag, bool &nohvFlag) const
get content
Definition: DTStatusFlag.h:88
bool checkNoisySegment(edm::ESHandle< DTStatusFlag > const &, std::vector< DTRecHit1D > const &)
std::string const & label() const
Definition: InputTag.h:36
HLT enums.
T get() const
Definition: EventSetup.h:73
constexpr double pi()
Definition: Pi.h:31
T x() const
Definition: PV3DBase.h:59
edm::InputTag muonTags_
id_type rawId() const
int degreesOfFreedom() const override
Degrees of freedom of the segment fit.
Definition: event.py:1