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