CMS 3D CMS Logo

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