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 &)
 
 TrackerMuonHitExtractor (const edm::ParameterSet &, edm::ConsumesCollector &&ic)
 
 ~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() [1/2]

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")) {}

◆ TrackerMuonHitExtractor() [2/2]

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")) {}

◆ ~TrackerMuonHitExtractor()

TrackerMuonHitExtractor::~TrackerMuonHitExtractor ( )

Definition at line 28 of file TrackerMuonHitExtractor.cc.

28 {}

Member Function Documentation

◆ getMuonHits()

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

Definition at line 100 of file TrackerMuonHitExtractor.cc.

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()
108  << ", arbitrated: " << mu.numberOfMatches(reco::Muon::SegmentAndTrackArbitration)
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 }

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(), amptDefaultParameters_cff::mu, reco::Muon::NoArbitration, 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().

◆ init()

void TrackerMuonHitExtractor::init ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)

Definition at line 30 of file TrackerMuonHitExtractor.cc.

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 }

References relativeConstraints::chamber, CSCDetId::chamber(), cscSegmentCollectionH_, dtSegmentCollectionH_, CSCDetId::endcap(), makeMuonMisalignmentScenario::endcap, iEvent, 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().

Member Data Documentation

◆ cscSegmentCollectionH_

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

Definition at line 29 of file TrackerMuonHitExtractor.h.

Referenced by init().

◆ dtSegmentCollectionH_

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

Definition at line 28 of file TrackerMuonHitExtractor.h.

Referenced by init().

◆ inputCSCSegmentCollection_

edm::InputTag TrackerMuonHitExtractor::inputCSCSegmentCollection_
private

Definition at line 34 of file TrackerMuonHitExtractor.h.

Referenced by init().

◆ inputCSCSegmentToken_

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

Definition at line 32 of file TrackerMuonHitExtractor.h.

◆ inputDTRecSegment4DCollection_

edm::InputTag TrackerMuonHitExtractor::inputDTRecSegment4DCollection_
private

Definition at line 33 of file TrackerMuonHitExtractor.h.

Referenced by init().

◆ inputDTRecSegment4DToken_

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

Definition at line 31 of file TrackerMuonHitExtractor.h.

Vector3DBase< float, LocalTag >
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:355
DTSLRecSegment2D
Definition: DTSLRecSegment2D.h:15
MuonSubdetId::CSC
static constexpr int CSC
Definition: MuonSubdetId.h:12
DTRecSegment4D
Definition: DTRecSegment4D.h:23
reco::Muon::SegmentAndTrackArbitration
Definition: Muon.h:190
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
relativeConstraints.station
station
Definition: relativeConstraints.py:67
CSCDetId::ring
int ring() const
Definition: CSCDetId.h:68
TrackerMuonHitExtractor::cscSegmentCollectionH_
edm::Handle< CSCSegmentCollection > cscSegmentCollectionH_
Definition: TrackerMuonHitExtractor.h:29
edm::Ref::get
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
TrackerMuonHitExtractor::inputCSCSegmentCollection_
edm::InputTag inputCSCSegmentCollection_
Definition: TrackerMuonHitExtractor.h:34
CSCSegmentCollection
makeMuonMisalignmentScenario.endcap
endcap
Definition: makeMuonMisalignmentScenario.py:320
reco::MuonSegmentMatch::BelongsToTrackByDR
static const unsigned int BelongsToTrackByDR
Definition: MuonSegmentMatch.h:25
edm::Ref< CSCSegmentCollection >
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
DTRecSegment2D::recHits
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
Definition: DTRecSegment2D.cc:86
DetId
Definition: DetId.h:17
LocalError::xx
float xx() const
Definition: LocalError.h:22
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:49
MuonSubdetId::DT
static constexpr int DT
Definition: MuonSubdetId.h:11
Point3DBase< float, LocalTag >
DTRecSegment4DCollection
CSCSegment
Definition: CSCSegment.h:21
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
reco::Muon::NoArbitration
Definition: Muon.h:188
LocalError
Definition: LocalError.h:12
edm::RangeMap::const_iterator
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
CSCDetId
Definition: CSCDetId.h:26
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
iEvent
int iEvent
Definition: GenABIO.cc:224
DTChamberRecSegment2D
Definition: DTChamberRecSegment2D.h:31
edm::LogVerbatim
Definition: MessageLogger.h:297
CSCDetId::chamber
int chamber() const
Definition: CSCDetId.h:62
TrackerMuonHitExtractor::dtSegmentCollectionH_
edm::Handle< DTRecSegment4DCollection > dtSegmentCollectionH_
Definition: TrackerMuonHitExtractor.h:28
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
TrackerMuonHitExtractor::inputDTRecSegment4DToken_
edm::EDGetTokenT< DTRecSegment4DCollection > inputDTRecSegment4DToken_
Definition: TrackerMuonHitExtractor.h:31
DTChamberId::sector
int sector() const
Definition: DTChamberId.h:49
DTRecSegment4D::hasZed
bool hasZed() const
Does it have the Z projection?
Definition: DTRecSegment4D.h:93
CSCDetId::endcap
int endcap() const
Definition: CSCDetId.h:85
relativeConstraints.ring
ring
Definition: relativeConstraints.py:68
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
DTRecSegment4D::hasPhi
bool hasPhi() const
Does it have the Phi projection?
Definition: DTRecSegment4D.h:90
edm::Ref::key
key_type key() const
Accessor for product key.
Definition: Ref.h:250
DTChamberId
Definition: DTChamberId.h:14
CSCDetId::station
int station() const
Definition: CSCDetId.h:79
DTRecSegment4D::phiSegment
const DTChamberRecSegment2D * phiSegment() const
The superPhi segment: 0 if no phi projection available.
Definition: DTRecSegment4D.h:96
LocalError::yy
float yy() const
Definition: LocalError.h:24
DTChamberId::wheel
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
edm::InputTag
Definition: InputTag.h:15
TrackerMuonHitExtractor::inputDTRecSegment4DCollection_
edm::InputTag inputDTRecSegment4DCollection_
Definition: TrackerMuonHitExtractor.h:33
TrackerMuonHitExtractor::inputCSCSegmentToken_
edm::EDGetTokenT< CSCSegmentCollection > inputCSCSegmentToken_
Definition: TrackerMuonHitExtractor.h:32
DTChamberId::station
int station() const
Return the station number.
Definition: DTChamberId.h:42
reco::MuonSegmentMatch::BestInChamberByDR
static const unsigned int BestInChamberByDR
Definition: MuonSegmentMatch.h:17
CSCSegment::recHits
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
Definition: CSCSegment.cc:32