CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DQMOffline/PFTau/src/PFMETMonitor.cc

Go to the documentation of this file.
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 // -- Constructor
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 // -- Destructor
00034 //
00035 PFMETMonitor::~PFMETMonitor() {}
00036 
00037 //
00038 // -- Set Parameters accessing them from ParameterSet
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 // -- Set Parameters 
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 // -- Create histograms accessing parameters from ParameterSet
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 // -- Create histograms using local parameters
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 dptPS      = PhaseSpace( 200, -500, 500);
00149     PhaseSpace setPS      = PhaseSpace( 50, 0.0, 3000);
00150     PhaseSpace dsetPS     = PhaseSpace( 50, -1000.0, 1000);
00151     PhaseSpace setOvsetPS = PhaseSpace( 100,0., 2.);
00152 
00153     px_  = book1D("px_", "px_;p_{X} (GeV)", pxPS.n, pxPS.m, pxPS.M);
00154 
00155     sumEt_ = book1D("sumEt_", "sumEt_;#sumE_{T}", setPS.n, setPS.m, setPS.M);
00156 
00157     delta_ex_ = book1D("delta_ex_", "#DeltaME_{X}", dpxPS.n, dpxPS.m, dpxPS.M);
00158     
00159     delta_ex_VS_set_ = book2D("delta_ex_VS_set_", ";SE_{T, true} (GeV);#DeltaE_{X}",
00160                               setPS.n, setPS.m, setPS.M, 
00161                               dpxPS.n, dpxPS.m, dpxPS.M );
00162     
00163     delta_set_VS_set_ = book2D("delta_set_VS_set_", 
00164                                ";SE_{T, true} (GeV);#DeltaSE_{T}",
00165                                setPS.n, setPS.m, setPS.M,
00166                                dsetPS.n, dsetPS.m, dsetPS.M );
00167     
00168     delta_set_Over_set_VS_set_ = book2D("delta_set_Over_set_VS_set_", 
00169                                         ";SE_{T, true} (GeV);#DeltaSE_{T}/SE_{T}",
00170                                         setPS.n, setPS.m, setPS.M,
00171                                         setOvsetPS.n, setOvsetPS.m, setOvsetPS.M );
00172     histogramBooked_ = true;
00173   }
00174 }
00175 
00176 void PFMETMonitor::setDirectory(TDirectory* dir) {
00177   Benchmark::setDirectory(dir);
00178 
00179   candBench_.setDirectory(dir);
00180   matchCandBench_.setDirectory(dir);
00181 }
00182 
00183 void PFMETMonitor::fillOne(const reco::MET& met,
00184                            const reco::MET& matchedMet, float& minVal, float& maxVal) {
00185   candBench_.fillOne(met);
00186   matchCandBench_.fillOne(met, matchedMet);
00187   if (createMETSpecificHistos_ && histogramBooked_) {
00188     if( !isInRange(met.pt(), met.eta(), met.phi() ) ) return;
00189 
00190     if (px_) px_->Fill(met.px());
00191     if (delta_ex_) {
00192       delta_ex_->Fill(met.px()-matchedMet.px());
00193       delta_ex_->Fill(met.py()-matchedMet.py());
00194     }
00195     if (sumEt_) sumEt_->Fill( met.sumEt());
00196 
00197     if (delta_ex_VS_set_) {
00198       delta_ex_VS_set_->Fill(matchedMet.sumEt(), met.px()-matchedMet.px());
00199       delta_ex_VS_set_->Fill(matchedMet.sumEt(), met.py()-matchedMet.py());
00200     }
00201     if (delta_set_VS_set_) delta_set_VS_set_->Fill(matchedMet.sumEt(),met.sumEt()-matchedMet.sumEt());
00202     if (delta_set_Over_set_VS_set_ &&  matchedMet.sumEt()>0.001 ) {
00203       float setRes = (met.sumEt() - matchedMet.sumEt())/matchedMet.sumEt();
00204       if (setRes > maxVal) maxVal = setRes;
00205       if (setRes < minVal) minVal = setRes;    
00206       delta_set_Over_set_VS_set_->Fill(matchedMet.sumEt(),setRes);
00207     }
00208   } 
00209 }