Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:13:11

0001 #include "DQMOffline/PFTau/interface/Matchers.h"
0002 #include "DataFormats/METReco/interface/MET.h"
0003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0004 
0005 #include "DQMOffline/PFTau/interface/PFMETMonitor.h"
0006 
0007 #include <TFile.h>
0008 #include <TH1.h>
0009 #include <TH2.h>
0010 #include <TROOT.h>
0011 
0012 #include <TProfile.h>
0013 
0014 //
0015 // -- Constructor
0016 //
0017 PFMETMonitor::PFMETMonitor(Benchmark::Mode mode) : Benchmark(mode), candBench_(mode), matchCandBench_(mode) {
0018   setRange(0.0, 10e10, -10.0, 10.0, -3.14, 3.14);
0019 
0020   px_ = nullptr;
0021   sumEt_ = nullptr;
0022   delta_ex_ = nullptr;
0023   delta_ex_VS_set_ = nullptr;
0024   delta_set_VS_set_ = nullptr;
0025   delta_set_Over_set_VS_set_ = nullptr;
0026 
0027   profile_delta_ex_VS_set_ = nullptr;
0028   profile_delta_set_VS_set_ = nullptr;
0029   profile_delta_set_Over_set_VS_set_ = nullptr;
0030   profileRMS_delta_ex_VS_set_ = nullptr;
0031   profileRMS_delta_set_VS_set_ = nullptr;
0032   profileRMS_delta_set_Over_set_VS_set_ = nullptr;
0033 
0034   createMETSpecificHistos_ = false;
0035   histogramBooked_ = false;
0036 }
0037 
0038 //
0039 // -- Destructor
0040 //
0041 PFMETMonitor::~PFMETMonitor() {}
0042 
0043 //
0044 // -- Set Parameters accessing them from ParameterSet
0045 //
0046 void PFMETMonitor::setParameters(const edm::ParameterSet &parameterSet) {
0047   mode_ = (Benchmark::Mode)parameterSet.getParameter<int>("mode");
0048   createMETSpecificHistos_ = parameterSet.getParameter<bool>("CreateMETSpecificHistos");
0049   setRange(parameterSet.getParameter<double>("ptMin"),
0050            parameterSet.getParameter<double>("ptMax"),
0051            parameterSet.getParameter<double>("etaMin"),
0052            parameterSet.getParameter<double>("etaMax"),
0053            parameterSet.getParameter<double>("phiMin"),
0054            parameterSet.getParameter<double>("phiMax"));
0055 
0056   candBench_.setParameters(mode_);
0057   matchCandBench_.setParameters(mode_);
0058 }
0059 
0060 //
0061 // -- Set Parameters
0062 //
0063 void PFMETMonitor::setParameters(Benchmark::Mode mode,
0064                                  float ptmin,
0065                                  float ptmax,
0066                                  float etamin,
0067                                  float etamax,
0068                                  float phimin,
0069                                  float phimax,
0070                                  bool metSpHistos) {
0071   mode_ = mode;
0072   createMETSpecificHistos_ = metSpHistos;
0073 
0074   setRange(ptmin, ptmax, etamin, etamax, phimin, phimax);
0075 
0076   candBench_.setParameters(mode_);
0077   matchCandBench_.setParameters(mode_);
0078 }
0079 
0080 //
0081 // -- Create histograms accessing parameters from ParameterSet
0082 //
0083 void PFMETMonitor::setup(DQMStore::IBooker &b, const edm::ParameterSet &parameterSet) {
0084   candBench_.setup(b, parameterSet);
0085   matchCandBench_.setup(b, parameterSet);
0086 
0087   if (createMETSpecificHistos_ && !histogramBooked_) {
0088     edm::ParameterSet pxPS = parameterSet.getParameter<edm::ParameterSet>("DeltaPxHistoParameter");
0089     edm::ParameterSet dpxPS = parameterSet.getParameter<edm::ParameterSet>("DeltaPxHistoParameter");
0090     edm::ParameterSet dptPS = parameterSet.getParameter<edm::ParameterSet>("DeltaPtHistoParameter");
0091     edm::ParameterSet setPS = parameterSet.getParameter<edm::ParameterSet>("SumEtHistoParameter");
0092     edm::ParameterSet dsetPS = parameterSet.getParameter<edm::ParameterSet>("DeltaSumEtHistoParameter");
0093     edm::ParameterSet setOvsetPS = parameterSet.getParameter<edm::ParameterSet>("DeltaSumEtOvSumEtHistoParameter");
0094 
0095     if (pxPS.getParameter<bool>("switchOn")) {
0096       px_ = book1D(b,
0097                    "px_",
0098                    "px_;p_{X} (GeV)",
0099                    pxPS.getParameter<int32_t>("nBin"),
0100                    pxPS.getParameter<double>("xMin"),
0101                    pxPS.getParameter<double>("xMax"));
0102     }
0103     if (setPS.getParameter<bool>("switchOn")) {
0104       sumEt_ = book1D(b,
0105                       "sumEt_",
0106                       "sumEt_;#sumE_{T}",
0107                       setPS.getParameter<int32_t>("nBin"),
0108                       setPS.getParameter<double>("xMin"),
0109                       setPS.getParameter<double>("xMax"));
0110     }
0111     if (dpxPS.getParameter<bool>("switchOn")) {
0112       delta_ex_ = book1D(b,
0113                          "delta_ex_",
0114                          "#DeltaME_{X}",
0115                          dpxPS.getParameter<int32_t>("nBin"),
0116                          dpxPS.getParameter<double>("xMin"),
0117                          dpxPS.getParameter<double>("xMax"));
0118     }
0119 
0120     if (dpxPS.getParameter<bool>("switchOn")) {
0121       delta_ex_VS_set_ = book2D(b,
0122                                 "delta_ex_VS_set_",
0123                                 ";SE_{T, true} (GeV);#DeltaE_{X}",
0124                                 setPS.getParameter<int32_t>("nBin"),
0125                                 setPS.getParameter<double>("xMin"),
0126                                 setPS.getParameter<double>("xMax"),
0127                                 dptPS.getParameter<int32_t>("nBin"),
0128                                 dptPS.getParameter<double>("xMin"),
0129                                 dptPS.getParameter<double>("xMax"));
0130     }
0131     if (dsetPS.getParameter<bool>("switchOn")) {
0132       delta_set_VS_set_ = book2D(b,
0133                                  "delta_set_VS_set_",
0134                                  ";SE_{T, true} (GeV);#DeltaSE_{T}",
0135                                  setPS.getParameter<int32_t>("nBin"),
0136                                  setPS.getParameter<double>("xMin"),
0137                                  setPS.getParameter<double>("xMax"),
0138                                  dsetPS.getParameter<int32_t>("nBin"),
0139                                  dsetPS.getParameter<double>("xMin"),
0140                                  dsetPS.getParameter<double>("xMax"));
0141     }
0142     if (setOvsetPS.getParameter<bool>("switchOn")) {
0143       delta_set_Over_set_VS_set_ = book2D(b,
0144                                           "delta_set_Over_set_VS_set_",
0145                                           ";SE_{T, true} (GeV);#DeltaSE_{T}/SE_{T}",
0146                                           setPS.getParameter<int32_t>("nBin"),
0147                                           setPS.getParameter<double>("xMin"),
0148                                           setPS.getParameter<double>("xMax"),
0149                                           setOvsetPS.getParameter<int32_t>("nBin"),
0150                                           setOvsetPS.getParameter<double>("xMin"),
0151                                           setOvsetPS.getParameter<double>("xMax"));
0152     }
0153 
0154     // TProfile
0155     if (dpxPS.getParameter<bool>("switchOn")) {
0156       profile_delta_ex_VS_set_ = bookProfile(b,
0157                                              "profile_delta_ex_VS_set_",
0158                                              ";SE_{T, true} (GeV);#DeltaE_{X}",
0159                                              setPS.getParameter<int32_t>("nBin"),
0160                                              setPS.getParameter<double>("xMin"),
0161                                              setPS.getParameter<double>("xMax"),
0162                                              dptPS.getParameter<double>("xMin"),
0163                                              dptPS.getParameter<double>("xMax"),
0164                                              "");
0165       profileRMS_delta_ex_VS_set_ = bookProfile(b,
0166                                                 "profileRMS_delta_ex_VS_set_",
0167                                                 ";SE_{T, true} (GeV);#DeltaE_{X}",
0168                                                 setPS.getParameter<int32_t>("nBin"),
0169                                                 setPS.getParameter<double>("xMin"),
0170                                                 setPS.getParameter<double>("xMax"),
0171                                                 dptPS.getParameter<double>("xMin"),
0172                                                 dptPS.getParameter<double>("xMax"),
0173                                                 "s");
0174     }
0175     if (dsetPS.getParameter<bool>("switchOn")) {
0176       profile_delta_set_VS_set_ = bookProfile(b,
0177                                               "profile_delta_set_VS_set_",
0178                                               ";SE_{T, true} (GeV);#DeltaSE_{T}",
0179                                               setPS.getParameter<int32_t>("nBin"),
0180                                               setPS.getParameter<double>("xMin"),
0181                                               setPS.getParameter<double>("xMax"),
0182                                               dsetPS.getParameter<double>("xMin"),
0183                                               dsetPS.getParameter<double>("xMax"),
0184                                               "");
0185       profileRMS_delta_set_VS_set_ = bookProfile(b,
0186                                                  "profileRMS_delta_set_VS_set_",
0187                                                  ";SE_{T, true} (GeV);#DeltaSE_{T}",
0188                                                  setPS.getParameter<int32_t>("nBin"),
0189                                                  setPS.getParameter<double>("xMin"),
0190                                                  setPS.getParameter<double>("xMax"),
0191                                                  dsetPS.getParameter<double>("xMin"),
0192                                                  dsetPS.getParameter<double>("xMax"),
0193                                                  "s");
0194     }
0195     if (setOvsetPS.getParameter<bool>("switchOn")) {
0196       profile_delta_set_Over_set_VS_set_ = bookProfile(b,
0197                                                        "profile_delta_set_Over_set_VS_set_",
0198                                                        ";SE_{T, true} (GeV);#DeltaSE_{T}/SE_{T}",
0199                                                        setPS.getParameter<int32_t>("nBin"),
0200                                                        setPS.getParameter<double>("xMin"),
0201                                                        setPS.getParameter<double>("xMax"),
0202                                                        setOvsetPS.getParameter<double>("xMin"),
0203                                                        setOvsetPS.getParameter<double>("xMax"),
0204                                                        "");
0205       profileRMS_delta_set_Over_set_VS_set_ = bookProfile(b,
0206                                                           "profileRMS_delta_set_Over_set_VS_set_",
0207                                                           ";SE_{T, true} (GeV);#DeltaSE_{T}/SE_{T}",
0208                                                           setPS.getParameter<int32_t>("nBin"),
0209                                                           setPS.getParameter<double>("xMin"),
0210                                                           setPS.getParameter<double>("xMax"),
0211                                                           setOvsetPS.getParameter<double>("xMin"),
0212                                                           setOvsetPS.getParameter<double>("xMax"),
0213                                                           "s");
0214     }
0215     histogramBooked_ = true;
0216   }
0217 }
0218 
0219 //
0220 // -- Create histograms using local parameters
0221 //
0222 void PFMETMonitor::setup(DQMStore::IBooker &b) {
0223   candBench_.setup(b);
0224   matchCandBench_.setup(b);
0225 
0226   if (createMETSpecificHistos_ && !histogramBooked_) {
0227     PhaseSpace pxPS = PhaseSpace(50, 0, 200);
0228     PhaseSpace dpxPS = PhaseSpace(50, -500, 500);
0229     PhaseSpace setPS = PhaseSpace(50, 0.0, 3000);
0230     PhaseSpace dsetPS = PhaseSpace(50, -1000.0, 1000);
0231     PhaseSpace setOvsetPS = PhaseSpace(100, 0., 2.);
0232 
0233     px_ = book1D(b, "px_", "px_;p_{X} (GeV)", pxPS.n, pxPS.m, pxPS.M);
0234     sumEt_ = book1D(b, "sumEt_", "sumEt_;#sumE_{T}", setPS.n, setPS.m, setPS.M);
0235     delta_ex_ = book1D(b, "delta_ex_", "#DeltaME_{X}", dpxPS.n, dpxPS.m, dpxPS.M);
0236     delta_ex_VS_set_ = book2D(
0237         b, "delta_ex_VS_set_", ";SE_{T, true} (GeV);#DeltaE_{X}", setPS.n, setPS.m, setPS.M, dpxPS.n, dpxPS.m, dpxPS.M);
0238     delta_set_VS_set_ = book2D(b,
0239                                "delta_set_VS_set_",
0240                                ";SE_{T, true} (GeV);#DeltaSE_{T}",
0241                                setPS.n,
0242                                setPS.m,
0243                                setPS.M,
0244                                dsetPS.n,
0245                                dsetPS.m,
0246                                dsetPS.M);
0247 
0248     delta_set_Over_set_VS_set_ = book2D(b,
0249                                         "delta_set_Over_set_VS_set_",
0250                                         ";SE_{T, true} (GeV);#DeltaSE_{T}/SE_{T}",
0251                                         setPS.n,
0252                                         setPS.m,
0253                                         setPS.M,
0254                                         setOvsetPS.n,
0255                                         setOvsetPS.m,
0256                                         setOvsetPS.M);
0257 
0258     // TProfile
0259     profile_delta_ex_VS_set_ = bookProfile(b,
0260                                            "profile_delta_ex_VS_set_",
0261                                            ";SE_{T, true} (GeV);#DeltaE_{X}",
0262                                            setPS.n,
0263                                            setPS.m,
0264                                            setPS.M,
0265                                            setOvsetPS.m,
0266                                            setOvsetPS.M,
0267                                            "");
0268 
0269     profile_delta_set_VS_set_ = bookProfile(b,
0270                                             "profile_delta_set_VS_set_",
0271                                             ";SE_{T, true} (GeV);#DeltaSE_{T}",
0272                                             setPS.n,
0273                                             setPS.m,
0274                                             setPS.M,
0275                                             setOvsetPS.m,
0276                                             setOvsetPS.M,
0277                                             "");
0278 
0279     profile_delta_set_Over_set_VS_set_ = bookProfile(b,
0280                                                      "profile_delta_set_Over_set_VS_set_",
0281                                                      ";SE_{T, true} (GeV);#DeltaSE_{T}/SE_{T}",
0282                                                      setPS.n,
0283                                                      setPS.m,
0284                                                      setPS.M,
0285                                                      setOvsetPS.m,
0286                                                      setOvsetPS.M,
0287                                                      "");
0288 
0289     // TProfile RMS
0290     profileRMS_delta_ex_VS_set_ = bookProfile(b,
0291                                               "profileRMS_delta_ex_VS_set_",
0292                                               ";SE_{T, true} (GeV);#DeltaE_{X}",
0293                                               setPS.n,
0294                                               setPS.m,
0295                                               setPS.M,
0296                                               setOvsetPS.m,
0297                                               setOvsetPS.M,
0298                                               "s");
0299 
0300     profileRMS_delta_set_VS_set_ = bookProfile(b,
0301                                                "profileRMS_delta_set_VS_set_",
0302                                                ";SE_{T, true} (GeV);#DeltaSE_{T}",
0303                                                setPS.n,
0304                                                setPS.m,
0305                                                setPS.M,
0306                                                setOvsetPS.m,
0307                                                setOvsetPS.M,
0308                                                "s");
0309 
0310     profileRMS_delta_set_Over_set_VS_set_ = bookProfile(b,
0311                                                         "profileRMS_delta_set_Over_set_VS_set_",
0312                                                         ";SE_{T, true} (GeV);#DeltaSE_{T}/SE_{T}",
0313                                                         setPS.n,
0314                                                         setPS.m,
0315                                                         setPS.M,
0316                                                         setOvsetPS.m,
0317                                                         setOvsetPS.M,
0318                                                         "s");
0319     histogramBooked_ = true;
0320   }
0321 }
0322 
0323 void PFMETMonitor::setDirectory(TDirectory *dir) {
0324   Benchmark::setDirectory(dir);
0325 
0326   candBench_.setDirectory(dir);
0327   matchCandBench_.setDirectory(dir);
0328 }
0329 
0330 void PFMETMonitor::fillOne(const reco::MET &met, const reco::MET &matchedMet, float &minVal, float &maxVal) {
0331   candBench_.fillOne(met);                   // std::cout <<"\nfillone MET candBench" <<std::endl;
0332   matchCandBench_.fillOne(met, matchedMet);  // std::cout <<"\nfillone MET
0333                                              // MatchCandBench done" <<std::endl;
0334 
0335   if (createMETSpecificHistos_ && histogramBooked_) {
0336     if (!isInRange(met.pt(), met.eta(), met.phi()))
0337       return;
0338 
0339     if (px_)
0340       px_->Fill(met.px());
0341     if (delta_ex_) {
0342       delta_ex_->Fill(met.px() - matchedMet.px());
0343       delta_ex_->Fill(met.py() - matchedMet.py());
0344     }
0345     if (sumEt_)
0346       sumEt_->Fill(met.sumEt());
0347 
0348     if (delta_ex_VS_set_) {
0349       delta_ex_VS_set_->Fill(matchedMet.sumEt(), met.px() - matchedMet.px());
0350       delta_ex_VS_set_->Fill(matchedMet.sumEt(), met.py() - matchedMet.py());
0351       profile_delta_ex_VS_set_->Fill(matchedMet.sumEt(), met.px() - matchedMet.px());
0352       profile_delta_ex_VS_set_->Fill(matchedMet.sumEt(), met.py() - matchedMet.py());
0353       profileRMS_delta_ex_VS_set_->Fill(matchedMet.sumEt(), met.px() - matchedMet.px());
0354       profileRMS_delta_ex_VS_set_->Fill(matchedMet.sumEt(), met.py() - matchedMet.py());
0355     }
0356     if (delta_set_VS_set_) {
0357       delta_set_VS_set_->Fill(matchedMet.sumEt(), met.sumEt() - matchedMet.sumEt());
0358       profile_delta_set_VS_set_->Fill(matchedMet.sumEt(), met.sumEt() - matchedMet.sumEt());
0359       profileRMS_delta_set_VS_set_->Fill(matchedMet.sumEt(), met.sumEt() - matchedMet.sumEt());
0360     }
0361     if (delta_set_Over_set_VS_set_ && matchedMet.sumEt() > 0.001) {
0362       float setRes = (met.sumEt() - matchedMet.sumEt()) / matchedMet.sumEt();
0363       if (setRes > maxVal)
0364         maxVal = setRes;
0365       if (setRes < minVal)
0366         minVal = setRes;
0367       delta_set_Over_set_VS_set_->Fill(matchedMet.sumEt(), setRes);
0368       profile_delta_set_Over_set_VS_set_->Fill(matchedMet.sumEt(), setRes);
0369       profileRMS_delta_set_Over_set_VS_set_->Fill(matchedMet.sumEt(), setRes);
0370     }
0371   }
0372 }