CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Protected Attributes | Private Attributes
RecoMuonValidator Class Reference

#include <RecoMuonValidator.h>

Inheritance diagram for RecoMuonValidator:
edm::EDAnalyzer

Classes

struct  CommonME
 
struct  MuonME
 

Public Member Functions

virtual void analyze (const edm::Event &event, const edm::EventSetup &eventSetup)
 
virtual void beginRun (const edm::Run &, const edm::EventSetup &eventSetup)
 
virtual int countMuonHits (const reco::Track &track) const
 
virtual int countTrackerHits (const reco::Track &track) const
 
virtual void endRun ()
 
 RecoMuonValidator (const edm::ParameterSet &pset)
 
 ~RecoMuonValidator ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Protected Attributes

const MuonAssociatorByHitsassoByHits
 
CommonMEcommonME_
 
bool doAbsEta_
 
bool doAssoc_
 
edm::InputTag muAssocLabel_
 
edm::InputTag muonLabel_
 
MuonMEmuonME_
 
std::string muonSelection_
 
std::string outputFileName_
 
edm::InputTag simLabel_
 
std::string subDir_
 
DQMStoretheDQM
 
MuonServiceProxytheMuonService
 
TrackingParticleSelector tpSelector_
 
MuonAssociatorByHits::MuonTrackType trackType_
 
unsigned int verbose_
 

Private Attributes

StringCutObjectSelector
< reco::Muon
selector_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 25 of file RecoMuonValidator.h.

Constructor & Destructor Documentation

RecoMuonValidator::RecoMuonValidator ( const edm::ParameterSet pset)

Definition at line 423 of file RecoMuonValidator.cc.

References DQMStore::book1D(), DQMStore::book2D(), RecoMuonValidator::MuonME::bookHistograms(), DQMStore::cd(), commonME_, doAbsEta_, doAssoc_, edm::hlt::Exception, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), MuonAssociatorByHits::GlobalTk, RecoMuonValidator::CommonME::hMuonAllEta_, RecoMuonValidator::CommonME::hMuonAllP_, RecoMuonValidator::CommonME::hMuonAllPhi_, RecoMuonValidator::CommonME::hMuonAllPt_, RecoMuonValidator::CommonME::hMuonEta_, RecoMuonValidator::CommonME::hMuonP_, RecoMuonValidator::CommonME::hMuonPhi_, RecoMuonValidator::CommonME::hMuonPt_, RecoMuonValidator::CommonME::hMuonTrackDxy_, RecoMuonValidator::CommonME::hMuonTrackDz_, RecoMuonValidator::CommonME::hMuonTrackEta_, RecoMuonValidator::CommonME::hMuonTrackP_, RecoMuonValidator::CommonME::hMuonTrackPhi_, RecoMuonValidator::CommonME::hMuonTrackPt_, RecoMuonValidator::CommonME::hNDeltaInvalidHitsHitPattern_, RecoMuonValidator::CommonME::hNInvalidHitsGTHitPattern_, RecoMuonValidator::CommonME::hNInvalidHitsITHitPattern_, RecoMuonValidator::CommonME::hNInvalidHitsOTHitPattern_, RecoMuonValidator::CommonME::hStaToGlbDiffNMuonHits_, RecoMuonValidator::CommonME::hStaToGlbDiffNMuonHitsEta_, RecoMuonValidator::CommonME::hStaToGlbDiffNMuonHitsPt_, RecoMuonValidator::CommonME::hTrkToGlbDiffNTrackerHits_, RecoMuonValidator::CommonME::hTrkToGlbDiffNTrackerHitsEta_, RecoMuonValidator::CommonME::hTrkToGlbDiffNTrackerHitsPt_, MuonAssociatorByHits::InnerTk, muAssocLabel_, muonLabel_, muonME_, MuonServiceProxy_cff::MuonServiceProxy, HistoDimensions::nBinP, cmsCodeRules.cppFunctionSkipper::operator, MuonAssociatorByHits::OuterTk, outputFileName_, Pi, MuonAssociatorByHits::Segments, DQMStore::setCurrentFolder(), DQMStore::showDirStructure(), simLabel_, subDir_, theDQM, theMuonService, tpSelector_, trackType_, and verbose_.

423  :
424  selector_(pset.getParameter<std::string>("selection"))
425 {
426  verbose_ = pset.getUntrackedParameter<unsigned int>("verbose", 0);
427 
428  outputFileName_ = pset.getUntrackedParameter<string>("outputFileName", "");
429 
430  // Set histogram dimensions from config
431  HistoDimensions hDim;
432 
433  hDim.nBinP = pset.getUntrackedParameter<unsigned int>("nBinP");
434  hDim.minP = pset.getUntrackedParameter<double>("minP");
435  hDim.maxP = pset.getUntrackedParameter<double>("maxP");
436 
437  hDim.nBinPt = pset.getUntrackedParameter<unsigned int>("nBinPt");
438  hDim.minPt = pset.getUntrackedParameter<double>("minPt");
439  hDim.maxPt = pset.getUntrackedParameter<double>("maxPt");
440 
441  doAbsEta_ = pset.getUntrackedParameter<bool>("doAbsEta");
442  hDim.doAbsEta = doAbsEta_;
443  hDim.nBinEta = pset.getUntrackedParameter<unsigned int>("nBinEta");
444  hDim.minEta = pset.getUntrackedParameter<double>("minEta");
445  hDim.maxEta = pset.getUntrackedParameter<double>("maxEta");
446 
447  hDim.nBinDxy = pset.getUntrackedParameter<unsigned int>("nBinDxy");
448  hDim.minDxy = pset.getUntrackedParameter<double>("minDxy");
449  hDim.maxDxy = pset.getUntrackedParameter<double>("maxDxy");
450 
451  hDim.nBinDz = pset.getUntrackedParameter<unsigned int>("nBinDz");
452  hDim.minDz = pset.getUntrackedParameter<double>("minDz");
453  hDim.maxDz = pset.getUntrackedParameter<double>("maxDz");
454 
455  hDim.nBinPhi = pset.getUntrackedParameter<unsigned int>("nBinPhi");
456  hDim.minPhi = pset.getUntrackedParameter<double>("minPhi", -TMath::Pi());
457  hDim.maxPhi = pset.getUntrackedParameter<double>("maxPhi", TMath::Pi());
458 
459  hDim.nBinErr = pset.getUntrackedParameter<unsigned int>("nBinErr");
460  hDim.nBinPull = pset.getUntrackedParameter<unsigned int>("nBinPull");
461 
462  hDim.wPull = pset.getUntrackedParameter<double>("wPull");
463 
464  hDim.minErrP = pset.getUntrackedParameter<double>("minErrP");
465  hDim.maxErrP = pset.getUntrackedParameter<double>("maxErrP");
466 
467  hDim.minErrPt = pset.getUntrackedParameter<double>("minErrPt");
468  hDim.maxErrPt = pset.getUntrackedParameter<double>("maxErrPt");
469 
470  hDim.minErrQPt = pset.getUntrackedParameter<double>("minErrQPt");
471  hDim.maxErrQPt = pset.getUntrackedParameter<double>("maxErrQPt");
472 
473  hDim.minErrEta = pset.getUntrackedParameter<double>("minErrEta");
474  hDim.maxErrEta = pset.getUntrackedParameter<double>("maxErrEta");
475 
476  hDim.minErrPhi = pset.getUntrackedParameter<double>("minErrPhi");
477  hDim.maxErrPhi = pset.getUntrackedParameter<double>("maxErrPhi");
478 
479  hDim.minErrDxy = pset.getUntrackedParameter<double>("minErrDxy");
480  hDim.maxErrDxy = pset.getUntrackedParameter<double>("maxErrDxy");
481 
482  hDim.minErrDz = pset.getUntrackedParameter<double>("minErrDz" );
483  hDim.maxErrDz = pset.getUntrackedParameter<double>("maxErrDz" );
484 
485  hDim.nTrks = pset.getUntrackedParameter<unsigned int>("nTrks");
486  hDim.nAssoc = pset.getUntrackedParameter<unsigned int>("nAssoc");
487  hDim.nDof = pset.getUntrackedParameter<unsigned int>("nDof", 55);
488 
489  // Labels for simulation and reconstruction tracks
490  simLabel_ = pset.getParameter<InputTag>("simLabel" );
491  muonLabel_ = pset.getParameter<InputTag>("muonLabel");
492 
493  // Labels for sim-reco association
494  doAssoc_ = pset.getUntrackedParameter<bool>("doAssoc", true);
495  muAssocLabel_ = pset.getParameter<InputTag>("muAssocLabel");
496 
497  //type of track
498  std::string trackType = pset.getParameter< std::string >("trackType");
499  if (trackType == "inner") trackType_ = MuonAssociatorByHits::InnerTk;
500  else if (trackType == "outer") trackType_ = MuonAssociatorByHits::OuterTk;
501  else if (trackType == "global") trackType_ = MuonAssociatorByHits::GlobalTk;
502  else if (trackType == "segments") trackType_ = MuonAssociatorByHits::Segments;
503  else throw cms::Exception("Configuration") << "Track type '" << trackType << "' not supported.\n";
504 
505 // seedPropagatorName_ = pset.getParameter<string>("SeedPropagator");
506 
507  ParameterSet tpset = pset.getParameter<ParameterSet>("tpSelector");
508  tpSelector_ = TrackingParticleSelector(tpset.getParameter<double>("ptMin"),
509  tpset.getParameter<double>("minRapidity"),
510  tpset.getParameter<double>("maxRapidity"),
511  tpset.getParameter<double>("tip"),
512  tpset.getParameter<double>("lip"),
513  tpset.getParameter<int>("minHit"),
514  tpset.getParameter<bool>("signalOnly"),
515  tpset.getParameter<bool>("chargedOnly"),
516  tpset.getParameter<bool>("stableOnly"),
517  tpset.getParameter<std::vector<int> >("pdgId"));
518 
519  // the service parameters
520  ParameterSet serviceParameters
521  = pset.getParameter<ParameterSet>("ServiceParameters");
522  theMuonService = new MuonServiceProxy(serviceParameters);
523 
524  // retrieve the instance of DQMService
525  theDQM = 0;
527 
528  if ( ! theDQM ) {
529  LogError("RecoMuonValidator") << "DQMService not initialized\n";
530  return;
531  }
532 
533  subDir_ = pset.getUntrackedParameter<string>("subDir");
534  if ( subDir_.empty() ) subDir_ = "RecoMuonV";
535  if ( subDir_[subDir_.size()-1] == '/' ) subDir_.erase(subDir_.size()-1);
536 
537  // book histograms
538  theDQM->cd();
539 
541 
542  commonME_ = new CommonME;
543  muonME_ = new MuonME;
544 
545  //commonME
546  const int nHits = 201;
547 
548  // - diffs
549  commonME_->hTrkToGlbDiffNTrackerHits_ = theDQM->book1D("TrkGlbDiffNTrackerHits", "Difference of number of tracker hits (tkMuon - globalMuon)", nHits, -100.5, 100.5);
550  commonME_->hStaToGlbDiffNMuonHits_ = theDQM->book1D("StaGlbDiffNMuonHits", "Difference of number of muon hits (staMuon - globalMuon)", nHits, -100.5, 100.5);
551 
552  commonME_->hTrkToGlbDiffNTrackerHitsEta_ = theDQM->book2D("TrkGlbDiffNTrackerHitsEta", "Difference of number of tracker hits (tkMuon - globalMuon)", hDim.nBinEta, hDim.minEta, hDim.maxEta,nHits, -100.5, 100.5);
553  commonME_->hStaToGlbDiffNMuonHitsEta_ = theDQM->book2D("StaGlbDiffNMuonHitsEta", "Difference of number of muon hits (staMuon - globalMuon)", hDim.nBinEta, hDim.minEta, hDim.maxEta,nHits, -100.5, 100.5);
554 
555  commonME_->hTrkToGlbDiffNTrackerHitsPt_ = theDQM->book2D("TrkGlbDiffNTrackerHitsPt", "Difference of number of tracker hits (tkMuon - globalMuon)", hDim.nBinPt, hDim.minPt, hDim.maxPt,nHits, -100.5, 100.5);
556  commonME_->hStaToGlbDiffNMuonHitsPt_ = theDQM->book2D("StaGlbDiffNMuonHitsPt", "Difference of number of muon hits (staMuon - globalMuon)", hDim.nBinPt, hDim.minPt, hDim.maxPt,nHits, -100.5, 100.5);
557 
558  // -global muon hit pattern
559  commonME_->hNInvalidHitsGTHitPattern_ = theDQM->book1D("NInvalidHitsGTHitPattern", "Number of invalid hits on a global track", nHits, 0, nHits);
560  commonME_->hNInvalidHitsITHitPattern_ = theDQM->book1D("NInvalidHitsITHitPattern", "Number of invalid hits on an inner track", nHits, 0, nHits);
561  commonME_->hNInvalidHitsOTHitPattern_ = theDQM->book1D("NInvalidHitsOTHitPattern", "Number of invalid hits on an outer track", nHits, 0, nHits);
562  commonME_->hNDeltaInvalidHitsHitPattern_ = theDQM->book1D("hNDeltaInvalidHitsHitPattern", "The discrepancy for Number of invalid hits on an global track and inner and outer tracks", 2.*nHits, -nHits, nHits);
563 
564  //muon based kinematics
565  commonME_->hMuonP_ = theDQM->book1D("PMuon" , "p of muon" , hDim.nBinP , hDim.minP , hDim.maxP );
566  commonME_->hMuonPt_ = theDQM->book1D("PtMuon" , "p_{T} of muon", hDim.nBinPt , hDim.minPt , hDim.maxPt );
567  commonME_->hMuonEta_ = theDQM->book1D("EtaMuon", "#eta of muon" , hDim.nBinEta, hDim.minEta, hDim.maxEta);
568  commonME_->hMuonPhi_ = theDQM->book1D("PhiMuon", "#phi of muon" , hDim.nBinPhi, hDim.minPhi, hDim.maxPhi);
569  //track based kinematics
570  commonME_->hMuonTrackP_ = theDQM->book1D("PMuonTrack" , "p of reco muon track" , hDim.nBinP , hDim.minP , hDim.maxP );
571  commonME_->hMuonTrackPt_ = theDQM->book1D("PtMuonTrack" , "p_{T} of reco muon track", hDim.nBinPt , hDim.minPt , hDim.maxPt );
572  commonME_->hMuonTrackEta_ = theDQM->book1D("EtaMuonTrack", "#eta of reco muon track" , hDim.nBinEta, hDim.minEta, hDim.maxEta);
573  commonME_->hMuonTrackPhi_ = theDQM->book1D("PhiMuonTrack", "#phi of reco muon track" , hDim.nBinPhi, hDim.minPhi, hDim.maxPhi);
574  commonME_->hMuonTrackDxy_ = theDQM->book1D("DxyMuonTrack", "Dxy of reco muon track" , hDim.nBinDxy, hDim.minDxy, hDim.maxDxy);
575  commonME_->hMuonTrackDz_ = theDQM->book1D("DzMuonTrack", "Dz of reco muon track" , hDim.nBinDz, hDim.minDz, hDim.maxDz);
576 
577  //histograms for fractions
578  commonME_->hMuonAllP_ = theDQM->book1D("PMuonAll" , "p of muons of all types" , hDim.nBinP , hDim.minP , hDim.maxP );
579  commonME_->hMuonAllPt_ = theDQM->book1D("PtMuonAll" , "p_{T} of muon of all types", hDim.nBinPt , hDim.minPt , hDim.maxPt );
580  commonME_->hMuonAllEta_ = theDQM->book1D("EtaMuonAll", "#eta of muon of all types" , hDim.nBinEta, hDim.minEta, hDim.maxEta);
581  commonME_->hMuonAllPhi_ = theDQM->book1D("PhiMuonAll", "#phi of muon of all types" , hDim.nBinPhi, hDim.minPhi, hDim.maxPhi);
582 
584 
585  if ( verbose_ > 0 ) theDQM->showDirStructure();
586 }
const double Pi
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:514
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:209
edm::InputTag simLabel_
StringCutObjectSelector< reco::Muon > selector_
TrackingParticleSelector tpSelector_
SingleObjectSelector< TrackingParticleCollection,::TrackingParticleSelector > TrackingParticleSelector
MuonServiceProxy * theMuonService
edm::InputTag muAssocLabel_
std::string outputFileName_
unsigned int verbose_
edm::InputTag muonLabel_
MuonAssociatorByHits::MuonTrackType trackType_
unsigned int nBinP
void showDirStructure(void) const
Definition: DQMStore.cc:2554
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:642
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:232
void bookHistograms(DQMStore *dqm, const string &dirName, const HistoDimensions &hDim)
RecoMuonValidator::~RecoMuonValidator ( )

Definition at line 591 of file RecoMuonValidator.cc.

References theMuonService.

592 {
593  if ( theMuonService ) delete theMuonService;
594 }
MuonServiceProxy * theMuonService

Member Function Documentation

void RecoMuonValidator::analyze ( const edm::Event event,
const edm::EventSetup eventSetup 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 623 of file RecoMuonValidator.cc.

References assoByHits, MuonAssociatorByHits::associateMuons(), edm::View< T >::begin(), commonME_, funct::cos(), countMuonHits(), countTrackerHits(), doAbsEta_, doAssoc_, edm::View< T >::end(), MonitorElement::Fill(), RecoMuonValidator::MuonME::fill(), edm::Ref< C, T, F >::get(), RecoMuonValidator::CommonME::hMuonAllEta_, RecoMuonValidator::CommonME::hMuonAllP_, RecoMuonValidator::CommonME::hMuonAllPhi_, RecoMuonValidator::CommonME::hMuonAllPt_, RecoMuonValidator::CommonME::hMuonEta_, RecoMuonValidator::CommonME::hMuonP_, RecoMuonValidator::CommonME::hMuonPhi_, RecoMuonValidator::CommonME::hMuonPt_, RecoMuonValidator::CommonME::hMuonTrackDxy_, RecoMuonValidator::CommonME::hMuonTrackDz_, RecoMuonValidator::CommonME::hMuonTrackEta_, RecoMuonValidator::CommonME::hMuonTrackP_, RecoMuonValidator::CommonME::hMuonTrackPhi_, RecoMuonValidator::CommonME::hMuonTrackPt_, RecoMuonValidator::CommonME::hNDeltaInvalidHitsHitPattern_, RecoMuonValidator::CommonME::hNInvalidHitsGTHitPattern_, RecoMuonValidator::CommonME::hNInvalidHitsITHitPattern_, RecoMuonValidator::CommonME::hNInvalidHitsOTHitPattern_, RecoMuonValidator::MuonME::hNMuon_, RecoMuonValidator::MuonME::hNMuonHits_, RecoMuonValidator::MuonME::hNMuonHits_vs_Eta_, RecoMuonValidator::MuonME::hNMuonHits_vs_Pt_, RecoMuonValidator::MuonME::hNSim_, RecoMuonValidator::MuonME::hNSimHits_, RecoMuonValidator::MuonME::hNSimToReco_, RecoMuonValidator::MuonME::hNTrackerHits_, RecoMuonValidator::MuonME::hNTrackerHits_vs_Eta_, RecoMuonValidator::MuonME::hNTrackerHits_vs_Pt_, RecoMuonValidator::MuonME::hNTrksEta_, RecoMuonValidator::MuonME::hNTrksPt_, RecoMuonValidator::MuonME::hSimDxy_, RecoMuonValidator::MuonME::hSimDz_, RecoMuonValidator::MuonME::hSimEta_, RecoMuonValidator::MuonME::hSimP_, RecoMuonValidator::MuonME::hSimPhi_, RecoMuonValidator::MuonME::hSimPt_, RecoMuonValidator::CommonME::hStaToGlbDiffNMuonHits_, RecoMuonValidator::CommonME::hStaToGlbDiffNMuonHitsEta_, RecoMuonValidator::CommonME::hStaToGlbDiffNMuonHitsPt_, RecoMuonValidator::CommonME::hTrkToGlbDiffNTrackerHits_, RecoMuonValidator::CommonME::hTrkToGlbDiffNTrackerHitsEta_, RecoMuonValidator::CommonME::hTrkToGlbDiffNTrackerHitsPt_, i, edm::Ref< C, T, F >::isNonnull(), Mu, muonLabel_, muonME_, edm::Handle< T >::product(), edm::RefVector< C, T, F >::push_back(), selector_, simLabel_, funct::sin(), edm::View< T >::size(), theDQM, tpSelector_, reco::Muon::track(), trackType_, and PV3DBase< T, PVType, FrameType >::x().

624 {
625  if ( ! theDQM ) {
626  LogError("RecoMuonValidator") << "DQMService not initialized\n";
627  return;
628  }
629 
630  // Get TrackingParticles
632  event.getByLabel(simLabel_, simHandle);
633  const TrackingParticleCollection simColl = *(simHandle.product());
634 
635  // Get Muons
636  Handle<View<Muon> > muonHandle;
637  event.getByLabel(muonLabel_, muonHandle);
638  View<Muon> muonColl = *(muonHandle.product());
639 
640  const TrackingParticleCollection::size_type nSim = simColl.size();
641 
643  Muons = muonHandle->refVector();
644 
646  for (size_t i = 0; i < nSim; ++i) {
647  allTPs.push_back(TrackingParticleRef(simHandle,i));
648  }
649 
650  muonME_->hNSim_->Fill(nSim);
651  muonME_->hNMuon_->Fill(muonColl.size());
652 
655 
656  if ( doAssoc_ ) {
657  assoByHits->associateMuons(muonToSimColl, simToMuonColl, Muons, trackType_, allTPs, &event, &eventSetup);
658  } else {
659 /*
660  // SimToMuon associations
661  Handle<reco::RecoToSimCollection> simToTrkMuHandle;
662  event.getByLabel(trkMuAssocLabel_, simToTrkMuHandle);
663  trkSimRecColl = *(simToTrkMuHandle.product());
664 
665  Handle<reco::RecoToSimCollection> simToStaMuHandle;
666  event.getByLabel(staMuAssocLabel_, simToStaMuHandle);
667  staSimRecColl = *(simToStaMuHandle.product());
668 
669  Handle<reco::RecoToSimCollection> simToGlbMuHandle;
670  event.getByLabel(glbMuAssocLabel_, simToGlbMuHandle);
671  glbSimRecColl = *(simToGlbMuHandle.product());
672 
673  // MuonToSim associations
674  Handle<reco::SimToRecoCollection> trkMuToSimHandle;
675  event.getByLabel(trkMuAssocLabel_, trkMuToSimHandle);
676  trkRecSimColl = *(trkMuToSimHandle.product());
677 
678  Handle<reco::SimToRecoCollection> staMuToSimHandle;
679  event.getByLabel(staMuAssocLabel_, staMuToSimHandle);
680  staRecSimColl = *(staMuToSimHandle.product());
681 
682  Handle<reco::SimToRecoCollection> glbMuToSimHandle;
683  event.getByLabel(glbMuAssocLabel_, glbMuToSimHandle);
684  glbRecSimColl = *(glbMuToSimHandle.product());
685 */
686  }
687 
688  int glbNTrackerHits = 0; int trkNTrackerHits = 0; int staNTrackerHits = 0;
689  int glbNMuonHits = 0; int trkNMuonHits = 0; int staNMuonHits = 0;
690  int NTrackerHits = 0; int NMuonHits = 0;
691 
692  // Analyzer reco::Muon
693  for(View<Muon>::const_iterator iMuon = muonColl.begin();
694  iMuon != muonColl.end(); ++iMuon) {
695 
696  //histograms for fractions
697  commonME_->hMuonAllP_->Fill(iMuon->p());
698  commonME_->hMuonAllPt_->Fill(iMuon->pt());
699  commonME_->hMuonAllEta_->Fill(iMuon->eta());
700  commonME_->hMuonAllPhi_->Fill(iMuon->phi());
701 
702  if (!selector_(*iMuon)) continue;
703 
704 
705  TrackRef Track = iMuon->track();
706 
707  if (Track.isNonnull()) {
708  commonME_->hMuonTrackP_->Fill(Track->p());
709  commonME_->hMuonTrackPt_->Fill(Track->pt());
710  commonME_->hMuonTrackEta_->Fill(Track->eta());
711  commonME_->hMuonTrackPhi_->Fill(Track->phi());
712 
713  //ip histograms
714  commonME_->hMuonTrackDxy_->Fill(Track->dxy());
715  commonME_->hMuonTrackDz_->Fill(Track->dz());
716  }
717 
718  if (iMuon->isGlobalMuon()) {
719  Track = iMuon->combinedMuon();
720  glbNTrackerHits = countTrackerHits(*Track);
721  glbNMuonHits = countMuonHits(*Track);
722  } else if (iMuon->isTrackerMuon()) {
723  Track = iMuon->track();
724  trkNTrackerHits = countTrackerHits(*Track);
725  trkNMuonHits = countMuonHits(*Track);
726  } else {
727  Track = iMuon->standAloneMuon();
728  staNTrackerHits = countTrackerHits(*Track);
729  staNMuonHits = countMuonHits(*Track);
730  }
731 
732  NTrackerHits = countTrackerHits(*Track);
733  NMuonHits = countMuonHits(*Track);
734 
735 //list of histos for each type
736 
737 // muonME_->hNTrks_->Fill();
738  muonME_->hNTrksEta_->Fill(Track->eta());
739  muonME_->hNTrksPt_->Fill(Track->pt());
740 
741  commonME_->hMuonP_->Fill(iMuon->p());
742  commonME_->hMuonPt_->Fill(iMuon->pt());
743  commonME_->hMuonEta_->Fill(iMuon->eta());
744  commonME_->hMuonPhi_->Fill(iMuon->phi());
745 
746  if (iMuon->isGlobalMuon()) {
747  double gtHitPat = iMuon->globalTrack()->hitPattern().numberOfHits() - iMuon->globalTrack()->hitPattern().numberOfValidHits();
748  double itHitPat = iMuon->innerTrack()->hitPattern().numberOfHits() - iMuon->innerTrack()->hitPattern().numberOfValidHits();
749  double otHitPat = iMuon->outerTrack()->hitPattern().numberOfHits() - iMuon->outerTrack()->hitPattern().numberOfValidHits();
750 
754  commonME_->hNDeltaInvalidHitsHitPattern_->Fill(gtHitPat - itHitPat - otHitPat);
755  }
756 
757  muonME_->hNTrackerHits_->Fill(NTrackerHits);
758  muonME_->hNTrackerHits_vs_Pt_->Fill(Track->pt(), NTrackerHits);
759  muonME_->hNTrackerHits_vs_Eta_->Fill(Track->eta(), NTrackerHits);
760 
761  muonME_->hNMuonHits_->Fill(NMuonHits);
762  muonME_->hNMuonHits_vs_Pt_->Fill(Track->pt(), NMuonHits);
763  muonME_->hNMuonHits_vs_Eta_->Fill(Track->eta(), NMuonHits);
764 
765  //must be global and standalone
766  if (iMuon->isGlobalMuon() && iMuon->isStandAloneMuon()) {
767  commonME_->hStaToGlbDiffNMuonHitsEta_->Fill(Track->eta(),staNMuonHits-glbNMuonHits);
768  commonME_->hStaToGlbDiffNMuonHitsPt_->Fill(Track->pt(),staNMuonHits-glbNMuonHits);
769  commonME_->hStaToGlbDiffNMuonHits_->Fill(staNMuonHits-glbNMuonHits);
770  }
771 
772  //must be global and tracker
773  if (iMuon->isGlobalMuon() && iMuon->isTrackerMuon()) {
774  commonME_->hTrkToGlbDiffNTrackerHitsEta_->Fill(Track->eta(),trkNTrackerHits-glbNTrackerHits);
775  commonME_->hTrkToGlbDiffNTrackerHitsPt_->Fill(Track->pt(),trkNTrackerHits-glbNTrackerHits);
776  commonME_->hTrkToGlbDiffNTrackerHits_->Fill(trkNTrackerHits-glbNTrackerHits);
777  }
778 
779  }//end of reco muon loop
780 
781  // Associate by hits
782  for(TrackingParticleCollection::size_type i=0; i<nSim; i++) {
783  TrackingParticleRef simRef(simHandle, i);
784  const TrackingParticle* simTP = simRef.get();
785  if ( ! tpSelector_(*simTP) ) continue;
786 
787  //denominators for efficiency plots
788  const double simP = simRef->p();
789  const double simPt = simRef->pt();
790  const double simEta = doAbsEta_ ? fabs(simRef->eta()) : simRef->eta();
791  const double simPhi = simRef->phi();
792 
793  GlobalPoint simVtx(simRef->vertex().x(), simRef->vertex().y(), simRef->vertex().z());
794  GlobalVector simMom(simRef->momentum().x(), simRef->momentum().y(), simRef->momentum().z());
795  const double simDxy = -simVtx.x()*sin(simPhi)+simVtx.y()*cos(simPhi);
796  const double simDz = simVtx.z() - (simVtx.x()*simMom.x()+simVtx.y()*simMom.y())*simMom.z()/simMom.perp2();
797 
798  const unsigned int nSimHits = simRef->pSimHit_end() - simRef->pSimHit_begin();
799 
800  muonME_->hSimP_ ->Fill(simP );
801  muonME_->hSimPt_ ->Fill(simPt );
802  muonME_->hSimEta_->Fill(simEta);
803  muonME_->hSimPhi_->Fill(simPhi);
804  muonME_->hSimDxy_->Fill(simDxy);
805  muonME_->hSimDz_->Fill(simDz);
806  muonME_->hNSimHits_->Fill(nSimHits);
807 
808  // Get sim-reco association for a simRef
809  vector<pair<RefToBase<Muon>, double> > MuRefV;
810  if ( simToMuonColl.find(simRef) != simToMuonColl.end() ) {
811  MuRefV = simToMuonColl[simRef];
812 
813  if ( !MuRefV.empty()) {
814  muonME_->hNSimToReco_->Fill(MuRefV.size());
815  const Muon* Mu = MuRefV.begin()->first.get();
816  if (!selector_(*Mu)) continue;
817 
818  reco::TrackRef muonTrack = Mu->track();
819 
820  if (muonTrack.isNonnull())
821  muonME_->fill(&*simTP, &*muonTrack);
822  }
823  }
824  }
825 }
int i
Definition: DBlmapReader.cc:9
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
void associateMuons(MuonToSimCollection &recoToSim, SimToMuonCollection &simToReco, const edm::RefToBaseVector< reco::Muon > &, MuonTrackType, const edm::RefVector< TrackingParticleCollection > &, const edm::Event *event=0, const edm::EventSetup *setup=0) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
edm::InputTag simLabel_
virtual TrackRef track() const
reference to a Track
Definition: Muon.h:39
StringCutObjectSelector< reco::Muon > selector_
virtual int countTrackerHits(const reco::Track &track) const
uint16_t size_type
void Fill(long long x)
TrackingParticleSelector tpSelector_
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:249
std::map< TrackingParticleRef, std::vector< std::pair< edm::RefToBase< reco::Muon >, double > > > SimToMuonCollection
double p() const
magnitude of momentum vector
Definition: ParticleBase.h:100
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
virtual int countMuonHits(const reco::Track &track) const
const MuonAssociatorByHits * assoByHits
edm::InputTag muonLabel_
MuonAssociatorByHits::MuonTrackType trackType_
size_type size() const
T const * product() const
Definition: Handle.h:74
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:60
const_iterator begin() const
const_iterator end() const
std::vector< TrackingParticle > TrackingParticleCollection
T x() const
Definition: PV3DBase.h:56
void fill(const TrackingParticle *simRef, const Track *recoRef)
std::map< edm::RefToBase< reco::Muon >, std::vector< std::pair< TrackingParticleRef, double > >, RefToBaseSort > MuonToSimCollection
edm::Ref< TrackingParticleCollection > TrackingParticleRef
void RecoMuonValidator::beginRun ( const edm::Run ,
const edm::EventSetup eventSetup 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 599 of file RecoMuonValidator.cc.

References assoByHits, doAssoc_, edm::hlt::Exception, edm::EventSetup::get(), edm::InputTag::label(), muAssocLabel_, edm::ESHandle< class >::product(), and theMuonService.

600 {
601  if ( theMuonService ) theMuonService->update(eventSetup);
602 
603  if ( doAssoc_ ) {
604  edm::ESHandle<TrackAssociatorBase> associatorBase;
605  eventSetup.get<TrackAssociatorRecord>().get(muAssocLabel_.label(), associatorBase);
606  assoByHits = dynamic_cast<const MuonAssociatorByHits *>(associatorBase.product());
607  if (assoByHits == 0) throw cms::Exception("Configuration") << "The Track Associator with label '" << muAssocLabel_.label() << "' is not a MuonAssociatorByHits.\n";
608  }
609 
610 }
MuonServiceProxy * theMuonService
edm::InputTag muAssocLabel_
const MuonAssociatorByHits * assoByHits
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
std::string const & label() const
Definition: InputTag.h:25
int RecoMuonValidator::countMuonHits ( const reco::Track track) const
virtual

Definition at line 828 of file RecoMuonValidator.cc.

References prof2calltree::count, DetId::det(), DetId::Muon, reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), and query::result.

Referenced by analyze().

828  {
830 
831  int count = 0;
832 
833  for (trackingRecHit_iterator hit = track.recHitsBegin(); hit != track.recHitsEnd(); ++hit) {
834  if((*hit)->isValid()) {
835  DetId recoid = (*hit)->geographicalId();
836  if ( recoid.det() == DetId::Muon ) count++;
837  }
838  }
839  return count;
840 }
tuple result
Definition: query.py:137
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:63
std::vector< ConstRecHitPointer > ConstRecHitContainer
Definition: DetId.h:20
Detector det() const
get the detector field from this detid
Definition: DetId.h:37
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:65
int RecoMuonValidator::countTrackerHits ( const reco::Track track) const
virtual

Definition at line 843 of file RecoMuonValidator.cc.

References prof2calltree::count, DetId::det(), reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), query::result, and DetId::Tracker.

Referenced by analyze().

843  {
845 
846  int count = 0;
847 
848  for (trackingRecHit_iterator hit = track.recHitsBegin(); hit != track.recHitsEnd(); ++hit) {
849  if((*hit)->isValid()) {
850  DetId recoid = (*hit)->geographicalId();
851  if ( recoid.det() == DetId::Tracker ) count++;
852  }
853  }
854  return count;
855 }
tuple result
Definition: query.py:137
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:63
std::vector< ConstRecHitPointer > ConstRecHitContainer
Definition: DetId.h:20
Detector det() const
get the detector field from this detid
Definition: DetId.h:37
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:65
void RecoMuonValidator::endRun ( void  )
virtual

Definition at line 615 of file RecoMuonValidator.cc.

References outputFileName_, DQMStore::save(), and theDQM.

616 {
617  if ( theDQM && ! outputFileName_.empty() ) theDQM->save(outputFileName_);
618 }
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:1898
std::string outputFileName_

Member Data Documentation

const MuonAssociatorByHits* RecoMuonValidator::assoByHits
protected

Definition at line 45 of file RecoMuonValidator.h.

Referenced by analyze(), and beginRun().

CommonME* RecoMuonValidator::commonME_
protected

Definition at line 64 of file RecoMuonValidator.h.

Referenced by analyze(), and RecoMuonValidator().

bool RecoMuonValidator::doAbsEta_
protected

Definition at line 53 of file RecoMuonValidator.h.

Referenced by analyze(), and RecoMuonValidator().

bool RecoMuonValidator::doAssoc_
protected

Definition at line 54 of file RecoMuonValidator.h.

Referenced by analyze(), beginRun(), and RecoMuonValidator().

edm::InputTag RecoMuonValidator::muAssocLabel_
protected

Definition at line 44 of file RecoMuonValidator.h.

Referenced by beginRun(), and RecoMuonValidator().

edm::InputTag RecoMuonValidator::muonLabel_
protected

Definition at line 41 of file RecoMuonValidator.h.

Referenced by analyze(), and RecoMuonValidator().

MuonME* RecoMuonValidator::muonME_
protected

Definition at line 61 of file RecoMuonValidator.h.

Referenced by analyze(), and RecoMuonValidator().

std::string RecoMuonValidator::muonSelection_
protected

Definition at line 42 of file RecoMuonValidator.h.

std::string RecoMuonValidator::outputFileName_
protected

Definition at line 47 of file RecoMuonValidator.h.

Referenced by endRun(), and RecoMuonValidator().

StringCutObjectSelector<reco::Muon> RecoMuonValidator::selector_
private

Definition at line 68 of file RecoMuonValidator.h.

Referenced by analyze().

edm::InputTag RecoMuonValidator::simLabel_
protected

Definition at line 40 of file RecoMuonValidator.h.

Referenced by analyze(), and RecoMuonValidator().

std::string RecoMuonValidator::subDir_
protected

Definition at line 48 of file RecoMuonValidator.h.

Referenced by RecoMuonValidator().

DQMStore* RecoMuonValidator::theDQM
protected

Definition at line 51 of file RecoMuonValidator.h.

Referenced by analyze(), endRun(), and RecoMuonValidator().

MuonServiceProxy* RecoMuonValidator::theMuonService
protected

Definition at line 50 of file RecoMuonValidator.h.

Referenced by beginRun(), RecoMuonValidator(), and ~RecoMuonValidator().

TrackingParticleSelector RecoMuonValidator::tpSelector_
protected

Definition at line 56 of file RecoMuonValidator.h.

Referenced by analyze(), and RecoMuonValidator().

MuonAssociatorByHits::MuonTrackType RecoMuonValidator::trackType_
protected

Definition at line 59 of file RecoMuonValidator.h.

Referenced by analyze(), and RecoMuonValidator().

unsigned int RecoMuonValidator::verbose_
protected

Definition at line 38 of file RecoMuonValidator.h.

Referenced by RecoMuonValidator().