Public Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &) |
DimuonStatistics (const edm::ParameterSet &cfg) | |
virtual void | endJob () |
Private Attributes | |
double | etaMax_ |
double | etaMin_ |
double | massMax_ |
double | massMin_ |
std::vector< unsigned int > | matched_ |
double | ptMin_ |
edm::InputTag | src_ |
double | trkIso_ |
std::vector< unsigned int > | unMatched_ |
Definition at line 5 of file DimuonStatistics.cc.
DimuonStatistics::DimuonStatistics | ( | const edm::ParameterSet & | cfg | ) |
Definition at line 30 of file DimuonStatistics.cc.
: src_(cfg.getParameter<InputTag>("src")), matched_(maxEntries + 1, 0), unMatched_(maxEntries + 1, 0), ptMin_(cfg.getUntrackedParameter<double>("ptMin")), massMin_(cfg.getUntrackedParameter<double>("massMin")), massMax_(cfg.getUntrackedParameter<double>("massMax")), etaMin_(cfg.getUntrackedParameter<double>("etaMin")), etaMax_(cfg.getUntrackedParameter<double>("etaMax")), trkIso_(cfg.getUntrackedParameter<double>("trkIso")){ }
void DimuonStatistics::analyze | ( | const edm::Event & | evt, |
const edm::EventSetup & | |||
) | [virtual] |
Implements edm::EDAnalyzer.
Definition at line 58 of file DimuonStatistics.cc.
References alignmentValidation::c1, gather_cfg::cout, reco::Candidate::eta(), etaMax_, etaMin_, Exception, pat::PATObject< ObjectType >::genParticleRef(), edm::RefToBase< T >::get(), edm::Event::getByLabel(), i, edm::errors::InvalidReference, edm::Ref< C, T, F >::isNonnull(), j, gen::k, massMax_, massMin_, reco::Candidate::masterClone(), matched_, maxEntries, reco::Candidate::pt(), ptMin_, align_tpl::src, src_, pat::Muon::trackIso(), trkIso_, and unMatched_.
{ Handle<CandidateView> src; evt.getByLabel(src_, src); double trackIso1=-1; double trackIso2=-1; int j=0; unsigned int matched = 0, unMatched = 0; cout << ">> entries in " << src_ << ": " << src->size() << endl; for(CandidateView::const_iterator i = src->begin(); i != src->end(); ++i) { j++; const Candidate * dau1 = i->daughter(0); const Candidate * dau2 = i->daughter(1); if(dau1 == 0|| dau2 == 0) throw Exception(errors::InvalidReference) << "one of the two daughter does not exist\n"; const Candidate * c1 = dau1->masterClone().get(); GenParticleRef mc1; const pat::Muon * mu1 = dynamic_cast<const pat::Muon*>(c1); if(mu1 != 0) { mc1 = mu1->genParticleRef(); // if (mc1.isNonnull()) cout << "DimuonStatistics> genParticleRef1 " << mc1->pdgId() << endl; trackIso1=mu1->trackIso(); } else { const pat::GenericParticle * gp1 = dynamic_cast<const pat::GenericParticle*>(c1); if(gp1 == 0) throw Exception(errors::InvalidReference) << "first of two daughter is neither a pat::Muon not pat::GenericParticle\n"; mc1 = gp1->genParticleRef(); } const Candidate * c2 = dau2->masterClone().get(); GenParticleRef mc2; const pat::Muon * mu2 = dynamic_cast<const pat::Muon*>(c2); if(mu2 != 0) { mc2 = mu2->genParticleRef(); // if (mc2.isNonnull()) cout << "DimuonStatistics> genParticleRef2 " << mc2->pdgId() << endl; trackIso2=mu2->trackIso(); } else { const pat::GenericParticle * gp2 = dynamic_cast<const pat::GenericParticle*>(c2); if(gp2 == 0) throw Exception(errors::InvalidReference) << "first of two daughter is neither a pat::Muon not pat::GenericParticle\n"; mc2 = gp2->genParticleRef(); } GenParticleRef dimuonMatch; if(mc1.isNonnull() && mc2.isNonnull()) { cout << "DimuonStatistics> mc1: " << mc1->pdgId() << ", mc2: " << mc2->pdgId() << endl; int k=0; do { k++; mc1 = mc1->numberOfMothers() > 0 ? mc1->motherRef() : GenParticleRef(); mc2 = mc2->numberOfMothers() > 0 ? mc2->motherRef() : GenParticleRef(); // cout << "DimuonStatistics> do loop: " << k << " id1 " << mc1->pdgId() << " id2 " << mc2->pdgId() << endl; } while(mc1 != mc2 && mc1.isNonnull() && mc2.isNonnull()); if(mc1.isNonnull() && mc2.isNonnull() && mc1->pdgId()==23) { dimuonMatch = mc1; } } // cout << "DimuonMatcher> dimuonMatch " << dimuonMatch.isNonnull() << endl; if( (fabs(dau1->eta()) > etaMin_ && fabs(dau1->eta()) < etaMax_) && dau1->pt()>ptMin_ && ( (fabs(dau2->eta()) > etaMin_ ) && (fabs(dau2->eta()) < etaMax_) ) && dau2->pt()>ptMin_ && trackIso1 < trkIso_ && trackIso2 < trkIso_ && i->mass() > massMin_ && i->mass() < massMax_ ) { cout << "dimuon mass " << i->mass() << endl; if(dimuonMatch.isNonnull()) ++matched; else ++unMatched; } } cout << "matched: " << matched << ", unmatched: " << unMatched << endl; if(matched > maxEntries) matched = maxEntries; if(unMatched > maxEntries) unMatched = maxEntries; ++matched_[matched]; ++unMatched_[unMatched]; }
void DimuonStatistics::endJob | ( | void | ) | [virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 42 of file DimuonStatistics.cc.
References gather_cfg::cout, edm::InputTag::encode(), i, matched_, maxEntries, src_, and unMatched_.
{ cout << src_.encode() << endl ; cout << " == Matched == " << endl; for(unsigned int i = 0; i <= maxEntries; ++i) { cout << i << ": " << matched_[i]; if (i < maxEntries) cout << ", "; } cout << endl; cout << " == unMatched == " << endl; for(unsigned int i = 0; i <= maxEntries; ++i) { cout << i << ": " << unMatched_[i]; if (i < maxEntries) cout << ", "; } cout << endl; }
double DimuonStatistics::etaMax_ [private] |
Definition at line 13 of file DimuonStatistics.cc.
Referenced by analyze().
double DimuonStatistics::etaMin_ [private] |
Definition at line 13 of file DimuonStatistics.cc.
Referenced by analyze().
double DimuonStatistics::massMax_ [private] |
Definition at line 13 of file DimuonStatistics.cc.
Referenced by analyze().
double DimuonStatistics::massMin_ [private] |
Definition at line 13 of file DimuonStatistics.cc.
Referenced by analyze().
std::vector<unsigned int> DimuonStatistics::matched_ [private] |
Definition at line 12 of file DimuonStatistics.cc.
double DimuonStatistics::ptMin_ [private] |
Definition at line 13 of file DimuonStatistics.cc.
Referenced by analyze().
edm::InputTag DimuonStatistics::src_ [private] |
Definition at line 11 of file DimuonStatistics.cc.
double DimuonStatistics::trkIso_ [private] |
Definition at line 13 of file DimuonStatistics.cc.
Referenced by analyze().
std::vector<unsigned int> DimuonStatistics::unMatched_ [private] |
Definition at line 12 of file DimuonStatistics.cc.