CMS 3D CMS Logo

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

#include <TrackerMuonHitExtractor.h>

Public Member Functions

std::vector< const TrackingRecHit * > getMuonHits (const reco::Muon &mu) const
 
void init (const edm::Event &, const edm::EventSetup &)
 
 TrackerMuonHitExtractor (const edm::ParameterSet &, edm::ConsumesCollector &&ic)
 
 TrackerMuonHitExtractor (const edm::ParameterSet &)
 
 ~TrackerMuonHitExtractor ()
 

Private Attributes

edm::Handle< CSCSegmentCollectioncscSegmentCollectionH_
 
edm::Handle< DTRecSegment4DCollectiondtSegmentCollectionH_
 
edm::InputTag inputCSCSegmentCollection_
 
edm::EDGetTokenT< CSCSegmentCollectioninputCSCSegmentToken_
 
edm::InputTag inputDTRecSegment4DCollection_
 
edm::EDGetTokenT< DTRecSegment4DCollectioninputDTRecSegment4DToken_
 

Detailed Description

Definition at line 18 of file TrackerMuonHitExtractor.h.

Constructor & Destructor Documentation

TrackerMuonHitExtractor::TrackerMuonHitExtractor ( const edm::ParameterSet parset,
edm::ConsumesCollector &&  ic 
)
explicit

Definition at line 16 of file TrackerMuonHitExtractor.cc.

18  ic.consumes<DTRecSegment4DCollection>(parset.getParameter<edm::InputTag>("inputDTRecSegment4DCollection"))),
20  ic.consumes<CSCSegmentCollection>(parset.getParameter<edm::InputTag>("inputCSCSegmentCollection"))),
21  inputDTRecSegment4DCollection_(parset.getParameter<edm::InputTag>("inputDTRecSegment4DCollection")),
22  inputCSCSegmentCollection_(parset.getParameter<edm::InputTag>("inputCSCSegmentCollection")) {}
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::InputTag inputDTRecSegment4DCollection_
T getParameter(std::string const &) const
edm::EDGetTokenT< DTRecSegment4DCollection > inputDTRecSegment4DToken_
edm::EDGetTokenT< CSCSegmentCollection > inputCSCSegmentToken_
TrackerMuonHitExtractor::TrackerMuonHitExtractor ( const edm::ParameterSet parset)
explicit

Definition at line 24 of file TrackerMuonHitExtractor.cc.

25  : inputDTRecSegment4DCollection_(parset.getParameter<edm::InputTag>("inputDTRecSegment4DCollection")),
26  inputCSCSegmentCollection_(parset.getParameter<edm::InputTag>("inputCSCSegmentCollection")) {}
edm::InputTag inputDTRecSegment4DCollection_
T getParameter(std::string const &) const
TrackerMuonHitExtractor::~TrackerMuonHitExtractor ( )

Definition at line 28 of file TrackerMuonHitExtractor.cc.

28 {}

Member Function Documentation

std::vector< const TrackingRecHit * > TrackerMuonHitExtractor::getMuonHits ( const reco::Muon mu) const

Definition at line 100 of file TrackerMuonHitExtractor.cc.

References reco::MuonSegmentMatch::BelongsToTrackByDR, reco::MuonSegmentMatch::BestInChamberByDR, relativeConstraints::chamber, CSCDetId::chamber(), MuonSubdetId::CSC, MuonSubdetId::DT, CSCDetId::endcap(), makeMuonMisalignmentScenario::endcap, edm::Ref< C, T, F >::get(), DTRecSegment4D::hasPhi(), DTRecSegment4D::hasZed(), hfClusterShapes_cfi::hits, edm::Ref< C, T, F >::key(), reco::Muon::matches(), reco::Muon::NoArbitration, reco::Muon::numberOfMatches(), DTRecSegment4D::phiSegment(), CSCSegment::recHits(), DTRecSegment2D::recHits(), runTheMatrix::ret, CSCDetId::ring(), relativeConstraints::ring, DTChamberId::sector(), reco::Muon::SegmentAndTrackArbitration, DTChamberId::station(), relativeConstraints::station, CSCDetId::station(), AlCaHLTBitMon_QueryRunRegistry::string, DTChamberId::wheel(), and makeMuonMisalignmentScenario::wheel.

Referenced by MuonToSimAssociatorByHits::associateMuons(), and MuonToTrackingParticleAssociatorByHitsImpl::associateMuons().

100  {
101  std::vector<const TrackingRecHit *> ret;
102 
103  int wheel, station, sector;
104  int endcap, /*station, */ ring, chamber;
105 
106  edm::LogVerbatim("TrackerMuonHitExtractor")
107  << "Number of chambers: " << mu.matches().size()
109  << ", tot (no arbitration): " << mu.numberOfMatches(reco::Muon::NoArbitration);
110  unsigned int index_chamber = 0;
111  int n_segments_noArb = 0;
112 
113  for (std::vector<reco::MuonChamberMatch>::const_iterator chamberMatch = mu.matches().begin();
114  chamberMatch != mu.matches().end();
115  ++chamberMatch, index_chamber++) {
116  std::stringstream chamberStr;
117  chamberStr << "\nchamber index: " << index_chamber;
118 
119  int subdet = chamberMatch->detector();
120  DetId did = chamberMatch->id;
121 
122  if (subdet == MuonSubdetId::DT) {
123  DTChamberId dtdetid = DTChamberId(did);
124  wheel = dtdetid.wheel();
125  station = dtdetid.station();
126  sector = dtdetid.sector();
127  chamberStr << ", DT chamber Wh:" << wheel << ",St:" << station << ",Se:" << sector;
128  } else if (subdet == MuonSubdetId::CSC) {
129  CSCDetId cscdetid = CSCDetId(did);
130  endcap = cscdetid.endcap();
131  station = cscdetid.station();
132  ring = cscdetid.ring();
133  chamber = cscdetid.chamber();
134  chamberStr << ", CSC chamber End:" << endcap << ",St:" << station << ",Ri:" << ring << ",Ch:" << chamber;
135  }
136 
137  chamberStr << ", Number of segments: " << chamberMatch->segmentMatches.size();
138  edm::LogVerbatim("TrackerMuonHitExtractor") << chamberStr.str();
139  n_segments_noArb = n_segments_noArb + chamberMatch->segmentMatches.size();
140 
141  unsigned int index_segment = 0;
142 
143  for (std::vector<reco::MuonSegmentMatch>::const_iterator segmentMatch = chamberMatch->segmentMatches.begin();
144  segmentMatch != chamberMatch->segmentMatches.end();
145  ++segmentMatch, index_segment++) {
146  float segmentX = segmentMatch->x;
147  float segmentY = segmentMatch->y;
148  float segmentdXdZ = segmentMatch->dXdZ;
149  float segmentdYdZ = segmentMatch->dYdZ;
150  float segmentXerr = segmentMatch->xErr;
151  float segmentYerr = segmentMatch->yErr;
152  float segmentdXdZerr = segmentMatch->dXdZErr;
153  float segmentdYdZerr = segmentMatch->dYdZErr;
154 
155  CSCSegmentRef segmentCSC = segmentMatch->cscSegmentRef;
156  DTRecSegment4DRef segmentDT = segmentMatch->dtSegmentRef;
157 
158  bool segment_arbitrated_Ok = (segmentMatch->isMask(reco::MuonSegmentMatch::BestInChamberByDR) &&
159  segmentMatch->isMask(reco::MuonSegmentMatch::BelongsToTrackByDR));
160 
161  std::string ARBITRATED(" ***Arbitrated Off*** ");
162  if (segment_arbitrated_Ok)
163  ARBITRATED = " ***ARBITRATED OK*** ";
164 
165  if (subdet == MuonSubdetId::DT) {
166  edm::LogVerbatim("TrackerMuonHitExtractor")
167  << "\n\t segment index: " << index_segment << ARBITRATED << "\n\t Local Position (X,Y)=(" << segmentX
168  << "," << segmentY << ") +/- (" << segmentXerr << "," << segmentYerr << "), "
169  << "\n\t Local Direction (dXdZ,dYdZ)=(" << segmentdXdZ << "," << segmentdYdZ << ") +/- (" << segmentdXdZerr
170  << "," << segmentdYdZerr << ")";
171 
172  // with the following line the DT segments failing standard arbitration
173  // are skipped
174  if (!segment_arbitrated_Ok)
175  continue;
176 
177  if (segmentDT.get() != nullptr) {
178  const DTRecSegment4D *segment = segmentDT.get();
179 
180  edm::LogVerbatim("TrackerMuonHitExtractor")
181  << "\t ===> MATCHING with DT segment with index = " << segmentDT.key();
182 
183  if (segment->hasPhi()) {
184  const DTChamberRecSegment2D *phiSeg = segment->phiSegment();
185  std::vector<const TrackingRecHit *> phiHits = phiSeg->recHits();
186  for (std::vector<const TrackingRecHit *>::const_iterator ihit = phiHits.begin(); ihit != phiHits.end();
187  ++ihit) {
188  ret.push_back(*ihit);
189  }
190  }
191 
192  if (segment->hasZed()) {
193  const DTSLRecSegment2D *zSeg = (*segment).zSegment();
194  std::vector<const TrackingRecHit *> zedHits = zSeg->recHits();
195  for (std::vector<const TrackingRecHit *>::const_iterator ihit = zedHits.begin(); ihit != zedHits.end();
196  ++ihit) {
197  ret.push_back(*ihit);
198  }
199  }
200  } else
201  edm::LogWarning("TrackerMuonHitExtractor") << "\n***WARNING: UNMATCHED DT segment ! \n";
202  } // if (subdet == MuonSubdetId::DT)
203 
204  else if (subdet == MuonSubdetId::CSC) {
205  edm::LogVerbatim("TrackerMuonHitExtractor")
206  << "\n\t segment index: " << index_segment << ARBITRATED << "\n\t Local Position (X,Y)=(" << segmentX
207  << "," << segmentY << ") +/- (" << segmentXerr << "," << segmentYerr << "), "
208  << "\n\t Local Direction (dXdZ,dYdZ)=(" << segmentdXdZ << "," << segmentdYdZ << ") +/- (" << segmentdXdZerr
209  << "," << segmentdYdZerr << ")";
210 
211  // with the following line the CSC segments failing standard arbitration
212  // are skipped
213  if (!segment_arbitrated_Ok)
214  continue;
215 
216  if (segmentCSC.get() != nullptr) {
217  const CSCSegment *segment = segmentCSC.get();
218 
219  edm::LogVerbatim("TrackerMuonHitExtractor")
220  << "\t ===> MATCHING with CSC segment with index = " << segmentCSC.key();
221 
222  std::vector<const TrackingRecHit *> hits = segment->recHits();
223  for (std::vector<const TrackingRecHit *>::const_iterator ihit = hits.begin(); ihit != hits.end(); ++ihit) {
224  ret.push_back(*ihit);
225  }
226  } else
227  edm::LogWarning("TrackerMuonHitExtractor") << "\n***WARNING: UNMATCHED CSC segment ! \n";
228  } // else if (subdet == MuonSubdetId::CSC)
229 
230  } // loop on vector<MuonSegmentMatch>
231  } // loop on vector<MuonChamberMatch>
232 
233  edm::LogVerbatim("TrackerMuonHitExtractor") << "\n N. matched Segments before arbitration = " << n_segments_noArb;
234 
235  return ret;
236 }
int chamber() const
Definition: CSCDetId.h:62
ret
prodAgent to be discontinued
const DTChamberRecSegment2D * phiSegment() const
The superPhi segment: 0 if no phi projection available.
key_type key() const
Accessor for product key.
Definition: Ref.h:250
int endcap() const
Definition: CSCDetId.h:85
static const unsigned int BestInChamberByDR
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
bool hasPhi() const
Does it have the Phi projection?
int ring() const
Definition: CSCDetId.h:68
bool hasZed() const
Does it have the Z projection?
Definition: DetId.h:17
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
Definition: CSCSegment.cc:32
std::vector< MuonChamberMatch > & matches()
get muon matching information
Definition: Muon.h:145
int numberOfMatches(ArbitrationType type=SegmentAndTrackArbitration) const
get number of chambers with matched segments
static const unsigned int BelongsToTrackByDR
int sector() const
Definition: DTChamberId.h:49
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
int station() const
Definition: CSCDetId.h:79
static constexpr int DT
Definition: MuonSubdetId.h:11
int station() const
Return the station number.
Definition: DTChamberId.h:42
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
static constexpr int CSC
Definition: MuonSubdetId.h:12
void TrackerMuonHitExtractor::init ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)

Definition at line 30 of file TrackerMuonHitExtractor.cc.

References relativeConstraints::chamber, CSCDetId::chamber(), cscSegmentCollectionH_, dtSegmentCollectionH_, CSCDetId::endcap(), makeMuonMisalignmentScenario::endcap, edm::Event::getByLabel(), inputCSCSegmentCollection_, inputDTRecSegment4DCollection_, CSCDetId::ring(), relativeConstraints::ring, DTChamberId::sector(), mathSSE::sqrt(), DTChamberId::station(), relativeConstraints::station, CSCDetId::station(), DTChamberId::wheel(), makeMuonMisalignmentScenario::wheel, PV3DBase< T, PVType, FrameType >::x(), LocalError::xx(), PV3DBase< T, PVType, FrameType >::y(), LocalError::yy(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by MuonToSimAssociatorByHits::associateMuons(), and MuonToTrackingParticleAssociatorEDProducer::produce().

30  {
33 
34  edm::LogVerbatim("TrackerMuonHitExtractor") << "\nThere are " << dtSegmentCollectionH_->size() << " DT segments.";
35  unsigned int index_dt_segment = 0;
37  segment != dtSegmentCollectionH_->end();
38  ++segment, index_dt_segment++) {
39  LocalPoint segmentLocalPosition = segment->localPosition();
40  LocalVector segmentLocalDirection = segment->localDirection();
41  LocalError segmentLocalPositionError = segment->localPositionError();
42  LocalError segmentLocalDirectionError = segment->localDirectionError();
43  DetId geoid = segment->geographicalId();
44  DTChamberId dtdetid = DTChamberId(geoid);
45  int wheel = dtdetid.wheel();
46  int station = dtdetid.station();
47  int sector = dtdetid.sector();
48 
49  float segmentX = segmentLocalPosition.x();
50  float segmentY = segmentLocalPosition.y();
51  float segmentdXdZ = segmentLocalDirection.x() / segmentLocalDirection.z();
52  float segmentdYdZ = segmentLocalDirection.y() / segmentLocalDirection.z();
53  float segmentXerr = sqrt(segmentLocalPositionError.xx());
54  float segmentYerr = sqrt(segmentLocalPositionError.yy());
55  float segmentdXdZerr = sqrt(segmentLocalDirectionError.xx());
56  float segmentdYdZerr = sqrt(segmentLocalDirectionError.yy());
57 
58  edm::LogVerbatim("TrackerMuonHitExtractor")
59  << "\nDT segment index :" << index_dt_segment << "\nchamber Wh:" << wheel << ",St:" << station
60  << ",Se:" << sector << "\nLocal Position (X,Y)=(" << segmentX << "," << segmentY << ") +/- (" << segmentXerr
61  << "," << segmentYerr << "), "
62  << "Local Direction (dXdZ,dYdZ)=(" << segmentdXdZ << "," << segmentdYdZ << ") +/- (" << segmentdXdZerr << ","
63  << segmentdYdZerr << ")";
64  }
65 
66  edm::LogVerbatim("TrackerMuonHitExtractor") << "\nThere are " << cscSegmentCollectionH_->size() << " CSC segments.";
67  unsigned int index_csc_segment = 0;
69  segment != cscSegmentCollectionH_->end();
70  ++segment, index_csc_segment++) {
71  LocalPoint segmentLocalPosition = segment->localPosition();
72  LocalVector segmentLocalDirection = segment->localDirection();
73  LocalError segmentLocalPositionError = segment->localPositionError();
74  LocalError segmentLocalDirectionError = segment->localDirectionError();
75 
76  DetId geoid = segment->geographicalId();
77  CSCDetId cscdetid = CSCDetId(geoid);
78  int endcap = cscdetid.endcap();
79  int station = cscdetid.station();
80  int ring = cscdetid.ring();
81  int chamber = cscdetid.chamber();
82 
83  float segmentX = segmentLocalPosition.x();
84  float segmentY = segmentLocalPosition.y();
85  float segmentdXdZ = segmentLocalDirection.x() / segmentLocalDirection.z();
86  float segmentdYdZ = segmentLocalDirection.y() / segmentLocalDirection.z();
87  float segmentXerr = sqrt(segmentLocalPositionError.xx());
88  float segmentYerr = sqrt(segmentLocalPositionError.yy());
89  float segmentdXdZerr = sqrt(segmentLocalDirectionError.xx());
90  float segmentdYdZerr = sqrt(segmentLocalDirectionError.yy());
91 
92  edm::LogVerbatim("TrackerMuonHitExtractor")
93  << "\nCSC segment index :" << index_csc_segment << "\nchamber Endcap:" << endcap << ",St:" << station
94  << ",Ri:" << ring << ",Ch:" << chamber << "\nLocal Position (X,Y)=(" << segmentX << "," << segmentY << ") +/- ("
95  << segmentXerr << "," << segmentYerr << "), "
96  << "Local Direction (dXdZ,dYdZ)=(" << segmentdXdZ << "," << segmentdYdZ << ") +/- (" << segmentdXdZerr << ","
97  << segmentdYdZerr << ")";
98  }
99 }
int chamber() const
Definition: CSCDetId.h:62
edm::InputTag inputDTRecSegment4DCollection_
float xx() const
Definition: LocalError.h:22
T y() const
Definition: PV3DBase.h:60
edm::Handle< CSCSegmentCollection > cscSegmentCollectionH_
int endcap() const
Definition: CSCDetId.h:85
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
float yy() const
Definition: LocalError.h:24
T sqrt(T t)
Definition: SSEVec.h:19
T z() const
Definition: PV3DBase.h:61
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:488
edm::Handle< DTRecSegment4DCollection > dtSegmentCollectionH_
int ring() const
Definition: CSCDetId.h:68
Definition: DetId.h:17
int sector() const
Definition: DTChamberId.h:49
int station() const
Definition: CSCDetId.h:79
int station() const
Return the station number.
Definition: DTChamberId.h:42
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
T x() const
Definition: PV3DBase.h:59

Member Data Documentation

edm::Handle<CSCSegmentCollection> TrackerMuonHitExtractor::cscSegmentCollectionH_
private

Definition at line 29 of file TrackerMuonHitExtractor.h.

Referenced by init().

edm::Handle<DTRecSegment4DCollection> TrackerMuonHitExtractor::dtSegmentCollectionH_
private

Definition at line 28 of file TrackerMuonHitExtractor.h.

Referenced by init().

edm::InputTag TrackerMuonHitExtractor::inputCSCSegmentCollection_
private

Definition at line 34 of file TrackerMuonHitExtractor.h.

Referenced by init().

edm::EDGetTokenT<CSCSegmentCollection> TrackerMuonHitExtractor::inputCSCSegmentToken_
private

Definition at line 32 of file TrackerMuonHitExtractor.h.

edm::InputTag TrackerMuonHitExtractor::inputDTRecSegment4DCollection_
private

Definition at line 33 of file TrackerMuonHitExtractor.h.

Referenced by init().

edm::EDGetTokenT<DTRecSegment4DCollection> TrackerMuonHitExtractor::inputDTRecSegment4DToken_
private

Definition at line 31 of file TrackerMuonHitExtractor.h.