52 virtual void endJob()
override;
70 double ptminMinus_, ptmaxMinus_, etaminMinus_, etamaxMinus_, isomax_;
72 double etamax_,
ptmin_, massMin_, massMax_, isoMax_;
186 noCut_(pset.getParameter<bool>(
"noCut")),
188 zMassMin_(pset.getUntrackedParameter<double>(
"zMassMin")),
189 zMassMax_(pset.getUntrackedParameter<double>(
"zMassMax")),
190 ptminPlus_(pset.getUntrackedParameter<double>(
"ptminPlus")),
191 ptmaxPlus_(pset.getUntrackedParameter<double>(
"ptmaxPlus")),
192 etaminPlus_(pset.getUntrackedParameter<double>(
"etaminPlus")),
193 etamaxPlus_(pset.getUntrackedParameter<double>(
"etamaxPlus")),
194 ptminMinus_(pset.getUntrackedParameter<double>(
"ptminMinus")),
195 ptmaxMinus_(pset.getUntrackedParameter<double>(
"ptmaxMinus")),
196 etaminMinus_(pset.getUntrackedParameter<double>(
"etaminMinus")),
197 etamaxMinus_(pset.getUntrackedParameter<double>(
"etamaxMinus")),
198 isomax_(pset.getUntrackedParameter<double>(
"isomax")) {
241 h_DPtGlobalGenvsPtGen = fs->
make<TH2D>(
"h_DPtGlobalGenovePtvsPtGen",
"Pt global - Pt Gen over Pt vs Pt gen",50,0.,100.,100,-.5,.5);
283 h_DRSta_ZMuMuTagged = fs->
make<TH1D>(
"DRTrackSta_ZMuMuTagged_staSelected",
"DR track-sta sta selected (global-global)",100, 0., 5.);
380 int n_globalMuon_perEvent=0;
381 int n_staOnlyMuon_perEvent=0;
382 int n_trackerOnlyMuon_perEvent=0;
383 int n_trackerStaOnlyMuon_perEvent=0;
384 int n_globalMuon_perEvent_MCmatch=0;
385 int n_staOnlyMuon_perEvent_MCmatch=0;
386 int n_trackerOnlyMuon_perEvent_MCmatch=0;
387 int n_trackerStaOnlyMuon_perEvent_MCmatch=0;
389 for(
unsigned int j = 0; j < muons->
size() ; ++j) {
398 if (muCandRef->
isGlobalMuon()==1) n_globalMuon_perEvent++;
403 if (muonMatch.isNonnull()) {
404 if (muCandRef->
isGlobalMuon()==1) n_globalMuon_perEvent_MCmatch++;
408 double productCharge = muCandRef->
charge() * muonMatch->charge();
446 if (zMuMu->
size() > 0 ) {
450 float muGenplus_pt = 0, muGenminus_pt = 0, muGenplus_eta = 100, muGenminus_eta = 100;
451 for(
unsigned int i = 0;
i < zMuMu->
size(); ++
i) {
455 bool isMCMatched =
false;
458 if(zMuMuMatch->pdgId() == 23 && zMuMuMatch->status()==3 && zMuMuMatch->numberOfDaughters() == 3) {
460 const Candidate * dauGen0 = zMuMuMatch->daughter(0);
461 const Candidate * dauGen1 = zMuMuMatch->daughter(1);
462 const Candidate * dauGen2 = zMuMuMatch->daughter(2);
471 pZ = muplusp4 + muminusp4;
492 double massGlobalSta = (pg1+ps2).
mass();
493 double massStaGlobal = (ps1+pg2).
mass();
495 double massGlobalTracker = (pg1+ptrk2).
mass();
496 double massTrackerGlobal = (ptrk1+pg2).
mass();
497 double etaGlobal1 = a1->eta();
498 double etaGlobal2 = a2->eta();
499 double etaSta1 = as1->eta();
500 double etaSta2 = as2->eta();
501 double etaTracker1 = at1->eta();
502 double etaTracker2 = at2->eta();
505 double phiSta1 = as1->phi();
506 double phiSta2 = as2->phi();
507 double phiTracker1 = at1->phi();
508 double phiTracker2 = at2->phi();
509 double ptGlobal1 = a1->pt();
510 double ptGlobal2 = a2->pt();
511 double ptSta1 = as1->pt();
512 double ptSta2 = as2->pt();
513 double ptTracker1 = at1->pt();
514 double ptTracker2 = at2->pt();
515 double chargeGlobal1 = a1->charge();
516 double chargeGlobal2 = a2->charge();
517 double chargeSta1 = as1->charge();
518 double chargeSta2 = as2->charge();
519 double chargeTracker1 = at1->charge();
520 double chargeTracker2 = at2->charge();
521 double DR1 =
deltaR(etaSta1, phiSta1, etaTracker1, phiTracker1);
522 double DR2 =
deltaR(etaSta2, phiSta2, etaTracker2, phiTracker2);
524 if (chargeGlobal1 == chargeGlobal2) {
539 bool massCut =
false;
547 if (ptGlobal1>
ptmin_ && ptTracker2>
ptmin_) ptCut =
true;
548 if (massGlobalTracker>
massMin_ && massGlobalTracker<
massMax_) massCut =
true;
556 if (etaCut && ptCut && massCut) {
558 if (chargeSta1 == chargeTracker1 && chargeTracker1 != chargeTracker2) {
567 double etaGen, ptGen;
568 if (chargeGlobal1==1) {
569 etaGen = muGenplus_eta;
570 ptGen = muGenplus_pt;
572 etaGen = muGenminus_eta;
573 ptGen = muGenminus_pt;
590 if (chargeSta2 == chargeTracker2) {
598 if (chargeSta2 != chargeTracker2) {
615 if (ptGlobal2>
ptmin_ && ptTracker1>
ptmin_) ptCut =
true;
616 if (massTrackerGlobal>
massMin_ && massTrackerGlobal<
massMax_) massCut =
true;
624 if (etaCut && ptCut && massCut) {
626 if (chargeSta2 == chargeTracker2 && chargeTracker1 != chargeTracker2) {
636 double etaGen, ptGen;
637 if (chargeGlobal2==1) {
638 etaGen = muGenplus_eta;
639 ptGen = muGenplus_pt;
641 etaGen = muGenminus_eta;
642 ptGen = muGenminus_pt;
659 if (chargeSta1 == chargeTracker1) {
667 if (chargeSta1 != chargeTracker1) {
698 if (etaCut && ptCut && massCut) {
700 if (chargeSta1 == chargeTracker1 && chargeTracker1 != chargeSta2) {
708 if (chargeSta2 == chargeTracker2) {
712 if (chargeSta2 != chargeTracker2) {
739 if (etaCut && ptCut && massCut) {
741 if (chargeSta2 == chargeTracker2 && chargeTracker2 != chargeSta1) {
749 if (chargeSta1 == chargeTracker1) {
753 if (chargeSta1 != chargeTracker1) {
772 int taggedZ_index = -1;
773 int taggedMuon_index = -1;
774 int n_ZMuTrackTagged_inEvent = 0;
775 if (zMuTrack->
size() > 0 && zMuMu->
size()==0) {
777 for(
unsigned int i = 0;
i < zMuTrack->
size(); ++
i) {
778 const Candidate & zMuTrackCand = (*zMuTrack)[
i];
780 GenParticleRef zMuTrackMatch = (*zMuTrackMatchMap)[zMuTrackCandRef];
786 double m = zMuTrackCand.
mass();
793 double ZtrackerDaughterCharge = ztrackerDaughter->
charge();
794 double ZtrackerDaughterPt = ztrackerDaughter->
pt();
795 double ZtrackerDaughterEta = ztrackerDaughter->
eta();
796 double ZtrackerDaughterPhi = ztrackerDaughter->
phi();
797 double ZglobalDaughterPt = zglobalDaughter->
pt();
798 double ZglobalDaughterEta = zglobalDaughter->
eta();
799 double ZglobalDaughter_StaComponentCharge = zglobalDaughter_StaComponentRef->charge();
800 double ZglobalDaughter_TrackComponentCharge = zglobalDaughter_TrackComponentRef->charge();
810 bool massCut =
false;
812 if (ZglobalDaughterPt>
ptmin_ && ZtrackerDaughterPt>
ptmin_) ptCut =
true;
820 if (etaCut && ptCut && massCut && ZglobalDaughter_StaComponentCharge == ZglobalDaughter_TrackComponentCharge &&
821 ZglobalDaughter_TrackComponentCharge != ZtrackerDaughterCharge) {
822 n_ZMuTrackTagged_inEvent++;
827 for(
unsigned int j = 0; j < muons->
size() ; ++j) {
834 double muEta = muCandRef->
eta();
835 double muPhi = muCandRef->
phi();
837 double DRmuSta_trackOfZ =
deltaR(muEta, muPhi, ZtrackerDaughterEta, ZtrackerDaughterPhi);
838 if (DRmuSta_trackOfZ == 0) {
840 taggedMuon_index = j;
850 if (n_ZMuTrackTagged_inEvent>0) {
852 if (taggedZ_index==-1) {
856 const Candidate & zMuTrackCand = (*zMuTrack)[taggedZ_index];
858 double m = zMuTrackCand.
mass();
865 double ZtrackerDaughterCharge = ztrackerDaughter->
charge();
866 double ZtrackerDaughterPt = ztrackerDaughter->
pt();
867 double ZtrackerDaughterEta = ztrackerDaughter->
eta();
868 double ZtrackerDaughterPhi = ztrackerDaughter->
phi();
871 const Candidate & muCand = (*muons)[taggedMuon_index];
875 double muEta = muStaComponentRef->eta();
876 double muPhi = muStaComponentRef->phi();
877 double muCharge = muStaComponentRef->charge();
879 double DRmuSta_trackOfZ =
deltaR(muEta, muPhi, ZtrackerDaughterEta, ZtrackerDaughterPhi);
889 if (muCharge != ZtrackerDaughterCharge) {
908 bool isZMuStaMatched=
false;
911 taggedMuon_index = -1;
912 int n_ZMuStaTagged_inEvent = 0;
913 if (zMuStandAlone->
size() > 0) {
915 for(
unsigned int i = 0;
i < zMuStandAlone->
size(); ++
i) {
916 const Candidate & zMuStaCand = (*zMuStandAlone)[
i];
919 GenParticleRef zMuStaMatch = (*zMuStandAloneMatchMap)[zMuStaCandRef];
922 isZMuStaMatched =
true;
925 double m = zMuStaCand.
mass();
932 zglobalDaughter = zstandaloneDaughter;
933 zstandaloneDaughter = buffer;
945 double ZglobalDaughterPt = zglobalDaughter->
pt();
946 double ZglobalDaughterEta = zglobalDaughter->
eta();
948 double ZstaDaughter_StaComponentCharge = zstaDaughter_StaComponentRef->charge();
949 double ZstaDaughter_StaComponentPt = zstaDaughter_StaComponentRef->pt();
950 double ZstaDaughter_StaComponentEta = zstaDaughter_StaComponentRef->eta();
951 double ZstaDaughter_StaComponentPhi = zstaDaughter_StaComponentRef->phi();
952 double ZstaDaughter_TrackComponentCharge = zstaDaughter_TrackComponentRef->charge();
954 double ZglobalDaughter_StaComponentCharge = zglobalDaughter_StaComponentRef->charge();
955 double ZglobalDaughter_TrackComponentCharge = zglobalDaughter_TrackComponentRef->charge();
961 bool massCut =
false;
962 if (
abs(ZglobalDaughterEta)<
etamax_ &&
abs(ZstaDaughter_StaComponentEta)<
etamax_) etaCut =
true;
963 if (ZglobalDaughterPt>
ptmin_ && ZstaDaughter_StaComponentPt>
ptmin_) ptCut =
true;
971 if (etaCut && ptCut && massCut && ZglobalDaughter_StaComponentCharge == ZglobalDaughter_TrackComponentCharge &&
972 ZglobalDaughter_StaComponentCharge != ZstaDaughter_StaComponentCharge) {
973 n_ZMuStaTagged_inEvent++;
985 if (ZstaDaughter_StaComponentCharge != ZstaDaughter_TrackComponentCharge) {
999 if (n_ZMuStaTagged_inEvent==0) {
1010 int partId0 = dauGen0->
pdgId();
1011 int partId1 = dauGen1->
pdgId();
1012 int partId2 = dauGen2->
pdgId();
1013 bool muplusFound=
false;
1014 bool muminusFound=
false;
1016 if (partId0==13 || partId1==13 || partId2==13) muminusFound=
true;
1017 if (partId0==-13 || partId1==-13 || partId2==-13) muplusFound=
true;
1018 if (partId0==23 || partId1==23 || partId2==23) ZFound=
true;
1019 return muplusFound*muminusFound*ZFound;
1024 int partId0 = dauGen0->
pdgId();
1025 int partId1 = dauGen1->
pdgId();
1026 int partId2 = dauGen2->
pdgId();
1028 if (partId0 == ipart) {
1031 if(dauMuGen->
pdgId() == ipart && dauMuGen->
status() ==1) {
1032 ptpart = dauMuGen->
pt();
1036 if (partId1 == ipart) {
1039 if(dauMuGen->
pdgId() == ipart && dauMuGen->
status() ==1) {
1040 ptpart = dauMuGen->
pt();
1044 if (partId2 == ipart) {
1048 ptpart = dauMuGen->
pt();
1057 int partId0 = dauGen0->
pdgId();
1058 int partId1 = dauGen1->
pdgId();
1059 int partId2 = dauGen2->
pdgId();
1061 if (partId0 == ipart) {
1064 if(dauMuGen->
pdgId() == ipart && dauMuGen->
status() ==1) {
1065 etapart = dauMuGen->
eta();
1069 if (partId1 == ipart) {
1072 if(dauMuGen->
pdgId() == ipart && dauMuGen->
status() ==1) {
1073 etapart = dauMuGen->
eta();
1077 if (partId2 == ipart) {
1081 etapart = dauMuGen->
eta();
1090 int partId0 = dauGen0->
pdgId();
1091 int partId1 = dauGen1->
pdgId();
1092 int partId2 = dauGen2->
pdgId();
1094 if (partId0 == ipart) {
1097 if(dauMuGen->
pdgId() == ipart && dauMuGen->
status() ==1) {
1098 phipart = dauMuGen->
phi();
1102 if (partId1 == ipart) {
1105 if(dauMuGen->
pdgId() == ipart && dauMuGen->
status() ==1) {
1106 phipart = dauMuGen->
phi();
1110 if (partId2 == ipart) {
1114 phipart = dauMuGen->
phi();
1123 int partId0 = dauGen0->
pdgId();
1124 int partId1 = dauGen1->
pdgId();
1125 int partId2 = dauGen2->
pdgId();
1127 if (partId0 == ipart) {
1130 if(dauMuGen->
pdgId() == ipart && dauMuGen->
status() ==1) {
1131 p4part = dauMuGen->
p4();
1135 if (partId1 == ipart) {
1138 if(dauMuGen->
pdgId() == ipart && dauMuGen->
status() ==1) {
1139 p4part = dauMuGen->
p4();
1143 if (partId2 == ipart) {
1147 p4part = dauMuGen->
p4();
1158 cout <<
"------------------------------------ Counters --------------------------------" << endl;
1164 cout <<
"------------------------------------ Counters for standAlone charge mis-id studies --------------------------------" << endl;
1173 cout <<
"------------------------------------ Counters for Track charge mis-id studies --------------------------------" << endl;
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
bool isNonnull() const
Checks for non-null.
virtual bool isStandAloneMuon() const =0
def analyze(function, filename, filter=None)
#define DEFINE_FWK_MODULE(type)
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
stand alone muon component tag
virtual TrackRef track() const
reference to a Track
def setup(process, global_tag, zero_tesla=False)
T * make(const Args &...args) const
make new ROOT object
RefToBase< value_type > refAt(size_type i) const
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
virtual bool isTrackerMuon() const =0
virtual int status() const =0
status word
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
virtual int pdgId() const =0
PDG identifier.
Abs< T >::type abs(const T &t)
double deltaR(double eta1, double eta2, double phi1, double phi2)
virtual const CandidateBaseRef & masterClone() const =0
virtual bool isGlobalMuon() const =0
virtual double eta() const =0
momentum pseudorapidity
virtual double pt() const =0
transverse momentum
conbined muon component tag
virtual double mass() const =0
mass
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
virtual int charge() const =0
electric charge
T get() const
get a component
virtual size_type numberOfDaughters() const =0
number of daughters
virtual double phi() const =0
momentum azimuthal angle
math::PtEtaPhiELorentzVectorF LorentzVector
virtual TrackRef standAloneMuon() const
reference to a stand-alone muon Track