00001 #include "DataFormats/METReco/interface/MET.h"
00002 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00003 #include "DQMOffline/PFTau/interface/Matchers.h"
00004
00005 #include "DQMOffline/PFTau/interface/PFMETMonitor.h"
00006
00007 #include <TROOT.h>
00008 #include <TFile.h>
00009 #include <TH1.h>
00010 #include <TH2.h>
00011
00012
00013
00014
00015 PFMETMonitor::PFMETMonitor( Benchmark::Mode mode) :
00016 Benchmark(mode),
00017 candBench_(mode),
00018 matchCandBench_(mode) {
00019
00020 setRange( 0.0, 10e10, -10.0, 10.0, -3.14, 3.14);
00021
00022 px_ = 0;
00023 sumEt_ = 0;
00024 delta_ex_ = 0;
00025 delta_ex_VS_set_ = 0;
00026 delta_set_VS_set_ = 0;
00027 delta_set_Over_set_VS_set_ = 0;
00028
00029 createMETSpecificHistos_ = false;
00030 histogramBooked_ = false;
00031 }
00032
00033
00034
00035 PFMETMonitor::~PFMETMonitor() {}
00036
00037
00038
00039
00040 void PFMETMonitor::setParameters( const edm::ParameterSet & parameterSet) {
00041
00042 mode_ = (Benchmark::Mode) parameterSet.getParameter<int>( "mode" );
00043 createMETSpecificHistos_ = parameterSet.getParameter<bool>( "CreateMETSpecificHistos" );
00044 setRange( parameterSet.getParameter<double>("ptMin"),
00045 parameterSet.getParameter<double>("ptMax"),
00046 parameterSet.getParameter<double>("etaMin"),
00047 parameterSet.getParameter<double>("etaMax"),
00048 parameterSet.getParameter<double>("phiMin"),
00049 parameterSet.getParameter<double>("phiMax") );
00050
00051
00052 candBench_.setParameters(mode_);
00053 matchCandBench_.setParameters(mode_);
00054 }
00055
00056
00057
00058 void PFMETMonitor::setParameters(Benchmark::Mode mode, float ptmin, float ptmax,
00059 float etamin, float etamax, float phimin,
00060 float phimax, bool metSpHistos) {
00061 mode_ = mode;
00062 createMETSpecificHistos_ = metSpHistos;
00063
00064 setRange( ptmin, ptmax, etamin, etamax, phimin, phimax);
00065
00066 candBench_.setParameters(mode_);
00067 matchCandBench_.setParameters(mode_);
00068 }
00069
00070
00071
00072 void PFMETMonitor::setup(const edm::ParameterSet & parameterSet) {
00073 candBench_.setup(parameterSet);
00074 matchCandBench_.setup(parameterSet);
00075
00076 if (createMETSpecificHistos_ && !histogramBooked_) {
00077
00078 edm::ParameterSet pxPS = parameterSet.getParameter<edm::ParameterSet>("DeltaPxHistoParameter");
00079 edm::ParameterSet dpxPS = parameterSet.getParameter<edm::ParameterSet>("DeltaPxHistoParameter");
00080 edm::ParameterSet dptPS = parameterSet.getParameter<edm::ParameterSet>("DeltaPtHistoParameter");
00081 edm::ParameterSet setPS = parameterSet.getParameter<edm::ParameterSet>("SumEtHistoParameter");
00082 edm::ParameterSet dsetPS = parameterSet.getParameter<edm::ParameterSet>("DeltaSumEtHistoParameter");
00083 edm::ParameterSet setOvsetPS = parameterSet.getParameter<edm::ParameterSet>("DeltaSumEtOvSumEtHistoParameter");
00084
00085 if (pxPS.getParameter<bool>("switchOn")) {
00086 px_ = book1D("px_", "px_;p_{X} (GeV)",
00087 pxPS.getParameter<int32_t>("nBin"),
00088 pxPS.getParameter<double>("xMin"),
00089 pxPS.getParameter<double>("xMax"));
00090 }
00091 if (setPS.getParameter<bool>("switchOn")) {
00092 sumEt_ = book1D("sumEt_", "sumEt_;#sumE_{T}",
00093 setPS.getParameter<int32_t>("nBin"),
00094 setPS.getParameter<double>("xMin"),
00095 setPS.getParameter<double>("xMax"));
00096 }
00097 if (dpxPS.getParameter<bool>("switchOn")) {
00098 delta_ex_ = book1D("delta_ex_", "#DeltaME_{X}",
00099 dpxPS.getParameter<int32_t>("nBin"),
00100 dpxPS.getParameter<double>("xMin"),
00101 dpxPS.getParameter<double>("xMax"));
00102 }
00103
00104 if (dpxPS.getParameter<bool>("switchOn")) {
00105 delta_ex_VS_set_ = book2D("delta_ex_VS_set_",
00106 ";SE_{T, true} (GeV);#DeltaE_{X}",
00107 setPS.getParameter<int32_t>("nBin"),
00108 setPS.getParameter<double>("xMin"),
00109 setPS.getParameter<double>("xMax"),
00110 dptPS.getParameter<int32_t>("nBin"),
00111 dptPS.getParameter<double>("xMin"),
00112 dptPS.getParameter<double>("xMax"));
00113 }
00114 if (dsetPS.getParameter<bool>("switchOn")) {
00115 delta_set_VS_set_ = book2D("delta_set_VS_set_",
00116 ";SE_{T, true} (GeV);#DeltaSE_{T}",
00117 setPS.getParameter<int32_t>("nBin"),
00118 setPS.getParameter<double>("xMin"),
00119 setPS.getParameter<double>("xMax"),
00120 dsetPS.getParameter<int32_t>("nBin"),
00121 dsetPS.getParameter<double>("xMin"),
00122 dsetPS.getParameter<double>("xMax"));
00123 }
00124 if (setOvsetPS.getParameter<bool>("switchOn")) {
00125 delta_set_Over_set_VS_set_ = book2D("delta_set_Over_set_VS_set_",
00126 ";SE_{T, true} (GeV);#DeltaSE_{T}/SE_{T}",
00127 setPS.getParameter<int32_t>("nBin"),
00128 setPS.getParameter<double>("xMin"),
00129 setPS.getParameter<double>("xMax"),
00130 setOvsetPS.getParameter<int32_t>("nBin"),
00131 setOvsetPS.getParameter<double>("xMin"),
00132 setOvsetPS.getParameter<double>("xMax"));
00133 }
00134 histogramBooked_ = true;
00135 }
00136 }
00137
00138
00139
00140 void PFMETMonitor::setup() {
00141 candBench_.setup();
00142 matchCandBench_.setup();
00143
00144 if (createMETSpecificHistos_ && !histogramBooked_) {
00145
00146 PhaseSpace pxPS = PhaseSpace( 50, 0, 200);
00147 PhaseSpace dpxPS = PhaseSpace( 50, -500, 500);
00148 PhaseSpace setPS = PhaseSpace( 50, 0.0, 3000);
00149 PhaseSpace dsetPS = PhaseSpace( 50, -1000.0, 1000);
00150 PhaseSpace setOvsetPS = PhaseSpace( 100,0., 2.);
00151
00152 px_ = book1D("px_", "px_;p_{X} (GeV)", pxPS.n, pxPS.m, pxPS.M);
00153
00154 sumEt_ = book1D("sumEt_", "sumEt_;#sumE_{T}", setPS.n, setPS.m, setPS.M);
00155
00156 delta_ex_ = book1D("delta_ex_", "#DeltaME_{X}", dpxPS.n, dpxPS.m, dpxPS.M);
00157
00158 delta_ex_VS_set_ = book2D("delta_ex_VS_set_", ";SE_{T, true} (GeV);#DeltaE_{X}",
00159 setPS.n, setPS.m, setPS.M,
00160 dpxPS.n, dpxPS.m, dpxPS.M );
00161
00162 delta_set_VS_set_ = book2D("delta_set_VS_set_",
00163 ";SE_{T, true} (GeV);#DeltaSE_{T}",
00164 setPS.n, setPS.m, setPS.M,
00165 dsetPS.n, dsetPS.m, dsetPS.M );
00166
00167 delta_set_Over_set_VS_set_ = book2D("delta_set_Over_set_VS_set_",
00168 ";SE_{T, true} (GeV);#DeltaSE_{T}/SE_{T}",
00169 setPS.n, setPS.m, setPS.M,
00170 setOvsetPS.n, setOvsetPS.m, setOvsetPS.M );
00171 histogramBooked_ = true;
00172 }
00173 }
00174
00175 void PFMETMonitor::setDirectory(TDirectory* dir) {
00176 Benchmark::setDirectory(dir);
00177
00178 candBench_.setDirectory(dir);
00179 matchCandBench_.setDirectory(dir);
00180 }
00181
00182 void PFMETMonitor::fillOne(const reco::MET& met,
00183 const reco::MET& matchedMet, float& minVal, float& maxVal) {
00184 candBench_.fillOne(met);
00185 matchCandBench_.fillOne(met, matchedMet);
00186 if (createMETSpecificHistos_ && histogramBooked_) {
00187 if( !isInRange(met.pt(), met.eta(), met.phi() ) ) return;
00188
00189 if (px_) px_->Fill(met.px());
00190 if (delta_ex_) {
00191 delta_ex_->Fill(met.px()-matchedMet.px());
00192 delta_ex_->Fill(met.py()-matchedMet.py());
00193 }
00194 if (sumEt_) sumEt_->Fill( met.sumEt());
00195
00196 if (delta_ex_VS_set_) {
00197 delta_ex_VS_set_->Fill(matchedMet.sumEt(), met.px()-matchedMet.px());
00198 delta_ex_VS_set_->Fill(matchedMet.sumEt(), met.py()-matchedMet.py());
00199 }
00200 if (delta_set_VS_set_) delta_set_VS_set_->Fill(matchedMet.sumEt(),met.sumEt()-matchedMet.sumEt());
00201 if (delta_set_Over_set_VS_set_ && matchedMet.sumEt()>0.001 ) {
00202 float setRes = (met.sumEt() - matchedMet.sumEt())/matchedMet.sumEt();
00203 if (setRes > maxVal) maxVal = setRes;
00204 if (setRes < minVal) minVal = setRes;
00205 delta_set_Over_set_VS_set_->Fill(matchedMet.sumEt(),setRes);
00206 }
00207 }
00208 }