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 17 of file TrackerMuonHitExtractor.h.

Constructor & Destructor Documentation

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

Definition at line 15 of file TrackerMuonHitExtractor.cc.

16  :
17  inputDTRecSegment4DToken_(ic.consumes<DTRecSegment4DCollection>(parset.getParameter<edm::InputTag>("inputDTRecSegment4DCollection"))),
18  inputCSCSegmentToken_(ic.consumes<CSCSegmentCollection>(parset.getParameter<edm::InputTag>("inputCSCSegmentCollection"))),
19  inputDTRecSegment4DCollection_(parset.getParameter<edm::InputTag>("inputDTRecSegment4DCollection")),
20  inputCSCSegmentCollection_(parset.getParameter<edm::InputTag>("inputCSCSegmentCollection"))
21 {
22 }
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.

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

Definition at line 30 of file TrackerMuonHitExtractor.cc.

30  {
31 }

Member Function Documentation

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

Definition at line 102 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(), relativeConstraints::ring, CSCDetId::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().

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

Definition at line 33 of file TrackerMuonHitExtractor.cc.

References relativeConstraints::chamber, CSCDetId::chamber(), cscSegmentCollectionH_, dtSegmentCollectionH_, CSCDetId::endcap(), makeMuonMisalignmentScenario::endcap, edm::Event::getByLabel(), inputCSCSegmentCollection_, inputDTRecSegment4DCollection_, relativeConstraints::ring, CSCDetId::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().

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

Member Data Documentation

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

Definition at line 27 of file TrackerMuonHitExtractor.h.

Referenced by init().

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

Definition at line 26 of file TrackerMuonHitExtractor.h.

Referenced by init().

edm::InputTag TrackerMuonHitExtractor::inputCSCSegmentCollection_
private

Definition at line 32 of file TrackerMuonHitExtractor.h.

Referenced by init().

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

Definition at line 30 of file TrackerMuonHitExtractor.h.

edm::InputTag TrackerMuonHitExtractor::inputDTRecSegment4DCollection_
private

Definition at line 31 of file TrackerMuonHitExtractor.h.

Referenced by init().

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

Definition at line 29 of file TrackerMuonHitExtractor.h.