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 edm::EDConsumerBase

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
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Protected Attributes

const MuonAssociatorByHitsassoByHits
 
edm::InputTag beamspotLabel_
 
edm::EDGetTokenT< reco::BeamSpotbeamspotToken_
 
CommonMEcommonME_
 
bool doAbsEta_
 
bool doAssoc_
 
edm::InputTag muAssocLabel_
 
edm::InputTag muonLabel_
 
MuonMEmuonME_
 
std::string muonSelection_
 
edm::EDGetTokenT< edm::View
< reco::Muon > > 
muonToken_
 
std::string outputFileName_
 
edm::InputTag primvertexLabel_
 
edm::EDGetTokenT
< reco::VertexCollection
primvertexToken_
 
edm::InputTag simLabel_
 
edm::EDGetTokenT
< TrackingParticleCollection
simToken_
 
std::string subDir_
 
DQMStoretheDQM
 
MuonServiceProxytheMuonService
 
TrackingParticleSelector tpSelector_
 
MuonAssociatorByHits::MuonTrackType trackType_
 
bool usePFMuon_
 
unsigned int verbose_
 

Private Attributes

StringCutObjectSelector
< reco::Muon
selector_
 
bool wantTightMuon_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 32 of file RecoMuonValidator.h.

Constructor & Destructor Documentation

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

Definition at line 462 of file RecoMuonValidator.cc.

References beamspotLabel_, beamspotToken_, 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, muonToken_, HistoDimensions::nBinP, cppFunctionSkipper::operator, MuonAssociatorByHits::OuterTk, outputFileName_, Pi, primvertexLabel_, primvertexToken_, MuonAssociatorByHits::Segments, DQMStore::setCurrentFolder(), DQMStore::showDirStructure(), simLabel_, simToken_, AlCaHLTBitMon_QueryRunRegistry::string, subDir_, theDQM, theMuonService, tpSelector_, trackType_, usePFMuon_, verbose_, and wantTightMuon_.

462  :
463  selector_(pset.getParameter<std::string>("selection"))
464 {
465 
466  verbose_ = pset.getUntrackedParameter<unsigned int>("verbose", 0);
467 
468  outputFileName_ = pset.getUntrackedParameter<string>("outputFileName", "");
469 
470  wantTightMuon_ = pset.getParameter<bool>("wantTightMuon");
471  beamspotLabel_ = pset.getParameter< edm::InputTag >("beamSpot");
472  primvertexLabel_ = pset.getParameter< edm::InputTag >("primaryVertex");
473  beamspotToken_ = consumes<reco::BeamSpot>(beamspotLabel_);
474  primvertexToken_ = consumes<reco::VertexCollection>(primvertexLabel_);
475 
476  // Set histogram dimensions from config
477  HistoDimensions hDim;
478 
479  hDim.nBinP = pset.getUntrackedParameter<unsigned int>("nBinP");
480  hDim.minP = pset.getUntrackedParameter<double>("minP");
481  hDim.maxP = pset.getUntrackedParameter<double>("maxP");
482 
483  hDim.nBinPt = pset.getUntrackedParameter<unsigned int>("nBinPt");
484  hDim.minPt = pset.getUntrackedParameter<double>("minPt");
485  hDim.maxPt = pset.getUntrackedParameter<double>("maxPt");
486 
487  doAbsEta_ = pset.getUntrackedParameter<bool>("doAbsEta");
488  hDim.doAbsEta = doAbsEta_;
489  hDim.nBinEta = pset.getUntrackedParameter<unsigned int>("nBinEta");
490  hDim.minEta = pset.getUntrackedParameter<double>("minEta");
491  hDim.maxEta = pset.getUntrackedParameter<double>("maxEta");
492 
493  hDim.nBinDxy = pset.getUntrackedParameter<unsigned int>("nBinDxy");
494  hDim.minDxy = pset.getUntrackedParameter<double>("minDxy");
495  hDim.maxDxy = pset.getUntrackedParameter<double>("maxDxy");
496 
497  hDim.nBinDz = pset.getUntrackedParameter<unsigned int>("nBinDz");
498  hDim.minDz = pset.getUntrackedParameter<double>("minDz");
499  hDim.maxDz = pset.getUntrackedParameter<double>("maxDz");
500 
501  hDim.nBinPhi = pset.getUntrackedParameter<unsigned int>("nBinPhi");
502  hDim.minPhi = pset.getUntrackedParameter<double>("minPhi", -TMath::Pi());
503  hDim.maxPhi = pset.getUntrackedParameter<double>("maxPhi", TMath::Pi());
504 
505  hDim.nBinErr = pset.getUntrackedParameter<unsigned int>("nBinErr");
506  hDim.nBinPull = pset.getUntrackedParameter<unsigned int>("nBinPull");
507 
508  hDim.wPull = pset.getUntrackedParameter<double>("wPull");
509 
510  hDim.minErrP = pset.getUntrackedParameter<double>("minErrP");
511  hDim.maxErrP = pset.getUntrackedParameter<double>("maxErrP");
512 
513  hDim.minErrPt = pset.getUntrackedParameter<double>("minErrPt");
514  hDim.maxErrPt = pset.getUntrackedParameter<double>("maxErrPt");
515 
516  hDim.minErrQPt = pset.getUntrackedParameter<double>("minErrQPt");
517  hDim.maxErrQPt = pset.getUntrackedParameter<double>("maxErrQPt");
518 
519  hDim.minErrEta = pset.getUntrackedParameter<double>("minErrEta");
520  hDim.maxErrEta = pset.getUntrackedParameter<double>("maxErrEta");
521 
522  hDim.minErrPhi = pset.getUntrackedParameter<double>("minErrPhi");
523  hDim.maxErrPhi = pset.getUntrackedParameter<double>("maxErrPhi");
524 
525  hDim.minErrDxy = pset.getUntrackedParameter<double>("minErrDxy");
526  hDim.maxErrDxy = pset.getUntrackedParameter<double>("maxErrDxy");
527 
528  hDim.minErrDz = pset.getUntrackedParameter<double>("minErrDz" );
529  hDim.maxErrDz = pset.getUntrackedParameter<double>("maxErrDz" );
530 
531  hDim.nTrks = pset.getUntrackedParameter<unsigned int>("nTrks");
532  hDim.nAssoc = pset.getUntrackedParameter<unsigned int>("nAssoc");
533  hDim.nDof = pset.getUntrackedParameter<unsigned int>("nDof", 55);
534 
535 
536  // Labels for simulation and reconstruction tracks
537  simLabel_ = pset.getParameter<InputTag>("simLabel" );
538  muonLabel_ = pset.getParameter<InputTag>("muonLabel");
539  simToken_ = consumes<TrackingParticleCollection>(simLabel_);
540  muonToken_ = consumes<edm::View<reco::Muon> >(muonLabel_);
541 
542  // Labels for sim-reco association
543  doAssoc_ = pset.getUntrackedParameter<bool>("doAssoc", true);
544  muAssocLabel_ = pset.getParameter<InputTag>("muAssocLabel");
545  // muAssocToken = consumes<>(muAssocLabel_);
546 
547 // Different momentum assignment and additional histos in case of PF muons
548  usePFMuon_ = pset.getUntrackedParameter<bool>("usePFMuon");
549  hDim.usePFMuon = usePFMuon_;
550 
551 
552 
553  //type of track
554  std::string trackType = pset.getParameter< std::string >("trackType");
555  if (trackType == "inner") trackType_ = MuonAssociatorByHits::InnerTk;
556  else if (trackType == "outer") trackType_ = MuonAssociatorByHits::OuterTk;
557  else if (trackType == "global") trackType_ = MuonAssociatorByHits::GlobalTk;
558  else if (trackType == "segments") trackType_ = MuonAssociatorByHits::Segments;
559  else throw cms::Exception("Configuration") << "Track type '" << trackType << "' not supported.\n";
560 
561 // seedPropagatorName_ = pset.getParameter<string>("SeedPropagator");
562 
563  ParameterSet tpset = pset.getParameter<ParameterSet>("tpSelector");
564  tpSelector_ = TrackingParticleSelector(tpset.getParameter<double>("ptMin"),
565  tpset.getParameter<double>("minRapidity"),
566  tpset.getParameter<double>("maxRapidity"),
567  tpset.getParameter<double>("tip"),
568  tpset.getParameter<double>("lip"),
569  tpset.getParameter<int>("minHit"),
570  tpset.getParameter<bool>("signalOnly"),
571  tpset.getParameter<bool>("chargedOnly"),
572  tpset.getParameter<bool>("stableOnly"),
573  tpset.getParameter<std::vector<int> >("pdgId"));
574 
575 
576  // the service parameters
577  ParameterSet serviceParameters
578  = pset.getParameter<ParameterSet>("ServiceParameters");
579  theMuonService = new MuonServiceProxy(serviceParameters);
580 
581  // retrieve the instance of DQMService
582  theDQM = 0;
584 
585  if ( ! theDQM ) {
586  LogError("RecoMuonValidator") << "DQMService not initialized\n";
587  return;
588  }
589 
590  subDir_ = pset.getUntrackedParameter<string>("subDir");
591  if ( subDir_.empty() ) subDir_ = "RecoMuonV";
592  if ( subDir_[subDir_.size()-1] == '/' ) subDir_.erase(subDir_.size()-1);
593 
594  // book histograms
595  theDQM->cd();
596 
598 
599  commonME_ = new CommonME;
600  muonME_ = new MuonME;
601 
602  //commonME
603  const int nHits = 100;
604 
605  // - diffs
606  commonME_->hTrkToGlbDiffNTrackerHits_ = theDQM->book1D("TrkGlbDiffNTrackerHits", "Difference of number of tracker hits (tkMuon - globalMuon)", 2*nHits+1, -nHits-0.5, nHits+0.5);
607  commonME_->hStaToGlbDiffNMuonHits_ = theDQM->book1D("StaGlbDiffNMuonHits", "Difference of number of muon hits (staMuon - globalMuon)", 2*nHits+1, -nHits-0.5, nHits+0.5);
608 
609  commonME_->hTrkToGlbDiffNTrackerHitsEta_ = theDQM->book2D("TrkGlbDiffNTrackerHitsEta", "Difference of number of tracker hits (tkMuon - globalMuon)", hDim.nBinEta, hDim.minEta, hDim.maxEta,2*nHits+1, -nHits-0.5, nHits+0.5);
610  commonME_->hStaToGlbDiffNMuonHitsEta_ = theDQM->book2D("StaGlbDiffNMuonHitsEta", "Difference of number of muon hits (staMuon - globalMuon)", hDim.nBinEta, hDim.minEta, hDim.maxEta,2*nHits+1, -nHits-0.5, nHits+0.5);
611 
612  commonME_->hTrkToGlbDiffNTrackerHitsPt_ = theDQM->book2D("TrkGlbDiffNTrackerHitsPt", "Difference of number of tracker hits (tkMuon - globalMuon)", hDim.nBinPt, hDim.minPt, hDim.maxPt,2*nHits+1, -nHits-0.5, nHits+0.5);
613  commonME_->hStaToGlbDiffNMuonHitsPt_ = theDQM->book2D("StaGlbDiffNMuonHitsPt", "Difference of number of muon hits (staMuon - globalMuon)", hDim.nBinPt, hDim.minPt, hDim.maxPt,2*nHits+1, -nHits-0.5, nHits+0.5);
614 
615  // -global muon hit pattern
616  commonME_->hNInvalidHitsGTHitPattern_ = theDQM->book1D("NInvalidHitsGTHitPattern", "Number of invalid hits on a global track", nHits+1, -0.5, nHits+0.5);
617  commonME_->hNInvalidHitsITHitPattern_ = theDQM->book1D("NInvalidHitsITHitPattern", "Number of invalid hits on an inner track", nHits+1, -0.5, nHits+0.5);
618  commonME_->hNInvalidHitsOTHitPattern_ = theDQM->book1D("NInvalidHitsOTHitPattern", "Number of invalid hits on an outer track", nHits+1, -0.5, nHits+0.5);
619  commonME_->hNDeltaInvalidHitsHitPattern_ = theDQM->book1D("hNDeltaInvalidHitsHitPattern", "The discrepancy for Number of invalid hits on an global track and inner and outer tracks", 2*nHits+1, -nHits-0.5, nHits+0.5);
620 
621  //muon based kinematics
622  commonME_->hMuonP_ = theDQM->book1D("PMuon" , "p of muon" , hDim.nBinP , hDim.minP , hDim.maxP );
623  commonME_->hMuonPt_ = theDQM->book1D("PtMuon" , "p_{T} of muon", hDim.nBinPt , hDim.minPt , hDim.maxPt );
624  commonME_->hMuonEta_ = theDQM->book1D("EtaMuon", "#eta of muon" , hDim.nBinEta, hDim.minEta, hDim.maxEta);
625  commonME_->hMuonPhi_ = theDQM->book1D("PhiMuon", "#phi of muon" , hDim.nBinPhi, hDim.minPhi, hDim.maxPhi);
626  //track based kinematics
627  commonME_->hMuonTrackP_ = theDQM->book1D("PMuonTrack" , "p of reco muon track" , hDim.nBinP , hDim.minP , hDim.maxP );
628  commonME_->hMuonTrackPt_ = theDQM->book1D("PtMuonTrack" , "p_{T} of reco muon track", hDim.nBinPt , hDim.minPt , hDim.maxPt );
629  commonME_->hMuonTrackEta_ = theDQM->book1D("EtaMuonTrack", "#eta of reco muon track" , hDim.nBinEta, hDim.minEta, hDim.maxEta);
630  commonME_->hMuonTrackPhi_ = theDQM->book1D("PhiMuonTrack", "#phi of reco muon track" , hDim.nBinPhi, hDim.minPhi, hDim.maxPhi);
631  commonME_->hMuonTrackDxy_ = theDQM->book1D("DxyMuonTrack", "Dxy of reco muon track" , hDim.nBinDxy, hDim.minDxy, hDim.maxDxy);
632  commonME_->hMuonTrackDz_ = theDQM->book1D("DzMuonTrack", "Dz of reco muon track" , hDim.nBinDz, hDim.minDz, hDim.maxDz);
633 
634  //histograms for fractions
635  commonME_->hMuonAllP_ = theDQM->book1D("PMuonAll" , "p of muons of all types" , hDim.nBinP , hDim.minP , hDim.maxP );
636  commonME_->hMuonAllPt_ = theDQM->book1D("PtMuonAll" , "p_{T} of muon of all types", hDim.nBinPt , hDim.minPt , hDim.maxPt );
637  commonME_->hMuonAllEta_ = theDQM->book1D("EtaMuonAll", "#eta of muon of all types" , hDim.nBinEta, hDim.minEta, hDim.maxEta);
638  commonME_->hMuonAllPhi_ = theDQM->book1D("PhiMuonAll", "#phi of muon of all types" , hDim.nBinPhi, hDim.minPhi, hDim.maxPhi);
639 
641 
642  if ( verbose_ > 0 ) theDQM->showDirStructure();
643 
644 }
const double Pi
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
edm::EDGetTokenT< TrackingParticleCollection > simToken_
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:873
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:562
edm::InputTag simLabel_
StringCutObjectSelector< reco::Muon > selector_
edm::EDGetTokenT< reco::VertexCollection > primvertexToken_
TrackingParticleSelector tpSelector_
SingleObjectSelector< TrackingParticleCollection,::TrackingParticleSelector > TrackingParticleSelector
MuonServiceProxy * theMuonService
edm::InputTag muAssocLabel_
std::string outputFileName_
edm::EDGetTokenT< reco::BeamSpot > beamspotToken_
unsigned int verbose_
edm::InputTag muonLabel_
MuonAssociatorByHits::MuonTrackType trackType_
unsigned int nBinP
edm::InputTag beamspotLabel_
edm::InputTag primvertexLabel_
void showDirStructure(void) const
Definition: DQMStore.cc:2962
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:1001
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:585
void bookHistograms(DQMStore *dqm, const string &dirName, const HistoDimensions &hDim)
RecoMuonValidator::~RecoMuonValidator ( )

Definition at line 649 of file RecoMuonValidator.cc.

References theMuonService.

650 {
651  if ( theMuonService ) delete theMuonService;
652 }
MuonServiceProxy * theMuonService

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 682 of file RecoMuonValidator.cc.

References assoByHits, MuonAssociatorByHits::associateMuons(), beamspotToken_, reco::BeamSpot::BeamWidthX(), reco::BeamSpot::BeamWidthY(), edm::View< T >::begin(), commonME_, funct::cos(), countMuonHits(), countTrackerHits(), doAbsEta_, doAssoc_, edm::View< T >::end(), relativeConstraints::error, 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(), muon::isTightMuon(), Mu, PatBasicFWLiteAnalyzer::muonEta, muonME_, PatBasicFWLiteAnalyzer::muonPhi, PatBasicFWLiteAnalyzer::muonPt, muonToken_, reco::BeamSpot::position(), position, primvertexToken_, edm::Handle< T >::product(), edm::RefVector< C, T, F >::push_back(), selector_, reco::BeamSpot::sigmaZ(), simToken_, funct::sin(), edm::View< T >::size(), theDQM, tpSelector_, trackType_, usePFMuon_, wantTightMuon_, and PV3DBase< T, PVType, FrameType >::x().

683 {
684  if ( ! theDQM ) {
685  LogError("RecoMuonValidator") << "DQMService not initialized\n";
686  return;
687  }
688 
689  // Look for the Primary Vertex (and use the BeamSpot instead, if you can't find it):
690  reco::Vertex::Point posVtx;
691  reco::Vertex::Error errVtx;
693  event.getByToken(primvertexToken_,recVtxs);
694  unsigned int theIndexOfThePrimaryVertex = 999.;
695  for (unsigned int ind=0; ind<recVtxs->size(); ++ind) {
696  if ( (*recVtxs)[ind].isValid() && !((*recVtxs)[ind].isFake()) ) {
697  theIndexOfThePrimaryVertex = ind;
698  break;
699  }
700  }
701  if (theIndexOfThePrimaryVertex<100) {
702  posVtx = ((*recVtxs)[theIndexOfThePrimaryVertex]).position();
703  errVtx = ((*recVtxs)[theIndexOfThePrimaryVertex]).error();
704  }
705  else {
706  LogInfo("RecoMuonValidator") << "reco::PrimaryVertex not found, use BeamSpot position instead\n";
707  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
708  event.getByToken(beamspotToken_,recoBeamSpotHandle);
709  reco::BeamSpot bs = *recoBeamSpotHandle;
710  posVtx = bs.position();
711  errVtx(0,0) = bs.BeamWidthX();
712  errVtx(1,1) = bs.BeamWidthY();
713  errVtx(2,2) = bs.sigmaZ();
714  }
715  const reco::Vertex thePrimaryVertex(posVtx,errVtx);
716 
717 
718  // Get TrackingParticles
720  event.getByToken(simToken_, simHandle);
721  const TrackingParticleCollection simColl = *(simHandle.product());
722 
723  // Get Muons
724  Handle<edm::View<Muon> > muonHandle;
725  event.getByToken(muonToken_, muonHandle);
726  View<Muon> muonColl = *(muonHandle.product());
727 
728  const TrackingParticleCollection::size_type nSim = simColl.size();
729 
731  Muons = muonHandle->refVector();
732 
734  for (size_t i = 0; i < nSim; ++i) {
735  allTPs.push_back(TrackingParticleRef(simHandle,i));
736  }
737 
738 
739  muonME_->hNSim_->Fill(nSim);
740  muonME_->hNMuon_->Fill(muonColl.size());
741 
744 
745 
746  if ( doAssoc_ ) {
747  assoByHits->associateMuons(muonToSimColl, simToMuonColl, Muons, trackType_, allTPs, &event, &eventSetup);
748  } else {
749 
750 /*
751  // SimToMuon associations
752  Handle<reco::RecoToSimCollection> simToTrkMuHandle;
753  event.getByLabel(trkMuAssocLabel_, simToTrkMuHandle);
754  trkSimRecColl = *(simToTrkMuHandle.product());
755 
756  Handle<reco::RecoToSimCollection> simToStaMuHandle;
757  event.getByLabel(staMuAssocLabel_, simToStaMuHandle);
758  staSimRecColl = *(simToStaMuHandle.product());
759 
760  Handle<reco::RecoToSimCollection> simToGlbMuHandle;
761  event.getByLabel(glbMuAssocLabel_, simToGlbMuHandle);
762  glbSimRecColl = *(simToGlbMuHandle.product());
763 
764  // MuonToSim associations
765  Handle<reco::SimToRecoCollection> trkMuToSimHandle;
766  event.getByLabel(trkMuAssocLabel_, trkMuToSimHandle);
767  trkRecSimColl = *(trkMuToSimHandle.product());
768 
769  Handle<reco::SimToRecoCollection> staMuToSimHandle;
770  event.getByLabel(staMuAssocLabel_, staMuToSimHandle);
771  staRecSimColl = *(staMuToSimHandle.product());
772 
773  Handle<reco::SimToRecoCollection> glbMuToSimHandle;
774  event.getByLabel(glbMuAssocLabel_, glbMuToSimHandle);
775  glbRecSimColl = *(glbMuToSimHandle.product());
776 */
777  }
778 
779 
780 
781  int glbNTrackerHits = 0; int trkNTrackerHits = 0;
782  int glbNMuonHits = 0; int staNMuonHits = 0;
783  int NTrackerHits = 0; int NMuonHits = 0;
784 
785 
786  // Analyzer reco::Muon
787  for(View<Muon>::const_iterator iMuon = muonColl.begin();
788  iMuon != muonColl.end(); ++iMuon) {
789 
790  double muonP, muonPt, muonEta, muonPhi;
791  if (usePFMuon_) {
792  muonP = iMuon->pfP4().P();
793  muonPt = iMuon->pfP4().Pt();
794  muonEta = iMuon->pfP4().Eta();
795  muonPhi = iMuon->pfP4().Phi();
796  }
797  else {
798  muonP = iMuon->p();
799  muonPt = iMuon->pt();
800  muonEta = iMuon->eta();
801  muonPhi = iMuon->phi();
802  }
803 
804  //histograms for fractions
805  commonME_->hMuonAllP_->Fill(muonP);
806  commonME_->hMuonAllPt_->Fill(muonPt);
807  commonME_->hMuonAllEta_->Fill(muonEta);
808  commonME_->hMuonAllPhi_->Fill(muonPhi);
809 
810  if (!selector_(*iMuon)) continue;
811  if (wantTightMuon_)
812  {
813  if (!muon::isTightMuon(*iMuon, thePrimaryVertex)) continue;
814  }
815 
816  TrackRef Track = iMuon->track();
817 
818  if (Track.isNonnull()) {
819  commonME_->hMuonTrackP_->Fill(Track->p());
820  commonME_->hMuonTrackPt_->Fill(Track->pt());
821  commonME_->hMuonTrackEta_->Fill(Track->eta());
822  commonME_->hMuonTrackPhi_->Fill(Track->phi());
823 
824  //ip histograms
825  commonME_->hMuonTrackDxy_->Fill(Track->dxy());
826  commonME_->hMuonTrackDz_->Fill(Track->dz());
827  }
828 
829  if (iMuon->isGlobalMuon()) {
830  Track = iMuon->combinedMuon();
831  glbNTrackerHits = countTrackerHits(*Track);
832  glbNMuonHits = countMuonHits(*Track);
833  } else if (iMuon->isTrackerMuon()) {
834  Track = iMuon->track();
835  trkNTrackerHits = countTrackerHits(*Track);
836  } else {
837  Track = iMuon->standAloneMuon();
838  }
839 
840  NTrackerHits = countTrackerHits(*Track);
841  muonME_->hNTrackerHits_->Fill(NTrackerHits);
842  muonME_->hNTrackerHits_vs_Pt_->Fill(Track->pt(), NTrackerHits);
843  muonME_->hNTrackerHits_vs_Eta_->Fill(Track->eta(), NTrackerHits);
844 
845  NMuonHits = countMuonHits(*Track);
846  muonME_->hNMuonHits_->Fill(NMuonHits);
847  muonME_->hNMuonHits_vs_Pt_->Fill(Track->pt(), NMuonHits);
848  muonME_->hNMuonHits_vs_Eta_->Fill(Track->eta(), NMuonHits);
849 
850 //list of histos for each type
851 
852 // muonME_->hNTrks_->Fill();
853  muonME_->hNTrksEta_->Fill(Track->eta());
854  muonME_->hNTrksPt_->Fill(Track->pt());
855 
856  commonME_->hMuonP_->Fill(muonP);
857  commonME_->hMuonPt_->Fill(muonPt);
858  commonME_->hMuonEta_->Fill(muonEta);
859  commonME_->hMuonPhi_->Fill(muonPhi);
860 
861  if (iMuon->isGlobalMuon()) {
862  double gtHitPat = iMuon->globalTrack()->hitPattern().numberOfHits() - iMuon->globalTrack()->hitPattern().numberOfValidHits();
863  double itHitPat = iMuon->innerTrack()->hitPattern().numberOfHits() - iMuon->innerTrack()->hitPattern().numberOfValidHits();
864  double otHitPat = iMuon->outerTrack()->hitPattern().numberOfHits() - iMuon->outerTrack()->hitPattern().numberOfValidHits();
865 
869  commonME_->hNDeltaInvalidHitsHitPattern_->Fill(gtHitPat - itHitPat - otHitPat);
870 
871  //must be global and standalone
872  if (iMuon->isStandAloneMuon()) {
873  commonME_->hStaToGlbDiffNMuonHitsEta_->Fill(Track->eta(),staNMuonHits-glbNMuonHits);
874  commonME_->hStaToGlbDiffNMuonHitsPt_->Fill(Track->pt(),staNMuonHits-glbNMuonHits);
875  commonME_->hStaToGlbDiffNMuonHits_->Fill(staNMuonHits-glbNMuonHits);
876  }
877 
878  //must be global and tracker
879  if (iMuon->isTrackerMuon()) {
880  commonME_->hTrkToGlbDiffNTrackerHitsEta_->Fill(Track->eta(),trkNTrackerHits-glbNTrackerHits);
881  commonME_->hTrkToGlbDiffNTrackerHitsPt_->Fill(Track->pt(),trkNTrackerHits-glbNTrackerHits);
882  commonME_->hTrkToGlbDiffNTrackerHits_->Fill(trkNTrackerHits-glbNTrackerHits);
883  }
884  }
885 
886  }//end of reco muon loop
887 
888 
889  // Associate by hits
890  for(TrackingParticleCollection::size_type i=0; i<nSim; i++) {
891  TrackingParticleRef simRef(simHandle, i);
892  const TrackingParticle* simTP = simRef.get();
893  if ( ! tpSelector_(*simTP) ) continue;
894 
895  //denominators for efficiency plots
896  const double simP = simRef->p();
897  const double simPt = simRef->pt();
898  const double simEta = doAbsEta_ ? fabs(simRef->eta()) : simRef->eta();
899  const double simPhi = simRef->phi();
900 
901  GlobalPoint simVtx(simRef->vertex().x(), simRef->vertex().y(), simRef->vertex().z());
902  GlobalVector simMom(simRef->momentum().x(), simRef->momentum().y(), simRef->momentum().z());
903  const double simDxy = -simVtx.x()*sin(simPhi)+simVtx.y()*cos(simPhi);
904  const double simDz = simVtx.z() - (simVtx.x()*simMom.x()+simVtx.y()*simMom.y())*simMom.z()/simMom.perp2();
905 
906  const unsigned int nSimHits = simRef->numberOfHits();
907 
908  muonME_->hSimP_ ->Fill(simP );
909  muonME_->hSimPt_ ->Fill(simPt );
910  muonME_->hSimEta_->Fill(simEta);
911  muonME_->hSimPhi_->Fill(simPhi);
912  muonME_->hSimDxy_->Fill(simDxy);
913  muonME_->hSimDz_->Fill(simDz);
914  muonME_->hNSimHits_->Fill(nSimHits);
915 
916  // Get sim-reco association for a simRef
917  vector<pair<RefToBase<Muon>, double> > MuRefV;
918  if ( simToMuonColl.find(simRef) != simToMuonColl.end() ) {
919  MuRefV = simToMuonColl[simRef];
920 
921  if ( !MuRefV.empty()) {
922  muonME_->hNSimToReco_->Fill(MuRefV.size());
923  const Muon* Mu = MuRefV.begin()->first.get();
924  if (!selector_(*Mu)) continue;
925  if (wantTightMuon_)
926  {
927  if (!muon::isTightMuon(*Mu, thePrimaryVertex)) continue;
928  }
929 
930  muonME_->fill(&*simTP, Mu);
931  }
932  }
933  }
934 }
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
edm::EDGetTokenT< TrackingParticleCollection > simToken_
int i
Definition: DBlmapReader.cc:9
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
std::vector< TrackingParticle > TrackingParticleCollection
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
StringCutObjectSelector< reco::Muon > selector_
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
edm::EDGetTokenT< reco::VertexCollection > primvertexToken_
virtual int countTrackerHits(const reco::Track &track) const
uint16_t size_type
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
void Fill(long long x)
TrackingParticleSelector tpSelector_
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
std::map< TrackingParticleRef, std::vector< std::pair< edm::RefToBase< reco::Muon >, double > > > SimToMuonCollection
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
virtual int countMuonHits(const reco::Track &track) const
const MuonAssociatorByHits * assoByHits
edm::EDGetTokenT< reco::BeamSpot > beamspotToken_
double p() const
Magnitude of momentum vector. Note this is taken from the first SimTrack only.
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
double BeamWidthX() const
beam width X
Definition: BeamSpot.h:86
MuonAssociatorByHits::MuonTrackType trackType_
void fill(const TrackingParticle *simRef, const Muon *muonRef)
Definition: L1GtObject.h:30
double sigmaZ() const
sigma z
Definition: BeamSpot.h:80
double BeamWidthY() const
beam width Y
Definition: BeamSpot.h:88
size_type size() const
T const * product() const
Definition: Handle.h:81
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:64
Monte Carlo truth information used for tracking validation.
const_iterator begin() const
const Point & position() const
position
Definition: BeamSpot.h:62
const_iterator end() const
bool isTightMuon(const reco::Muon &, const reco::Vertex &)
T x() const
Definition: PV3DBase.h:62
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 658 of file RecoMuonValidator.cc.

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

659 {
660  if ( theMuonService ) theMuonService->update(eventSetup);
661 
662  if ( doAssoc_ ) {
663  edm::ESHandle<TrackAssociatorBase> associatorBase;
664  eventSetup.get<TrackAssociatorRecord>().get(muAssocLabel_.label(), associatorBase);
665  assoByHits = dynamic_cast<const MuonAssociatorByHits *>(associatorBase.product());
666  if (assoByHits == 0) throw cms::Exception("Configuration") << "The Track Associator with label '" << muAssocLabel_.label() << "' is not a MuonAssociatorByHits.\n";
667  }
668 
669 }
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:42
int RecoMuonValidator::countMuonHits ( const reco::Track track) const
virtual

Definition at line 937 of file RecoMuonValidator.cc.

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

Referenced by analyze().

937  {
939 
940  int count = 0;
941 
942  for (trackingRecHit_iterator hit = track.recHitsBegin(); hit != track.recHitsEnd(); ++hit) {
943  if((*hit)->isValid()) {
944  DetId recoid = (*hit)->geographicalId();
945  if ( recoid.det() == DetId::Muon ) count++;
946  }
947  }
948  return count;
949 }
tuple result
Definition: query.py:137
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:62
std::vector< ConstRecHitPointer > ConstRecHitContainer
Definition: DetId.h:18
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:64
int RecoMuonValidator::countTrackerHits ( const reco::Track track) const
virtual

Definition at line 952 of file RecoMuonValidator.cc.

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

Referenced by analyze().

952  {
954 
955  int count = 0;
956 
957  for (trackingRecHit_iterator hit = track.recHitsBegin(); hit != track.recHitsEnd(); ++hit) {
958  if((*hit)->isValid()) {
959  DetId recoid = (*hit)->geographicalId();
960  if ( recoid.det() == DetId::Tracker ) count++;
961  }
962  }
963  return count;
964 }
tuple result
Definition: query.py:137
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:62
std::vector< ConstRecHitPointer > ConstRecHitContainer
Definition: DetId.h:18
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:64
void RecoMuonValidator::endRun ( void  )
virtual

Definition at line 674 of file RecoMuonValidator.cc.

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

675 {
676  if ( theDQM && ! outputFileName_.empty() ) theDQM->save(outputFileName_);
677 }
std::string outputFileName_
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2297

Member Data Documentation

const MuonAssociatorByHits* RecoMuonValidator::assoByHits
protected

Definition at line 54 of file RecoMuonValidator.h.

Referenced by analyze(), and beginRun().

edm::InputTag RecoMuonValidator::beamspotLabel_
protected

Definition at line 57 of file RecoMuonValidator.h.

Referenced by RecoMuonValidator().

edm::EDGetTokenT<reco::BeamSpot> RecoMuonValidator::beamspotToken_
protected

Definition at line 59 of file RecoMuonValidator.h.

Referenced by analyze(), and RecoMuonValidator().

CommonME* RecoMuonValidator::commonME_
protected

Definition at line 80 of file RecoMuonValidator.h.

Referenced by analyze(), and RecoMuonValidator().

bool RecoMuonValidator::doAbsEta_
protected

Definition at line 68 of file RecoMuonValidator.h.

Referenced by analyze(), and RecoMuonValidator().

bool RecoMuonValidator::doAssoc_
protected

Definition at line 69 of file RecoMuonValidator.h.

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

edm::InputTag RecoMuonValidator::muAssocLabel_
protected

Definition at line 53 of file RecoMuonValidator.h.

Referenced by beginRun(), and RecoMuonValidator().

edm::InputTag RecoMuonValidator::muonLabel_
protected

Definition at line 48 of file RecoMuonValidator.h.

Referenced by RecoMuonValidator().

MuonME* RecoMuonValidator::muonME_
protected

Definition at line 77 of file RecoMuonValidator.h.

Referenced by analyze(), and RecoMuonValidator().

std::string RecoMuonValidator::muonSelection_
protected

Definition at line 49 of file RecoMuonValidator.h.

edm::EDGetTokenT<edm::View<reco::Muon> > RecoMuonValidator::muonToken_
protected

Definition at line 51 of file RecoMuonValidator.h.

Referenced by analyze(), and RecoMuonValidator().

std::string RecoMuonValidator::outputFileName_
protected

Definition at line 62 of file RecoMuonValidator.h.

Referenced by endRun(), and RecoMuonValidator().

edm::InputTag RecoMuonValidator::primvertexLabel_
protected

Definition at line 58 of file RecoMuonValidator.h.

Referenced by RecoMuonValidator().

edm::EDGetTokenT<reco::VertexCollection> RecoMuonValidator::primvertexToken_
protected

Definition at line 60 of file RecoMuonValidator.h.

Referenced by analyze(), and RecoMuonValidator().

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

Definition at line 84 of file RecoMuonValidator.h.

Referenced by analyze().

edm::InputTag RecoMuonValidator::simLabel_
protected

Definition at line 47 of file RecoMuonValidator.h.

Referenced by RecoMuonValidator().

edm::EDGetTokenT<TrackingParticleCollection> RecoMuonValidator::simToken_
protected

Definition at line 50 of file RecoMuonValidator.h.

Referenced by analyze(), and RecoMuonValidator().

std::string RecoMuonValidator::subDir_
protected

Definition at line 63 of file RecoMuonValidator.h.

Referenced by RecoMuonValidator().

DQMStore* RecoMuonValidator::theDQM
protected

Definition at line 66 of file RecoMuonValidator.h.

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

MuonServiceProxy* RecoMuonValidator::theMuonService
protected

Definition at line 65 of file RecoMuonValidator.h.

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

TrackingParticleSelector RecoMuonValidator::tpSelector_
protected

Definition at line 72 of file RecoMuonValidator.h.

Referenced by analyze(), and RecoMuonValidator().

MuonAssociatorByHits::MuonTrackType RecoMuonValidator::trackType_
protected

Definition at line 75 of file RecoMuonValidator.h.

Referenced by analyze(), and RecoMuonValidator().

bool RecoMuonValidator::usePFMuon_
protected

Definition at line 70 of file RecoMuonValidator.h.

Referenced by analyze(), and RecoMuonValidator().

unsigned int RecoMuonValidator::verbose_
protected

Definition at line 45 of file RecoMuonValidator.h.

Referenced by RecoMuonValidator().

bool RecoMuonValidator::wantTightMuon_
private

Definition at line 85 of file RecoMuonValidator.h.

Referenced by analyze(), and RecoMuonValidator().