Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-10 02:54:40

0001 #include <iostream>
0002 //
0003 
0004 #include "Validation/RecoEgamma/plugins/PhotonPostprocessing.h"
0005 
0006 //#define TWOPI 6.283185308
0007 //
0008 
0009 /** \class PhotonPostprocessing
0010  **
0011  **
0012  **  $Id: PhotonPostprocessing
0013  **  author:
0014  **   Nancy Marinelli, U. of Notre Dame, US
0015  **
0016  **
0017  ***/
0018 
0019 using namespace std;
0020 
0021 PhotonPostprocessing::PhotonPostprocessing(const edm::ParameterSet& pset) {
0022   dbe_ = nullptr;
0023   dbe_ = edm::Service<DQMStore>().operator->();
0024   parameters_ = pset;
0025 
0026   analyzerName_ = pset.getParameter<std::string>("analyzerName");
0027   standAlone_ = pset.getParameter<bool>("standAlone");
0028   batch_ = pset.getParameter<bool>("batch");
0029   outputFileName_ = pset.getParameter<string>("OutputFileName");
0030   inputFileName_ = pset.getParameter<std::string>("InputFileName");
0031   isRunCentrally_ = pset.getParameter<bool>("isRunCentrally");
0032   fastSim_ = pset.getParameter<bool>("fastSim");
0033 
0034   etMin = parameters_.getParameter<double>("etMin");
0035   etMax = parameters_.getParameter<double>("etMax");
0036   etBin = parameters_.getParameter<int>("etBin");
0037 
0038   etaMin = parameters_.getParameter<double>("etaMin");
0039   etaMax = parameters_.getParameter<double>("etaMax");
0040   etaBin = parameters_.getParameter<int>("etaBin");
0041   etaBin2 = parameters_.getParameter<int>("etaBin2");
0042 
0043   phiMin = parameters_.getParameter<double>("phiMin");
0044   phiMax = parameters_.getParameter<double>("phiMax");
0045   phiBin = parameters_.getParameter<int>("phiBin");
0046 
0047   rMin = parameters_.getParameter<double>("rMin");
0048   rMax = parameters_.getParameter<double>("rMax");
0049   rBin = parameters_.getParameter<int>("rBin");
0050 
0051   zMin = parameters_.getParameter<double>("zMin");
0052   zMax = parameters_.getParameter<double>("zMax");
0053   zBin = parameters_.getParameter<int>("zBin");
0054 }
0055 
0056 PhotonPostprocessing::~PhotonPostprocessing() {}
0057 
0058 void PhotonPostprocessing::beginJob() {}
0059 
0060 void PhotonPostprocessing::analyze(const edm::Event& e, const edm::EventSetup&) {}
0061 
0062 void PhotonPostprocessing::endJob() {
0063   if (standAlone_)
0064     runPostprocessing();
0065 }
0066 
0067 void PhotonPostprocessing::endRun(const edm::Run& run, const edm::EventSetup&) {
0068   if (!standAlone_)
0069     runPostprocessing();
0070 }
0071 
0072 void PhotonPostprocessing::runPostprocessing() {
0073   std::string simInfoPathName = "EgammaV/" + analyzerName_ + "/SimulationInfo/";
0074   std::string convPathName = "EgammaV/" + analyzerName_ + "/ConversionInfo/";
0075   std::string effPathName = "EgammaV/" + analyzerName_ + "/Efficiencies/";
0076   std::string photonPathName = "EgammaV/" + analyzerName_ + "/Photons/";
0077 
0078   if (batch_)
0079     dbe_->open(inputFileName_);
0080 
0081   dbe_->setCurrentFolder(simInfoPathName);
0082   //  Numerators for Total efficiency
0083   string histname = "h_simConvEtaMTotal";
0084   h_simConvEtaMTotal_ = dbe_->book1D(histname, histname, etaBin2, etaMin, etaMax);
0085   histname = "h_simConvPhiMTotal";
0086   h_simConvPhiMTotal_ = dbe_->book1D(histname, histname, phiBin, phiMin, phiMax);
0087   histname = "h_simConvRMTotal";
0088   h_simConvRMTotal_ = dbe_->book1D(histname, histname, rBin, rMin, rMax);
0089   histname = "h_simConvZMTotal";
0090   h_simConvZMTotal_ = dbe_->book1D(histname, histname, zBin, zMin, zMax);
0091   histname = "h_simConvEtMTotal";
0092   h_simConvEtMTotal_ = dbe_->book1D(histname, histname, etBin, etMin, etMax);
0093 
0094   dbe_->setCurrentFolder(effPathName);
0095   //  Photon reconstruction efficiencies
0096   histname = "recoEffVsEta";
0097   phoRecoEffEta_ = dbe_->book1D(histname, "Photon reconstruction efficiency vs simulated #eta", etaBin, etaMin, etaMax);
0098   histname = "recoEffVsPhi";
0099   phoRecoEffPhi_ = dbe_->book1D(histname, "Photon reconstruction efficiency vs simulated #phi", phiBin, phiMin, phiMax);
0100   histname = "recoEffVsEt";
0101   phoRecoEffEt_ = dbe_->book1D(histname, "Photon reconstruction efficiency vs simulated Et", etBin, etMin, etMax);
0102   // Fraction of photons with at least one dead channel
0103   histname = "deadChVsEta";
0104   phoDeadChEta_ =
0105       dbe_->book1D(histname, "Fraction of photons with >=1 dead Xtal vs simulated #eta", etaBin, etaMin, etaMax);
0106   histname = "deadChVsPhi";
0107   phoDeadChPhi_ =
0108       dbe_->book1D(histname, "Fraction of photons with >=1 dead Xtal vs simulated #phi", phiBin, phiMin, phiMax);
0109   histname = "deadChVsEt";
0110   phoDeadChEt_ = dbe_->book1D(histname, "Fraction of photons with >=1 dead Xtal vs simulated Et", etBin, etMin, etMax);
0111 
0112   if (!isRunCentrally_) {
0113     histname = "convVsEt";
0114     convVsEt_[0] =
0115         dbe_->book1D(histname + "Barrel", "Fraction of good conversions in R9<0.93 vs Et ", etBin, etMin, etMax);
0116     convVsEt_[1] =
0117         dbe_->book1D(histname + "Endcap", "Fraction of good conversions in R9<0.93 vs Et ", etBin, etMin, etMax);
0118   }
0119 
0120   // Conversion reconstruction efficiency
0121   histname = "convEffVsEtaTwoTracks";
0122   convEffEtaTwoTracks_ = dbe_->book1D(histname, histname, etaBin2, etaMin, etaMax);
0123 
0124   histname = "convEffVsPhiTwoTracks";
0125   convEffPhiTwoTracks_ = dbe_->book1D(histname, histname, phiBin, phiMin, phiMax);
0126 
0127   histname = "convEffVsRTwoTracks";
0128   convEffRTwoTracks_ = dbe_->book1D(histname, histname, rBin, rMin, rMax);
0129 
0130   histname = "convEffVsZTwoTracks";
0131   convEffZTwoTracks_ = dbe_->book1D(histname, histname, zBin, zMin, zMax);
0132 
0133   histname = "convEffVsEtTwoTracks";
0134   convEffEtTwoTracks_ = dbe_->book1D(histname, histname, etBin, etMin, etMax);
0135   //
0136   histname = "convEffVsEtaTwoTracksAndVtxProbGT0";
0137   convEffEtaTwoTracksAndVtxProbGT0_ = dbe_->book1D(histname, histname, etaBin2, etaMin, etaMax);
0138   histname = "convEffVsEtaTwoTracksAndVtxProbGT0005";
0139   convEffEtaTwoTracksAndVtxProbGT0005_ = dbe_->book1D(histname, histname, etaBin2, etaMin, etaMax);
0140   histname = "convEffVsRTwoTracksAndVtxProbGT0";
0141   convEffRTwoTracksAndVtxProbGT0_ = dbe_->book1D(histname, histname, rBin, rMin, rMax);
0142   histname = "convEffVsRTwoTracksAndVtxProbGT0005";
0143   convEffRTwoTracksAndVtxProbGT0005_ = dbe_->book1D(histname, histname, rBin, rMin, rMax);
0144   //
0145   histname = "convEffVsEtaOneTrack";
0146   convEffEtaOneTrack_ = dbe_->book1D(histname, histname, etaBin2, etaMin, etaMax);
0147   histname = "convEffVsROneTrack";
0148   convEffROneTrack_ = dbe_->book1D(histname, histname, rBin, rMin, rMax);
0149   histname = "convEffVsZOneTrack";
0150   convEffZOneTrack_ = dbe_->book1D(histname, histname, rBin, rMin, rMax);
0151   histname = "convEffVsEtOneTrack";
0152   convEffEtOneTrack_ = dbe_->book1D(histname, histname, etBin, etMin, etMax);
0153   histname = "convEffVsPhiOneTrack";
0154   convEffPhiOneTrack_ = dbe_->book1D(histname, histname, phiBin, phiMin, phiMax);
0155   //
0156   histname = "convEffVsEtaTotal";
0157   convEffEtaTotal_ = dbe_->book1D(histname, histname, etaBin2, etaMin, etaMax);
0158   histname = "convEffVsRTotal";
0159   convEffRTotal_ = dbe_->book1D(histname, histname, rBin, rMin, rMax);
0160   histname = "convEffVsZTotal";
0161   convEffZTotal_ = dbe_->book1D(histname, histname, zBin, zMin, zMax);
0162   histname = "convEffVsEtTotal";
0163   convEffEtTotal_ = dbe_->book1D(histname, histname, etBin, etMin, etMax);
0164   histname = "convEffVsPhiTotal";
0165   convEffPhiTotal_ = dbe_->book1D(histname, histname, phiBin, phiMin, phiMax);
0166   // Fake rate
0167   histname = "convFakeRateVsEtaTwoTracks";
0168   convFakeRateEtaTwoTracks_ = dbe_->book1D(histname, histname, etaBin2, etaMin, etaMax);
0169   histname = "convFakeRateVsPhiTwoTracks";
0170   convFakeRatePhiTwoTracks_ = dbe_->book1D(histname, histname, phiBin, phiMin, phiMax);
0171   histname = "convFakeRateVsRTwoTracks";
0172   convFakeRateRTwoTracks_ = dbe_->book1D(histname, histname, rBin, rMin, rMax);
0173   histname = "convFakeRateVsZTwoTracks";
0174   convFakeRateZTwoTracks_ = dbe_->book1D(histname, histname, zBin, zMin, zMax);
0175   histname = "convFakeRateVsEtTwoTracks";
0176   convFakeRateEtTwoTracks_ = dbe_->book1D(histname, histname, etBin, etMin, etMax);
0177 
0178   histname = "bkgEffVsEta";
0179   bkgRecoEffEta_ = dbe_->book1D(histname, "Bkg reconstruction efficiency vs simulated #eta", etaBin, etaMin, etaMax);
0180   histname = "bkgEffVsPhi";
0181   bkgRecoEffPhi_ = dbe_->book1D(histname, "Bkg reconstruction efficiency vs simulated #phi", phiBin, phiMin, phiMax);
0182   histname = "bkgEffVsEt";
0183   bkgRecoEffEt_ = dbe_->book1D(histname, "Bkg reconstruction efficiency vs simulated Et", etBin, etMin, etMax);
0184   // Fraction of photons with at least one dead channel
0185   histname = "deadChVsEtaBkg";
0186   bkgDeadChEta_ =
0187       dbe_->book1D(histname, "Fraction of bkg  with >=1 dead Xtal vs simulated #eta", etaBin, etaMin, etaMax);
0188   histname = "deadChVsPhiBkg";
0189   bkgDeadChPhi_ =
0190       dbe_->book1D(histname, "Fraction of bkg with >=1 dead Xtal vs simulated #phi", phiBin, phiMin, phiMax);
0191   histname = "deadChVsEtBkg";
0192   bkgDeadChEt_ = dbe_->book1D(histname, "Fraction of bkg with >=1 dead Xtal vs simulated Et", etBin, etMin, etMax);
0193 
0194   //
0195   if ((dbe_->get(simInfoPathName + "h_SimConvOneMTracksEta")) != nullptr and
0196       (dbe_->get(convPathName + "h_RecoConvTwoMTracksEta") != nullptr)) {
0197     h_simConvEtaMTotal_->getTH1F()->Add(dbe_->get(simInfoPathName + "h_SimConvOneMTracksEta")->getTH1F(),
0198                                         dbe_->get(convPathName + "h_RecoConvTwoMTracksEta")->getTH1F());
0199   }
0200   if ((dbe_->get(simInfoPathName + "h_SimConvOneMTracksPhi") != nullptr) and
0201       (dbe_->get(convPathName + "h_RecoConvTwoMTracksPhi") != nullptr)) {
0202     h_simConvPhiMTotal_->getTH1F()->Add(dbe_->get(simInfoPathName + "h_SimConvOneMTracksPhi")->getTH1F(),
0203                                         dbe_->get(convPathName + "h_RecoConvTwoMTracksPhi")->getTH1F());
0204   }
0205   if ((dbe_->get(simInfoPathName + "h_SimConvOneMTracksR")->getTH1F() != nullptr) and
0206       (dbe_->get(convPathName + "h_RecoConvTwoMTracksR") != nullptr)) {
0207     h_simConvRMTotal_->getTH1F()->Add(dbe_->get(simInfoPathName + "h_SimConvOneMTracksR")->getTH1F(),
0208                                       dbe_->get(convPathName + "h_RecoConvTwoMTracksR")->getTH1F());
0209   }
0210   if ((dbe_->get(simInfoPathName + "h_SimConvOneMTracksZ") != nullptr) and
0211       (dbe_->get(convPathName + "h_RecoConvTwoMTracksZ") != nullptr)) {
0212     h_simConvZMTotal_->getTH1F()->Add(dbe_->get(simInfoPathName + "h_SimConvOneMTracksZ")->getTH1F(),
0213                                       dbe_->get(convPathName + "h_RecoConvTwoMTracksZ")->getTH1F());
0214   }
0215   if ((dbe_->get(simInfoPathName + "h_SimConvOneMTracksEt") != nullptr) and
0216       (dbe_->get(convPathName + "h_RecoConvTwoMTracksEt") != nullptr)) {
0217     h_simConvEtMTotal_->getTH1F()->Add(dbe_->get(simInfoPathName + "h_SimConvOneMTracksEt")->getTH1F(),
0218                                        dbe_->get(convPathName + "h_RecoConvTwoMTracksEt")->getTH1F());
0219   }
0220 
0221   // efficiencies
0222   if (!isRunCentrally_) {
0223     dividePlots(dbe_->get(effPathName + "convVsEtBarrel"),
0224                 dbe_->get(photonPathName + "EtR9Less093ConvBarrel"),
0225                 dbe_->get(photonPathName + "EtR9Less093Barrel"),
0226                 "effic");
0227     dividePlots(dbe_->get(effPathName + "convVsEtEndcap"),
0228                 dbe_->get(photonPathName + "EtR9Less093ConvEndcap"),
0229                 dbe_->get(photonPathName + "EtR9Less093Endcap"),
0230                 "effic");
0231   }
0232 
0233   dividePlots(dbe_->get(effPathName + "recoEffVsEta"),
0234               dbe_->get(simInfoPathName + "h_MatchedSimPhoEta"),
0235               dbe_->get(simInfoPathName + "h_SimPhoEta"),
0236               "effic");
0237   dividePlots(dbe_->get(effPathName + "recoEffVsPhi"),
0238               dbe_->get(simInfoPathName + "h_MatchedSimPhoPhi"),
0239               dbe_->get(simInfoPathName + "h_SimPhoPhi"),
0240               "effic");
0241   dividePlots(dbe_->get(effPathName + "recoEffVsEt"),
0242               dbe_->get(simInfoPathName + "h_MatchedSimPhoEt"),
0243               dbe_->get(simInfoPathName + "h_SimPhoEt"),
0244               "effic");
0245   // fraction of photons with at least one dead channel
0246   dividePlots(dbe_->get(effPathName + "deadChVsEta"),
0247               dbe_->get(simInfoPathName + "h_MatchedSimPhoBadChEta"),
0248               dbe_->get(simInfoPathName + "h_MatchedSimPhoEta"),
0249               "effic");
0250   dividePlots(dbe_->get(effPathName + "deadChVsPhi"),
0251               dbe_->get(simInfoPathName + "h_MatchedSimPhoBadChPhi"),
0252               dbe_->get(simInfoPathName + "h_MatchedSimPhoPhi"),
0253               "effic");
0254   dividePlots(dbe_->get(effPathName + "deadChVsEt"),
0255               dbe_->get(simInfoPathName + "h_MatchedSimPhoBadChEt"),
0256               dbe_->get(simInfoPathName + "h_MatchedSimPhoEt"),
0257               "effic");
0258   //
0259   if (!fastSim_) {
0260     dividePlots(dbe_->get(effPathName + "convEffVsEtaTwoTracks"),
0261                 dbe_->get(simInfoPathName + "h_SimConvTwoMTracksEta"),
0262                 dbe_->get(simInfoPathName + "h_VisSimConvEta"),
0263                 "effic");
0264     dividePlots(dbe_->get(effPathName + "convEffVsPhiTwoTracks"),
0265                 dbe_->get(simInfoPathName + "h_SimConvTwoMTracksPhi"),
0266                 dbe_->get(simInfoPathName + "h_VisSimConvPhi"),
0267                 "effic");
0268     dividePlots(dbe_->get(effPathName + "convEffVsRTwoTracks"),
0269                 dbe_->get(simInfoPathName + "h_SimConvTwoMTracksR"),
0270                 dbe_->get(simInfoPathName + "h_VisSimConvR"),
0271                 "effic");
0272     dividePlots(dbe_->get(effPathName + "convEffVsZTwoTracks"),
0273                 dbe_->get(simInfoPathName + "h_SimConvTwoMTracksZ"),
0274                 dbe_->get(simInfoPathName + "h_VisSimConvZ"),
0275                 "effic");
0276     dividePlots(dbe_->get(effPathName + "convEffVsEtTwoTracks"),
0277                 dbe_->get(simInfoPathName + "h_SimConvTwoMTracksEt"),
0278                 dbe_->get(simInfoPathName + "h_VisSimConvEt"),
0279                 "effic");
0280     dividePlots(dbe_->get(effPathName + "convEffVsEtaTwoTracksAndVtxProbGT0"),
0281                 dbe_->get(simInfoPathName + "h_SimConvTwoMTracksEtaAndVtxPGT0"),
0282                 dbe_->get(simInfoPathName + "h_SimConvTwoMTracksEta"),
0283                 "effic");
0284     dividePlots(dbe_->get(effPathName + "convEffVsEtaTwoTracksAndVtxProbGT0005"),
0285                 dbe_->get(simInfoPathName + "h_SimConvTwoMTracksEtaAndVtxPGT0005"),
0286                 dbe_->get(simInfoPathName + "h_SimConvTwoMTracksEta"),
0287                 "effic");
0288     dividePlots(dbe_->get(effPathName + "convEffVsRTwoTracksAndVtxProbGT0"),
0289                 dbe_->get(simInfoPathName + "h_SimConvTwoMTracksRAndVtxPGT0"),
0290                 dbe_->get(simInfoPathName + "h_SimConvTwoMTracksR"),
0291                 "effic");
0292     dividePlots(dbe_->get(effPathName + "convEffVsRTwoTracksAndVtxProbGT0005"),
0293                 dbe_->get(simInfoPathName + "h_SimConvTwoMTracksRAndVtxPGT0005"),
0294                 dbe_->get(simInfoPathName + "h_SimConvTwoMTracksR"),
0295                 "effic");
0296     //
0297     dividePlots(dbe_->get(effPathName + "convEffVsEtaOneTrack"),
0298                 dbe_->get(simInfoPathName + "h_SimConvOneMTracksEta"),
0299                 dbe_->get(simInfoPathName + "h_VisSimConvEta"),
0300                 "effic");
0301     dividePlots(dbe_->get(effPathName + "convEffVsPhiOneTrack"),
0302                 dbe_->get(simInfoPathName + "h_SimConvOneMTracksPhi"),
0303                 dbe_->get(simInfoPathName + "h_VisSimConvPhi"),
0304                 "effic");
0305     dividePlots(dbe_->get(effPathName + "convEffVsROneTrack"),
0306                 dbe_->get(simInfoPathName + "h_SimConvOneMTracksR"),
0307                 dbe_->get(simInfoPathName + "h_VisSimConvR"),
0308                 "effic");
0309     dividePlots(dbe_->get(effPathName + "convEffVsZOneTrack"),
0310                 dbe_->get(simInfoPathName + "h_SimConvOneMTracksZ"),
0311                 dbe_->get(simInfoPathName + "h_VisSimConvZ"),
0312                 "effic");
0313     dividePlots(dbe_->get(effPathName + "convEffVsEtOneTrack"),
0314                 dbe_->get(simInfoPathName + "h_SimConvOneMTracksEt"),
0315                 dbe_->get(simInfoPathName + "h_VisSimConvEt"),
0316                 "effic");
0317     //
0318     dividePlots(dbe_->get(effPathName + "convEffVsEtaTotal"),
0319                 dbe_->get(simInfoPathName + "h_simConvEtaMTotal"),
0320                 dbe_->get(simInfoPathName + "h_VisSimConvEta"),
0321                 "effic");
0322     dividePlots(dbe_->get(effPathName + "convEffVsPhiTotal"),
0323                 dbe_->get(simInfoPathName + "h_simConvPhiMTotal"),
0324                 dbe_->get(simInfoPathName + "h_VisSimConvPhi"),
0325                 "effic");
0326     dividePlots(dbe_->get(effPathName + "convEffVsRTotal"),
0327                 dbe_->get(simInfoPathName + "h_simConvRMTotal"),
0328                 dbe_->get(simInfoPathName + "h_VisSimConvR"),
0329                 "effic");
0330     dividePlots(dbe_->get(effPathName + "convEffVsZTotal"),
0331                 dbe_->get(simInfoPathName + "h_simConvZMTotal"),
0332                 dbe_->get(simInfoPathName + "h_VisSimConvZ"),
0333                 "effic");
0334     dividePlots(dbe_->get(effPathName + "convEffVsEtTotal"),
0335                 dbe_->get(simInfoPathName + "h_simConvEtMTotal"),
0336                 dbe_->get(simInfoPathName + "h_VisSimConvEt"),
0337                 "effic");
0338     // fake rate
0339     dividePlots(dbe_->get(effPathName + "convFakeRateVsEtaTwoTracks"),
0340                 dbe_->get(convPathName + "h_RecoConvTwoMTracksEta"),
0341                 dbe_->get(convPathName + "h_RecoConvTwoTracksEta"),
0342                 "fakerate");
0343     dividePlots(dbe_->get(effPathName + "convFakeRateVsPhiTwoTracks"),
0344                 dbe_->get(convPathName + "h_RecoConvTwoMTracksPhi"),
0345                 dbe_->get(convPathName + "h_RecoConvTwoTracksPhi"),
0346                 "fakerate");
0347     dividePlots(dbe_->get(effPathName + "convFakeRateVsRTwoTracks"),
0348                 dbe_->get(convPathName + "h_RecoConvTwoMTracksR"),
0349                 dbe_->get(convPathName + "h_RecoConvTwoTracksR"),
0350                 "fakerate");
0351     dividePlots(dbe_->get(effPathName + "convFakeRateVsZTwoTracks"),
0352                 dbe_->get(convPathName + "h_RecoConvTwoMTracksZ"),
0353                 dbe_->get(convPathName + "h_RecoConvTwoTracksZ"),
0354                 "fakerate");
0355     dividePlots(dbe_->get(effPathName + "convFakeRateVsEtTwoTracks"),
0356                 dbe_->get(convPathName + "h_RecoConvTwoMTracksEt"),
0357                 dbe_->get(convPathName + "h_RecoConvTwoTracksEt"),
0358                 "fakerate");
0359   }
0360   // Background efficiency
0361   dividePlots(dbe_->get(effPathName + "bkgEffVsEta"),
0362               dbe_->get(simInfoPathName + "h_MatchedSimJetEta"),
0363               dbe_->get(simInfoPathName + "h_SimJetEta"),
0364               "effic");
0365   dividePlots(dbe_->get(effPathName + "bkgEffVsPhi"),
0366               dbe_->get(simInfoPathName + "h_MatchedSimJetPhi"),
0367               dbe_->get(simInfoPathName + "h_SimJetPhi"),
0368               "effic");
0369   dividePlots(dbe_->get(effPathName + "bkgEffVsEt"),
0370               dbe_->get(simInfoPathName + "h_MatchedSimJetEt"),
0371               dbe_->get(simInfoPathName + "h_SimJetEt"),
0372               "effic");
0373   // fraction of photons with at least one dead channel
0374   dividePlots(dbe_->get(effPathName + "deadChVsEtaBkg"),
0375               dbe_->get(simInfoPathName + "h_MatchedSimJetBadChEta"),
0376               dbe_->get(simInfoPathName + "h_MatchedSimJetEta"),
0377               "effic");
0378   dividePlots(dbe_->get(effPathName + "deadChVsPhiBkg"),
0379               dbe_->get(simInfoPathName + "h_MatchedSimJetBadChPhi"),
0380               dbe_->get(simInfoPathName + "h_MatchedSimJetPhi"),
0381               "effic");
0382   dividePlots(dbe_->get(effPathName + "deadChVsEtBkg"),
0383               dbe_->get(simInfoPathName + "h_MatchedSimJetBadChEt"),
0384               dbe_->get(simInfoPathName + "h_MatchedSimJetEt"),
0385               "effic");
0386 
0387   if (standAlone_)
0388     dbe_->save(outputFileName_);
0389   else if (batch_)
0390     dbe_->save(inputFileName_);
0391 }
0392 
0393 void PhotonPostprocessing::dividePlots(MonitorElement* dividend,
0394                                        MonitorElement* numerator,
0395                                        MonitorElement* denominator,
0396                                        std::string type) {
0397   double value, err;
0398   if (nullptr == dividend or nullptr == denominator or nullptr == numerator) {
0399     return;
0400   }
0401   for (int j = 1; j <= numerator->getNbinsX(); j++) {
0402     dividend->setEfficiencyFlag();
0403 
0404     if (denominator->getBinContent(j) != 0) {
0405       if (type == "effic")
0406         value = ((double)numerator->getBinContent(j)) / ((double)denominator->getBinContent(j));
0407       else if (type == "fakerate")
0408         value = 1 - ((double)numerator->getBinContent(j)) / ((double)denominator->getBinContent(j));
0409       else
0410         return;
0411       err = sqrt(value * (1 - value) / ((double)denominator->getBinContent(j)));
0412       dividend->setBinContent(j, value);
0413       if (err != 0)
0414         dividend->setBinError(j, err);
0415     } else {
0416       dividend->setBinContent(j, 0);
0417       dividend->setBinError(j, 0);
0418     }
0419   }
0420 }
0421 
0422 void PhotonPostprocessing::dividePlots(MonitorElement* dividend, MonitorElement* numerator, double denominator) {
0423   double value, err;
0424 
0425   if (nullptr == dividend or nullptr == numerator) {
0426     return;
0427   }
0428   for (int j = 1; j <= numerator->getNbinsX(); j++) {
0429     if (denominator != 0) {
0430       value = ((double)numerator->getBinContent(j)) / denominator;
0431       err = sqrt(value * (1 - value) / denominator);
0432       dividend->setBinContent(j, value);
0433       dividend->setBinError(j, err);
0434     } else {
0435       dividend->setBinContent(j, 0);
0436     }
0437   }
0438 }