CMS 3D CMS Logo

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

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
 DimuonStatistics (const edm::ParameterSet &cfg)
 
void endJob () override
 
- 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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 etaMax_
 
double etaMin_
 
double massMax_
 
double massMin_
 
std::vector< unsigned int > matched_
 
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 wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 7 of file DimuonStatistics.cc.

Constructor & Destructor Documentation

DimuonStatistics::DimuonStatistics ( const edm::ParameterSet cfg)

Definition at line 32 of file DimuonStatistics.cc.

33  : src_(cfg.getParameter<InputTag>("src")),
34  srcToken_(consumes<CandidateView>(src_)),
35  matched_(maxEntries + 1, 0),
36  unMatched_(maxEntries + 1, 0),
37  ptMin_(cfg.getUntrackedParameter<double>("ptMin")),
38  massMin_(cfg.getUntrackedParameter<double>("massMin")),
39  massMax_(cfg.getUntrackedParameter<double>("massMax")),
40  etaMin_(cfg.getUntrackedParameter<double>("etaMin")),
41  etaMax_(cfg.getUntrackedParameter<double>("etaMax")),
42  trkIso_(cfg.getUntrackedParameter<double>("trkIso")) {}
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< reco::CandidateView > srcToken_
const unsigned int maxEntries
std::vector< unsigned int > unMatched_
std::vector< unsigned int > matched_
edm::InputTag src_

Member Function Documentation

void DimuonStatistics::analyze ( const edm::Event evt,
const edm::EventSetup  
)
override

Definition at line 62 of file DimuonStatistics.cc.

References edm::View< T >::begin(), alignmentValidation::c1, gather_cfg::cout, DEFINE_FWK_MODULE, edm::View< T >::end(), reco::Candidate::eta(), etaMax_, etaMin_, Exception, pat::PATObject< ObjectType >::genParticleRef(), edm::RefToBase< T >::get(), edm::Event::getByToken(), mps_fire::i, edm::errors::InvalidReference, edm::Ref< C, T, F >::isNonnull(), dqmiolumiharvest::j, dqmdumpme::k, massMax_, massMin_, reco::Candidate::masterClone(), muonTagProbeFilters_cff::matched, matched_, maxEntries, reco::Candidate::pt(), ptMin_, edm::View< T >::size(), TrackRefitter_38T_cff::src, src_, srcToken_, pat::Muon::trackIso(), trkIso_, and unMatched_.

62  {
64  evt.getByToken(srcToken_, src);
65  double trackIso1 = -1;
66  double trackIso2 = -1;
67  int j = 0;
68  unsigned int matched = 0, unMatched = 0;
69  cout << ">> entries in " << src_ << ": " << src->size() << endl;
70  for (CandidateView::const_iterator i = src->begin(); i != src->end(); ++i) {
71  j++;
72  const Candidate* dau1 = i->daughter(0);
73  const Candidate* dau2 = i->daughter(1);
74  if (dau1 == nullptr || dau2 == nullptr)
75  throw Exception(errors::InvalidReference) << "one of the two daughter does not exist\n";
76  const Candidate* c1 = dau1->masterClone().get();
77  GenParticleRef mc1;
78  const pat::Muon* mu1 = dynamic_cast<const pat::Muon*>(c1);
79  if (mu1 != nullptr) {
80  mc1 = mu1->genParticleRef();
81  // if (mc1.isNonnull()) cout << "DimuonStatistics> genParticleRef1 " << mc1->pdgId() << endl;
82  trackIso1 = mu1->trackIso();
83  } else {
84  const pat::GenericParticle* gp1 = dynamic_cast<const pat::GenericParticle*>(c1);
85  if (gp1 == nullptr)
87  << "first of two daughter is neither a pat::Muon not pat::GenericParticle\n";
88  mc1 = gp1->genParticleRef();
89  }
90  const Candidate* c2 = dau2->masterClone().get();
91  GenParticleRef mc2;
92  const pat::Muon* mu2 = dynamic_cast<const pat::Muon*>(c2);
93  if (mu2 != nullptr) {
94  mc2 = mu2->genParticleRef();
95  // if (mc2.isNonnull()) cout << "DimuonStatistics> genParticleRef2 " << mc2->pdgId() << endl;
96  trackIso2 = mu2->trackIso();
97  } else {
98  const pat::GenericParticle* gp2 = dynamic_cast<const pat::GenericParticle*>(c2);
99  if (gp2 == nullptr)
101  << "first of two daughter is neither a pat::Muon not pat::GenericParticle\n";
102  mc2 = gp2->genParticleRef();
103  }
104  GenParticleRef dimuonMatch;
105  if (mc1.isNonnull() && mc2.isNonnull()) {
106  cout << "DimuonStatistics> mc1: " << mc1->pdgId() << ", mc2: " << mc2->pdgId() << endl;
107  int k = 0;
108  do {
109  k++;
110  mc1 = mc1->numberOfMothers() > 0 ? mc1->motherRef() : GenParticleRef();
111  mc2 = mc2->numberOfMothers() > 0 ? mc2->motherRef() : GenParticleRef();
112  // cout << "DimuonStatistics> do loop: " << k << " id1 " << mc1->pdgId() << " id2 " << mc2->pdgId() << endl;
113  } while (mc1 != mc2 && mc1.isNonnull() && mc2.isNonnull());
114  if (mc1.isNonnull() && mc2.isNonnull() && mc1->pdgId() == 23) {
115  dimuonMatch = mc1;
116  }
117  }
118  // cout << "DimuonMatcher> dimuonMatch " << dimuonMatch.isNonnull() << endl;
119  if ((fabs(dau1->eta()) > etaMin_ && fabs(dau1->eta()) < etaMax_) && dau1->pt() > ptMin_ &&
120  ((fabs(dau2->eta()) > etaMin_) && (fabs(dau2->eta()) < etaMax_)) && dau2->pt() > ptMin_ &&
121  trackIso1 < trkIso_ && trackIso2 < trkIso_ && i->mass() > massMin_ && i->mass() < massMax_) {
122  cout << "dimuon mass " << i->mass() << endl;
123  if (dimuonMatch.isNonnull())
124  ++matched;
125  else
126  ++unMatched;
127  }
128  }
129  cout << "matched: " << matched << ", unmatched: " << unMatched << endl;
130 
131  if (matched > maxEntries)
132  matched = maxEntries;
133  if (unMatched > maxEntries)
134  unMatched = maxEntries;
135  ++matched_[matched];
136  ++unMatched_[unMatched];
137 }
value_type const * get() const
Definition: RefToBase.h:209
edm::EDGetTokenT< reco::CandidateView > srcToken_
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
reco::GenParticleRef genParticleRef(size_t idx=0) const
Definition: PATObject.h:270
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
size_type size() const
const unsigned int maxEntries
std::vector< unsigned int > unMatched_
float trackIso() const
Definition: Muon.h:177
std::vector< unsigned int > matched_
Analysis-level Generic Particle class (e.g. for hadron or muon not fully reconstructed) ...
const_iterator begin() const
virtual const CandidateBaseRef & masterClone() const =0
virtual double eta() const =0
momentum pseudorapidity
virtual double pt() const =0
transverse momentum
edm::Ref< edm::HepMCProduct, HepMC::GenParticle > GenParticleRef
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
edm::InputTag src_
const_iterator end() const
Analysis-level muon class.
Definition: Muon.h:51
void DimuonStatistics::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 44 of file DimuonStatistics.cc.

References gather_cfg::cout, edm::InputTag::encode(), mps_fire::i, matched_, maxEntries, src_, and unMatched_.

44  {
45  cout << src_.encode() << endl;
46  cout << " == Matched == " << endl;
47  for (unsigned int i = 0; i <= maxEntries; ++i) {
48  cout << i << ": " << matched_[i];
49  if (i < maxEntries)
50  cout << ", ";
51  }
52  cout << endl;
53  cout << " == unMatched == " << endl;
54  for (unsigned int i = 0; i <= maxEntries; ++i) {
55  cout << i << ": " << unMatched_[i];
56  if (i < maxEntries)
57  cout << ", ";
58  }
59  cout << endl;
60 }
const unsigned int maxEntries
std::vector< unsigned int > unMatched_
std::string encode() const
Definition: InputTag.cc:159
std::vector< unsigned int > matched_
edm::InputTag src_

Member Data Documentation

double DimuonStatistics::etaMax_
private

Definition at line 17 of file DimuonStatistics.cc.

Referenced by analyze().

double DimuonStatistics::etaMin_
private

Definition at line 17 of file DimuonStatistics.cc.

Referenced by analyze().

double DimuonStatistics::massMax_
private

Definition at line 17 of file DimuonStatistics.cc.

Referenced by analyze().

double DimuonStatistics::massMin_
private

Definition at line 17 of file DimuonStatistics.cc.

Referenced by analyze().

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

Definition at line 16 of file DimuonStatistics.cc.

Referenced by analyze(), and endJob().

double DimuonStatistics::ptMin_
private

Definition at line 17 of file DimuonStatistics.cc.

Referenced by analyze().

edm::InputTag DimuonStatistics::src_
private

Definition at line 14 of file DimuonStatistics.cc.

Referenced by analyze(), and endJob().

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

Definition at line 15 of file DimuonStatistics.cc.

Referenced by analyze().

double DimuonStatistics::trkIso_
private

Definition at line 17 of file DimuonStatistics.cc.

Referenced by analyze().

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

Definition at line 16 of file DimuonStatistics.cc.

Referenced by analyze(), and endJob().