CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
GlbMuQualityCutsAnalysis Class Reference
Inheritance diagram for GlbMuQualityCutsAnalysis:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
 GlbMuQualityCutsAnalysis (const edm::ParameterSet &cfg)
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

double chi2Cut_
 
double etaMax_
 
double etaMin_
 
TH1D * h_GlbMuChi2_
 
TH1D * h_GlbMuDxy_
 
TH1D * h_GlbMuNofHitsGlbMu_
 
TH1D * h_TrkMuNofHitsGlbMu_
 
double massMax_
 
double massMin_
 
std::vector< unsigned int > matched_
 
int nHitCut_
 
double ptMin_
 
edm::InputTag src_
 
edm::EDGetTokenT< reco::CandidateViewsrcToken_
 
double trkIso_
 
std::vector< unsigned int > unMatched_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 8 of file GlbMuQualityCutsAnalysis.cc.

Constructor & Destructor Documentation

◆ GlbMuQualityCutsAnalysis()

GlbMuQualityCutsAnalysis::GlbMuQualityCutsAnalysis ( const edm::ParameterSet cfg)

Definition at line 35 of file GlbMuQualityCutsAnalysis.cc.

36  : src_(cfg.getParameter<InputTag>("src")),
37  srcToken_(consumes<CandidateView>(src_)),
38  ptMin_(cfg.getUntrackedParameter<double>("ptMin")),
39  massMin_(cfg.getUntrackedParameter<double>("massMin")),
40  massMax_(cfg.getUntrackedParameter<double>("massMax")),
41  etaMin_(cfg.getUntrackedParameter<double>("etaMin")),
42  etaMax_(cfg.getUntrackedParameter<double>("etaMax")),
43  trkIso_(cfg.getUntrackedParameter<double>("trkIso")),
44  chi2Cut_(cfg.getUntrackedParameter<double>("chi2Cut")),
45  nHitCut_(cfg.getUntrackedParameter<int>("nHitCut")) {
47  TFileDirectory trackEffDir = fs->mkdir("QualityOfGlbMu");
48  h_GlbMuNofHitsGlbMu_ = trackEffDir.make<TH1D>("# of Hits of GlobalMuon", "# of Hits of GlobalMuon", 100, 0, 100);
49  h_TrkMuNofHitsGlbMu_ = trackEffDir.make<TH1D>("# of Hits of TrackerMuon", "# of Hits of TrackerMuon", 100, 0, 100);
50  h_GlbMuChi2_ = trackEffDir.make<TH1D>("chi2 of GlobalMuon", "chi2 of GlobalMuon", 100, 0, 10);
51  h_GlbMuDxy_ = trackEffDir.make<TH1D>("Dxy of GlobalMuon", "Dxy of GlobalMuon", 1000, -5., 5.);
52 }

References h_GlbMuChi2_, h_GlbMuDxy_, h_GlbMuNofHitsGlbMu_, h_TrkMuNofHitsGlbMu_, TFileDirectory::make(), and TFileService::mkdir().

Member Function Documentation

◆ analyze()

void GlbMuQualityCutsAnalysis::analyze ( const edm::Event evt,
const edm::EventSetup  
)
overridevirtual

Implements edm::EDAnalyzer.

Definition at line 59 of file GlbMuQualityCutsAnalysis.cc.

59  {
61  evt.getByToken(srcToken_, src);
62  int j = 0;
63  cout << ">> entries in " << src_ << ": " << src->size() << endl;
64  for (CandidateView::const_iterator i = src->begin(); i != src->end(); ++i) {
65  j++;
66  const Candidate* dau1 = i->daughter(0);
67  const Candidate* dau2 = i->daughter(1);
68  if (dau1 == nullptr || dau2 == nullptr)
69  throw Exception(errors::InvalidReference) << "one of the two daughter does not exist\n";
70  const Candidate* c1 = dau1->masterClone().get();
71  GenParticleRef mc1;
72  const pat::Muon* mu1 = dynamic_cast<const pat::Muon*>(c1);
73  std::cout << " dimuon mass " << i->mass() << std::endl;
74  std::cout << "dau1.pt() " << dau1->pt() << std::endl;
75  std::cout << "dau2.pt() " << dau2->pt() << std::endl;
76  std::cout << "dau1.isGlobalMuon() " << dau1->isGlobalMuon() << std::endl;
77  std::cout << "dau2.isGlobalMuon() " << dau2->isGlobalMuon() << std::endl;
78  std::cout << "dau1.isTrackerMuon() " << dau1->isTrackerMuon() << std::endl;
79  std::cout << "dau2.isTrackerlMuon() " << dau2->isTrackerMuon() << std::endl;
80  std::cout << "dau1.isStandAloneMuon() " << dau1->isStandAloneMuon() << std::endl;
81  std::cout << "dau2.isStandAloneMuon() " << dau2->isStandAloneMuon() << std::endl;
82  std::cout << "dau1.charge() " << dau1->charge() << std::endl;
83  std::cout << "dau2.charge() " << dau2->charge() << std::endl;
84  if (mu1 != nullptr) {
85  // if (mc1.isNonnull()) cout << "GlbMuQualityCutsAnalysis> genParticleRef1 " << mc1->pdgId() << endl;
86  // double trackIso1=mu1->trackIso();
87  // std::cout << " mu1 iso" << trackIso1 << std::endl;
88  } else {
89  const pat::GenericParticle* gp1 = dynamic_cast<const pat::GenericParticle*>(c1);
90  if (gp1 == nullptr)
92  << "first of two daughter is neither a pat::Muon not pat::GenericParticle\n";
93  }
94  const Candidate* c2 = dau2->masterClone().get();
95 
96  const pat::Muon* mu2 = dynamic_cast<const pat::Muon*>(c2);
97  if (mu2 != nullptr) {
98  // double trackIso2=mu2->trackIso();
99  //std::cout << " mu2 iso" << trackIso2 << std::endl;
100  } else {
101  const pat::GenericParticle* gp2 = dynamic_cast<const pat::GenericParticle*>(c2);
102  if (gp2 == nullptr)
104  << "first of two daughter is neither a pat::Muon not pat::GenericParticle\n";
105  }
106 
107  int nOfHit_1 = 0, nOfHit_tk_1 = 0, nOfHit_2 = 0, nOfHit_tk_2 = 0;
108  if (mu1->isGlobalMuon())
109  nOfHit_1 = mu1->numberOfValidHits();
110  std::cout << "n of hit of GlbMu1: " << nOfHit_1 << std::endl;
111  if (mu1->isTrackerMuon())
112  nOfHit_tk_1 = mu1->innerTrack()->numberOfValidHits();
113  std::cout << "n of hit of TrkMu1: " << nOfHit_tk_1 << std::endl;
114  if (mu2->isGlobalMuon())
115  nOfHit_2 = mu2->numberOfValidHits();
116  std::cout << "n of hit of GlbMu2: " << nOfHit_2 << std::endl;
117  if (mu2->isTrackerMuon())
118  nOfHit_tk_2 = mu2->innerTrack()->numberOfValidHits();
119  std::cout << "n of hit of TrkMu2: " << nOfHit_tk_2 << std::endl;
120  h_GlbMuNofHitsGlbMu_->Fill(nOfHit_1);
121  h_GlbMuNofHitsGlbMu_->Fill(nOfHit_2);
122  h_TrkMuNofHitsGlbMu_->Fill(nOfHit_tk_1);
123  h_TrkMuNofHitsGlbMu_->Fill(nOfHit_tk_2);
124  double nChi2_1 = 0, nChi2_2 = 0;
125  if (mu1->isGlobalMuon())
126  nChi2_1 = mu1->normChi2();
127  std::cout << "chi2 of GlbMu1: " << nChi2_1 << std::endl;
128  if (mu2->isGlobalMuon())
129  nChi2_2 = mu2->normChi2();
130  std::cout << "chi2 of GlbMu2: " << nChi2_2 << std::endl;
131  h_GlbMuChi2_->Fill(nChi2_1);
132  h_GlbMuChi2_->Fill(nChi2_2);
133  double dxy_1 = mu1->dB();
134  double dxy_2 = mu2->dB();
135 
136  h_GlbMuDxy_->Fill(dxy_1);
137  h_GlbMuDxy_->Fill(dxy_2);
138  if (mu1->isGlobalMuon() && (nOfHit_tk_1 < nHitCut_)) {
139  std::cout << "found a GlbMuon with nOfHit " << nOfHit_tk_1 << ", it has eta: " << mu1->eta() << std::endl;
140  }
141  if (mu2->isGlobalMuon() && (nOfHit_tk_2 < nHitCut_)) {
142  std::cout << "found a GlbMuon with nOfHit " << nOfHit_tk_2 << ", it has eta: " << mu2->eta() << std::endl;
143  }
144  if (mu1->isGlobalMuon() && (nChi2_1 > chi2Cut_)) {
145  std::cout << "found a GlbMuon with chi2 " << nChi2_1
146  << ", it has chi2 of track: " << mu1->innerTrack()->normalizedChi2()
147  << ", and chi2 of Sta: " << mu1->outerTrack()->normalizedChi2() << ", eta: " << mu1->eta()
148  << ",pt: " << mu1->pt() << std::endl;
149  }
150  if (mu2->isGlobalMuon() && (nChi2_2 > chi2Cut_)) {
151  std::cout << "found a GlbMuon with chi2 " << nChi2_2
152  << ", it has chi2 of track: " << mu2->innerTrack()->normalizedChi2()
153  << ", and chi2 of Sta: " << mu2->outerTrack()->normalizedChi2() << ", eta: " << mu2->eta()
154  << ",pt: " << mu2->pt() << std::endl;
155  }
156  }
157 }

References alignmentValidation::c1, reco::Candidate::charge(), chi2Cut_, gather_cfg::cout, pat::Muon::dB(), reco::LeafCandidate::eta(), Exception, edm::RefToBase< T >::get(), edm::Event::getByToken(), h_GlbMuChi2_, h_GlbMuDxy_, h_GlbMuNofHitsGlbMu_, h_TrkMuNofHitsGlbMu_, mps_fire::i, pat::Muon::innerTrack(), edm::errors::InvalidReference, reco::Candidate::isGlobalMuon(), reco::Muon::isGlobalMuon(), reco::Candidate::isStandAloneMuon(), reco::Candidate::isTrackerMuon(), reco::Muon::isTrackerMuon(), dqmiolumiharvest::j, reco::Candidate::masterClone(), nHitCut_, pat::Muon::normChi2(), pat::Muon::numberOfValidHits(), pat::Muon::outerTrack(), reco::Candidate::pt(), reco::LeafCandidate::pt(), TrackRefitter_38T_cff::src, src_, and srcToken_.

Member Data Documentation

◆ chi2Cut_

double GlbMuQualityCutsAnalysis::chi2Cut_
private

Definition at line 17 of file GlbMuQualityCutsAnalysis.cc.

Referenced by analyze().

◆ etaMax_

double GlbMuQualityCutsAnalysis::etaMax_
private

Definition at line 17 of file GlbMuQualityCutsAnalysis.cc.

◆ etaMin_

double GlbMuQualityCutsAnalysis::etaMin_
private

Definition at line 17 of file GlbMuQualityCutsAnalysis.cc.

◆ h_GlbMuChi2_

TH1D * GlbMuQualityCutsAnalysis::h_GlbMuChi2_
private

Definition at line 19 of file GlbMuQualityCutsAnalysis.cc.

Referenced by analyze(), and GlbMuQualityCutsAnalysis().

◆ h_GlbMuDxy_

TH1D * GlbMuQualityCutsAnalysis::h_GlbMuDxy_
private

Definition at line 19 of file GlbMuQualityCutsAnalysis.cc.

Referenced by analyze(), and GlbMuQualityCutsAnalysis().

◆ h_GlbMuNofHitsGlbMu_

TH1D* GlbMuQualityCutsAnalysis::h_GlbMuNofHitsGlbMu_
private

Definition at line 19 of file GlbMuQualityCutsAnalysis.cc.

Referenced by analyze(), and GlbMuQualityCutsAnalysis().

◆ h_TrkMuNofHitsGlbMu_

TH1D * GlbMuQualityCutsAnalysis::h_TrkMuNofHitsGlbMu_
private

Definition at line 19 of file GlbMuQualityCutsAnalysis.cc.

Referenced by analyze(), and GlbMuQualityCutsAnalysis().

◆ massMax_

double GlbMuQualityCutsAnalysis::massMax_
private

Definition at line 17 of file GlbMuQualityCutsAnalysis.cc.

◆ massMin_

double GlbMuQualityCutsAnalysis::massMin_
private

Definition at line 17 of file GlbMuQualityCutsAnalysis.cc.

◆ matched_

std::vector<unsigned int> GlbMuQualityCutsAnalysis::matched_
private

Definition at line 16 of file GlbMuQualityCutsAnalysis.cc.

◆ nHitCut_

int GlbMuQualityCutsAnalysis::nHitCut_
private

Definition at line 18 of file GlbMuQualityCutsAnalysis.cc.

Referenced by analyze().

◆ ptMin_

double GlbMuQualityCutsAnalysis::ptMin_
private

Definition at line 17 of file GlbMuQualityCutsAnalysis.cc.

◆ src_

edm::InputTag GlbMuQualityCutsAnalysis::src_
private

Definition at line 14 of file GlbMuQualityCutsAnalysis.cc.

Referenced by analyze().

◆ srcToken_

edm::EDGetTokenT<reco::CandidateView> GlbMuQualityCutsAnalysis::srcToken_
private

Definition at line 15 of file GlbMuQualityCutsAnalysis.cc.

Referenced by analyze().

◆ trkIso_

double GlbMuQualityCutsAnalysis::trkIso_
private

Definition at line 17 of file GlbMuQualityCutsAnalysis.cc.

◆ unMatched_

std::vector<unsigned int> GlbMuQualityCutsAnalysis::unMatched_
private

Definition at line 16 of file GlbMuQualityCutsAnalysis.cc.

pat::Muon::normChi2
double normChi2() const
Norm chi2 gives the normalized chi2 of the global track.
GlbMuQualityCutsAnalysis::h_GlbMuDxy_
TH1D * h_GlbMuDxy_
Definition: GlbMuQualityCutsAnalysis.cc:19
mps_fire.i
i
Definition: mps_fire.py:428
GlbMuQualityCutsAnalysis::massMax_
double massMax_
Definition: GlbMuQualityCutsAnalysis.cc:17
edm::errors::InvalidReference
Definition: EDMException.h:39
GlbMuQualityCutsAnalysis::srcToken_
edm::EDGetTokenT< reco::CandidateView > srcToken_
Definition: GlbMuQualityCutsAnalysis.cc:15
GlbMuQualityCutsAnalysis::h_GlbMuChi2_
TH1D * h_GlbMuChi2_
Definition: GlbMuQualityCutsAnalysis.cc:19
TFileDirectory::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileDirectory.h:53
gather_cfg.cout
cout
Definition: gather_cfg.py:144
reco::Candidate::pt
virtual double pt() const =0
transverse momentum
TFileDirectory
Definition: TFileDirectory.h:24
reco::LeafCandidate::pt
double pt() const final
transverse momentum
Definition: LeafCandidate.h:146
pat::Muon
Analysis-level muon class.
Definition: Muon.h:51
pat::Muon::dB
double dB(IPTYPE type) const
edm::Handle
Definition: AssociativeIterator.h:50
edm::Ref< GenParticleCollection >
reco::Candidate::charge
virtual int charge() const =0
electric charge
reco::Candidate::isStandAloneMuon
virtual bool isStandAloneMuon() const =0
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:531
edm::RefToBase::get
value_type const * get() const
Definition: RefToBase.h:209
pat::Muon::numberOfValidHits
unsigned int numberOfValidHits() const
numberOfValidHits returns the number of valid hits on the global track.
GlbMuQualityCutsAnalysis::etaMax_
double etaMax_
Definition: GlbMuQualityCutsAnalysis.cc:17
reco::Muon::isGlobalMuon
bool isGlobalMuon() const override
Definition: Muon.h:299
pat::Muon::outerTrack
reco::TrackRef outerTrack() const override
reference to Track reconstructed in the muon detector only (reimplemented from reco::Muon)
Definition: Muon.h:76
TFileService::mkdir
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
Definition: TFileService.h:69
pat::GenericParticle
Analysis-level Generic Particle class (e.g. for hadron or muon not fully reconstructed)
Definition: GenericParticle.h:38
TrackRefitter_38T_cff.src
src
Definition: TrackRefitter_38T_cff.py:24
reco::LeafCandidate::eta
double eta() const final
momentum pseudorapidity
Definition: LeafCandidate.h:152
GlbMuQualityCutsAnalysis::h_GlbMuNofHitsGlbMu_
TH1D * h_GlbMuNofHitsGlbMu_
Definition: GlbMuQualityCutsAnalysis.cc:19
edm::Service< TFileService >
alignmentValidation.c1
c1
do drawing
Definition: alignmentValidation.py:1025
GlbMuQualityCutsAnalysis::massMin_
double massMin_
Definition: GlbMuQualityCutsAnalysis.cc:17
looper.cfg
cfg
Definition: looper.py:297
reco::Candidate
Definition: Candidate.h:27
GlbMuQualityCutsAnalysis::ptMin_
double ptMin_
Definition: GlbMuQualityCutsAnalysis.cc:17
GlbMuQualityCutsAnalysis::nHitCut_
int nHitCut_
Definition: GlbMuQualityCutsAnalysis.cc:18
reco::Muon::isTrackerMuon
bool isTrackerMuon() const override
Definition: Muon.h:300
GlbMuQualityCutsAnalysis::chi2Cut_
double chi2Cut_
Definition: GlbMuQualityCutsAnalysis.cc:17
Exception
Definition: hltDiff.cc:246
GlbMuQualityCutsAnalysis::etaMin_
double etaMin_
Definition: GlbMuQualityCutsAnalysis.cc:17
GlbMuQualityCutsAnalysis::trkIso_
double trkIso_
Definition: GlbMuQualityCutsAnalysis.cc:17
reco::Candidate::masterClone
virtual const CandidateBaseRef & masterClone() const =0
reco::Candidate::isTrackerMuon
virtual bool isTrackerMuon() const =0
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
GlbMuQualityCutsAnalysis::src_
edm::InputTag src_
Definition: GlbMuQualityCutsAnalysis.cc:14
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
pat::Muon::innerTrack
reco::TrackRef innerTrack() const override
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon)
Definition: Muon.h:72
reco::Candidate::isGlobalMuon
virtual bool isGlobalMuon() const =0
edm::InputTag
Definition: InputTag.h:15
GlbMuQualityCutsAnalysis::h_TrkMuNofHitsGlbMu_
TH1D * h_TrkMuNofHitsGlbMu_
Definition: GlbMuQualityCutsAnalysis.cc:19