CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
DTSegmentSelector Class Reference

#include <DTSegmentSelector.h>

Public Member Functions

 DTSegmentSelector (edm::ParameterSet const &pset, edm::ConsumesCollector &iC)
 
bool operator() (DTRecSegment4D const &, edm::Event const &, edm::EventSetup const &)
 
 ~DTSegmentSelector ()
 

Private Member Functions

bool checkNoisySegment (edm::ESHandle< DTStatusFlag > const &, std::vector< DTRecHit1D > const &)
 

Private Attributes

bool checkNoisyChannels_
 
double maxAnglePhi_
 
double maxAngleZ_
 
double maxChi2_
 
int minHitsPhi_
 
int minHitsZ_
 
edm::InputTag muonTags_
 
edm::EDGetTokenT< reco::MuonCollectionmuonToken_
 

Detailed Description

Definition at line 24 of file DTSegmentSelector.h.

Constructor & Destructor Documentation

DTSegmentSelector::DTSegmentSelector ( edm::ParameterSet const &  pset,
edm::ConsumesCollector iC 
)

Definition at line 16 of file DTSegmentSelector.cc.

References edm::ConsumesCollector::consumes(), muonTags_, and muonToken_.

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 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
edm::EDGetTokenT< reco::MuonCollection > muonToken_
edm::InputTag muonTags_
DTSegmentSelector::~DTSegmentSelector ( )
inline

Definition at line 27 of file DTSegmentSelector.h.

References checkNoisySegment(), and operator()().

27 {}

Member Function Documentation

bool DTSegmentSelector::checkNoisySegment ( edm::ESHandle< DTStatusFlag > const &  statusMap,
std::vector< DTRecHit1D > const &  dtHits 
)
private

Definition at line 125 of file DTSegmentSelector.cc.

References DTStatusFlag::cellStatus(), and LogTrace.

Referenced by operator()(), and ~DTSegmentSelector().

126  {
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 }
#define LogTrace(id)
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 DTSegmentSelector::operator() ( DTRecSegment4D const &  segment,
edm::Event const &  event,
edm::EventSetup const &  setup 
)

Definition at line 27 of file DTSegmentSelector.cc.

References checkNoisyChannels_, checkNoisySegment(), DTRecSegment4D::chi2(), simKBmtfDigis_cfi::chiSquare, DTRecSegment4D::degreesOfFreedom(), flavorHistoryFilter_cfi::dr, PVValHelper::dx, PVValHelper::dy, edm::EventSetup::get(), DTRecSegment4D::hasPhi(), DTRecSegment4D::hasZed(), edm::InputTag::label(), DTRecSegment4D::localDirection(), DTRecSegment4D::localPosition(), muonTagProbeFilters_cff::matched, maxAnglePhi_, maxAngleZ_, maxChi2_, minHitsPhi_, minHitsZ_, PDWG_BPHSkim_cff::muons, muonTags_, muonToken_, DTRecSegment4D::phiSegment(), Geom::pi(), edm::Handle< T >::product(), TrackingRecHit::rawId(), mps_fire::result, DTRecSegment2D::specificRecHits(), mathSSE::sqrt(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), PV3DBase< T, PVType, FrameType >::z(), and DTRecSegment4D::zSegment().

Referenced by ~DTSegmentSelector().

29  {
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 }
T y() const
Definition: PV3DBase.h:60
T sqrt(T t)
Definition: SSEVec.h:19
T z() const
Definition: PV3DBase.h:61
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
Definition: DetId.h:17
edm::EDGetTokenT< reco::MuonCollection > muonToken_
T const * product() const
Definition: Handle.h:69
bool checkNoisySegment(edm::ESHandle< DTStatusFlag > const &, std::vector< DTRecHit1D > const &)
std::string const & label() const
Definition: InputTag.h:36
constexpr double pi()
Definition: Pi.h:31
T x() const
Definition: PV3DBase.h:59
edm::InputTag muonTags_

Member Data Documentation

bool DTSegmentSelector::checkNoisyChannels_
private

Definition at line 35 of file DTSegmentSelector.h.

Referenced by operator()().

double DTSegmentSelector::maxAnglePhi_
private

Definition at line 39 of file DTSegmentSelector.h.

Referenced by operator()().

double DTSegmentSelector::maxAngleZ_
private

Definition at line 40 of file DTSegmentSelector.h.

Referenced by operator()().

double DTSegmentSelector::maxChi2_
private

Definition at line 38 of file DTSegmentSelector.h.

Referenced by operator()().

int DTSegmentSelector::minHitsPhi_
private

Definition at line 36 of file DTSegmentSelector.h.

Referenced by operator()().

int DTSegmentSelector::minHitsZ_
private

Definition at line 37 of file DTSegmentSelector.h.

Referenced by operator()().

edm::InputTag DTSegmentSelector::muonTags_
private

Definition at line 33 of file DTSegmentSelector.h.

Referenced by DTSegmentSelector(), and operator()().

edm::EDGetTokenT<reco::MuonCollection> DTSegmentSelector::muonToken_
private

Definition at line 34 of file DTSegmentSelector.h.

Referenced by DTSegmentSelector(), and operator()().