CMS 3D CMS Logo

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

#include <MuonTrackProducer.h>

Inheritance diagram for MuonTrackProducer:
edm::stream::EDProducer<>

Public Member Functions

 MuonTrackProducer (const edm::ParameterSet &)
 
 ~MuonTrackProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

edm::Handle< CSCSegmentCollectioncscSegmentCollectionH_
 
edm::Handle< DTRecSegment4DCollectiondtSegmentCollectionH_
 
bool ignoreMissingMuonCollection
 
edm::EDGetTokenT< CSCSegmentCollectioninputCSCSegmentToken_
 
edm::EDGetTokenT< DTRecSegment4DCollectioninputDTRecSegment4DToken_
 
edm::Handle< reco::MuonCollectionmuonCollectionH
 
edm::EDGetTokenT< reco::MuonCollectionmuonsToken
 
const edm::ParameterSet parset_
 
std::vector< std::string > selectionTags
 
std::string trackType
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 18 of file MuonTrackProducer.h.

Constructor & Destructor Documentation

◆ MuonTrackProducer()

MuonTrackProducer::MuonTrackProducer ( const edm::ParameterSet parset)
explicit

Definition at line 20 of file MuonTrackProducer.cc.

21  : muonsToken(consumes<reco::MuonCollection>(parset.getParameter<edm::InputTag>("muonsTag"))),
23  consumes<DTRecSegment4DCollection>(parset.getParameter<edm::InputTag>("inputDTRecSegment4DCollection"))),
25  consumes<CSCSegmentCollection>(parset.getParameter<edm::InputTag>("inputCSCSegmentCollection"))),
26  selectionTags(parset.getParameter<std::vector<std::string>>("selectionTags")),
27  trackType(parset.getParameter<std::string>("trackType")),
28  ignoreMissingMuonCollection(parset.getUntrackedParameter<bool>("ignoreMissingMuonCollection", false)),
29  parset_(parset) {
30  edm::LogVerbatim("MuonTrackProducer") << "constructing MuonTrackProducer" << parset_.dump();
31  produces<reco::TrackCollection>();
32  produces<reco::TrackExtraCollection>();
33  produces<TrackingRecHitCollection>();
34 }

References edm::ParameterSet::dump(), and parset_.

◆ ~MuonTrackProducer()

MuonTrackProducer::~MuonTrackProducer ( )
override

Definition at line 36 of file MuonTrackProducer.cc.

36 {}

Member Function Documentation

◆ produce()

void MuonTrackProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 38 of file MuonTrackProducer.cc.

38  {
39  bool muonAvailable = iEvent.getByToken(muonsToken, muonCollectionH);
40  if (ignoreMissingMuonCollection && !muonAvailable)
41  edm::LogVerbatim("MuonTrackProducer") << "\n ignoring missing muon collection.";
42 
43  else {
46 
48  iSetup.get<TrackerTopologyRcd>().get(httopo);
49  const TrackerTopology &ttopo = *httopo;
50 
51  std::unique_ptr<reco::TrackCollection> selectedTracks(new reco::TrackCollection);
52  std::unique_ptr<reco::TrackExtraCollection> selectedTrackExtras(new reco::TrackExtraCollection());
53  std::unique_ptr<TrackingRecHitCollection> selectedTrackHits(new TrackingRecHitCollection());
54 
55  reco::TrackRefProd rTracks = iEvent.getRefBeforePut<reco::TrackCollection>();
56  reco::TrackExtraRefProd rTrackExtras = iEvent.getRefBeforePut<reco::TrackExtraCollection>();
57  TrackingRecHitRefProd rHits = iEvent.getRefBeforePut<TrackingRecHitCollection>();
58 
61 
62  edm::LogVerbatim("MuonTrackProducer") << "\nThere are " << dtSegmentCollectionH_->size() << " DT segments.";
63  unsigned int index_dt_segment = 0;
65  segment != dtSegmentCollectionH_->end();
66  ++segment, index_dt_segment++) {
67  LocalPoint segmentLocalPosition = segment->localPosition();
68  LocalVector segmentLocalDirection = segment->localDirection();
69  LocalError segmentLocalPositionError = segment->localPositionError();
70  LocalError segmentLocalDirectionError = segment->localDirectionError();
71  DetId geoid = segment->geographicalId();
72  DTChamberId dtdetid = DTChamberId(geoid);
73  int wheel = dtdetid.wheel();
74  int station = dtdetid.station();
75  int sector = dtdetid.sector();
76 
77  float segmentX = segmentLocalPosition.x();
78  float segmentY = segmentLocalPosition.y();
79  float segmentdXdZ = segmentLocalDirection.x() / segmentLocalDirection.z();
80  float segmentdYdZ = segmentLocalDirection.y() / segmentLocalDirection.z();
81  float segmentXerr = sqrt(segmentLocalPositionError.xx());
82  float segmentYerr = sqrt(segmentLocalPositionError.yy());
83  float segmentdXdZerr = sqrt(segmentLocalDirectionError.xx());
84  float segmentdYdZerr = sqrt(segmentLocalDirectionError.yy());
85 
86  edm::LogVerbatim("MuonTrackProducer")
87  << "\nDT segment index :" << index_dt_segment << "\nchamber Wh:" << wheel << ",St:" << station
88  << ",Se:" << sector << "\nLocal Position (X,Y)=(" << segmentX << "," << segmentY << ") +/- (" << segmentXerr
89  << "," << segmentYerr << "), "
90  << "Local Direction (dXdZ,dYdZ)=(" << segmentdXdZ << "," << segmentdYdZ << ") +/- (" << segmentdXdZerr << ","
91  << segmentdYdZerr << ")";
92  }
93 
94  edm::LogVerbatim("MuonTrackProducer") << "\nThere are " << cscSegmentCollectionH_->size() << " CSC segments.";
95  unsigned int index_csc_segment = 0;
97  segment != cscSegmentCollectionH_->end();
98  ++segment, index_csc_segment++) {
99  LocalPoint segmentLocalPosition = segment->localPosition();
100  LocalVector segmentLocalDirection = segment->localDirection();
101  LocalError segmentLocalPositionError = segment->localPositionError();
102  LocalError segmentLocalDirectionError = segment->localDirectionError();
103 
104  DetId geoid = segment->geographicalId();
105  CSCDetId cscdetid = CSCDetId(geoid);
106  int endcap = cscdetid.endcap();
107  int station = cscdetid.station();
108  int ring = cscdetid.ring();
109  int chamber = cscdetid.chamber();
110 
111  float segmentX = segmentLocalPosition.x();
112  float segmentY = segmentLocalPosition.y();
113  float segmentdXdZ = segmentLocalDirection.x() / segmentLocalDirection.z();
114  float segmentdYdZ = segmentLocalDirection.y() / segmentLocalDirection.z();
115  float segmentXerr = sqrt(segmentLocalPositionError.xx());
116  float segmentYerr = sqrt(segmentLocalPositionError.yy());
117  float segmentdXdZerr = sqrt(segmentLocalDirectionError.xx());
118  float segmentdYdZerr = sqrt(segmentLocalDirectionError.yy());
119 
120  edm::LogVerbatim("MuonTrackProducer")
121  << "\nCSC segment index :" << index_csc_segment << "\nchamber Endcap:" << endcap << ",St:" << station
122  << ",Ri:" << ring << ",Ch:" << chamber << "\nLocal Position (X,Y)=(" << segmentX << "," << segmentY
123  << ") +/- (" << segmentXerr << "," << segmentYerr << "), "
124  << "Local Direction (dXdZ,dYdZ)=(" << segmentdXdZ << "," << segmentdYdZ << ") +/- (" << segmentdXdZerr << ","
125  << segmentdYdZerr << ")";
126  }
127 
128  edm::LogVerbatim("MuonTrackProducer") << "\nThere are " << muonCollectionH->size() << " reco::Muons.";
129  unsigned int muon_index = 0;
130  for (reco::MuonCollection::const_iterator muon = muonCollectionH->begin(); muon != muonCollectionH->end();
131  ++muon, muon_index++) {
132  edm::LogVerbatim("MuonTrackProducer") << "\n******* muon index : " << muon_index;
133 
134  std::vector<bool> isGood;
135  for (unsigned int index = 0; index < selectionTags.size(); ++index) {
136  isGood.push_back(false);
137 
139  isGood[index] = muon::isGoodMuon(*muon, muonType);
140  }
141 
142  bool isGoodResult = true;
143  for (unsigned int index = 0; index < isGood.size(); ++index) {
144  isGoodResult *= isGood[index];
145  }
146 
147  if (isGoodResult) {
148  // new copy of Track
149  reco::TrackRef trackref;
150  bool addMatchedMuonSegments = false;
151 
152  if (trackType == "innerTrack") {
153  if (muon->innerTrack().isNonnull())
154  trackref = muon->innerTrack();
155  else
156  continue;
157  } else if (trackType == "outerTrack") {
158  if (muon->outerTrack().isNonnull())
159  trackref = muon->outerTrack();
160  else
161  continue;
162  } else if (trackType == "globalTrack") {
163  if (muon->globalTrack().isNonnull())
164  trackref = muon->globalTrack();
165  else
166  continue;
167  } else if (trackType == "innerTrackPlusSegments") {
168  if (muon->innerTrack().isNonnull()) {
169  trackref = muon->innerTrack();
170  addMatchedMuonSegments = true;
171  } else
172  continue;
173  } else if (trackType == "rpcMuonTrack") {
174  if (muon->innerTrack().isNonnull() && muon->isRPCMuon()) {
175  trackref = muon->innerTrack();
176  } else
177  continue;
178  } else if (trackType == "gemMuonTrack") {
179  if (muon->innerTrack().isNonnull() && muon->isGEMMuon()) {
180  trackref = muon->innerTrack();
181  } else
182  continue;
183  } else if (trackType == "me0MuonTrack") {
184  if (muon->innerTrack().isNonnull() && muon->isME0Muon()) {
185  trackref = muon->innerTrack();
186  } else
187  continue;
188  } else if (trackType == "tunepTrack") {
189  if (muon->isGlobalMuon() && muon->tunePMuonBestTrack().isNonnull())
190  trackref = muon->tunePMuonBestTrack();
191  else
192  continue;
193  } else if (trackType == "pfTrack") {
194  if (muon->isPFMuon() && muon->muonBestTrack().isNonnull())
195  trackref = muon->muonBestTrack();
196  else
197  continue;
198  } else if (trackType == "recomuonTrack") {
199  if (muon->isGlobalMuon())
200  trackref = muon->globalTrack();
201  else if (muon->isTrackerMuon()) {
202  trackref = muon->innerTrack();
203  addMatchedMuonSegments = true;
204  } else if (muon->isStandAloneMuon())
205  trackref = muon->outerTrack();
206  else if (muon->isRPCMuon())
207  trackref = muon->innerTrack();
208  else if (muon->isGEMMuon())
209  trackref = muon->innerTrack();
210  else if (muon->isME0Muon())
211  trackref = muon->innerTrack();
212  else
213  trackref = muon->muonBestTrack();
214 
215  if (muon->muonBestTrackType() != muon->tunePMuonBestTrackType())
216  edm::LogVerbatim("MuonTrackProducer") << "\n *** PF != TuneP *** \n" << std::endl;
217 
218  edm::LogVerbatim("MuonTrackProducer") << "isGlobal ? " << muon->isGlobalMuon() << std::endl;
219  edm::LogVerbatim("MuonTrackProducer")
220  << "isTracker ? " << muon->isTrackerMuon() << ", isRPC ? " << muon->isRPCMuon() << ", isGEM ? "
221  << muon->isGEMMuon() << ", isME0 ? " << muon->isME0Muon() << std::endl;
222  edm::LogVerbatim("MuonTrackProducer") << "isStandAlone ? " << muon->isStandAloneMuon() << std::endl;
223  edm::LogVerbatim("MuonTrackProducer") << "isCalo ? " << muon->isCaloMuon() << std::endl;
224  edm::LogVerbatim("MuonTrackProducer") << "isPF ? " << muon->isPFMuon() << std::endl << std::endl;
225 
226  edm::LogVerbatim("MuonTrackProducer")
227  << " enum MuonTrackType {None, InnerTrack, OuterTrack, CombinedTrack, TPFMS, Picky, DYT }" << std::endl;
228 
229  edm::LogVerbatim("MuonTrackProducer")
230  << "(muon) pt = " << muon->pt() << ", eta = " << muon->eta() << ", phi = " << muon->phi() << std::endl;
231 
232  if (muon->muonBestTrack().isNonnull())
233  edm::LogVerbatim("MuonTrackProducer")
234  << "(best) pt = " << muon->muonBestTrack()->pt() << ", eta = " << muon->muonBestTrack()->eta()
235  << ", phi = " << muon->muonBestTrack()->phi()
236  << ", N mu hits = " << muon->muonBestTrack()->hitPattern().numberOfValidMuonHits()
237  << ", N trk hits = " << muon->muonBestTrack()->hitPattern().numberOfValidTrackerHits()
238  << ", MuonTrackType = " << muon->muonBestTrackType() << std::endl;
239  if (muon->tunePMuonBestTrack().isNonnull())
240  edm::LogVerbatim("MuonTrackProducer")
241  << "(tuneP) pt = " << muon->tunePMuonBestTrack()->pt()
242  << ", eta = " << muon->tunePMuonBestTrack()->eta() << ", phi = " << muon->tunePMuonBestTrack()->phi()
243  << ", N mu hits = " << muon->tunePMuonBestTrack()->hitPattern().numberOfValidMuonHits()
244  << ", N trk hits = " << muon->tunePMuonBestTrack()->hitPattern().numberOfValidTrackerHits()
245  << ", MuonTrackType = " << muon->tunePMuonBestTrackType() << std::endl;
246  if (muon->innerTrack().isNonnull())
247  edm::LogVerbatim("MuonTrackProducer")
248  << "(inner) pt = " << muon->innerTrack()->pt() << ", eta = " << muon->innerTrack()->eta()
249  << ", phi = " << muon->innerTrack()->phi()
250  << ", N trk hits = " << muon->innerTrack()->hitPattern().numberOfValidTrackerHits() << std::endl;
251  if (muon->globalTrack().isNonnull())
252  edm::LogVerbatim("MuonTrackProducer")
253  << "(global) pt = " << muon->globalTrack()->pt() << ", eta = " << muon->globalTrack()->eta()
254  << ", phi = " << muon->globalTrack()->phi()
255  << ", N mu hits = " << muon->globalTrack()->hitPattern().numberOfValidMuonHits()
256  << ", N trk hits = " << muon->globalTrack()->hitPattern().numberOfValidTrackerHits() << std::endl;
257  if (muon->outerTrack().isNonnull())
258  edm::LogVerbatim("MuonTrackProducer")
259  << "(outer) pt = " << muon->outerTrack()->pt() << ", eta = " << muon->outerTrack()->eta()
260  << ", phi = " << muon->outerTrack()->phi()
261  << ", N mu hits = " << muon->outerTrack()->hitPattern().numberOfValidMuonHits() << std::endl;
262  if (muon->tpfmsTrack().isNonnull())
263  edm::LogVerbatim("MuonTrackProducer")
264  << "(tpfms) pt = " << muon->tpfmsTrack()->pt() << ", eta = " << muon->tpfmsTrack()->eta()
265  << ", phi = " << muon->tpfmsTrack()->phi()
266  << ", N mu hits = " << muon->tpfmsTrack()->hitPattern().numberOfValidMuonHits()
267  << ", N trk hits = " << muon->tpfmsTrack()->hitPattern().numberOfValidTrackerHits() << std::endl;
268  if (muon->pickyTrack().isNonnull())
269  edm::LogVerbatim("MuonTrackProducer")
270  << "(picky) pt = " << muon->pickyTrack()->pt() << ", eta = " << muon->pickyTrack()->eta()
271  << ", phi = " << muon->pickyTrack()->phi()
272  << ", N mu hits = " << muon->pickyTrack()->hitPattern().numberOfValidMuonHits()
273  << ", N trk hits = " << muon->pickyTrack()->hitPattern().numberOfValidTrackerHits() << std::endl;
274  if (muon->dytTrack().isNonnull())
275  edm::LogVerbatim("MuonTrackProducer")
276  << "(dyt) pt = " << muon->dytTrack()->pt() << ", eta = " << muon->dytTrack()->eta()
277  << ", phi = " << muon->dytTrack()->phi()
278  << ", N mu hits = " << muon->dytTrack()->hitPattern().numberOfValidMuonHits()
279  << ", N trk hits = " << muon->dytTrack()->hitPattern().numberOfValidTrackerHits() << std::endl;
280  }
281 
282  edm::LogVerbatim("MuonTrackProducer") << "\t *** Selected *** ";
283  const reco::Track *trk = &(*trackref);
284  // pointer to old track:
285  std::unique_ptr<reco::Track> newTrk(new reco::Track(*trk));
286 
287  newTrk->setExtra(reco::TrackExtraRef(rTrackExtras, idx++));
288  PropagationDirection seedDir = trk->seedDirection();
289  // new copy of track Extras
290  std::unique_ptr<reco::TrackExtra> newExtra(new reco::TrackExtra(trk->outerPosition(),
291  trk->outerMomentum(),
292  trk->outerOk(),
293  trk->innerPosition(),
294  trk->innerMomentum(),
295  trk->innerOk(),
296  trk->outerStateCovariance(),
297  trk->outerDetId(),
298  trk->innerStateCovariance(),
299  trk->innerDetId(),
300  seedDir));
301 
302  // new copy of the silicon hits; add hit refs to Extra and hits to hit
303  // collection
304 
305  // edm::LogVerbatim("MuonTrackProducer")<<"\n printing initial
306  // hit_pattern"; trk->hitPattern().print();
307  unsigned int nHitsToAdd = 0;
308  for (trackingRecHit_iterator iHit = trk->recHitsBegin(); iHit != trk->recHitsEnd(); iHit++) {
309  TrackingRecHit *hit = (*iHit)->clone();
310  selectedTrackHits->push_back(hit);
311  ++nHitsToAdd;
312  }
313 
314  if (addMatchedMuonSegments) {
315  int wheel, station, sector;
316  int endcap, /*station, */ ring, chamber;
317 
318  edm::LogVerbatim("MuonTrackProducer")
319  << "Number of chambers: " << muon->matches().size()
320  << ", arbitrated: " << muon->numberOfMatches(reco::Muon::SegmentAndTrackArbitration);
321  unsigned int index_chamber = 0;
322 
323  for (std::vector<reco::MuonChamberMatch>::const_iterator chamberMatch = muon->matches().begin();
324  chamberMatch != muon->matches().end();
325  ++chamberMatch, index_chamber++) {
326  std::stringstream chamberStr;
327  chamberStr << "\nchamber index: " << index_chamber;
328 
329  int subdet = chamberMatch->detector();
330  DetId did = chamberMatch->id;
331 
332  if (subdet == MuonSubdetId::DT) {
333  DTChamberId dtdetid = DTChamberId(did);
334  wheel = dtdetid.wheel();
335  station = dtdetid.station();
336  sector = dtdetid.sector();
337  chamberStr << ", DT chamber Wh:" << wheel << ",St:" << station << ",Se:" << sector;
338  } else if (subdet == MuonSubdetId::CSC) {
339  CSCDetId cscdetid = CSCDetId(did);
340  endcap = cscdetid.endcap();
341  station = cscdetid.station();
342  ring = cscdetid.ring();
343  chamber = cscdetid.chamber();
344  chamberStr << ", CSC chamber End:" << endcap << ",St:" << station << ",Ri:" << ring << ",Ch:" << chamber;
345  }
346 
347  chamberStr << ", Number of segments: " << chamberMatch->segmentMatches.size();
348  edm::LogVerbatim("MuonTrackProducer") << chamberStr.str();
349 
350  unsigned int index_segment = 0;
351 
352  for (std::vector<reco::MuonSegmentMatch>::const_iterator segmentMatch =
353  chamberMatch->segmentMatches.begin();
354  segmentMatch != chamberMatch->segmentMatches.end();
355  ++segmentMatch, index_segment++) {
356  float segmentX = segmentMatch->x;
357  float segmentY = segmentMatch->y;
358  float segmentdXdZ = segmentMatch->dXdZ;
359  float segmentdYdZ = segmentMatch->dYdZ;
360  float segmentXerr = segmentMatch->xErr;
361  float segmentYerr = segmentMatch->yErr;
362  float segmentdXdZerr = segmentMatch->dXdZErr;
363  float segmentdYdZerr = segmentMatch->dYdZErr;
364 
365  CSCSegmentRef segmentCSC = segmentMatch->cscSegmentRef;
366  DTRecSegment4DRef segmentDT = segmentMatch->dtSegmentRef;
367 
368  bool segment_arbitrated_Ok = (segmentMatch->isMask(reco::MuonSegmentMatch::BestInChamberByDR) &&
369  segmentMatch->isMask(reco::MuonSegmentMatch::BelongsToTrackByDR));
370 
371  std::string ARBITRATED(" ***Arbitrated Off*** ");
372  if (segment_arbitrated_Ok)
373  ARBITRATED = " ***ARBITRATED OK*** ";
374 
375  if (subdet == MuonSubdetId::DT) {
376  edm::LogVerbatim("MuonTrackProducer")
377  << "\n\t segment index: " << index_segment << ARBITRATED << "\n\t Local Position (X,Y)=("
378  << segmentX << "," << segmentY << ") +/- (" << segmentXerr << "," << segmentYerr << "), "
379  << "\n\t Local Direction (dXdZ,dYdZ)=(" << segmentdXdZ << "," << segmentdYdZ << ") +/- ("
380  << segmentdXdZerr << "," << segmentdYdZerr << ")";
381 
382  if (!segment_arbitrated_Ok)
383  continue;
384 
385  if (segmentDT.get() != nullptr) {
386  const DTRecSegment4D *segment = segmentDT.get();
387 
388  edm::LogVerbatim("MuonTrackProducer")
389  << "\t ===> MATCHING with DT segment with index = " << segmentDT.key();
390 
391  if (segment->hasPhi()) {
392  const DTChamberRecSegment2D *phiSeg = segment->phiSegment();
393  std::vector<const TrackingRecHit *> phiHits = phiSeg->recHits();
394  for (std::vector<const TrackingRecHit *>::const_iterator ihit = phiHits.begin();
395  ihit != phiHits.end();
396  ++ihit) {
397  TrackingRecHit *seghit = (*ihit)->clone();
398  newTrk->appendHitPattern(*seghit, ttopo);
399  // edm::LogVerbatim("MuonTrackProducer")<<"hit
400  // pattern for position "<<index_hit<<" set to:";
401  // newTrk->hitPattern().printHitPattern(index_hit,
402  // std::cout);
403  selectedTrackHits->push_back(seghit);
404  ++nHitsToAdd;
405  }
406  }
407 
408  if (segment->hasZed()) {
409  const DTSLRecSegment2D *zSeg = (*segment).zSegment();
410  std::vector<const TrackingRecHit *> zedHits = zSeg->recHits();
411  for (std::vector<const TrackingRecHit *>::const_iterator ihit = zedHits.begin();
412  ihit != zedHits.end();
413  ++ihit) {
414  TrackingRecHit *seghit = (*ihit)->clone();
415  newTrk->appendHitPattern(*seghit, ttopo);
416  // edm::LogVerbatim("MuonTrackProducer")<<"hit
417  // pattern for position "<<index_hit<<" set to:";
418  // newTrk->hitPattern().printHitPattern(index_hit,
419  // std::cout);
420  selectedTrackHits->push_back(seghit);
421  ++nHitsToAdd;
422  }
423  }
424  } else
425  edm::LogWarning("MuonTrackProducer") << "\n***WARNING: UNMATCHED DT segment ! \n";
426  } // if (subdet == MuonSubdetId::DT)
427 
428  else if (subdet == MuonSubdetId::CSC) {
429  edm::LogVerbatim("MuonTrackProducer")
430  << "\n\t segment index: " << index_segment << ARBITRATED << "\n\t Local Position (X,Y)=("
431  << segmentX << "," << segmentY << ") +/- (" << segmentXerr << "," << segmentYerr << "), "
432  << "\n\t Local Direction (dXdZ,dYdZ)=(" << segmentdXdZ << "," << segmentdYdZ << ") +/- ("
433  << segmentdXdZerr << "," << segmentdYdZerr << ")";
434 
435  if (!segment_arbitrated_Ok)
436  continue;
437 
438  if (segmentCSC.get() != nullptr) {
439  const CSCSegment *segment = segmentCSC.get();
440 
441  edm::LogVerbatim("MuonTrackProducer")
442  << "\t ===> MATCHING with CSC segment with index = " << segmentCSC.key();
443 
444  std::vector<const TrackingRecHit *> hits = segment->recHits();
445  for (std::vector<const TrackingRecHit *>::const_iterator ihit = hits.begin(); ihit != hits.end();
446  ++ihit) {
447  TrackingRecHit *seghit = (*ihit)->clone();
448  newTrk->appendHitPattern(*seghit, ttopo);
449  // edm::LogVerbatim("MuonTrackProducer")<<"hit
450  // pattern for position "<<index_hit<<" set to:";
451  // newTrk->hitPattern().printHitPattern(index_hit,
452  // std::cout);
453  selectedTrackHits->push_back(seghit);
454  ++nHitsToAdd;
455  }
456  } else
457  edm::LogWarning("MuonTrackProducer") << "\n***WARNING: UNMATCHED CSC segment ! \n";
458  } // else if (subdet == MuonSubdetId::CSC)
459 
460  } // loop on vector<MuonSegmentMatch>
461  } // loop on vector<MuonChamberMatch>
462  } // if (trackType == "innerTrackPlusSegments")
463 
464  // edm::LogVerbatim("MuonTrackProducer")<<"\n printing final
465  // hit_pattern"; newTrk->hitPattern().print();
466 
467  newExtra->setHits(rHits, hidx, nHitsToAdd);
468  hidx += nHitsToAdd;
469 
470  selectedTracks->push_back(*newTrk);
471  selectedTrackExtras->push_back(*newExtra);
472 
473  } // if (isGoodResult)
474  } // loop on reco::MuonCollection
475 
477  iEvent.put(std::move(selectedTrackExtras));
478  iEvent.put(std::move(selectedTrackHits));
479  }
480 }

References reco::MuonSegmentMatch::BelongsToTrackByDR, reco::MuonSegmentMatch::BestInChamberByDR, relativeConstraints::chamber, CSCDetId::chamber(), TrackingRecHit::clone(), MuonSubdetId::CSC, cscSegmentCollectionH_, MuonSubdetId::DT, dtSegmentCollectionH_, CSCDetId::endcap(), makeMuonMisalignmentScenario::endcap, edm::EventSetup::get(), get, edm::Ref< C, T, F >::get(), DTRecSegment4D::hasPhi(), DTRecSegment4D::hasZed(), hfClusterShapes_cfi::hits, charmTagsComputerCvsB_cfi::idx, iEvent, ignoreMissingMuonCollection, reco::Track::innerDetId(), reco::Track::innerMomentum(), reco::Track::innerOk(), reco::Track::innerPosition(), reco::Track::innerStateCovariance(), inputCSCSegmentToken_, inputDTRecSegment4DToken_, muon::isGoodMuon(), edm::Ref< C, T, F >::key(), eostools::move(), HLT_2018_cff::muon, muonCollectionH, muonsToken, reco::Track::outerDetId(), reco::Track::outerMomentum(), reco::Track::outerOk(), reco::Track::outerPosition(), reco::Track::outerStateCovariance(), DTRecSegment4D::phiSegment(), CSCSegment::recHits(), DTRecSegment2D::recHits(), reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), CSCDetId::ring(), relativeConstraints::ring, DTChamberId::sector(), reco::Track::seedDirection(), reco::Muon::SegmentAndTrackArbitration, TrackCollections2monitor_cff::selectedTracks, selectionTags, muon::selectionTypeFromString(), mathSSE::sqrt(), DTChamberId::station(), relativeConstraints::station, CSCDetId::station(), AlCaHLTBitMon_QueryRunRegistry::string, trackType, DTChamberId::wheel(), makeMuonMisalignmentScenario::wheel, PV3DBase< T, PVType, FrameType >::x(), LocalError::xx(), PV3DBase< T, PVType, FrameType >::y(), LocalError::yy(), and PV3DBase< T, PVType, FrameType >::z().

Member Data Documentation

◆ cscSegmentCollectionH_

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

Definition at line 28 of file MuonTrackProducer.h.

Referenced by produce().

◆ dtSegmentCollectionH_

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

Definition at line 27 of file MuonTrackProducer.h.

Referenced by produce().

◆ ignoreMissingMuonCollection

bool MuonTrackProducer::ignoreMissingMuonCollection
private

Definition at line 36 of file MuonTrackProducer.h.

Referenced by produce().

◆ inputCSCSegmentToken_

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

Definition at line 32 of file MuonTrackProducer.h.

Referenced by produce().

◆ inputDTRecSegment4DToken_

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

Definition at line 31 of file MuonTrackProducer.h.

Referenced by produce().

◆ muonCollectionH

edm::Handle<reco::MuonCollection> MuonTrackProducer::muonCollectionH
private

Definition at line 26 of file MuonTrackProducer.h.

Referenced by produce().

◆ muonsToken

edm::EDGetTokenT<reco::MuonCollection> MuonTrackProducer::muonsToken
private

Definition at line 30 of file MuonTrackProducer.h.

Referenced by produce().

◆ parset_

const edm::ParameterSet MuonTrackProducer::parset_
private

Definition at line 37 of file MuonTrackProducer.h.

Referenced by MuonTrackProducer().

◆ selectionTags

std::vector<std::string> MuonTrackProducer::selectionTags
private

Definition at line 34 of file MuonTrackProducer.h.

Referenced by produce().

◆ trackType

std::string MuonTrackProducer::trackType
private

Definition at line 35 of file MuonTrackProducer.h.

Referenced by produce().

reco::Track::outerPosition
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:62
Vector3DBase< float, LocalTag >
reco::Track::outerMomentum
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:65
edm::RefProd< TrackCollection >
DTSLRecSegment2D
Definition: DTSLRecSegment2D.h:15
reco::Track::outerStateCovariance
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
Definition: Track.h:68
MuonSubdetId::CSC
static constexpr int CSC
Definition: MuonSubdetId.h:12
DTRecSegment4D
Definition: DTRecSegment4D.h:23
reco::Track::outerDetId
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
Definition: Track.h:79
reco::Muon::SegmentAndTrackArbitration
Definition: Muon.h:190
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
reco::Track::recHitsBegin
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:88
muon
Definition: MuonCocktails.h:17
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
relativeConstraints.station
station
Definition: relativeConstraints.py:67
CSCDetId::ring
int ring() const
Definition: CSCDetId.h:68
TrackerTopology
Definition: TrackerTopology.h:16
edm::Ref::get
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
MuonTrackProducer::inputCSCSegmentToken_
edm::EDGetTokenT< CSCSegmentCollection > inputCSCSegmentToken_
Definition: MuonTrackProducer.h:32
charmTagsComputerCvsB_cfi.idx
idx
Definition: charmTagsComputerCvsB_cfi.py:108
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
makeMuonMisalignmentScenario.endcap
endcap
Definition: makeMuonMisalignmentScenario.py:320
HLT_2018_cff.muon
muon
Definition: HLT_2018_cff.py:10349
reco::Track::outerOk
bool outerOk() const
return true if the outermost hit is valid
Definition: Track.h:50
MuonTrackProducer::inputDTRecSegment4DToken_
edm::EDGetTokenT< DTRecSegment4DCollection > inputDTRecSegment4DToken_
Definition: MuonTrackProducer.h:31
reco::MuonSegmentMatch::BelongsToTrackByDR
static const unsigned int BelongsToTrackByDR
Definition: MuonSegmentMatch.h:25
edm::Ref< TrackCollection >
reco::Track::innerStateCovariance
CovarianceMatrix innerStateCovariance() const
innermost trajectory state curvilinear errors
Definition: Track.h:71
reco::Track::innerOk
bool innerOk() const
return true if the innermost hit is valid
Definition: Track.h:53
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
reco::TrackExtra
Definition: TrackExtra.h:26
MuonTrackProducer::dtSegmentCollectionH_
edm::Handle< DTRecSegment4DCollection > dtSegmentCollectionH_
Definition: MuonTrackProducer.h:27
MuonTrackProducer::muonsToken
edm::EDGetTokenT< reco::MuonCollection > muonsToken
Definition: MuonTrackProducer.h:30
reco::Track::innerMomentum
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:59
muon::isGoodMuon
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
Definition: MuonSelectors.cc:664
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
muon::selectionTypeFromString
SelectionType selectionTypeFromString(const std::string &label)
Definition: MuonSelectors.cc:9
muon::SelectionType
SelectionType
Selector type.
Definition: MuonSelectors.h:19
MuonTrackProducer::selectionTags
std::vector< std::string > selectionTags
Definition: MuonTrackProducer.h:34
LocalError::xx
float xx() const
Definition: LocalError.h:22
edm::ParameterSet::dump
std::string dump(unsigned int indent=0) const
Definition: ParameterSet.cc:825
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
reco::Track::recHitsEnd
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:91
reco::Track
Definition: Track.h:27
edm::ESHandle< TrackerTopology >
reco::TrackExtraCollection
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:10
MuonSubdetId::DT
static constexpr int DT
Definition: MuonSubdetId.h:11
Point3DBase< float, LocalTag >
CSCSegment
Definition: CSCSegment.h:21
edm::OwnVector::const_iterator
Definition: OwnVector.h:41
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
MuonTrackProducer::parset_
const edm::ParameterSet parset_
Definition: MuonTrackProducer.h:37
reco::Track::seedDirection
const PropagationDirection & seedDirection() const
direction of how the hits were sorted in the original seed
Definition: Track.h:148
LocalError
Definition: LocalError.h:12
MuonTrackProducer::cscSegmentCollectionH_
edm::Handle< CSCSegmentCollection > cscSegmentCollectionH_
Definition: MuonTrackProducer.h:28
edm::RangeMap::const_iterator
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
CSCDetId
Definition: CSCDetId.h:26
MuonTrackProducer::ignoreMissingMuonCollection
bool ignoreMissingMuonCollection
Definition: MuonTrackProducer.h:36
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
reco::Track::innerPosition
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:56
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
reco::Track::innerDetId
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
Definition: Track.h:82
CSCDetId::chamber
int chamber() const
Definition: CSCDetId.h:62
get
#define get
TrackingRecHit::clone
virtual TrackingRecHit * clone() const =0
edm::Ref::key_type
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:164
MuonTrackProducer::trackType
std::string trackType
Definition: MuonTrackProducer.h:35
TrackingRecHit
Definition: TrackingRecHit.h:21
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
DTChamberId::sector
int sector() const
Definition: DTChamberId.h:49
eostools.move
def move(src, dest)
Definition: eostools.py:511
DTRecSegment4D::hasZed
bool hasZed() const
Does it have the Z projection?
Definition: DTRecSegment4D.h:93
CSCDetId::endcap
int endcap() const
Definition: CSCDetId.h:85
PropagationDirection
PropagationDirection
Definition: PropagationDirection.h:4
TrackingRecHitCollection
edm::OwnVector< TrackingRecHit > TrackingRecHitCollection
collection of TrackingRecHits
Definition: TrackingRecHitFwd.h:10
relativeConstraints.ring
ring
Definition: relativeConstraints.py:68
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
MuonTrackProducer::muonCollectionH
edm::Handle< reco::MuonCollection > muonCollectionH
Definition: MuonTrackProducer.h:26
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
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
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
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
DTChamberId::station
int station() const
Return the station number.
Definition: DTChamberId.h:42
hit
Definition: SiStripHitEffFromCalibTree.cc:88
edm::OwnVector< TrackingRecHit >
TrackCollections2monitor_cff.selectedTracks
selectedTracks
Definition: TrackCollections2monitor_cff.py:32
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