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
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Protected Attributes

const MuonAssociatorByHitsassoByHits
 
edm::InputTag beamspotLabel_
 
CommonMEcommonME_
 
bool doAbsEta_
 
bool doAssoc_
 
edm::InputTag muAssocLabel_
 
edm::InputTag muonLabel_
 
MuonMEmuonME_
 
std::string muonSelection_
 
std::string outputFileName_
 
edm::InputTag primvertexLabel_
 
edm::InputTag simLabel_
 
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
 
typedef WorkerT< EDAnalyzerWorkerType
 
- 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::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- 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 25 of file RecoMuonValidator.h.

Constructor & Destructor Documentation

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

Definition at line 469 of file RecoMuonValidator.cc.

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

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

Definition at line 646 of file RecoMuonValidator.cc.

References theMuonService.

647 {
648  if ( theMuonService ) delete theMuonService;
649 }
MuonServiceProxy * theMuonService

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 678 of file RecoMuonValidator.cc.

References assoByHits, MuonAssociatorByHits::associateMuons(), beamspotLabel_, reco::BeamSpot::BeamWidthX(), reco::BeamSpot::BeamWidthY(), edm::View< T >::begin(), commonME_, funct::cos(), countMuonHits(), countTrackerHits(), doAbsEta_, doAssoc_, edm::View< T >::end(), 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, muonLabel_, muonME_, reco::BeamSpot::position(), position, primvertexLabel_, edm::Handle< T >::product(), edm::RefVector< C, T, F >::push_back(), selector_, reco::BeamSpot::sigmaZ(), simLabel_, funct::sin(), edm::View< T >::size(), theDQM, tpSelector_, trackType_, usePFMuon_, wantTightMuon_, and PV3DBase< T, PVType, FrameType >::x().

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

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

655 {
656  if ( theMuonService ) theMuonService->update(eventSetup);
657 
658  if ( doAssoc_ ) {
659  edm::ESHandle<TrackAssociatorBase> associatorBase;
660  eventSetup.get<TrackAssociatorRecord>().get(muAssocLabel_.label(), associatorBase);
661  assoByHits = dynamic_cast<const MuonAssociatorByHits *>(associatorBase.product());
662  if (assoByHits == 0) throw cms::Exception("Configuration") << "The Track Associator with label '" << muAssocLabel_.label() << "' is not a MuonAssociatorByHits.\n";
663  }
664 
665 }
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 926 of file RecoMuonValidator.cc.

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

Referenced by analyze().

926  {
928 
929  int count = 0;
930 
931  for (trackingRecHit_iterator hit = track.recHitsBegin(); hit != track.recHitsEnd(); ++hit) {
932  if((*hit)->isValid()) {
933  DetId recoid = (*hit)->geographicalId();
934  if ( recoid.det() == DetId::Muon ) count++;
935  }
936  }
937  return count;
938 }
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 941 of file RecoMuonValidator.cc.

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

Referenced by analyze().

941  {
943 
944  int count = 0;
945 
946  for (trackingRecHit_iterator hit = track.recHitsBegin(); hit != track.recHitsEnd(); ++hit) {
947  if((*hit)->isValid()) {
948  DetId recoid = (*hit)->geographicalId();
949  if ( recoid.det() == DetId::Tracker ) count++;
950  }
951  }
952  return count;
953 }
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 670 of file RecoMuonValidator.cc.

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

671 {
672  if ( theDQM && ! outputFileName_.empty() ) theDQM->save(outputFileName_);
673 }
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:2118
std::string outputFileName_

Member Data Documentation

const MuonAssociatorByHits* RecoMuonValidator::assoByHits
protected

Definition at line 45 of file RecoMuonValidator.h.

Referenced by analyze(), and beginRun().

edm::InputTag RecoMuonValidator::beamspotLabel_
protected

Definition at line 47 of file RecoMuonValidator.h.

Referenced by analyze(), and RecoMuonValidator().

CommonME* RecoMuonValidator::commonME_
protected

Definition at line 68 of file RecoMuonValidator.h.

Referenced by analyze(), and RecoMuonValidator().

bool RecoMuonValidator::doAbsEta_
protected

Definition at line 56 of file RecoMuonValidator.h.

Referenced by analyze(), and RecoMuonValidator().

bool RecoMuonValidator::doAssoc_
protected

Definition at line 57 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 65 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 50 of file RecoMuonValidator.h.

Referenced by endRun(), and RecoMuonValidator().

edm::InputTag RecoMuonValidator::primvertexLabel_
protected

Definition at line 48 of file RecoMuonValidator.h.

Referenced by analyze(), and RecoMuonValidator().

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

Definition at line 72 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 51 of file RecoMuonValidator.h.

Referenced by RecoMuonValidator().

DQMStore* RecoMuonValidator::theDQM
protected

Definition at line 54 of file RecoMuonValidator.h.

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

MuonServiceProxy* RecoMuonValidator::theMuonService
protected

Definition at line 53 of file RecoMuonValidator.h.

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

TrackingParticleSelector RecoMuonValidator::tpSelector_
protected

Definition at line 60 of file RecoMuonValidator.h.

Referenced by analyze(), and RecoMuonValidator().

MuonAssociatorByHits::MuonTrackType RecoMuonValidator::trackType_
protected

Definition at line 63 of file RecoMuonValidator.h.

Referenced by analyze(), and RecoMuonValidator().

bool RecoMuonValidator::usePFMuon_
protected

Definition at line 58 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().

bool RecoMuonValidator::wantTightMuon_
private

Definition at line 73 of file RecoMuonValidator.h.

Referenced by analyze(), and RecoMuonValidator().