CMS 3D CMS Logo

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