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