50 void endJob()
override;
67 double zMassMin_, zMassMax_, ptmin_, etamax_, isomax_;
89 TH1D *h_DELTA_ZMuMuMassReco_dimuonMassGen_, *h_DELTA_ZMuStaMassReco_dimuonMassGen_,
129 zMassMin_(pset.getUntrackedParameter<double>(
"zMassMin")),
130 zMassMax_(pset.getUntrackedParameter<double>(
"zMassMax")),
131 ptmin_(pset.getUntrackedParameter<double>(
"ptmin")),
132 etamax_(pset.getUntrackedParameter<double>(
"etamax")),
133 isomax_(pset.getUntrackedParameter<double>(
"isomax")),
134 nbinsPt_(pset.getUntrackedParameter<unsigned
int>(
"nbinsPt")),
135 nbinsEta_(pset.getUntrackedParameter<unsigned
int>(
"nbinsEta")) {
143 trackEffDir.
make<TH1D>(
"MuonOverlappedToStandAloneEta",
144 "Global muon overlapped to standAlone #eta for Z -> #mu + sa",
149 trackEffDir.
make<TH1D>(
"StandAloneMuonPt",
"StandAlone p_{t} for Z -> #mu + standalone",
nbinsPt_,
ptmin_, 100);
151 trackEffDir.
make<TH1D>(
"MuonOverlappedToStandAlonePt",
152 "Global muon overlapped to standAlone p_{t} for Z -> #mu + sa",
162 "Global muon overlapped to track #eta for Z -> #mu + tk",
168 "MuonOverlappedToTrackPt",
"Global muon overlapped to track p_{t} for Z -> #mu + tk",
nbinsPt_,
ptmin_, 100);
173 invMassResolutionDir.make<TH1D>(
"zMuMu_invMassResolution",
"zMuMu invariant Mass Resolution", 50, -25, 25);
175 invMassResolutionDir.make<TH1D>(
"zMuSta_invMassResolution",
"zMuSta invariant Mass Resolution", 50, -25, 25);
177 invMassResolutionDir.make<TH1D>(
"zMuTrack_invMassResolution",
"zMuTrack invariant Mass Resolution", 50, -25, 25);
181 h_nZMCfound_ = genParticleDir.make<TH1D>(
"NumberOfgeneratedZeta",
"n. of generated Z per event", 4, -.5, 3.5);
182 h_ZetaGen_ = genParticleDir.make<TH1D>(
"generatedZeta",
"#eta of generated Z", 100, -5., 5.);
183 h_ZptGen_ = genParticleDir.make<TH1D>(
"generatedZpt",
"pt of generated Z", 100, 0., 200.);
184 h_ZmassGen_ = genParticleDir.make<TH1D>(
"generatedZmass",
"mass of generated Z", 100, 0., 200.);
185 h_muetaGen_ = genParticleDir.make<TH1D>(
"generatedMuonEta",
"#eta of generated muons from Z decay", 100, -5., 5.);
186 h_muptGen_ = genParticleDir.make<TH1D>(
"generatedMuonpt",
"pt of generated muons from Z decay", 100, 0., 200.);
187 h_dimuonEtaGen_ = genParticleDir.make<TH1D>(
"generatedDimuonEta",
"#eta of generated dimuon", 100, -5., 5.);
188 h_dimuonPtGen_ = genParticleDir.make<TH1D>(
"generatedDimuonPt",
"pt of generated dimuon", 100, 0., 200.);
189 h_dimuonMassGen_ = genParticleDir.make<TH1D>(
"generatedDimuonMass",
"mass of generated dimuon", 100, 0., 200.);
190 h_ZetaGenPassed_ = genParticleDir.make<TH1D>(
"generatedZeta_passed",
"#eta of generated Z after cuts", 100, -5., 5.);
191 h_ZptGenPassed_ = genParticleDir.make<TH1D>(
"generatedZpt_passed",
"pt of generated Z after cuts", 100, 0., 200.);
193 genParticleDir.make<TH1D>(
"generatedZmass_passed",
"mass of generated Z after cuts", 100, 0., 200.);
195 "generatedMuonEta_passed",
"#eta of generated muons from Z decay after cuts", 100, -5., 5.);
197 "generatedMuonpt_passed",
"pt of generated muons from Z decay after cuts", 100, 0., 200.);
199 genParticleDir.make<TH1D>(
"generatedDimuonEta_passed",
"#eta of generated dimuon after cuts", 100, -5., 5.);
201 genParticleDir.make<TH1D>(
"generatedDimuonPt_passed",
"pt of generated dimuon after cuts", 100, 0., 200.);
203 genParticleDir.make<TH1D>(
"generatedDimuonMass_passed",
"mass of generated dimuon after cuts", 100, 0., 200.);
262 cout <<
"********* zMuMu size : " << zMuMu->
size() << endl;
263 cout <<
"********* zMuStandAlone size : " << zMuStandAlone->
size() << endl;
264 cout <<
"********* zMuTrack size : " << zMuTrack->
size() << endl;
265 cout <<
"********* muons size : " << muons->
size() << endl;
266 cout <<
"********* standAlone size : " << standAlone->
size() << endl;
267 cout <<
"********* tracks size : " << tracks->
size() << endl;
268 cout <<
"********* generated size : " << genParticles->size() << endl;
274 int ngen = genParticles->size();
275 bool ZMuMuMatchedfound =
false;
276 bool ZMuMuMatchedSelectedfound =
false;
277 bool ZMuStaMatchedfound =
false;
279 int ZMuTrackMatchedfound = 0;
280 int ZMuTrackMatchedSelected_exclusivefound = 0;
282 double dimuonMassGen = 0;
284 for (
int i = 0;
i < ngen;
i++) {
285 const Candidate &genCand = (*genParticles)[
i];
289 if ((genCand.
pdgId() == 23) && (genCand.
status() == 3)) {
297 bool checkpt =
false;
298 bool checketa =
false;
299 bool checkmass =
false;
300 float mupluspt, muminuspt, mupluseta, muminuseta;
310 pZ = muplusp4 + muminusp4;
311 double dimuon_pt =
sqrt(pZ.x() * pZ.x() + pZ.y() * pZ.y());
312 double tan_theta_half =
tan(atan(dimuon_pt / pZ.z()) / 2.);
313 double dimuon_eta = 0.;
314 if (tan_theta_half > 0)
315 dimuon_eta = -
log(
tan(tan_theta_half));
316 if (tan_theta_half <= 0)
317 dimuon_eta =
log(
tan(-tan_theta_half));
319 dimuonMassGen = pZ.mass();
345 if (checkpt && checketa && checkmass) {
358 if (!zMuMu->
empty()) {
360 }
else if (!zMuStandAlone->
empty()) {
374 if (!zMuMu->
empty()) {
380 for (
unsigned int i = 0;
i < zMuMu->
size(); ++
i) {
393 ZMuMuMatchedfound =
true;
400 const double globalMuonIsolation0 = (*muonIso)[dau0];
401 const double globalMuonIsolation1 = (*muonIso)[dau1];
402 if ((globalMuonIsolation0 <
isomax_) &&
403 (globalMuonIsolation1 <
isomax_)) {
404 ZMuMuMatchedSelectedfound =
true;
426 for (
unsigned int j = 0;
j < muons->
size(); ++
j) {
436 if (!zMuStandAlone->
empty()) {
442 for (
unsigned int i = 0;
i < zMuStandAlone->
size(); ++
i) {
443 const Candidate &zMuStaCand = (*zMuStandAlone)[
i];
446 GenParticleRef zMuStaMatch = (*zMuStandAloneMatchMap)[zMuStaCandRef];
449 ZMuStaMatchedfound =
true;
461 standAloneMuonCandRef_ = dau1;
462 globalMuonCandRef_ = dau0;
465 standAloneMuonCandRef_ = dau0;
466 globalMuonCandRef_ = dau1;
472 if ((globalMuonIsolation <
isomax_) && (standAloneMuonIsolation <
isomax_)) {
478 zMuStaCand.
mass() - dimuonMassGen);
486 if (!zMuTrack->
empty()) {
491 for (
unsigned int i = 0;
i < zMuTrack->
size(); ++
i) {
503 ZMuTrackMatchedfound++;
504 if (ZMuMuMatchedfound)
506 if (ZMuMuMatchedSelectedfound)
508 if (!ZMuMuMatchedfound)
514 (isMatched) && !ZMuMuMatchedfound && !ZMuStaMatchedfound) {
516 const double globalMuonIsolation = (*muonIso)[dau0];
517 const double trackMuonIsolation = (*trackIso)[dau1];
518 if ((globalMuonIsolation <
isomax_) &&
519 (trackMuonIsolation <
isomax_)) {
521 ZMuTrackMatchedSelected_exclusivefound++;
530 if (!ZMuMuMatchedfound && !ZMuStaMatchedfound && ZMuTrackMatchedfound == 0)
532 if (!ZMuMuMatchedfound && ZMuTrackMatchedfound == 1)
534 if (!ZMuMuMatchedfound && ZMuTrackMatchedfound > 1)
536 if (!ZMuMuMatchedfound && ZMuTrackMatchedSelected_exclusivefound == 1)
538 if (!ZMuMuMatchedfound && ZMuTrackMatchedSelected_exclusivefound > 1)
540 if (ZMuMuMatchedfound && ZMuTrackMatchedfound == 1)
542 if (ZMuMuMatchedfound && ZMuTrackMatchedfound == 2)
544 if (ZMuMuMatchedfound && ZMuTrackMatchedfound > 2)
549 int partId0 = dauGen0->
pdgId();
550 int partId1 = dauGen1->
pdgId();
551 int partId2 = dauGen2->
pdgId();
552 bool muplusFound =
false;
553 bool muminusFound =
false;
555 if (partId0 == 13 || partId1 == 13 || partId2 == 13)
557 if (partId0 == -13 || partId1 == -13 || partId2 == -13)
559 if (partId0 == 23 || partId1 == 23 || partId2 == 23)
561 return (muplusFound && muminusFound && ZFound);
568 int partId0 = dauGen0->
pdgId();
569 int partId1 = dauGen1->
pdgId();
570 int partId2 = dauGen2->
pdgId();
572 if (partId0 == ipart) {
575 if (dauMuGen->
pdgId() == ipart && dauMuGen->
status() == 1) {
576 ptpart = dauMuGen->
pt();
580 if (partId1 == ipart) {
583 if (dauMuGen->
pdgId() == ipart && dauMuGen->
status() == 1) {
584 ptpart = dauMuGen->
pt();
588 if (partId2 == ipart) {
592 ptpart = dauMuGen->
pt();
603 int partId0 = dauGen0->
pdgId();
604 int partId1 = dauGen1->
pdgId();
605 int partId2 = dauGen2->
pdgId();
607 if (partId0 == ipart) {
610 if (dauMuGen->
pdgId() == ipart && dauMuGen->
status() == 1) {
611 etapart = dauMuGen->
eta();
615 if (partId1 == ipart) {
618 if (dauMuGen->
pdgId() == ipart && dauMuGen->
status() == 1) {
619 etapart = dauMuGen->
eta();
623 if (partId2 == ipart) {
627 etapart = dauMuGen->
eta();
638 int partId0 = dauGen0->
pdgId();
639 int partId1 = dauGen1->
pdgId();
640 int partId2 = dauGen2->
pdgId();
642 if (partId0 == ipart) {
645 if (dauMuGen->
pdgId() == ipart && dauMuGen->
status() == 1) {
646 phipart = dauMuGen->
phi();
650 if (partId1 == ipart) {
653 if (dauMuGen->
pdgId() == ipart && dauMuGen->
status() == 1) {
654 phipart = dauMuGen->
phi();
658 if (partId2 == ipart) {
662 phipart = dauMuGen->
phi();
673 int partId0 = dauGen0->
pdgId();
674 int partId1 = dauGen1->
pdgId();
675 int partId2 = dauGen2->
pdgId();
677 if (partId0 == ipart) {
680 if (dauMuGen->
pdgId() == ipart && dauMuGen->
status() == 1) {
681 p4part = dauMuGen->
p4();
685 if (partId1 == ipart) {
688 if (dauMuGen->
pdgId() == ipart && dauMuGen->
status() == 1) {
689 p4part = dauMuGen->
p4();
693 if (partId2 == ipart) {
697 p4part = dauMuGen->
p4();
710 double myErrTrackEff =
sqrt(myTrackEff * (1 - myTrackEff) /
715 double myErrStaEff =
sqrt(myTrackEff * (1 - myTrackEff) /
721 cout <<
"------------------------------------ Counters for MC acceptance --------------------------------" << endl;
729 cout <<
"---------------------------- Counter for MC truth efficiency calculation--------------------- " << endl;
733 cout <<
"-------------------------------------------------------------------------------------- " << endl;
746 cout <<
"numberOfMatchedSelectedZMuSta = " << numberOfMatchedSelectedZMuSta_ << endl;
750 cout <<
"numberOfMatchedSelectedZMuTrack exclusive = " << numberOfMatchedSelectedZMuTrack_exclusive << endl;
751 cout <<
" ----------------------------- Efficiency --------------------------------- " << endl;
752 cout <<
"Efficiency StandAlone = " << myStaEff <<
" +/- " << myErrStaEff << endl;
753 cout <<
"Efficiency Track = " << myTrackEff <<
" +/- " << myErrTrackEff << endl;
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
EDGetTokenT< GenParticleMatch > zMuMuMatchMapToken_
bool isNonnull() const
Checks for non-null.
TH1D * h_ptMuonOverlappedToTrack_
int n_zMuMufound_genZsele
TH1D * h_dimuonPtGenPassed_
ZMuMuEfficiency(const edm::ParameterSet &pset)
bool check_ifZmumu(const Candidate *dauGen0, const Candidate *dauGen1, const Candidate *dauGen2)
EDGetTokenT< CandidateView > zMuStandAloneToken_
int numberOfMatchedSelectedZMuSta_
TH1D * h_etaMuonOverlappedToStandAlone_
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
int ZMuTrackselected_exclusive_1match
int numberOfMatchedZMuTrack_exclusive
TH1D * h_dimuonEtaGenPassed_
EDGetTokenT< CandidateView > zMuTrackToken_
int numberOfMatchedZMuTrack_matchedSelectedZMuMu
reco::CandidateBaseRef standAloneMuonCandRef_
int numberOfOverlappedStandAlone_
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
TH1D * h_DELTA_ZMuMuMassReco_dimuonMassGen_
int numberOfMatchedZMuTrack_matchedZMuMu
int ZMuTrack_ZMuMu_1match
RefToBase< value_type > refAt(size_type i) const
EDGetTokenT< CandidateView > tracksToken_
virtual int status() const =0
status word
EDGetTokenT< GenParticleCollection > genParticlesToken_
#define DEFINE_FWK_MODULE(type)
float getParticlePt(const int ipart, const Candidate *dauGen0, const Candidate *dauGen1, const Candidate *dauGen2)
int n_zMuTrkfound_genZsele
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
virtual int pdgId() const =0
PDG identifier.
int numberOfMatchedZMuMu_
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
int ZMuTrackselected_exclusive_morematch
int numberOfMatchedSelectedZMuTrack_exclusive
int ZMuTrack_ZMuMu_2match
bool isMatched(TrackingRecHit const &hit)
int numberOfMatchedZMuSta_
float getParticleEta(const int ipart, const Candidate *dauGen0, const Candidate *dauGen1, const Candidate *dauGen2)
T * make(const Args &...args) const
make new ROOT object
reco::CandidateBaseRef trackMuonCandRef_
EDGetTokenT< CandidateView > zMuMuToken_
float getParticlePhi(const int ipart, const Candidate *dauGen0, const Candidate *dauGen1, const Candidate *dauGen2)
TH1D * h_DELTA_ZMuStaMassReco_dimuonMassGen_
virtual const CandidateBaseRef & masterClone() const =0
virtual bool isGlobalMuon() const =0
zMuMu
zMuMu vector of PSet is common to all categories except zMuTrk category
virtual double eta() const =0
momentum pseudorapidity
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
void analyze(const edm::Event &event, const edm::EventSetup &setup) override
virtual double pt() const =0
transverse momentum
int numberOfEventsWithZMuMufound
virtual double mass() const =0
mass
int ZMuTrack_exclusive_1match
int numberOfMatchedZMuTrack_notOverlapped
Particle::LorentzVector getParticleP4(const int ipart, const Candidate *dauGen0, const Candidate *dauGen1, const Candidate *dauGen2)
int numberOfMatchedSelectedZMuMu_
ValueMap< float > IsolationCollection
TH1D * h_dimuonMassGenPassed_
TH1D * h_ptMuonOverlappedToStandAlone_
EDGetTokenT< CandidateView > standAloneToken_
TH1D * h_DELTA_ZMuTrackMassReco_dimuonMassGen_
EDGetTokenT< IsolationCollection > standAloneIsoToken_
EDGetTokenT< GenParticleMatch > zMuTrackMatchMapToken_
int numberOfEventsWithZMuStafound
TH1D * h_etaMuonOverlappedToTrack_
int numberOfOverlappedTracks_
int ZMuTrack_exclusive_morematch
int n_zMuStafound_genZsele
EDGetTokenT< GenParticleMatch > muonMatchMapToken_
virtual size_type numberOfDaughters() const =0
number of daughters
EDGetTokenT< IsolationCollection > trackIsoToken_
virtual double phi() const =0
momentum azimuthal angle
EDGetTokenT< CandidateView > muonsToken_
int ZMuTrack_ZMuMu_morematch
EDGetTokenT< IsolationCollection > muonIsoToken_
math::PtEtaPhiELorentzVectorF LorentzVector
EDGetTokenT< GenParticleMatch > zMuStandAloneMatchMapToken_
reco::CandidateBaseRef globalMuonCandRef_