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"))
24 {
26 }
27 
28 
30 
31  bool result = true;
32 
33  /* get the muon collection if one is specified
34  (not specifying a muon collection switches off muon matching */
35  if (!muonTags_.label().empty()) {
37  event.getByToken(muonToken_,muonH);
38  const std::vector<reco::Muon>* muons = muonH.product();
39  //std::cout << " Muon collection size: " << muons->size() << std::endl;
40  if (muons->empty()) 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) continue;
49  if ( imuon.pt()<15 || !imuon.isGlobalMuon()) continue;
50 
51  int nsegs=ch.segmentMatches.size();
52  if (!nsegs) continue;
53 
54  LocalPoint posHit = segment.localPosition();
55  float dx = (posHit.x() ? posHit.x()-ch.x : 0 );
56  float dy = (posHit.y() ? posHit.y()-ch.y : 0 );
57  float dr = sqrt(dx*dx+dy*dy);
58  if (dr<5) matched=true;
59  }
60 
61  if (!matched) result=false;
62  }
63 
64 
65 
67  if(checkNoisyChannels_) setup.get<DTStatusFlagRcd>().get(statusMap);
68 
69  // Get the Phi 2D segment
70  int nPhiHits = -1;
71  bool segmentNoisyPhi = false;
72  if( segment.hasPhi() ){
73  const DTChamberRecSegment2D* phiSeg = segment.phiSegment(); // phiSeg lives in the chamber RF
74  std::vector<DTRecHit1D> phiRecHits = phiSeg->specificRecHits();
75  nPhiHits = phiRecHits.size();
76  if(checkNoisyChannels_) segmentNoisyPhi = checkNoisySegment(statusMap,phiRecHits);
77  //} else result = false;
78  }
79  // Get the Theta 2D segment
80  int nZHits = -1;
81  bool segmentNoisyZ = false;
82  if( segment.hasZed() ){
83  const DTSLRecSegment2D* zSeg = segment.zSegment(); // zSeg lives in the SL RF
84  std::vector<DTRecHit1D> zRecHits = zSeg->specificRecHits();
85  nZHits = zRecHits.size();
86  if(checkNoisyChannels_) segmentNoisyZ = checkNoisySegment(statusMap,zRecHits);
87  }
88 
89  // Segment selection
90  // Discard segment if it has a noisy cell
91  if(segmentNoisyPhi || segmentNoisyZ)
92  result = false;
93 
94  // 2D-segment number of hits
95  if(segment.hasPhi() && nPhiHits < minHitsPhi_)
96  result = false;
97 
98  if(segment.hasZed() && nZHits < minHitsZ_)
99  result = false;
100 
101  // Segment chi2
102  double chiSquare = segment.chi2()/segment.degreesOfFreedom();
103  if(chiSquare > maxChi2_)
104  result = false;
105 
106  // Segment angle
107  LocalVector segment4DLocalDir = segment.localDirection();
108  double angleZ = fabs( atan(segment4DLocalDir.y()/segment4DLocalDir.z())*180./Geom::pi() );
109  if( angleZ > maxAngleZ_)
110  result = false;
111 
112  double anglePhi = fabs( atan(segment4DLocalDir.x()/segment4DLocalDir.z())*180./Geom::pi() );
113  if( anglePhi > maxAnglePhi_)
114  result = false;
115 
116  return result;
117 }
118 
119 bool DTSegmentSelector::checkNoisySegment(edm::ESHandle<DTStatusFlag> const& statusMap, std::vector<DTRecHit1D> const& dtHits){
120 
121  bool segmentNoisy = false;
122 
123  std::vector<DTRecHit1D>::const_iterator dtHit = dtHits.begin();
124  std::vector<DTRecHit1D>::const_iterator dtHits_end = dtHits.end();
125  for(; dtHit != dtHits_end; ++dtHit){
126  DTWireId wireId = dtHit->wireId();
127  // Check for noisy channels to skip them
128  bool isNoisy = false, isFEMasked = false, isTDCMasked = false, isTrigMask = false,
129  isDead = false, isNohv = false;
130  statusMap->cellStatus(wireId, isNoisy, isFEMasked, isTDCMasked, isTrigMask, isDead, isNohv);
131  if(isNoisy) {
132  LogTrace("Calibration") << "Wire: " << wireId << " is noisy, skipping!";
133  segmentNoisy = true; break;
134  }
135  }
136  return segmentNoisy;
137 }
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:63
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
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:18
T z() const
Definition: PV3DBase.h:64
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:18
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:74
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:100
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:71
constexpr double pi()
Definition: Pi.h:31
T x() const
Definition: PV3DBase.h:62
edm::InputTag muonTags_
id_type rawId() const
int degreesOfFreedom() const override
Degrees of freedom of the segment fit.
Definition: event.py:1