523 iEvent.
getByLabel(
"offlinePrimaryVertices", vertexHandle);
526 std::cout << __FUNCTION__ <<
":" << __LINE__ <<
":vertexHandle handle not found!" << std::endl;
529 const int nvtx = vertexHandle->size();
531 using namespace reco;
539 edm::LogInfo(
"OutputInfo") <<
" failed to retrieve data required by MET Task";
540 edm::LogInfo(
"OutputInfo") <<
" MET Task cannot continue...!";
544 calomet = &(calometcol->front());
550 const double caloSumET = calomet->
sumEt();
551 const double caloMETSig = calomet->
mEtSig();
552 const double caloMET = calomet->
pt();
553 const double caloMEx = calomet->
px();
554 const double caloMEy = calomet->
py();
555 const double caloMETPhi = calomet->
phi();
559 const double caloEmEtFraction = calomet->
emEtFraction();
560 const double caloHadEtInHB = calomet->
hadEtInHB();
561 const double caloHadEtInHO = calomet->
hadEtInHO();
562 const double caloHadEtInHE = calomet->
hadEtInHE();
563 const double caloHadEtInHF = calomet->
hadEtInHF();
564 const double caloEmEtInEB = calomet->
emEtInEB();
565 const double caloEmEtInEE = calomet->
emEtInEE();
566 const double caloEmEtInHF = calomet->
emEtInHF();
570 edm::LogInfo(
"OutputInfo") << caloMET <<
" " << caloSumET << std::endl;
571 me[
"hNevents"]->Fill(0.5);
572 me[
"hCaloMEx"]->Fill(caloMEx);
573 me[
"hCaloMEy"]->Fill(caloMEy);
574 me[
"hCaloMET"]->Fill(caloMET);
575 me[
"hCaloMETPhi"]->Fill(caloMETPhi);
576 me[
"hCaloSumET"]->Fill(caloSumET);
577 me[
"hCaloMETSig"]->Fill(caloMETSig);
578 me[
"hCaloMaxEtInEmTowers"]->Fill(caloMaxEtInEMTowers);
579 me[
"hCaloMaxEtInHadTowers"]->Fill(caloMaxEtInHadTowers);
580 me[
"hCaloEtFractionHadronic"]->Fill(caloEtFractionHadronic);
581 me[
"hCaloEmEtFraction"]->Fill(caloEmEtFraction);
582 me[
"hCaloHadEtInHB"]->Fill(caloHadEtInHB);
583 me[
"hCaloHadEtInHO"]->Fill(caloHadEtInHO);
584 me[
"hCaloHadEtInHE"]->Fill(caloHadEtInHE);
585 me[
"hCaloHadEtInHF"]->Fill(caloHadEtInHF);
586 me[
"hCaloEmEtInEB"]->Fill(caloEmEtInEB);
587 me[
"hCaloEmEtInEE"]->Fill(caloEmEtInEE);
588 me[
"hCaloEmEtInHF"]->Fill(caloEmEtInHF);
589 me[
"hCaloSETInpHF"]->Fill(caloSETInpHF);
590 me[
"hCaloSETInmHF"]->Fill(caloSETInmHF);
595 me[
"hNvertex"]->Fill(nvtx);
599 me[
"hCaloMET_Nvtx0to5"]->Fill(caloMET);
600 me[
"hCaloSumET_Nvtx0to5"]->Fill(caloSumET);
601 }
else if (nvtx >= 6 && nvtx <= 10)
603 me[
"hCaloMET_Nvtx6to10"]->Fill(caloMET);
604 me[
"hCaloSumET_Nvtx6to10"]->Fill(caloSumET);
605 }
else if (nvtx >= 11 && nvtx <= 15)
607 me[
"hCaloMET_Nvtx11to15"]->Fill(caloMET);
608 me[
"hCaloSumET_Nvtx11to15"]->Fill(caloSumET);
609 }
else if (nvtx >= 16 && nvtx <= 20)
611 me[
"hCaloMET_Nvtx16to20"]->Fill(caloMET);
612 me[
"hCaloSumET_Nvtx16to20"]->Fill(caloSumET);
613 }
else if (nvtx >= 21 && nvtx <= 30)
615 me[
"hCaloMET_Nvtx21to30"]->Fill(caloMET);
616 me[
"hCaloSumET_Nvtx21to30"]->Fill(caloSumET);
617 }
else if (nvtx >= 31)
619 me[
"hCaloMET_Nvtx30toInf"]->Fill(caloMET);
620 me[
"hCaloSumET_Nvtx30toInf"]->Fill(caloSumET);
631 double genMET = genMetTrue->
pt();
632 double genMETPhi = genMetTrue->
phi();
634 me[
"hCaloMETResolution_GenMETTrue"]->Fill( caloMET - genMET );
635 me[
"hCaloMETPhiResolution_GenMETTrue"]->Fill( TMath::ACos( TMath::Cos( caloMETPhi - genMETPhi ) ) );
637 edm::LogInfo(
"OutputInfo") <<
" failed to retrieve data required by MET Task: genMetTrue";
646 const double genMET = genMetCalo->
pt();
647 const double genMETPhi = genMetCalo->
phi();
649 me[
"hCaloMETResolution_GenMETCalo"]->Fill( caloMET - genMET );
650 me[
"hCaloMETPhiResolution_GenMETCalo"]->Fill( TMath::ACos( TMath::Cos( caloMETPhi - genMETPhi ) ) );
652 edm::LogInfo(
"OutputInfo") <<
" failed to retrieve data required by MET Task: genMetCalo";
663 edm::LogInfo(
"OutputInfo") <<
" failed to retrieve data required by MET Task";
664 edm::LogInfo(
"OutputInfo") <<
" MET Task cannot continue...!";
668 genmet = &(genmetcol->front());
673 const double genSumET = genmet->
sumEt();
674 const double genMET = genmet->
pt();
675 const double genMEx = genmet->
px();
676 const double genMEy = genmet->
py();
677 const double genMETPhi = genmet->
phi();
678 const double genMETSig = genmet->
mEtSig();
693 me[
"hNevents"]->Fill(0);
694 me[
"hGenMEx"]->Fill(genMEx);
695 me[
"hGenMEy"]->Fill(genMEy);
696 me[
"hGenMET"]->Fill(genMET);
697 me[
"hGenMETPhi"]->Fill(genMETPhi);
698 me[
"hGenSumET"]->Fill(genSumET);
699 me[
"hGenMETSig"]->Fill(genMETSig);
702 me[
"hNeutralEMEtFraction"]->Fill( NeutralEMEtFraction );
703 me[
"hNeutralHadEtFraction"]->Fill( NeutralHadEtFraction );
704 me[
"hChargedEMEtFraction"]->Fill( ChargedEMEtFraction );
705 me[
"hChargedHadEtFraction"]->Fill( ChargedHadEtFraction );
706 me[
"hMuonEtFraction"]->Fill( MuonEtFraction );
707 me[
"hInvisibleEtFraction"]->Fill( InvisibleEtFraction );
709 me[
"hNevents"]->Fill(0.5);
717 edm::LogInfo(
"OutputInfo") <<
"falied to retrieve data require by MET Task";
718 edm::LogInfo(
"OutputInfo") <<
"MET Taks cannot continue...!";
723 pfmet = &(pfmetcol->front());
726 const double SumET = pfmet->
sumEt();
727 const double MET = pfmet->
pt();
728 const double MEx = pfmet->
px();
729 const double MEy = pfmet->
py();
730 const double METPhi = pfmet->
phi();
731 const double METSig = pfmet->
mEtSig();
732 me[
"hMEx"]->Fill(MEx);
733 me[
"hMEy"]->Fill(MEy);
734 me[
"hMET"]->Fill(MET);
735 me[
"hMETPhi"]->Fill(METPhi);
736 me[
"hSumET"]->Fill(SumET);
737 me[
"hMETSig"]->Fill(METSig);
738 me[
"hNevents"]->Fill(0.5);
744 me[
"hNvertex"]->Fill(nvtx);
747 me[
"hMET_Nvtx0to5"]->Fill(MET);
748 me[
"hSumET_Nvtx0to5"]->Fill(SumET);
749 }
else if (nvtx >= 6 && nvtx <= 10)
751 me[
"hMET_Nvtx6to10"]->Fill(MET);
752 me[
"hSumET_Nvtx6to10"]->Fill(SumET);
753 }
else if (nvtx >= 11 && nvtx <= 15)
755 me[
"hMET_Nvtx11to15"]->Fill(MET);
756 me[
"hSumET_Nvtx11to15"]->Fill(SumET);
757 }
else if (nvtx >= 16 && nvtx <= 20)
759 me[
"hMET_Nvtx16to20"]->Fill(MET);
760 me[
"hSumET_Nvtx16to20"]->Fill(SumET);
761 }
else if (nvtx >= 21 && nvtx <= 30)
763 me[
"hMET_Nvtx21to30"]->Fill(MET);
764 me[
"hSumET_Nvtx21to30"]->Fill(SumET);
765 }
else if (nvtx >= 31)
767 me[
"hMET_Nvtx30toInf"]->Fill(MET);
768 me[
"hSumET_Nvtx30toInf"]->Fill(SumET);
776 const GenMET *genMetTrue = &(genmetcol->front());
777 const double genMET = genMetTrue->
pt();
778 const double genMETPhi = genMetTrue->
phi();
780 me[
"hMETResolution_GenMETTrue"]->Fill( MET - genMET );
781 me[
"hMETPhiResolution_GenMETTrue"]->Fill( TMath::ACos( TMath::Cos( METPhi - genMETPhi ) ) );
785 if (MET > 0 && MET < 20)
me[
"hMETResolution_GenMETTrue_MET0to20"]->Fill( MET - genMET );
786 else if (MET > 20 && MET < 40)
me[
"hMETResolution_GenMETTrue_MET20to40"]->Fill( MET - genMET );
787 else if (MET > 40 && MET < 60)
me[
"hMETResolution_GenMETTrue_MET40to60"]->Fill( MET - genMET );
788 else if (MET > 60 && MET < 80)
me[
"hMETResolution_GenMETTrue_MET60to80"]->Fill( MET - genMET );
789 else if (MET > 80 && MET <100)
me[
"hMETResolution_GenMETTrue_MET80to100"]->Fill( MET - genMET );
790 else if (MET >100 && MET <150)
me[
"hMETResolution_GenMETTrue_MET100to150"]->Fill( MET - genMET );
791 else if (MET >150 && MET <200)
me[
"hMETResolution_GenMETTrue_MET150to200"]->Fill( MET - genMET );
792 else if (MET >200 && MET <300)
me[
"hMETResolution_GenMETTrue_MET200to300"]->Fill( MET - genMET );
793 else if (MET >300 && MET <400)
me[
"hMETResolution_GenMETTrue_MET300to400"]->Fill( MET - genMET );
794 else if (MET >400 && MET <500)
me[
"hMETResolution_GenMETTrue_MET400to500"]->Fill( MET - genMET );
803 edm::LogInfo(
"OutputInfo") <<
" failed to retrieve data required by MET Task: genMetTrue";
811 const GenMET *genMetCalo = &(genmetcol->front());
812 const double genMET = genMetCalo->
pt();
813 const double genMETPhi = genMetCalo->
phi();
815 me[
"hMETResolution_GenMETCalo"]->Fill( MET - genMET );
816 me[
"hMETPhiResolution_GenMETCalo"]->Fill( TMath::ACos( TMath::Cos( METPhi - genMETPhi ) ) );
818 edm::LogInfo(
"OutputInfo") <<
" failed to retrieve data required by MET Task: genMetCalo";
830 edm::LogInfo(
"OutputInfo") <<
" failed to retrieve data required by MET Task";
831 edm::LogInfo(
"OutputInfo") <<
" MET Task cannot continue...!";
835 met = &(metcol->front());
839 const double SumET = met->
sumEt();
840 const double MET = met->
pt();
841 const double MEx = met->
px();
842 const double MEy = met->
py();
843 const double METPhi = met->
phi();
844 const double METSig = met->
mEtSig();
846 me[
"hMEx"]->Fill(MEx);
847 me[
"hMEy"]->Fill(MEy);
848 me[
"hMET"]->Fill(MET);
849 me[
"hMETPhi"]->Fill(METPhi);
850 me[
"hSumET"]->Fill(SumET);
851 me[
"hMETSig"]->Fill(METSig);
852 me[
"hNevents"]->Fill(0.5);
878 edm::LogInfo(
"OutputInfo") <<
"falied to retrieve data require by MET Task";
879 edm::LogInfo(
"OutputInfo") <<
"MET Taks cannot continue...!";
885 tcMet = &(tcMetcol->front());
889 edm::LogInfo(
"OutputInfo") <<
"falied to retrieve data require by MET Task";
890 edm::LogInfo(
"OutputInfo") <<
"MET Taks cannot continue...!";
896 caloMet = &(caloMetcol->front());
900 edm::LogInfo(
"OutputInfo") <<
"falied to retrieve muon data require by MET Task";
901 edm::LogInfo(
"OutputInfo") <<
"MET Taks cannot continue...!";
906 edm::LogInfo(
"OutputInfo") <<
"falied to retrieve track data require by MET Task";
907 edm::LogInfo(
"OutputInfo") <<
"MET Taks cannot continue...!";
912 edm::LogInfo(
"OutputInfo") <<
"falied to retrieve electron data require by MET Task";
913 edm::LogInfo(
"OutputInfo") <<
"MET Taks cannot continue...!";
918 edm::LogInfo(
"OutputInfo") <<
"falied to retrieve beam spot data require by MET Task";
919 edm::LogInfo(
"OutputInfo") <<
"MET Taks cannot continue...!";
928 iEvent.
getByLabel(
"muonTCMETValueMapProducer" ,
"muCorrData", tcMet_ValueMap_Handle);
933 for(
unsigned int mus = 0; mus < muon_h->size() ; mus++ ) {
936 if( muref->pt() < 20 )
continue;
941 if( type == 1 || type == 2 || type == 5 ) ++nM;
948 if( eleit->p4().pt() < 20 )
continue;
952 if( strcmp(
sample_.c_str() ,
"zmm" ) == 0 && nM != 2 )
return;
954 if( strcmp(
sample_.c_str() ,
"zee" ) == 0 && nE != 2 )
return;
956 if( strcmp(
sample_.c_str() ,
"ttbar" ) == 0 && ( nE + nM ) == 0 )
return;
959 const double SumET = tcMet->
sumEt();
960 const double MET = tcMet->
pt();
961 const double MEx = tcMet->
px();
962 const double MEy = tcMet->
py();
963 const double METPhi = tcMet->
phi();
964 const double METSig = tcMet->
mEtSig();
966 me[
"hMEx"]->Fill(MEx);
967 me[
"hMEy"]->Fill(MEy);
968 me[
"hMET"]->Fill(MET);
969 me[
"hMETPhi"]->Fill(METPhi);
970 me[
"hSumET"]->Fill(SumET);
971 me[
"hMETSig"]->Fill(METSig);
972 me[
"hNevents"]->Fill(0.5);
974 const double caloMET = caloMet->
pt();
975 const double caloMEx = caloMet->
px();
976 const double caloMEy = caloMet->
py();
978 me[
"hdMETx"]->Fill(caloMEx-MEx);
979 me[
"hdMETy"]->Fill(caloMEy-MEy);
980 me[
"hdMET"]->Fill(caloMET-MET);
982 const unsigned int nTracks = track_h->size();
983 unsigned int nCorrTracks = 0;
984 unsigned int trackCount = 0;
985 for( reco::TrackCollection::const_iterator trkit = track_h->begin(); trkit != track_h->end(); trkit++ ) {
986 me[
"htrkPt"]->Fill( trkit->pt() );
987 me[
"htrkEta"]->Fill( trkit->eta() );
988 me[
"htrkNhits"]->Fill( trkit->numberOfValidHits() );
989 me[
"htrkChi2"]->Fill( trkit->chi2() / trkit->ndof() );
991 double d0 = -1 * trkit->dxy( bspot );
993 me[
"htrkD0"]->Fill( d0 );
995 me[
"htrkQuality"]->Fill( trkit->qualityMask() );
996 me[
"htrkAlgo"]->Fill( trkit->algo() );
997 me[
"htrkPtErr"]->Fill( trkit->ptError() / trkit->pt() );
1005 const float frac = (float)nCorrTracks / (
float)nTracks;
1006 me[
"hfracTrks"]->Fill(frac);
1010 me[
"helePt"]->Fill( eleit->p4().pt() );
1011 me[
"heleEta"]->Fill( eleit->p4().eta() );
1012 me[
"heleHoE"]->Fill( eleit->hadronicOverEm() );
1016 unsigned int ele_idx = el_track.
isNonnull() ? el_track.
key() : 99999;
1018 if( eleit->hadronicOverEm() < 0.1 && ele_idx < nTracks )
1022 me[
"hnEls"]->Fill(nEls);
1024 for( reco::MuonCollection::const_iterator muonit = muon_h->begin(); muonit != muon_h->end(); muonit++ ) {
1028 me[
"hmuPt"]->Fill( muonit->p4().pt() );
1029 me[
"hmuEta"]->Fill( muonit->p4().eta() );
1030 me[
"hmuNhits"]->Fill( siTrack.
isNonnull() ? siTrack->numberOfValidHits() : -999 );
1031 me[
"hmuChi2"]->Fill( siTrack.
isNonnull() ? siTrack->chi2()/siTrack->ndof() : -999 );
1033 double d0 = siTrack.
isNonnull() ? -1 * siTrack->dxy( bspot) : -999;
1035 me[
"hmuD0"]->Fill( d0 );
1042 iEvent.
getByLabel(
"muonMETValueMapProducer" ,
"muCorrData", muon_ValueMap_Handle);
1044 const unsigned int nMuons = muon_h->size();
1050 for(
unsigned int mus = 0; mus < nMuons; mus++ )
1059 int type = muCorrData.
type();
1060 me[
"hMuonCorrectionFlag"]->
Fill(type);
1062 if( type == 1 || type == 2 || type == 5 ) {
1066 muDx += muonCorrData.
corrX() - muref->globalTrack()->px();
1067 muDy += muonCorrData.
corrY() - muref->globalTrack()->py();
1069 else if( type == 2 ) {
1070 muDx += muonCorrData.
corrX() - muref->innerTrack()->px();
1071 muDy += muonCorrData.
corrY() - muref->innerTrack()->py();
1073 else if( type == 5 ) {
1074 muDx += muonCorrData.
corrX() - muref->px();
1075 muDy += muonCorrData.
corrY() - muref->py();
1078 else if( type == 4 )
1082 me[
"hnMus"]->Fill(nMus);
1083 me[
"hnMusPis"]->Fill(nMusPis);
1084 me[
"hdMUx"]->Fill(muDx);
1085 me[
"hdMUy"]->Fill(muDy);
1091 const GenMET *genMetTrue = &(genmetcol->front());
1092 const double genMET = genMetTrue->
pt();
1093 const double genMETPhi = genMetTrue->
phi();
1095 me[
"hMETResolution_GenMETTrue"]->Fill( MET - genMET );
1096 me[
"hMETPhiResolution_GenMETTrue"]->Fill( TMath::ACos( TMath::Cos( METPhi - genMETPhi ) ) );
1098 edm::LogInfo(
"OutputInfo") <<
" failed to retrieve data required by MET Task: genMetTrue";
1106 const GenMET *genMetCalo = &(genmetcol->front());
1107 const double genMET = genMetCalo->
pt();
1108 const double genMETPhi = genMetCalo->
phi();
1110 me[
"hMETResolution_GenMETCalo"]->Fill( MET - genMET );
1111 me[
"hMETPhiResolution_GenMETCalo"]->Fill( TMath::ACos( TMath::Cos( METPhi - genMETPhi ) ) );
1113 edm::LogInfo(
"OutputInfo") <<
" failed to retrieve data required by MET Task: genMetCalo";
1121 if(! hcorMetGlobalMuonscol.
isValid()){
1122 edm::LogInfo(
"OutputInfo") <<
"hcorMetGlobalMuonscol is NOT Valid";
1123 edm::LogInfo(
"OutputInfo") <<
"MET Taks continues anyway...!";
1128 corMetGlobalMuons = &(corMetGlobalMuonscol->front());
1132 const double SumET = corMetGlobalMuons->
sumEt();
1133 const double MET = corMetGlobalMuons->
pt();
1134 const double MEx = corMetGlobalMuons->
px();
1135 const double MEy = corMetGlobalMuons->
py();
1136 const double METPhi = corMetGlobalMuons->
phi();
1137 const double METSig = corMetGlobalMuons->
mEtSig();
1138 me[
"hMEx"]->Fill(MEx);
1139 me[
"hMEy"]->Fill(MEy);
1140 me[
"hMET"]->Fill(MET);
1141 me[
"hMETPhi"]->Fill(METPhi);
1142 me[
"hSumET"]->Fill(SumET);
1143 me[
"hMETSig"]->Fill(METSig);
1144 me[
"hNevents"]->Fill(0.5);
1147 iEvent.
getByLabel(
"muonMETValueMapProducer" ,
"muCorrData", corMetGlobalMuons_ValueMap_Handle);
1157 edm::LogInfo(
"OutputInfo") <<
"MET Taks continues anyway...!";
1162 for( reco::MuonCollection::const_iterator muonit = muon_Handle->begin(); muonit != muon_Handle->end(); muonit++ ) {
1167 me[
"hmuPt"]->Fill( muonit->p4().pt() );
1168 me[
"hmuEta"]->Fill( muonit->p4().eta() );
1169 me[
"hmuNhits"]->Fill( siTrack.
isNonnull() ? siTrack->numberOfValidHits() : -999 );
1170 me[
"hmuChi2"]->Fill( siTrack.
isNonnull() ? siTrack->chi2()/siTrack->ndof() : -999 );
1172 double d0 = siTrack.
isNonnull() ? -1 * siTrack->dxy( bspot) : -999;
1174 me[
"hmuD0"]->Fill( d0 );
1176 int nHits = globalTrack.
isNonnull() ? globalTrack->hitPattern().numberOfValidMuonHits() : -999;
1178 me[
"hmuSAhits"]->Fill( nHits );
1181 const unsigned int nMuons = muon_Handle->size();
1182 for(
unsigned int mus = 0; mus < nMuons; mus++ )
1189 me[
"hMuonCorrectionFlag"]->
Fill(muCorrData.
type());
1196 const GenMET *genMetTrue = &(genmetcol->front());
1197 const double genMET = genMetTrue->
pt();
1198 const double genMETPhi = genMetTrue->
phi();
1200 me[
"hMETResolution_GenMETTrue"]->Fill( MET - genMET );
1201 me[
"hMETPhiResolution_GenMETTrue"]->Fill( TMath::ACos( TMath::Cos( METPhi - genMETPhi ) ) );
1203 edm::LogInfo(
"OutputInfo") <<
" failed to retrieve data required by MET Task: genMetTrue";
1211 const GenMET *genMetCalo = &(genmetcol->front());
1212 const double genMET = genMetCalo->
pt();
1213 const double genMETPhi = genMetCalo->
phi();
1215 me[
"hMETResolution_GenMETCalo"]->Fill( MET - genMET );
1216 me[
"hMETPhiResolution_GenMETCalo"]->Fill( TMath::ACos( TMath::Cos( METPhi - genMETPhi ) ) );
1218 edm::LogInfo(
"OutputInfo") <<
" failed to retrieve data required by MET Task: genMetCalo";
edm::InputTag inputCaloMETLabel_
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
edm::InputTag inputTrackLabel_
double CaloSETInmHF() const
double maxEtInHadTowers() const
double MuonEtFraction() const
double maxEtInEmTowers() const
virtual double py() const GCC11_FINAL
y coordinate of momentum vector
edm::InputTag inputElectronLabel_
bool isNonnull() const
Checks for non-null.
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
edm::InputTag inputBeamSpotLabel_
double ChargedEMEtFraction() const
virtual double px() const GCC11_FINAL
x coordinate of momentum vector
double CaloSETInpHF() const
edm::InputTag inputMuonLabel_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
double InvisibleEtFraction() const
double etFractionHadronic() const
XYZPointD XYZPoint
point in space with cartesian internal representation
key_type key() const
Accessor for product key.
std::map< std::string, MonitorElement * > me
T const * product() const
double NeutralEMEtFraction() const
double NeutralHadEtFraction() const
bool isGoodTrack(const reco::TrackRef, float d0corr)
edm::InputTag inputMETLabel_
double ChargedHadEtFraction() const
virtual float pt() const GCC11_FINAL
transverse momentum
double emEtFraction() const