CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MuonIdProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: MuonIdentification
4 // Class: MuonIdProducer
5 //
6 //
7 // Original Author: Dmytro Kovalskyi
8 //
9 //
10 
11 // user include files
13 
27 
30 
33 
35  : geomTokenRun_(esConsumes<edm::Transition::BeginRun>()),
36  propagatorToken_(esConsumes(edm::ESInputTag("", "SteppingHelixPropagatorAny"))) {
37  LogTrace("MuonIdentification") << "RecoMuon/MuonIdProducer :: Constructor called";
38 
39  produces<reco::MuonCollection>();
40  produces<reco::CaloMuonCollection>();
41  produces<reco::MuonTimeExtraMap>("combined");
42  produces<reco::MuonTimeExtraMap>("dt");
43  produces<reco::MuonTimeExtraMap>("csc");
44 
45  minPt_ = iConfig.getParameter<double>("minPt");
46  minP_ = iConfig.getParameter<double>("minP");
47  minPCaloMuon_ = iConfig.getParameter<double>("minPCaloMuon");
48  minNumberOfMatches_ = iConfig.getParameter<int>("minNumberOfMatches");
49  addExtraSoftMuons_ = iConfig.getParameter<bool>("addExtraSoftMuons");
50  maxAbsEta_ = iConfig.getParameter<double>("maxAbsEta");
51  maxAbsDx_ = iConfig.getParameter<double>("maxAbsDx");
52  maxAbsPullX2_ = iConfig.getParameter<double>("maxAbsPullX");
53  maxAbsPullX2_ *= maxAbsPullX2_;
54  maxAbsDy_ = iConfig.getParameter<double>("maxAbsDy");
55  maxAbsPullY2_ = iConfig.getParameter<double>("maxAbsPullY");
56  maxAbsPullY2_ *= maxAbsPullY2_;
57  fillCaloCompatibility_ = iConfig.getParameter<bool>("fillCaloCompatibility");
58  fillEnergy_ = iConfig.getParameter<bool>("fillEnergy");
59  storeCrossedHcalRecHits_ = iConfig.getParameter<bool>("storeCrossedHcalRecHits");
60  fillMatching_ = iConfig.getParameter<bool>("fillMatching");
61  fillIsolation_ = iConfig.getParameter<bool>("fillIsolation");
62  fillShowerDigis_ = iConfig.getParameter<bool>("fillShowerDigis");
63  writeIsoDeposits_ = iConfig.getParameter<bool>("writeIsoDeposits");
64  fillGlobalTrackQuality_ = iConfig.getParameter<bool>("fillGlobalTrackQuality");
65  fillGlobalTrackRefits_ = iConfig.getParameter<bool>("fillGlobalTrackRefits");
66  arbitrateTrackerMuons_ = iConfig.getParameter<bool>("arbitrateTrackerMuons");
67  //SK: (maybe temporary) run it only if the global is also run
68  fillTrackerKink_ = false;
69  if (fillGlobalTrackQuality_)
70  fillTrackerKink_ = iConfig.getParameter<bool>("fillTrackerKink");
71 
73  iConfig.getParameter<double>("ptThresholdToFillCandidateP4WithGlobalFit");
75  iConfig.getParameter<double>("sigmaThresholdToFillCandidateP4WithGlobalFit");
76  caloCut_ = iConfig.getParameter<double>("minCaloCompatibility"); //CaloMuons
77  arbClean_ = iConfig.getParameter<bool>("runArbitrationCleaner"); // muon mesh
78 
79  // Load TrackDetectorAssociator parameters
80  const edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
81  edm::ConsumesCollector iC = consumesCollector();
82  parameters_.loadParameters(parameters, iC);
83 
84  // Load parameters for the TimingFiller
85  edm::ParameterSet timingParameters = iConfig.getParameter<edm::ParameterSet>("TimingFillerParameters");
86  theTimingFiller_ = std::make_unique<MuonTimingFiller>(timingParameters, consumesCollector());
87 
88  // Load parameters for the ShowerDigiFiller
89  if (fillShowerDigis_ && fillMatching_) {
90  edm::ParameterSet showerDigiParameters = iConfig.getParameter<edm::ParameterSet>("ShowerDigiFillerParameters");
91  theShowerDigiFiller_ = std::make_unique<MuonShowerDigiFiller>(showerDigiParameters, consumesCollector());
92  } else {
93  theShowerDigiFiller_ = std::make_unique<MuonShowerDigiFiller>(); // to be used to call fillDefault only
94  }
95 
97  // Load MuonCaloCompatibility parameters
98  const auto caloParams = iConfig.getParameter<edm::ParameterSet>("MuonCaloCompatibility");
100  }
101 
102  if (fillIsolation_) {
103  // Load MuIsoExtractor parameters
104  edm::ParameterSet caloExtractorPSet = iConfig.getParameter<edm::ParameterSet>("CaloExtractorPSet");
105  std::string caloExtractorName = caloExtractorPSet.getParameter<std::string>("ComponentName");
107  IsoDepositExtractorFactory::get()->create(caloExtractorName, caloExtractorPSet, consumesCollector());
108 
109  edm::ParameterSet trackExtractorPSet = iConfig.getParameter<edm::ParameterSet>("TrackExtractorPSet");
110  std::string trackExtractorName = trackExtractorPSet.getParameter<std::string>("ComponentName");
112  IsoDepositExtractorFactory::get()->create(trackExtractorName, trackExtractorPSet, consumesCollector());
113 
114  edm::ParameterSet jetExtractorPSet = iConfig.getParameter<edm::ParameterSet>("JetExtractorPSet");
115  std::string jetExtractorName = jetExtractorPSet.getParameter<std::string>("ComponentName");
117  IsoDepositExtractorFactory::get()->create(jetExtractorName, jetExtractorPSet, consumesCollector());
118  }
119  if (fillIsolation_ && writeIsoDeposits_) {
120  trackDepositName_ = iConfig.getParameter<std::string>("trackDepositName");
121  produces<reco::IsoDepositMap>(trackDepositName_);
122  ecalDepositName_ = iConfig.getParameter<std::string>("ecalDepositName");
123  produces<reco::IsoDepositMap>(ecalDepositName_);
124  hcalDepositName_ = iConfig.getParameter<std::string>("hcalDepositName");
125  produces<reco::IsoDepositMap>(hcalDepositName_);
126  hoDepositName_ = iConfig.getParameter<std::string>("hoDepositName");
127  produces<reco::IsoDepositMap>(hoDepositName_);
128  jetDepositName_ = iConfig.getParameter<std::string>("jetDepositName");
129  produces<reco::IsoDepositMap>(jetDepositName_);
130  }
131 
132  inputCollectionLabels_ = iConfig.getParameter<std::vector<edm::InputTag> >("inputCollectionLabels");
133  const auto inputCollectionTypes = iConfig.getParameter<std::vector<std::string> >("inputCollectionTypes");
134  if (inputCollectionLabels_.size() != inputCollectionTypes.size())
135  throw cms::Exception("ConfigurationError")
136  << "Number of input collection labels is different from number of types. "
137  << "For each collection label there should be exactly one collection type specified.";
138  if (inputCollectionLabels_.size() > 7 || inputCollectionLabels_.empty())
139  throw cms::Exception("ConfigurationError") << "Number of input collections should be from 1 to 7.";
140 
141  debugWithTruthMatching_ = iConfig.getParameter<bool>("debugWithTruthMatching");
143  edm::LogWarning("MuonIdentification")
144  << "========================================================================\n"
145  << "Debugging mode with truth matching is turned on!!! Make sure you understand what you are doing!\n"
146  << "========================================================================\n";
147 
149  }
150  if (fillGlobalTrackQuality_) {
151  const auto& glbQualTag = iConfig.getParameter<edm::InputTag>("globalTrackQualityInputTag");
152  glbQualToken_ = consumes<edm::ValueMap<reco::MuonQuality> >(glbQualTag);
153  }
154 
155  if (fillTrackerKink_) {
157  std::make_unique<MuonKinkFinder>(iConfig.getParameter<edm::ParameterSet>("TrackerKinkFinderParameters"), iC);
158  }
159 
160  //create mesh holder
161  meshAlgo_ = std::make_unique<MuonMesh>(iConfig.getParameter<edm::ParameterSet>("arbitrationCleanerOptions"));
162 
163  edm::InputTag rpcHitTag("rpcRecHits");
164  rpcHitToken_ = consumes<RPCRecHitCollection>(rpcHitTag);
165 
166  //Consumes... UGH
168  for (unsigned int i = 0; i < inputCollectionLabels_.size(); ++i) {
169  const auto inputLabel = inputCollectionLabels_[i];
170  const auto inputType = ICTypes::toKey(inputCollectionTypes[i]); // Note: thorws exception if type is undefined.
171 
172  if (inputType == ICTypes::INNER_TRACKS) {
173  innerTrackCollectionToken_ = consumes<reco::TrackCollection>(inputLabel);
174  } else if (inputType == ICTypes::OUTER_TRACKS) {
175  outerTrackCollectionToken_ = consumes<reco::TrackCollection>(inputLabel);
176  } else if (inputType == ICTypes::LINKS) {
177  linkCollectionToken_ = consumes<reco::MuonTrackLinksCollection>(inputLabel);
178  } else if (inputType == ICTypes::MUONS) {
179  muonCollectionToken_ = consumes<reco::MuonCollection>(inputLabel);
180  } else if (inputType == ICTypes::TEV_FIRSTHIT) {
181  tpfmsCollectionToken_ = consumes<reco::TrackToTrackMap>(inputLabel);
182  } else if (fillGlobalTrackRefits_ && inputType == ICTypes::TEV_PICKY) {
183  pickyCollectionToken_ = consumes<reco::TrackToTrackMap>(inputLabel);
184  } else if (fillGlobalTrackRefits_ && inputType == ICTypes::TEV_DYT) {
185  dytCollectionToken_ = consumes<reco::TrackToTrackMap>(inputCollectionLabels_.at(i));
186  }
187 
188  inputCollectionTypes_[i] = inputType;
189  }
190 }
191 
193  // TimingReport::current()->dump(std::cout);
194 }
195 
201 
205 
207 
208  if (fillTrackerKink_)
209  trackerKinkFinder_->init(iSetup);
210 
211  for (unsigned int i = 0; i < inputCollectionLabels_.size(); ++i) {
212  const auto& inputLabel = inputCollectionLabels_[i];
213  const auto inputType = inputCollectionTypes_[i];
214  if (inputType == ICTypes::INNER_TRACKS) {
217  throw cms::Exception("FatalError") << "Failed to get input track collection with label: " << inputLabel;
218  LogTrace("MuonIdentification") << "Number of input inner tracks: " << innerTrackCollectionHandle_->size();
219  } else if (inputType == ICTypes::OUTER_TRACKS) {
222  throw cms::Exception("FatalError") << "Failed to get input track collection with label: " << inputLabel;
223  LogTrace("MuonIdentification") << "Number of input outer tracks: " << outerTrackCollectionHandle_->size();
224  } else if (inputType == ICTypes::LINKS) {
227  throw cms::Exception("FatalError") << "Failed to get input link collection with label: " << inputLabel;
228  LogTrace("MuonIdentification") << "Number of input links: " << linkCollectionHandle_->size();
229  } else if (inputType == ICTypes::MUONS) {
232  throw cms::Exception("FatalError") << "Failed to get input muon collection with label: " << inputLabel;
233  LogTrace("MuonIdentification") << "Number of input muons: " << muonCollectionHandle_->size();
234  } else if (fillGlobalTrackRefits_ && inputType == ICTypes::TEV_FIRSTHIT) {
237  throw cms::Exception("FatalError") << "Failed to get input muon collection with label: " << inputLabel;
238  LogTrace("MuonIdentification") << "Number of input muons: " << tpfmsCollectionHandle_->size();
239  } else if (fillGlobalTrackRefits_ && inputType == ICTypes::TEV_PICKY) {
242  throw cms::Exception("FatalError") << "Failed to get input muon collection with label: " << inputLabel;
243  LogTrace("MuonIdentification") << "Number of input muons: " << pickyCollectionHandle_->size();
244  } else if (fillGlobalTrackRefits_ && inputType == ICTypes::TEV_DYT) {
247  throw cms::Exception("FatalError") << "Failed to get input muon collection with label: " << inputLabel;
248  LogTrace("MuonIdentification") << "Number of input muons: " << dytCollectionHandle_->size();
249  } else
250  throw cms::Exception("FatalError") << "Unknown input collection type: #" << ICTypes::toStr(inputType);
251  }
252 
256 }
257 
259  const edm::EventSetup& iSetup,
260  const reco::TrackRef& track,
262  LogTrace("MuonIdentification") << "Creating a muon from a track " << track.get()->pt()
263  << " Pt (GeV), eta: " << track.get()->eta();
264  reco::Muon aMuon(makeMuon(*(track.get())));
265 
266  LogTrace("MuonIdentification") << "Muon created from a track ";
267 
268  aMuon.setMuonTrack(type, track);
269  aMuon.setBestTrack(type);
270  aMuon.setTunePBestTrack(type);
271 
272  LogTrace("MuonIdentification")
273  << "Muon created from a track and setMuonBestTrack, setBestTrack and setTunePBestTrack called";
274 
275  return aMuon;
276 }
277 
279  LogTrace("MuonIdentification") << "Creating a CaloMuon from a Muon";
280 
281  reco::CaloMuon aMuon;
282  aMuon.setInnerTrack(muon.innerTrack());
283 
284  if (muon.isEnergyValid())
285  aMuon.setCalEnergy(muon.calEnergy());
286  // get calo compatibility
289  return aMuon;
290 }
291 
293  LogTrace("MuonIdentification") << "Creating a muon from a link to tracks object";
294 
295  reco::Muon aMuon;
296  reco::Muon::MuonTrackTypePair chosenTrack;
297  reco::TrackRef tpfmsRef;
298  reco::TrackRef pickyRef;
299  reco::TrackRef dytRef;
300  bool useSigmaSwitch = false;
301 
307 
308  if (tpfmsRef.isNull() && pickyRef.isNull() && dytRef.isNull()) {
309  edm::LogWarning("MakeMuonWithTEV") << "Failed to get TEV refits, fall back to sigma switch.";
310  useSigmaSwitch = true;
311  }
312  } else {
313  useSigmaSwitch = true;
314  }
315 
316  if (useSigmaSwitch) {
317  chosenTrack = muon::sigmaSwitch(links.globalTrack(),
318  links.trackerTrack(),
321  } else {
322  chosenTrack = muon::tevOptimized(links.globalTrack(),
323  links.trackerTrack(),
324  tpfmsRef,
325  pickyRef,
326  dytRef,
328  }
329  aMuon = makeMuon(*chosenTrack.first);
330  aMuon.setInnerTrack(links.trackerTrack());
331  aMuon.setOuterTrack(links.standAloneTrack());
332  aMuon.setGlobalTrack(links.globalTrack());
333  aMuon.setBestTrack(chosenTrack.second);
334  aMuon.setTunePBestTrack(chosenTrack.second);
335 
339  if (it != tpfmsCollectionHandle_->end())
340  aMuon.setMuonTrack(reco::Muon::TPFMS, (it->val));
341  }
344  if (it != pickyCollectionHandle_->end())
345  aMuon.setMuonTrack(reco::Muon::Picky, (it->val));
346  }
349  if (it != dytCollectionHandle_->end())
350  aMuon.setMuonTrack(reco::Muon::DYT, (it->val));
351  }
352  }
353  return aMuon;
354 }
355 
357  // Pt and absolute momentum requirement
358  const double p = track.p();
359  const double pt = track.pt();
360  if (pt < minPt_ || (p < minP_ && p < minPCaloMuon_)) {
361  LogTrace("MuonIdentification") << "Skipped low momentum track (Pt,P): " << pt << ", " << track.p() << " GeV";
362  return false;
363  }
364 
365  // Eta requirement
366  const double eta = track.eta();
367  const double absEta = std::abs(eta);
368  if (absEta > maxAbsEta_) {
369  LogTrace("MuonIdentification") << "Skipped track with large pseudo rapidity (Eta: " << track.eta() << " )";
370  return false;
371  }
372 
373  return true;
374 }
375 
376 unsigned int MuonIdProducer::chamberId(const DetId& id) {
377  if (id.det() != DetId::Muon)
378  return 0;
379 
380  const auto subdetId = id.subdetId();
381  if (subdetId == MuonSubdetId::DT) {
382  return DTChamberId(id.rawId()).rawId();
383  } else if (subdetId == MuonSubdetId::CSC) {
384  return CSCDetId(id.rawId()).chamberId().rawId();
385  }
386 
387  return 0;
388 }
389 
391  if (!muon.isMatchesValid() || track.extra().isNull() || track.extra()->recHitsSize() == 0)
392  return 0;
393 
394  int numberOfCommonDetIds = 0;
395  const std::vector<reco::MuonChamberMatch>& matches(muon.matches());
396  for (const auto& match : matches) {
397  if (match.segmentMatches.empty())
398  continue;
399 
400  bool foundCommonDetId = false;
401  for (auto hit = track.extra()->recHitsBegin(); hit != track.extra()->recHitsEnd(); ++hit) {
402  // LogTrace("MuonIdentification") << "hit DetId: " << std::hex << hit->get()->geographicalId().rawId() <<
403  // "\t hit chamber DetId: " << getChamberId(hit->get()->geographicalId()) <<
404  // "\t segment DetId: " << match->id.rawId() << std::dec;
405 
406  if (chamberId((*hit)->geographicalId()) == match.id.rawId()) {
407  foundCommonDetId = true;
408  break;
409  }
410  }
411  if (foundCommonDetId) {
412  ++numberOfCommonDetIds;
413  break;
414  }
415  }
416  return numberOfCommonDetIds;
417 }
418 
419 void MuonIdProducer::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
420  meshAlgo_->setCSCGeometry(&iSetup.getData(geomTokenRun_));
421 
423  theShowerDigiFiller_->getES(iSetup);
424 }
425 
426 bool validateGlobalMuonPair(const reco::MuonTrackLinks& goodMuon, const reco::MuonTrackLinks& badMuon) {
427  const int nHitsGood = goodMuon.globalTrack()->hitPattern().numberOfValidMuonHits();
428  const int nHitsBad = badMuon.globalTrack()->hitPattern().numberOfValidMuonHits();
429  if (std::min(nHitsGood, nHitsBad) > 10) {
430  const double chi2Good = goodMuon.globalTrack()->normalizedChi2();
431  const double chi2Bad = badMuon.globalTrack()->normalizedChi2();
432  return (chi2Good <= chi2Bad);
433  }
434 
435  return (nHitsGood >= nHitsBad);
436 }
437 
439  auto outputMuons = std::make_unique<reco::MuonCollection>();
440  auto caloMuons = std::make_unique<reco::CaloMuonCollection>();
441 
442  init(iEvent, iSetup);
443 
445  theShowerDigiFiller_->getDigis(iEvent);
446 
447  // loop over input collections
448 
449  // muons first - no cleaning, take as is.
451  for (const auto& muon : *muonCollectionHandle_) {
452  outputMuons->push_back(muon);
453  }
454  }
455 
456  // links second ( assume global muon type )
458  const auto nLink = linkCollectionHandle_->size();
459  std::vector<bool> goodmuons(nLink, true);
460  if (nLink > 1) {
461  // check for shared tracker tracks
462  for (unsigned int i = 0; i < nLink - 1; ++i) {
463  const auto& iLink = linkCollectionHandle_->at(i);
464  if (iLink.trackerTrack().isNull() || !checkLinks(&iLink))
465  continue;
466  for (unsigned int j = i + 1; j < nLink; ++j) {
467  const auto& jLink = linkCollectionHandle_->at(j);
468  if (!checkLinks(&jLink))
469  continue;
470  if (iLink.trackerTrack() == jLink.trackerTrack()) {
471  // Tracker track is the essential part that dominates muon resolution
472  // so taking either muon is fine. All that is important is to preserve
473  // the muon identification information. If number of hits is small,
474  // keep the one with large number of hits, otherwise take the smalest chi2/ndof
475  if (validateGlobalMuonPair(iLink, jLink))
476  goodmuons[j] = false;
477  else
478  goodmuons[i] = false;
479  }
480  }
481  }
482  // check for shared stand-alone muons.
483  for (unsigned int i = 0; i < nLink - 1; ++i) {
484  if (!goodmuons[i])
485  continue;
486  const auto& iLink = linkCollectionHandle_->at(i);
487  if (iLink.standAloneTrack().isNull() || !checkLinks(&iLink))
488  continue;
489  for (unsigned int j = i + 1; j < nLink; ++j) {
490  if (!goodmuons[j])
491  continue;
492  const auto& jLink = linkCollectionHandle_->at(j);
493  if (!checkLinks(&jLink))
494  continue;
495  if (iLink.standAloneTrack() == jLink.standAloneTrack()) {
496  if (validateGlobalMuonPair(iLink, jLink))
497  goodmuons[j] = false;
498  else
499  goodmuons[i] = false;
500  }
501  }
502  }
503  }
504  for (unsigned int i = 0; i < nLink; ++i) {
505  if (!goodmuons[i])
506  continue;
507  const auto& iLink = linkCollectionHandle_->at(i);
508  if (!checkLinks(&iLink))
509  continue;
510  // check if this muon is already in the list
511  bool newMuon = true;
512  for (const auto& muon : *outputMuons) {
513  if (muon.track() == iLink.trackerTrack() && muon.standAloneMuon() == iLink.standAloneTrack() &&
514  muon.combinedMuon() == iLink.globalTrack()) {
515  newMuon = false;
516  break;
517  }
518  }
519  if (newMuon) {
520  outputMuons->push_back(makeMuon(iLink));
521  outputMuons->back().setType(reco::Muon::GlobalMuon | reco::Muon::StandAloneMuon);
522  }
523  }
524  }
525 
526  // tracker and calo muons are next
528  LogTrace("MuonIdentification") << "Creating tracker muons";
529  std::vector<TrackDetectorAssociator::Direction> directions1, directions2;
530  directions1.push_back(TrackDetectorAssociator::InsideOut);
531  directions1.push_back(TrackDetectorAssociator::OutsideIn);
532  directions2.push_back(TrackDetectorAssociator::Any);
533 
534  const GlobalTrackingGeometry* geometry = nullptr;
536  geometry = &iSetup.getData(globalGeomToken_);
537  }
538 
539  for (unsigned int i = 0; i < innerTrackCollectionHandle_->size(); ++i) {
541  if (!isGoodTrack(track))
542  continue;
543  const auto& trackRef = reco::TrackRef(innerTrackCollectionHandle_, i);
544  bool splitTrack = false;
545  if (track.extra().isAvailable() && TrackDetectorAssociator::crossedIP(track))
546  splitTrack = true;
547  const auto& directions = splitTrack ? directions1 : directions2;
548  for (const auto direction : directions) {
549  // make muon
550  reco::Muon trackerMuon(makeMuon(iEvent, iSetup, trackRef, reco::Muon::InnerTrack));
551  fillMuonId(iEvent, iSetup, trackerMuon, direction);
552 
554  // add MC hits to a list of matched segments.
555  // Since it's debugging mode - code is slow
556  MuonIdTruthInfo::truthMatchMuon(iEvent, *geometry, trackerMuon);
557  }
558 
559  // check if this muon is already in the list
560  // have to check where muon hits are really located
561  // to match properly
562  bool newMuon = true;
563  const bool goodTrackerMuon = isGoodTrackerMuon(trackerMuon);
564  const bool goodRPCMuon = isGoodRPCMuon(trackerMuon);
565  const bool goodGEMMuon = isGoodGEMMuon(trackerMuon);
566  const bool goodME0Muon = isGoodME0Muon(trackerMuon);
567  if (goodTrackerMuon)
568  trackerMuon.setType(trackerMuon.type() | reco::Muon::TrackerMuon);
569  if (goodRPCMuon)
570  trackerMuon.setType(trackerMuon.type() | reco::Muon::RPCMuon);
571  if (goodGEMMuon)
572  trackerMuon.setType(trackerMuon.type() | reco::Muon::GEMMuon);
573  if (goodME0Muon)
574  trackerMuon.setType(trackerMuon.type() | reco::Muon::ME0Muon);
575 
576  for (auto& muon : *outputMuons) {
577  if (muon.innerTrack().get() == trackerMuon.innerTrack().get() &&
579  M_PI_2) {
580  newMuon = false;
581  muon.setMatches(trackerMuon.matches());
582  if (trackerMuon.isTimeValid())
583  muon.setTime(trackerMuon.time());
584  if (trackerMuon.isEnergyValid())
585  muon.setCalEnergy(trackerMuon.calEnergy());
586  if (goodTrackerMuon)
587  muon.setType(muon.type() | reco::Muon::TrackerMuon);
588  if (goodRPCMuon)
589  muon.setType(muon.type() | reco::Muon::RPCMuon);
590  if (goodGEMMuon)
591  muon.setType(muon.type() | reco::Muon::GEMMuon);
592  if (goodME0Muon)
593  muon.setType(muon.type() | reco::Muon::ME0Muon);
594  LogTrace("MuonIdentification") << "Found a corresponding global muon. Set energy, matches and move on";
595  break;
596  }
597  }
598  if (newMuon) {
599  if (goodTrackerMuon || goodRPCMuon || goodGEMMuon || goodME0Muon) {
600  outputMuons->push_back(trackerMuon);
601  } else {
602  LogTrace("MuonIdentification") << "track failed minimal number of muon matches requirement";
603  const reco::CaloMuon& caloMuon = makeCaloMuon(trackerMuon);
604  if (isGoodCaloMuon(caloMuon))
605  caloMuons->push_back(caloMuon);
606  }
607  }
608  }
609  }
610  }
611 
612  // and at last the stand alone muons
614  LogTrace("MuonIdentification") << "Looking for new muons among stand alone muon tracks";
615  for (unsigned int i = 0; i < outerTrackCollectionHandle_->size(); ++i) {
616  const auto& outerTrack = outerTrackCollectionHandle_->at(i);
617 
618  // check if this muon is already in the list of global muons
619  bool newMuon = true;
620  for (auto& muon : *outputMuons) {
621  if (!muon.standAloneMuon().isNull()) {
622  // global muon
623  if (muon.standAloneMuon().get() == &outerTrack) {
624  newMuon = false;
625  break;
626  }
627  } else {
628  // tracker muon - no direct links to the standalone muon
629  // since we have only a few real muons in an event, matching
630  // the stand alone muon to the tracker muon by DetIds should
631  // be good enough for association. At the end it's up to a
632  // user to redefine the association and what it means. Here
633  // we would like to avoid obvious double counting and we
634  // tolerate a potential miss association
635  if (overlap(muon, outerTrack) > 0) {
636  LogTrace("MuonIdentification") << "Found associated tracker muon. Set a reference and move on";
637  newMuon = false;
639  muon.setType(muon.type() | reco::Muon::StandAloneMuon);
640  break;
641  }
642  }
643  }
644  if (newMuon) {
645  LogTrace("MuonIdentification") << "No associated stand alone track is found. Making a muon";
646  outputMuons->push_back(
648  outputMuons->back().setType(reco::Muon::StandAloneMuon);
649  }
650  }
651  }
652 
654  fillArbitrationInfo(outputMuons.get());
655  arbitrateMuons(outputMuons.get(), caloMuons.get());
656  }
657 
658  LogTrace("MuonIdentification") << "Dress up muons if it's necessary";
659 
660  const int nMuons = outputMuons->size();
661 
662  std::vector<reco::MuonTimeExtra> dtTimeColl(nMuons);
663  std::vector<reco::MuonTimeExtra> cscTimeColl(nMuons);
664  std::vector<reco::MuonTimeExtra> combinedTimeColl(nMuons);
665  std::vector<reco::IsoDeposit> trackDepColl(nMuons);
666  std::vector<reco::IsoDeposit> ecalDepColl(nMuons);
667  std::vector<reco::IsoDeposit> hcalDepColl(nMuons);
668  std::vector<reco::IsoDeposit> hoDepColl(nMuons);
669  std::vector<reco::IsoDeposit> jetDepColl(nMuons);
670 
671  // Fill various information
672  for (unsigned int i = 0; i < outputMuons->size(); ++i) {
673  auto& muon = outputMuons->at(i);
674 
675  // Fill muonID
676  if ((fillMatching_ && !muon.isMatchesValid()) || (fillEnergy_ && !muon.isEnergyValid())) {
677  // predict direction based on the muon interaction region location
678  // if it's available
679  if (muon.isStandAloneMuon()) {
682  } else {
684  }
685  } else {
686  LogTrace("MuonIdentification") << "THIS SHOULD NEVER HAPPEN";
687  fillMuonId(iEvent, iSetup, muon);
688  }
689  }
690 
692  // Fill global quality information
693  fillGlbQuality(iEvent, iSetup, muon);
694  }
695  LogDebug("MuonIdentification") << "";
696 
697  if (fillTrackerKink_) {
699  }
700 
702  muon.setCaloCompatibility(muonCaloCompatibility_.evaluate(muon));
703 
704  if (fillIsolation_) {
706  iEvent, iSetup, muon, trackDepColl[i], ecalDepColl[i], hcalDepColl[i], hoDepColl[i], jetDepColl[i]);
707  }
708 
709  // fill timing information
710  reco::MuonTime muonTime;
711  reco::MuonTimeExtra dtTime;
712  reco::MuonTimeExtra cscTime;
713  reco::MuonTime rpcTime;
714  reco::MuonTimeExtra combinedTime;
715 
716  theTimingFiller_->fillTiming(muon, dtTime, cscTime, rpcTime, combinedTime, iEvent, iSetup);
717 
718  muonTime.nDof = combinedTime.nDof();
719  muonTime.timeAtIpInOut = combinedTime.timeAtIpInOut();
720  muonTime.timeAtIpInOutErr = combinedTime.timeAtIpInOutErr();
721  muonTime.timeAtIpOutIn = combinedTime.timeAtIpOutIn();
722  muonTime.timeAtIpOutInErr = combinedTime.timeAtIpOutInErr();
723 
724  muon.setTime(muonTime);
725  muon.setRPCTime(rpcTime);
726  dtTimeColl[i] = dtTime;
727  cscTimeColl[i] = cscTime;
728  combinedTimeColl[i] = combinedTime;
729  }
730 
731  LogTrace("MuonIdentification") << "number of muons produced: " << outputMuons->size();
732  if (fillMatching_) {
733  fillArbitrationInfo(outputMuons.get(), reco::Muon::TrackerMuon);
734  fillArbitrationInfo(outputMuons.get(), reco::Muon::ME0Muon);
735  fillArbitrationInfo(outputMuons.get(), reco::Muon::GEMMuon);
736  }
737  edm::OrphanHandle<reco::MuonCollection> muonHandle = iEvent.put(std::move(outputMuons));
738 
739  auto fillMap = [](auto refH, auto& vec, edm::Event& ev, const std::string& cAl = "") {
741  auto oMap = std::make_unique<MapType>();
742  {
743  typename MapType::Filler filler(*oMap);
744  filler.insert(refH, vec.begin(), vec.end());
745  vec.clear();
746  filler.fill();
747  }
748  ev.put(std::move(oMap), cAl);
749  };
750  fillMap(muonHandle, combinedTimeColl, iEvent, "combined");
751  fillMap(muonHandle, dtTimeColl, iEvent, "dt");
752  fillMap(muonHandle, cscTimeColl, iEvent, "csc");
753 
755  fillMap(muonHandle, trackDepColl, iEvent, trackDepositName_);
756  fillMap(muonHandle, ecalDepColl, iEvent, ecalDepositName_);
757  fillMap(muonHandle, hcalDepColl, iEvent, hcalDepositName_);
758  fillMap(muonHandle, hoDepColl, iEvent, hoDepositName_);
759  fillMap(muonHandle, jetDepColl, iEvent, jetDepositName_);
760  }
761 
762  iEvent.put(std::move(caloMuons));
763 }
764 
766  if (muon.track()->pt() < minPt_ || muon.track()->p() < minP_)
767  return false;
768  if (addExtraSoftMuons_ && muon.pt() < 5 && std::abs(muon.eta()) < 1.5 &&
770  return true;
772 }
773 
775  if (!caloMuon.isCaloCompatibilityValid() || caloMuon.caloCompatibility() < caloCut_ || caloMuon.p() < minPCaloMuon_)
776  return false;
777  return true;
778 }
779 
781  if (muon.track()->pt() < minPt_ || muon.track()->p() < minP_)
782  return false;
783  if (addExtraSoftMuons_ && muon.pt() < 5 && std::abs(muon.eta()) < 1.5 &&
785  return true;
787 }
788 
790  if (muon.track()->pt() < minPt_ || muon.track()->p() < minP_)
791  return false;
793 }
794 
796  // need to update min cuts on pt
797  if (muon.track()->p() < minP_)
798  return false;
800 }
801 
803  const edm::EventSetup& iSetup,
804  reco::Muon& aMuon,
806  LogTrace("MuonIdentification") << "RecoMuon/MuonIdProducer :: fillMuonId";
807 
808  // perform track - detector association
809  const reco::Track* track = nullptr;
810  if (aMuon.track().isNonnull())
811  track = aMuon.track().get();
812  else if (aMuon.standAloneMuon().isNonnull())
813  track = aMuon.standAloneMuon().get();
814  else
815  throw cms::Exception("FatalError")
816  << "Failed to fill muon id information for a muon with undefined references to tracks";
817 
818  TrackDetMatchInfo info = trackAssociator_.associate(iEvent, iSetup, *track, parameters_, direction);
819 
820  LogTrace("MuonIdentification") << "RecoMuon/MuonIdProducer :: fillMuonId :: fillEnergy = " << fillEnergy_;
821 
822  if (fillEnergy_) {
823  reco::MuonEnergy muonEnergy;
826  muonEnergy.ho = info.crossedEnergy(TrackDetMatchInfo::HORecHits);
828  muonEnergy.emS9 = info.nXnEnergy(TrackDetMatchInfo::EcalRecHits, 1); // 3x3 energy
829  muonEnergy.emS25 = info.nXnEnergy(TrackDetMatchInfo::EcalRecHits, 2); // 5x5 energy
830  muonEnergy.hadS9 = info.nXnEnergy(TrackDetMatchInfo::HcalRecHits, 1); // 3x3 energy
831  muonEnergy.hoS9 = info.nXnEnergy(TrackDetMatchInfo::HORecHits, 1); // 3x3 energy
832  muonEnergy.towerS9 = info.nXnEnergy(TrackDetMatchInfo::TowerTotal, 1); // 3x3 energy
834  muonEnergy.crossedHadRecHits.clear();
835  for (auto hit : info.crossedHcalRecHits) {
837  mhit.energy = hit->energy();
838  mhit.chi2 = hit->chi2();
839  mhit.time = hit->time();
840  mhit.detId = hit->id();
841  muonEnergy.crossedHadRecHits.push_back(mhit);
842  }
843  }
844  muonEnergy.ecal_position = info.trkGlobPosAtEcal;
845  muonEnergy.hcal_position = info.trkGlobPosAtHcal;
846  if (!info.crossedEcalIds.empty())
847  muonEnergy.ecal_id = info.crossedEcalIds.front();
848  if (!info.crossedHcalIds.empty())
849  muonEnergy.hcal_id = info.crossedHcalIds.front();
850  // find maximal energy depositions and their time
851  DetId emMaxId = info.findMaxDeposition(TrackDetMatchInfo::EcalRecHits, 2); // max energy deposit in 5x5 shape
852  for (const auto& hit : info.ecalRecHits) {
853  if (hit->id() != emMaxId)
854  continue;
855  muonEnergy.emMax = hit->energy();
856  muonEnergy.ecal_time = hit->time();
857  }
858  DetId hadMaxId = info.findMaxDeposition(TrackDetMatchInfo::HcalRecHits, 1); // max energy deposit in 3x3 shape
859  for (const auto& hit : info.hcalRecHits) {
860  if (hit->id() != hadMaxId)
861  continue;
862  muonEnergy.hadMax = hit->energy();
863  muonEnergy.hcal_time = hit->time();
864  }
865  aMuon.setCalEnergy(muonEnergy);
866  }
867  if (!fillMatching_ && !aMuon.isTrackerMuon() && !aMuon.isRPCMuon())
868  return;
869 
870  // fill muon match info
871  LogTrace("MuonIdentification") << "RecoMuon/MuonIdProducer :: fillMuonId :: fill muon match info ";
872  std::vector<reco::MuonChamberMatch> muonChamberMatches;
873  unsigned int nubmerOfMatchesAccordingToTrackAssociator = 0;
874  for (const auto& chamber : info.chambers) {
875  if (chamber.id.subdetId() == MuonSubdetId::RPC && rpcHitHandle_.isValid())
876  continue; // Skip RPC chambers, they are taken care of below)
877  reco::MuonChamberMatch matchedChamber;
878 
879  const auto& lErr = chamber.tState.localError();
880  const auto& lPos = chamber.tState.localPosition();
881  const auto& lDir = chamber.tState.localDirection();
882 
883  const auto& localError = lErr.positionError();
884  matchedChamber.x = lPos.x();
885  matchedChamber.y = lPos.y();
886  matchedChamber.xErr = sqrt(localError.xx());
887  matchedChamber.yErr = sqrt(localError.yy());
888 
889  matchedChamber.dXdZ = lDir.z() != 0 ? lDir.x() / lDir.z() : 9999;
890  matchedChamber.dYdZ = lDir.z() != 0 ? lDir.y() / lDir.z() : 9999;
891  // DANGEROUS - compiler cannot guaranty parameters ordering
892  AlgebraicSymMatrix55 trajectoryCovMatrix = lErr.matrix();
893  matchedChamber.dXdZErr = trajectoryCovMatrix(1, 1) > 0 ? sqrt(trajectoryCovMatrix(1, 1)) : 0;
894  matchedChamber.dYdZErr = trajectoryCovMatrix(2, 2) > 0 ? sqrt(trajectoryCovMatrix(2, 2)) : 0;
895 
896  matchedChamber.edgeX = chamber.localDistanceX;
897  matchedChamber.edgeY = chamber.localDistanceY;
898 
899  matchedChamber.id = chamber.id;
900 
902  theShowerDigiFiller_->fill(matchedChamber);
903  } else {
904  theShowerDigiFiller_->fillDefault(matchedChamber);
905  }
906 
907  if (!chamber.segments.empty())
908  ++nubmerOfMatchesAccordingToTrackAssociator;
909 
910  // fill segments
911  for (const auto& segment : chamber.segments) {
912  reco::MuonSegmentMatch matchedSegment;
913  matchedSegment.x = segment.segmentLocalPosition.x();
914  matchedSegment.y = segment.segmentLocalPosition.y();
915  matchedSegment.dXdZ =
916  segment.segmentLocalDirection.z() ? segment.segmentLocalDirection.x() / segment.segmentLocalDirection.z() : 0;
917  matchedSegment.dYdZ =
918  segment.segmentLocalDirection.z() ? segment.segmentLocalDirection.y() / segment.segmentLocalDirection.z() : 0;
919  matchedSegment.xErr = segment.segmentLocalErrorXX > 0 ? sqrt(segment.segmentLocalErrorXX) : 0;
920  matchedSegment.yErr = segment.segmentLocalErrorYY > 0 ? sqrt(segment.segmentLocalErrorYY) : 0;
921  matchedSegment.dXdZErr = segment.segmentLocalErrorDxDz > 0 ? sqrt(segment.segmentLocalErrorDxDz) : 0;
922  matchedSegment.dYdZErr = segment.segmentLocalErrorDyDz > 0 ? sqrt(segment.segmentLocalErrorDyDz) : 0;
923  matchedSegment.t0 = segment.t0;
924  matchedSegment.mask = 0;
925  matchedSegment.dtSegmentRef = segment.dtSegmentRef;
926  matchedSegment.cscSegmentRef = segment.cscSegmentRef;
927  matchedSegment.gemSegmentRef = segment.gemSegmentRef;
928  matchedSegment.me0SegmentRef = segment.me0SegmentRef;
929  matchedSegment.hasZed_ = segment.hasZed;
930  matchedSegment.hasPhi_ = segment.hasPhi;
931  // test segment
932  bool matchedX = false;
933  bool matchedY = false;
934  LogTrace("MuonIdentification") << " matching local x, segment x: " << matchedSegment.x
935  << ", chamber x: " << matchedChamber.x << ", max: " << maxAbsDx_;
936  LogTrace("MuonIdentification") << " matching local y, segment y: " << matchedSegment.y
937  << ", chamber y: " << matchedChamber.y << ", max: " << maxAbsDy_;
938  const double matchedSegChDx = std::abs(matchedSegment.x - matchedChamber.x);
939  const double matchedSegChDy = std::abs(matchedSegment.y - matchedChamber.y);
940  if (matchedSegment.xErr > 0 && matchedChamber.xErr > 0)
941  LogTrace("MuonIdentification") << " xpull: "
942  << matchedSegChDx / std::sqrt(std::pow(matchedSegment.xErr, 2) +
943  std::pow(matchedChamber.xErr, 2));
944  if (matchedSegment.yErr > 0 && matchedChamber.yErr > 0)
945  LogTrace("MuonIdentification") << " ypull: "
946  << matchedSegChDy / std::sqrt(std::pow(matchedSegment.yErr, 2) +
947  std::pow(matchedChamber.yErr, 2));
948 
949  if (matchedSegChDx < maxAbsDx_)
950  matchedX = true;
951  else if (matchedSegment.xErr > 0 && matchedChamber.xErr > 0) {
952  const double invMatchedSegChPullX2 = std::pow(matchedSegment.xErr, 2) + std::pow(matchedChamber.xErr, 2);
953  if (matchedSegChDx * matchedSegChDx < maxAbsPullX2_ * invMatchedSegChPullX2)
954  matchedX = true;
955  }
956  if (matchedSegChDy < maxAbsDy_)
957  matchedY = true;
958  else if (matchedSegment.yErr > 0 && matchedChamber.yErr > 0) {
959  const double invMatchedSegChPullY2 = std::pow(matchedSegment.yErr, 2) + std::pow(matchedChamber.yErr, 2);
960  if (matchedSegChDy * matchedSegChDy < maxAbsPullY2_ * invMatchedSegChPullY2)
961  matchedY = true;
962  }
963  if (matchedX && matchedY) {
964  if (matchedChamber.id.subdetId() == MuonSubdetId::ME0)
965  matchedChamber.me0Matches.push_back(matchedSegment);
966  else if (matchedChamber.id.subdetId() == MuonSubdetId::GEM)
967  matchedChamber.gemMatches.push_back(matchedSegment);
968  else
969  matchedChamber.segmentMatches.push_back(matchedSegment);
970  }
971  }
972  muonChamberMatches.push_back(matchedChamber);
973  }
974 
975  // Fill RPC info
976  LogTrace("MuonIdentification") << "RecoMuon/MuonIdProducer :: fillMuonId :: fill RPC info";
977  if (rpcHitHandle_.isValid()) {
978  for (const auto& chamber : info.chambers) {
979  if (chamber.id.subdetId() != MuonSubdetId::RPC)
980  continue; // Consider RPC chambers only
981  const auto& lErr = chamber.tState.localError();
982  const auto& lPos = chamber.tState.localPosition();
983  const auto& lDir = chamber.tState.localDirection();
984 
985  reco::MuonChamberMatch matchedChamber;
986 
987  LocalError localError = lErr.positionError();
988  matchedChamber.x = lPos.x();
989  matchedChamber.y = lPos.y();
990  matchedChamber.xErr = sqrt(localError.xx());
991  matchedChamber.yErr = sqrt(localError.yy());
992 
993  matchedChamber.dXdZ = lDir.z() != 0 ? lDir.x() / lDir.z() : 9999;
994  matchedChamber.dYdZ = lDir.z() != 0 ? lDir.y() / lDir.z() : 9999;
995  // DANGEROUS - compiler cannot guaranty parameters ordering
996  AlgebraicSymMatrix55 trajectoryCovMatrix = lErr.matrix();
997  matchedChamber.dXdZErr = trajectoryCovMatrix(1, 1) > 0 ? sqrt(trajectoryCovMatrix(1, 1)) : 0;
998  matchedChamber.dYdZErr = trajectoryCovMatrix(2, 2) > 0 ? sqrt(trajectoryCovMatrix(2, 2)) : 0;
999 
1000  matchedChamber.edgeX = chamber.localDistanceX;
1001  matchedChamber.edgeY = chamber.localDistanceY;
1002 
1003  theShowerDigiFiller_->fillDefault(matchedChamber);
1004 
1005  matchedChamber.id = chamber.id;
1006 
1007  for (const auto& rpcRecHit : *rpcHitHandle_) {
1008  reco::MuonRPCHitMatch rpcHitMatch;
1009 
1010  if (rpcRecHit.rawId() != chamber.id.rawId())
1011  continue;
1012 
1013  rpcHitMatch.x = rpcRecHit.localPosition().x();
1014  rpcHitMatch.mask = 0;
1015  rpcHitMatch.bx = rpcRecHit.BunchX();
1016 
1017  const double absDx = std::abs(rpcRecHit.localPosition().x() - chamber.tState.localPosition().x());
1018  if (absDx <= 20 or absDx * absDx <= 16 * localError.xx())
1019  matchedChamber.rpcMatches.push_back(rpcHitMatch);
1020  }
1021 
1022  muonChamberMatches.push_back(matchedChamber);
1023  }
1024  }
1025 
1026  aMuon.setMatches(muonChamberMatches);
1027 
1028  LogTrace("MuonIdentification") << "number of muon chambers: " << aMuon.matches().size() << "\n"
1029  << "number of chambers with segments according to the associator requirements: "
1030  << nubmerOfMatchesAccordingToTrackAssociator;
1031  LogTrace("MuonIdentification") << "number of segment matches with the producer requirements: "
1033 
1034  // fillTime( iEvent, iSetup, aMuon );
1035 }
1036 
1039  // arbitrate TrackerMuons
1040  // if a muon was exclusively TrackerMuon check if it can be a calo muon
1041  for (reco::MuonCollection::iterator muon = muons->begin(); muon != muons->end();) {
1042  if (muon->isTrackerMuon()) {
1043  if (muon->numberOfMatches(arbitration) < minNumberOfMatches_) {
1044  // TrackerMuon failed arbitration
1045  // If not any other base type - erase the element
1046  // (PFMuon is not a base type)
1047  unsigned int mask = reco::Muon::TrackerMuon | reco::Muon::PFMuon;
1048  if ((muon->type() & (~mask)) == 0) {
1049  const reco::CaloMuon& caloMuon = makeCaloMuon(*muon);
1050  if (isGoodCaloMuon(caloMuon))
1051  caloMuons->push_back(caloMuon);
1052  muon = muons->erase(muon);
1053  continue;
1054  } else {
1055  muon->setType(muon->type() & (~reco::Muon::TrackerMuon));
1056  }
1057  }
1058  }
1059  muon++;
1060  }
1061 }
1062 
1063 void MuonIdProducer::fillArbitrationInfo(reco::MuonCollection* pOutputMuons, unsigned int muonType) {
1064  //
1065  // apply segment flags
1066  //
1067  std::vector<std::pair<reco::MuonChamberMatch*, reco::MuonSegmentMatch*> > chamberPairs; // for chamber segment sorting
1068  std::vector<std::pair<reco::MuonChamberMatch*, reco::MuonSegmentMatch*> > stationPairs; // for station segment sorting
1069  std::vector<std::pair<reco::MuonChamberMatch*, reco::MuonSegmentMatch*> >
1070  arbitrationPairs; // for muon segment arbitration
1071 
1072  // muonIndex1
1073  for (unsigned int muonIndex1 = 0; muonIndex1 < pOutputMuons->size(); ++muonIndex1) {
1074  auto& muon1 = pOutputMuons->at(muonIndex1);
1075  // chamberIter1
1076  for (auto& chamber1 : muon1.matches()) {
1077  // segmentIter1
1078  std::vector<reco::MuonSegmentMatch>* segmentMatches1 = getSegmentMatches(chamber1, muonType);
1079 
1080  if (segmentMatches1->empty())
1081  continue;
1082  chamberPairs.clear();
1083 
1084  for (auto& segment1 : *segmentMatches1) {
1085  chamberPairs.push_back(std::make_pair(&chamber1, &segment1));
1086  if (!segment1.isMask()) // has not yet been arbitrated
1087  {
1088  arbitrationPairs.clear();
1089  arbitrationPairs.push_back(std::make_pair(&chamber1, &segment1));
1090 
1091  // find identical segments with which to arbitrate
1092  // tracker muons only
1093  if (muon1.type() & muonType) {
1094  // muonIndex2
1095  for (unsigned int muonIndex2 = muonIndex1 + 1; muonIndex2 < pOutputMuons->size(); ++muonIndex2) {
1096  auto& muon2 = pOutputMuons->at(muonIndex2);
1097  // tracker muons only
1098  if (!(muon2.type() & muonType))
1099  continue;
1100  // chamberIter2
1101  for (auto& chamber2 : muon2.matches()) {
1102  // segmentIter2
1103  std::vector<reco::MuonSegmentMatch>* segmentMatches2 = getSegmentMatches(chamber2, muonType);
1104  for (auto& segment2 : *segmentMatches2) {
1105  if (segment2.isMask())
1106  continue; // has already been arbitrated
1107  if (approxEqual(segment2.x, segment1.x) && approxEqual(segment2.y, segment1.y) &&
1108  approxEqual(segment2.dXdZ, segment1.dXdZ) && approxEqual(segment2.dYdZ, segment1.dYdZ) &&
1109  approxEqual(segment2.xErr, segment1.xErr) && approxEqual(segment2.yErr, segment1.yErr) &&
1110  approxEqual(segment2.dXdZErr, segment1.dXdZErr) &&
1111  approxEqual(segment2.dYdZErr, segment1.dYdZErr)) {
1112  arbitrationPairs.push_back(std::make_pair(&chamber2, &segment2));
1113  }
1114  } // segmentIter2
1115  } // chamberIter2
1116  } // muonIndex2
1117  }
1118 
1119  // arbitration segment sort
1120  if (arbitrationPairs.empty())
1121  continue; // this should never happen
1122  if (arbitrationPairs.size() == 1) {
1123  arbitrationPairs.front().second->setMask(reco::MuonSegmentMatch::BelongsToTrackByDRSlope);
1124  arbitrationPairs.front().second->setMask(reco::MuonSegmentMatch::BelongsToTrackByDXSlope);
1125  arbitrationPairs.front().second->setMask(reco::MuonSegmentMatch::BelongsToTrackByDR);
1126  arbitrationPairs.front().second->setMask(reco::MuonSegmentMatch::BelongsToTrackByDX);
1127  arbitrationPairs.front().second->setMask(reco::MuonSegmentMatch::Arbitrated);
1128  } else {
1129  sort(arbitrationPairs.begin(),
1130  arbitrationPairs.end(),
1132  arbitrationPairs.front().second->setMask(reco::MuonSegmentMatch::BelongsToTrackByDRSlope);
1133  sort(arbitrationPairs.begin(),
1134  arbitrationPairs.end(),
1136  arbitrationPairs.front().second->setMask(reco::MuonSegmentMatch::BelongsToTrackByDXSlope);
1137  sort(arbitrationPairs.begin(),
1138  arbitrationPairs.end(),
1140  arbitrationPairs.front().second->setMask(reco::MuonSegmentMatch::BelongsToTrackByDR);
1141  sort(arbitrationPairs.begin(),
1142  arbitrationPairs.end(),
1144  arbitrationPairs.front().second->setMask(reco::MuonSegmentMatch::BelongsToTrackByDX);
1145  for (auto& ap : arbitrationPairs) {
1146  ap.second->setMask(reco::MuonSegmentMatch::Arbitrated);
1147  }
1148  }
1149  }
1150 
1151  // setup me1a cleaning for later
1152  if (muonType == reco::Muon::TrackerMuon && chamber1.id.subdetId() == MuonSubdetId::CSC && arbClean_ &&
1153  CSCDetId(chamber1.id).ring() == 4) {
1154  for (auto& segment2 : chamber1.segmentMatches) {
1155  if (segment1.cscSegmentRef.isNull() || segment2.cscSegmentRef.isNull())
1156  continue;
1157  if (meshAlgo_->isDuplicateOf(segment1.cscSegmentRef, segment2.cscSegmentRef) &&
1158  (segment2.mask & 0x1e0000) && (segment1.mask & 0x1e0000)) {
1160  //if the track has lost the segment already through normal arbitration no need to do it again.
1161  }
1162  }
1163  } // mark all ME1/a duplicates that this track owns
1164 
1165  } // segmentIter1
1166 
1167  // chamber segment sort
1168  if (chamberPairs.empty())
1169  continue; // this should never happen
1170  if (chamberPairs.size() == 1) {
1171  chamberPairs.front().second->setMask(reco::MuonSegmentMatch::BestInChamberByDRSlope);
1172  chamberPairs.front().second->setMask(reco::MuonSegmentMatch::BestInChamberByDXSlope);
1173  chamberPairs.front().second->setMask(reco::MuonSegmentMatch::BestInChamberByDR);
1174  chamberPairs.front().second->setMask(reco::MuonSegmentMatch::BestInChamberByDX);
1175  } else {
1176  sort(chamberPairs.begin(),
1177  chamberPairs.end(),
1179  chamberPairs.front().second->setMask(reco::MuonSegmentMatch::BestInChamberByDRSlope);
1180  sort(chamberPairs.begin(),
1181  chamberPairs.end(),
1183  chamberPairs.front().second->setMask(reco::MuonSegmentMatch::BestInChamberByDXSlope);
1184  sort(chamberPairs.begin(),
1185  chamberPairs.end(),
1187  chamberPairs.front().second->setMask(reco::MuonSegmentMatch::BestInChamberByDR);
1188  sort(chamberPairs.begin(),
1189  chamberPairs.end(),
1191  chamberPairs.front().second->setMask(reco::MuonSegmentMatch::BestInChamberByDX);
1192  }
1193  } // chamberIter1
1194 
1195  // station segment sort
1196  for (int stationIndex = 1; stationIndex < 5; ++stationIndex) {
1197  for (int detectorIndex = 1; detectorIndex <= 5;
1198  ++detectorIndex) // 1-5, as in DataFormats/MuonDetId/interface/MuonSubdetId.h
1199  {
1200  stationPairs.clear();
1201 
1202  // chamberIter
1203  for (auto& chamber : muon1.matches()) {
1204  if (!(chamber.station() == stationIndex && chamber.detector() == detectorIndex))
1205  continue;
1206  std::vector<reco::MuonSegmentMatch>* segmentMatches = getSegmentMatches(chamber, muonType);
1207  if (segmentMatches->empty())
1208  continue;
1209 
1210  for (auto& segment : *segmentMatches) {
1211  stationPairs.push_back(std::make_pair(&chamber, &segment));
1212  }
1213  } // chamberIter
1214 
1215  if (stationPairs.empty())
1216  continue; // this may very well happen
1217  if (stationPairs.size() == 1) {
1218  stationPairs.front().second->setMask(reco::MuonSegmentMatch::BestInStationByDRSlope);
1219  stationPairs.front().second->setMask(reco::MuonSegmentMatch::BestInStationByDXSlope);
1220  stationPairs.front().second->setMask(reco::MuonSegmentMatch::BestInStationByDR);
1221  stationPairs.front().second->setMask(reco::MuonSegmentMatch::BestInStationByDX);
1222  } else {
1223  sort(stationPairs.begin(),
1224  stationPairs.end(),
1226  stationPairs.front().second->setMask(reco::MuonSegmentMatch::BestInStationByDRSlope);
1227  sort(stationPairs.begin(),
1228  stationPairs.end(),
1230  stationPairs.front().second->setMask(reco::MuonSegmentMatch::BestInStationByDXSlope);
1231  sort(stationPairs.begin(),
1232  stationPairs.end(),
1234  stationPairs.front().second->setMask(reco::MuonSegmentMatch::BestInStationByDR);
1235  sort(stationPairs.begin(),
1236  stationPairs.end(),
1238  stationPairs.front().second->setMask(reco::MuonSegmentMatch::BestInStationByDX);
1239  }
1240  }
1241  }
1242 
1243  } // muonIndex1
1244 
1245  if (arbClean_) {
1246  // clear old mesh, create and prune new mesh!
1247  meshAlgo_->clearMesh();
1248  meshAlgo_->runMesh(pOutputMuons);
1249  }
1250 }
1251 
1253  const edm::EventSetup& iSetup,
1254  reco::Muon& aMuon,
1255  reco::IsoDeposit& trackDep,
1256  reco::IsoDeposit& ecalDep,
1257  reco::IsoDeposit& hcalDep,
1258  reco::IsoDeposit& hoDep,
1259  reco::IsoDeposit& jetDep) {
1260  const reco::Track* track = nullptr;
1261  if (aMuon.track().isNonnull())
1262  track = aMuon.track().get();
1263  else if (aMuon.standAloneMuon().isNonnull())
1264  track = aMuon.standAloneMuon().get();
1265  else
1266  throw cms::Exception("FatalError")
1267  << "Failed to compute muon isolation information for a muon with undefined references to tracks";
1268 
1269  reco::MuonIsolation isoR03, isoR05;
1270 
1271  // get deposits
1272  reco::IsoDeposit depTrk = muIsoExtractorTrack_->deposit(iEvent, iSetup, *track);
1273  std::vector<reco::IsoDeposit> caloDeps = muIsoExtractorCalo_->deposits(iEvent, iSetup, *track);
1274  reco::IsoDeposit depJet = muIsoExtractorJet_->deposit(iEvent, iSetup, *track);
1275 
1276  if (caloDeps.size() != 3) {
1277  LogTrace("MuonIdentification") << "Failed to fill vector of calorimeter isolation deposits!";
1278  return;
1279  }
1280 
1281  reco::IsoDeposit depEcal = caloDeps.at(0);
1282  reco::IsoDeposit depHcal = caloDeps.at(1);
1283  reco::IsoDeposit depHo = caloDeps.at(2);
1284 
1285  //no need to copy outside if we don't write them
1286  if (writeIsoDeposits_) {
1287  trackDep = depTrk;
1288  ecalDep = depEcal;
1289  hcalDep = depHcal;
1290  hoDep = depHo;
1291  jetDep = depJet;
1292  }
1293 
1294  isoR03.sumPt = depTrk.depositWithin(0.3);
1295  isoR03.emEt = depEcal.depositWithin(0.3);
1296  isoR03.hadEt = depHcal.depositWithin(0.3);
1297  isoR03.hoEt = depHo.depositWithin(0.3);
1298  isoR03.nTracks = depTrk.depositAndCountWithin(0.3).second;
1299  isoR03.nJets = depJet.depositAndCountWithin(0.3).second;
1300  isoR03.trackerVetoPt = depTrk.candEnergy();
1301  isoR03.emVetoEt = depEcal.candEnergy();
1302  isoR03.hadVetoEt = depHcal.candEnergy();
1303  isoR03.hoVetoEt = depHo.candEnergy();
1304 
1305  isoR05.sumPt = depTrk.depositWithin(0.5);
1306  isoR05.emEt = depEcal.depositWithin(0.5);
1307  isoR05.hadEt = depHcal.depositWithin(0.5);
1308  isoR05.hoEt = depHo.depositWithin(0.5);
1309  isoR05.nTracks = depTrk.depositAndCountWithin(0.5).second;
1310  isoR05.nJets = depJet.depositAndCountWithin(0.5).second;
1311  isoR05.trackerVetoPt = depTrk.candEnergy();
1312  isoR05.emVetoEt = depEcal.candEnergy();
1313  isoR05.hadVetoEt = depHcal.candEnergy();
1314  isoR05.hoVetoEt = depHo.candEnergy();
1315 
1316  aMuon.setIsolation(isoR03, isoR05);
1317 }
1318 
1320  const double energy = std::sqrt(track.p() * track.p() + 0.105658369 * 0.105658369);
1321  const math::XYZTLorentzVector p4(track.px(), track.py(), track.pz(), energy);
1322  return reco::Muon(track.charge(), p4, track.vertex());
1323 }
1324 
1326  double phi = 0;
1327  if (id.subdetId() == MuonSubdetId::DT) { // DT
1328  DTChamberId muonId(id.rawId());
1329  if (muonId.sector() <= 12)
1330  phi = (muonId.sector() - 1) / 6. * M_PI;
1331  if (muonId.sector() == 13)
1332  phi = 3 / 6. * M_PI;
1333  if (muonId.sector() == 14)
1334  phi = 9 / 6. * M_PI;
1335  }
1336  if (id.subdetId() == MuonSubdetId::CSC) { // CSC
1337  CSCDetId muonId(id.rawId());
1338  phi = M_PI / 4 + (muonId.triggerSector() - 1) / 3. * M_PI;
1339  }
1340  if (phi > M_PI)
1341  phi -= 2 * M_PI;
1342  return phi;
1343 }
1344 
1346  if (muon.isStandAloneMuon())
1347  return muon.standAloneMuon()->innerPosition().phi();
1348  // the rest is tracker muon only
1349  if (muon.matches().empty()) {
1350  if (muon.innerTrack().isAvailable() && muon.innerTrack()->extra().isAvailable())
1351  return muon.innerTrack()->outerPosition().phi();
1352  else
1353  return muon.phi(); // makes little sense, but what else can I use
1354  }
1355  return sectorPhi(muon.matches().at(0).id);
1356 }
1357 
1360  aMuon.setCombinedQuality((*glbQualHandle_)[aMuon.combinedMuon()]);
1361  }
1362 
1363  LogDebug("MuonIdentification") << "tkChiVal " << aMuon.combinedQuality().trkRelChi2;
1364 }
1365 
1367  // skip muons with no tracks
1368  if (aMuon.innerTrack().isNull())
1369  return;
1370  // get quality from muon if already there, otherwise make empty one
1372  // fill it
1373  const bool filled = trackerKinkFinder_->fillTrkKink(quality, *aMuon.innerTrack());
1374  // if quality was there, or if we filled it, commit to the muon
1375  if (filled || aMuon.isQualityValid())
1376  aMuon.setCombinedQuality(quality);
1377 }
1378 
1380  const bool trackBAD = links->trackerTrack().isNull();
1381  const bool staBAD = links->standAloneTrack().isNull();
1382  const bool glbBAD = links->globalTrack().isNull();
1383  if (trackBAD || staBAD || glbBAD) {
1384  edm::LogWarning("muonIDbadLinks") << "Global muon links to constituent tracks are invalid: trkBad " << trackBAD
1385  << " standaloneBad " << staBAD << " globalBad " << glbBAD
1386  << ". There should be no such object. Muon is skipped.";
1387  return false;
1388  }
1389  return true;
1390 }
1391 
1394  desc.setAllowAnything();
1395 
1396  desc.add<bool>("arbitrateTrackerMuons", false);
1397  desc.add<bool>("storeCrossedHcalRecHits", false);
1398  desc.add<bool>("fillShowerDigis", false);
1399 
1400  edm::ParameterSetDescription descTrkAsoPar;
1401  descTrkAsoPar.add<edm::InputTag>("GEMSegmentCollectionLabel", edm::InputTag("gemSegments"));
1402  descTrkAsoPar.add<edm::InputTag>("ME0SegmentCollectionLabel", edm::InputTag("me0Segments"));
1403  descTrkAsoPar.add<bool>("useGEM", false);
1404  descTrkAsoPar.add<bool>("useME0", false);
1405  descTrkAsoPar.setAllowAnything();
1406  desc.add<edm::ParameterSetDescription>("TrackAssociatorParameters", descTrkAsoPar);
1407 
1409  descJet.setAllowAnything();
1410  descJet.add<edm::ParameterSetDescription>("TrackAssociatorParameters", descTrkAsoPar);
1411  desc.add<edm::ParameterSetDescription>("JetExtractorPSet", descJet);
1412 
1414  descCalo.setAllowAnything();
1415  descCalo.add<edm::ParameterSetDescription>("TrackAssociatorParameters", descTrkAsoPar);
1416  desc.add<edm::ParameterSetDescription>("CaloExtractorPSet", descCalo);
1417 
1418  descriptions.addDefault(desc);
1419 }
std::string hoDepositName_
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
double p() const
momentum vector magnitude
Definition: TrackBase.h:631
bool isAvailable() const
Definition: Ref.h:537
float hadEt
hcal sum-Et
Definition: MuonIsolation.h:8
static const unsigned int BelongsToTrackByME1aClean
std::string jetDepositName_
double candEnergy() const
Get energy or pT attached to cand trajectory.
Definition: IsoDeposit.h:129
bool isGoodRPCMuon(const reco::Muon &muon)
int numberOfMatchedRPCLayers(ArbitrationType type=RPCHitAndTrackArbitration) const
float xx() const
Definition: LocalError.h:22
edm::EDGetTokenT< reco::TrackCollection > innerTrackCollectionToken_
reco::Muon makeMuon(edm::Event &iEvent, const edm::EventSetup &iSetup, const reco::TrackRef &track, TrackType type)
GEMSegmentRef gemSegmentRef
static const unsigned int GlobalMuon
Definition: Muon.h:285
void fillMuonIsolation(edm::Event &, const edm::EventSetup &, reco::Muon &aMuon, reco::IsoDeposit &trackDep, reco::IsoDeposit &ecalDep, reco::IsoDeposit &hcalDep, reco::IsoDeposit &hoDep, reco::IsoDeposit &jetDep)
edm::EDGetTokenT< edm::ValueMap< reco::MuonQuality > > glbQualToken_
DTRecSegment4DRef dtSegmentRef
static const TGPicture * info(bool iBackgroundIsBlack)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
TrackRef combinedMuon() const override
reference to a stand-alone muon Track
Definition: Muon.h:52
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
static constexpr int GEM
Definition: MuonSubdetId.h:14
std::vector< reco::MuonSegmentMatch > gemMatches
static bool crossedIP(const reco::Track &track)
float sumPt
sum-pt of tracks
Definition: MuonIsolation.h:6
double pt() const final
transverse momentum
void setType(unsigned int type)
Definition: Muon.h:294
static void truthMatchMuon(const edm::Event &iEvent, const GlobalTrackingGeometry &iGeometry, reco::Muon &aMuon)
TrackDetectorAssociator trackAssociator_
CSCSegmentRef cscSegmentRef
std::unique_ptr< MuonKinkFinder > trackerKinkFinder_
const TrackExtraRef & extra() const
reference to &quot;extra&quot; object
Definition: Track.h:139
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
static const unsigned int Arbitrated
segment mask flags
void fillMuonId(edm::Event &, const edm::EventSetup &, reco::Muon &, TrackDetectorAssociator::Direction direction=TrackDetectorAssociator::InsideOut)
std::vector< const HBHERecHit * > crossedHcalRecHits
virtual TrackRef innerTrack() const
Definition: Muon.h:45
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
void setAllowAnything()
allow any parameter label/value pairs
edm::Handle< reco::MuonTrackLinksCollection > linkCollectionHandle_
edm::EDGetTokenT< RPCRecHitCollection > rpcHitToken_
uint32_t const *__restrict__ Quality * quality
const edm::ESGetToken< Propagator, TrackingComponentsRecord > propagatorToken_
bool isGoodGEMMuon(const reco::Muon &muon)
int overlap(const reco::Muon &muon, const reco::Track &track)
bool fillCaloCompatibility_
std::vector< const EcalRecHit * > ecalRecHits
hits in the cone
std::vector< DetId > crossedEcalIds
std::string trackDepositName_
void fillArbitrationInfo(reco::MuonCollection *, unsigned int muonType=reco::Muon::TrackerMuon)
std::vector< CaloMuon > CaloMuonCollection
collection of Muon objects
Definition: MuonFwd.h:27
const edm::ESGetToken< CSCGeometry, MuonGeometryRecord > geomTokenRun_
void loadParameters(const edm::ParameterSet &, edm::ConsumesCollector &)
std::vector< reco::MuonSegmentMatch > * getSegmentMatches(reco::MuonChamberMatch &chamber, unsigned int muonType) const
get the segment matches of the appropriate type
DetId findMaxDeposition(EnergyType)
Find detector elements with highest energy deposition.
void produce(edm::Event &, const edm::EventSetup &) override
float hadVetoEt
hcal sum-et in the veto region in r-phi
Definition: MuonIsolation.h:14
float emS9
energy deposited in 3x3 ECAL crystal shape around central crystal
Definition: MuonEnergy.h:28
double evaluate(const reco::Muon &)
#define M_PI_2
MuonCaloCompatibility muonCaloCompatibility_
static const unsigned int BestInStationByDRSlope
float timeAtIpOutInErr() const
Definition: MuonTimeExtra.h:49
bool isMatchesValid() const
Definition: Muon.h:143
bool ev
tuple inputCollectionTypes
edm::EDGetTokenT< reco::TrackToTrackMap > pickyCollectionToken_
static std::string toStr(const ICTypeKey k)
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:640
bool arbitrateTrackerMuons_
static const unsigned int BelongsToTrackByDXSlope
void setCalEnergy(const MuonEnergy &calEnergy)
set energy deposition information
Definition: Muon.h:108
void fillGlbQuality(edm::Event &, const edm::EventSetup &, reco::Muon &aMuon)
int nDof() const
number of measurements used in timing calculation
Definition: MuonTimeExtra.h:22
TrackRef track() const override
reference to a Track
Definition: Muon.h:46
float timeAtIpOutInErr
Definition: MuonTime.h:17
std::vector< DetId > crossedHcalIds
float trkRelChi2
chi2 value for the inner track stub with respect to the global track
Definition: MuonQuality.h:15
double nXnEnergy(const DetId &, EnergyType, int gridSize=1)
get energy of the NxN shape (N = 2*gridSize + 1) around given detector element
std::unique_ptr< reco::isodeposit::IsoDepositExtractor > muIsoExtractorTrack_
float towerS9
total energy in 3x3 tower shape
Definition: MuonEnergy.h:22
static const unsigned int BestInStationByDR
MuonTime time() const
get DT/CSC combined timing information
Definition: Muon.h:132
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
bool isTrackerMuon() const override
Definition: Muon.h:300
std::unique_ptr< MuonTimingFiller > theTimingFiller_
#define LogTrace(id)
math::XYZPoint trkGlobPosAtHcal
float ecal_time
Calorimeter timing.
Definition: MuonEnergy.h:47
float ho
energy deposited in crossed HO towers
Definition: MuonEnergy.h:42
virtual void setTunePBestTrack(MuonTrackType muonType)
Definition: Muon.h:88
double depositWithin(double coneSize, const Vetos &vetos=Vetos(), bool skipDepositVeto=false) const
Get deposit.
Definition: IsoDeposit.cc:29
bool approxEqual(const double a, const double b, const double tol=1E-3) const
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > globalGeomToken_
bool getData(T &iHolder) const
Definition: EventSetup.h:128
std::unique_ptr< reco::isodeposit::IsoDepositExtractor > muIsoExtractorCalo_
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
void init(edm::Event &, const edm::EventSetup &)
virtual void setInnerTrack(const TrackRef &t)
set reference to Track
bool isRPCMuon() const
Definition: Muon.h:304
DetId hcal_id
DetId of the central HCAL tower with smallest depth.
Definition: MuonEnergy.h:60
edm::EDGetTokenT< reco::TrackToTrackMap > tpfmsCollectionToken_
const Point & vertex() const
reference point on the track. This method is DEPRECATED, please use referencePoint() instead ...
Definition: TrackBase.h:676
std::vector< reco::MuonSegmentMatch > me0Matches
int iEvent
Definition: GenABIO.cc:224
std::unique_ptr< MuonShowerDigiFiller > theShowerDigiFiller_
double ptThresholdToFillCandidateP4WithGlobalFit_
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:652
void addDefault(ParameterSetDescription const &psetDescription)
reco::Muon::MuonTrackTypePair sigmaSwitch(const reco::TrackRef &combinedTrack, const reco::TrackRef &trackerTrack, const double nSigma=2., const double ptThreshold=200.)
TrackAssociatorParameters parameters_
bool isCaloCompatibilityValid() const
Definition: CaloMuon.h:47
bool isGoodME0Muon(const reco::Muon &muon)
reco::Muon::MuonTrackTypePair tevOptimized(const reco::TrackRef &combinedTrack, const reco::TrackRef &trackerTrack, const reco::TrackRef &tpfmsTrack, const reco::TrackRef &pickyTrack, const reco::TrackRef &dytTrack, const double ptThreshold=200., const double tune1=17., const double tune2=40., const double dptcut=0.25)
Definition: MuonCocktails.cc:9
void fillTrackerKink(reco::Muon &aMuon)
void setPropagator(const Propagator *)
use a user configured propagator
float yy() const
Definition: LocalError.h:24
float emS25
energy deposited in 5x5 ECAL crystal shape around central crystal
Definition: MuonEnergy.h:30
double p() const
momentum vector magnitude
Definition: CaloMuon.h:54
static const unsigned int ME0Muon
Definition: Muon.h:292
ArbitrationType
define arbitration schemes
Definition: Muon.h:187
T sqrt(T t)
Definition: SSEVec.h:19
bool isGoodTrackerMuon(const reco::Muon &muon)
double pt() const
track transverse momentum
Definition: TrackBase.h:637
float emEt
ecal sum-Et
Definition: MuonIsolation.h:7
bool checkLinks(const reco::MuonTrackLinks *) const
float timeAtIpInOutErr
Definition: MuonTime.h:14
std::vector< TAMuonChamberMatch > chambers
int nJets
number of jets in the cone
Definition: MuonIsolation.h:11
def move
Definition: eostools.py:511
std::vector< const HBHERecHit * > hcalRecHits
static const unsigned int BestInChamberByDX
std::string ecalDepositName_
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
MuonQuality combinedQuality() const
get energy deposition information
Definition: Muon.h:119
float timeAtIpOutIn
b) particle is moving from outside in
Definition: MuonTime.h:16
int nDof
number of muon stations used
Definition: MuonTime.h:9
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float timeAtIpInOutErr() const
Definition: MuonTimeExtra.h:44
edm::EDGetTokenT< reco::MuonCollection > muonCollectionToken_
Transition
Definition: Transition.h:12
float hoEt
ho sum-Et
Definition: MuonIsolation.h:9
edm::EDGetTokenT< reco::TrackCollection > outerTrackCollectionToken_
edm::Handle< RPCRecHitCollection > rpcHitHandle_
float hoS9
energy deposited in 3x3 HO tower shape around central tower
Definition: MuonEnergy.h:44
std::vector< reco::MuonRPCHitMatch > rpcMatches
static constexpr int ME0
Definition: MuonSubdetId.h:15
static const unsigned int BestInChamberByDR
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
TrackRef standAloneMuon() const override
reference to a stand-alone muon Track
Definition: Muon.h:49
T min(T a, T b)
Definition: MathUtil.h:58
ME0SegmentRef me0SegmentRef
bool isQualityValid() const
Definition: Muon.h:117
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::Handle< reco::TrackToTrackMap > dytCollectionHandle_
bool isValid() const
Definition: HandleBase.h:70
edm::Handle< reco::TrackCollection > outerTrackCollectionHandle_
edm::EDGetTokenT< reco::MuonTrackLinksCollection > linkCollectionToken_
double crossedEnergy(EnergyType)
energy in detector elements crossed by the track by types
bool isNull() const
Checks for null.
Definition: Ref.h:235
static const unsigned int BestInStationByDXSlope
math::XYZPointF hcal_position
Definition: MuonEnergy.h:54
bool fillGlobalTrackRefits_
static double sectorPhi(const DetId &id)
void setMuonTrack(const MuonTrackType &, const TrackRef &)
bool isEnergyValid() const
Definition: Muon.h:104
float hoVetoEt
ho sum-et in the veto region in r-phi
Definition: MuonIsolation.h:15
#define M_PI
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:646
double phiOfMuonInteractionRegion(const reco::Muon &muon) const
MuonEnergy calEnergy() const
get energy deposition information
Definition: Muon.h:106
reco::CaloMuon makeCaloMuon(const reco::Muon &)
unsigned int id
int nTracks
number of tracks in the cone (excluding veto region)
Definition: MuonIsolation.h:10
static const unsigned int BestInChamberByDXSlope
float emMax
maximal energy of ECAL crystal in the 5x5 shape
Definition: MuonEnergy.h:32
bool failedToGet() const
Definition: HandleBase.h:72
void setCaloCompatibility(float input)
Definition: CaloMuon.h:46
Definition: DetId.h:17
static const unsigned int RPCMuon
Definition: Muon.h:290
static ICTypeKey toKey(const std::string &s)
bool isTimeValid() const
Definition: Muon.h:130
static const unsigned int TrackerMuon
Definition: Muon.h:286
float emVetoEt
ecal sum-et in the veto region in r-phi
Definition: MuonIsolation.h:13
void configure(const edm::ParameterSet &)
std::vector< ICTypes::ICTypeKey > inputCollectionTypes_
float timeAtIpInOut() const
Definition: MuonTimeExtra.h:43
float hadMax
maximal energy of HCAL tower in the 3x3 shape
Definition: MuonEnergy.h:40
static const unsigned int BelongsToTrackByDRSlope
virtual void setInnerTrack(const TrackRef &t)
set reference to Track
Definition: CaloMuon.h:30
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
static constexpr int RPC
Definition: MuonSubdetId.h:13
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
void setCombinedQuality(const MuonQuality &combinedQuality)
set energy deposition information
Definition: Muon.h:121
std::vector< edm::InputTag > inputCollectionLabels_
static const unsigned int PFMuon
Definition: Muon.h:289
std::vector< MuonChamberMatch > & matches()
get muon matching information
Definition: Muon.h:145
std::unique_ptr< reco::isodeposit::IsoDepositExtractor > muIsoExtractorJet_
void setCalEnergy(const MuonEnergy &calEnergy)
set energy deposition information
Definition: CaloMuon.h:37
int triggerSector() const
Definition: CSCDetId.cc:3
MuonIdProducer(const edm::ParameterSet &)
void arbitrateMuons(reco::MuonCollection *, reco::CaloMuonCollection *)
std::vector< reco::MuonSegmentMatch > segmentMatches
bool fillGlobalTrackQuality_
int numberOfMatches(ArbitrationType type=SegmentAndTrackArbitration) const
get number of chambers with matched segments
DetId ecal_id
DetId of the central ECAL crystal.
Definition: MuonEnergy.h:57
virtual void setOuterTrack(const TrackRef &t)
set reference to Track
static const unsigned int BelongsToTrackByDR
std::string hcalDepositName_
~MuonIdProducer() override
unsigned int chamberId(const DetId &)
reco::TrackRef getTevRefitTrack(const reco::TrackRef &combinedTrack, const reco::TrackToTrackMap &map)
static const unsigned int BelongsToTrackByDX
void setIsolation(const MuonIsolation &isoR03, const MuonIsolation &isoR05)
virtual void setBestTrack(MuonTrackType muonType)
Definition: Muon.h:86
tuple muons
Definition: patZpeak.py:39
functor predicate for standard library sort algorithm
static const unsigned int GEMMuon
Definition: Muon.h:291
int sector() const
Definition: DTChamberId.h:49
std::pair< double, int > depositAndCountWithin(double coneSize, const Vetos &vetos=Vetos(), double threshold=-1e+36, bool skipDepositVeto=false) const
Get deposit.
Definition: IsoDeposit.cc:37
edm::Handle< reco::TrackToTrackMap > tpfmsCollectionHandle_
def stationIndex
Definition: plotscripts.py:355
static const unsigned int BestInStationByDX
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
bool storeCrossedHcalRecHits_
edm::Handle< reco::TrackCollection > innerTrackCollectionHandle_
unsigned int type() const
Definition: Muon.h:295
math::XYZPoint trkGlobPosAtEcal
Track position at different parts of the calorimeter.
int charge() const
track electric charge
Definition: TrackBase.h:596
bool isGoodTrack(const reco::Track &track)
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
MuonTrackType
map for Global Muon refitters
Definition: Muon.h:36
double sigmaThresholdToFillCandidateP4WithGlobalFit_
#define get
static const unsigned int StandAloneMuon
Definition: Muon.h:287
std::vector< HcalMuonRecHit > crossedHadRecHits
Definition: MuonEnergy.h:66
static constexpr int DT
Definition: MuonSubdetId.h:11
Log< level::Warning, false > LogWarning
float timeAtIpOutIn() const
b) particle is moving from outside in
Definition: MuonTimeExtra.h:48
std::pair< TrackRef, Muon::MuonTrackType > MuonTrackTypePair
Definition: Muon.h:38
void setMatches(const std::vector< MuonChamberMatch > &matches)
set muon matching information
Definition: Muon.h:148
double phi() const final
momentum azimuthal angle
math::XYZPointF ecal_position
Trajectory position at the calorimeter.
Definition: MuonEnergy.h:53
static constexpr int CSC
Definition: MuonSubdetId.h:12
static const unsigned int BestInChamberByDRSlope
float caloCompatibility() const
Definition: CaloMuon.h:45
bool validateGlobalMuonPair(const reco::MuonTrackLinks &goodMuon, const reco::MuonTrackLinks &badMuon)
bool debugWithTruthMatching_
float timeAtIpInOut
Definition: MuonTime.h:13
bool isGoodCaloMuon(const reco::CaloMuon &muon)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool isGlobalMuon() const override
Definition: Muon.h:299
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
virtual void setGlobalTrack(const TrackRef &t)
set reference to Track
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
float trackerVetoPt
(sum-)pt inside the veto region in r-phi
Definition: MuonIsolation.h:12
float hadS9
energy deposited in 3x3 HCAL tower shape around central tower
Definition: MuonEnergy.h:38
edm::Handle< reco::MuonCollection > muonCollectionHandle_
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:643
Definition: Run.h:45
edm::Handle< edm::ValueMap< reco::MuonQuality > > glbQualHandle_
void beginRun(const edm::Run &, const edm::EventSetup &) override
edm::Handle< reco::TrackToTrackMap > pickyCollectionHandle_
std::unique_ptr< MuonMesh > meshAlgo_
#define LogDebug(id)
edm::EDGetTokenT< reco::TrackToTrackMap > dytCollectionToken_
bool isStandAloneMuon() const override
Definition: Muon.h:301
double eta() const final
momentum pseudorapidity