Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:12:46

0001 // -*- C++ -*-
0002 //
0003 // Package:    DQMOffline/JetMET
0004 // Class:      DataCertificationJetMET
0005 //
0006 // Original Author:  "Frank Chlebana"
0007 //         Created:  Sun Oct  5 13:57:25 CDT 2008
0008 //
0009 
0010 #include "DQMOffline/JetMET/interface/DataCertificationJetMET.h"
0011 #include "FWCore/Framework/interface/LuminosityBlock.h"
0012 #include "FWCore/Framework/interface/Run.h"
0013 
0014 // Some switches
0015 //
0016 // constructors and destructor
0017 //
0018 DataCertificationJetMET::DataCertificationJetMET(const edm::ParameterSet& iConfig) : conf_(iConfig) {
0019   // now do what ever initialization is needed
0020   inputMETLabelRECO_ = iConfig.getParameter<edm::InputTag>("METTypeRECO");
0021   inputMETLabelRECOUncleaned_ = iConfig.getParameter<edm::InputTag>("METTypeRECOUncleaned");
0022   inputMETLabelMiniAOD_ = iConfig.getParameter<edm::InputTag>("METTypeMiniAOD");
0023   inputJetLabelRECO_ = iConfig.getParameter<edm::InputTag>("JetTypeRECO");
0024   inputJetLabelMiniAOD_ = iConfig.getParameter<edm::InputTag>("JetTypeMiniAOD");
0025 
0026   nbinsPV_ = iConfig.getParameter<int>("pVBin");
0027   nPVMin_ = iConfig.getParameter<double>("pVMin");
0028   nPVMax_ = iConfig.getParameter<double>("pVMax");
0029 
0030   etaBin_ = iConfig.getParameter<int>("etaBin");
0031   etaMin_ = iConfig.getParameter<double>("etaMin");
0032   etaMax_ = iConfig.getParameter<double>("etaMax");
0033 
0034   ptBin_ = iConfig.getParameter<int>("ptBin");
0035   ptMin_ = iConfig.getParameter<double>("ptMin");
0036   ptMax_ = iConfig.getParameter<double>("ptMax");
0037 
0038   // -----------------------------------------
0039   // verbose_ 0: suppress printouts
0040   //          1: show printouts
0041   verbose_ = conf_.getUntrackedParameter<int>("Verbose", 0);
0042   metFolder = conf_.getUntrackedParameter<std::string>("metFolder");
0043   jetAlgo = conf_.getUntrackedParameter<std::string>("jetAlgo");
0044   folderName = conf_.getUntrackedParameter<std::string>("folderName");
0045 
0046   jetTests[0][0] = conf_.getUntrackedParameter<bool>("pfBarrelJetMeanTest", true);
0047   jetTests[0][1] = conf_.getUntrackedParameter<bool>("pfBarrelJetKSTest", false);
0048   jetTests[1][0] = conf_.getUntrackedParameter<bool>("pfEndcapJetMeanTest", true);
0049   jetTests[1][1] = conf_.getUntrackedParameter<bool>("pfEndcapJetKSTest", false);
0050   jetTests[2][0] = conf_.getUntrackedParameter<bool>("pfForwardJetMeanTest", true);
0051   jetTests[2][1] = conf_.getUntrackedParameter<bool>("pfForwardJetKSTest", false);
0052   jetTests[3][0] = conf_.getUntrackedParameter<bool>("caloJetMeanTest", true);
0053   jetTests[3][1] = conf_.getUntrackedParameter<bool>("caloJetKSTest", false);
0054   jetTests[4][0] = conf_.getUntrackedParameter<bool>("jptJetMeanTest", true);
0055   jetTests[4][1] = conf_.getUntrackedParameter<bool>("jptJetKSTest", false);
0056 
0057   metTests[0][0] = conf_.getUntrackedParameter<bool>("caloMETMeanTest", true);
0058   metTests[0][1] = conf_.getUntrackedParameter<bool>("caloMETKSTest", false);
0059   metTests[1][0] = conf_.getUntrackedParameter<bool>("pfMETMeanTest", true);
0060   metTests[1][1] = conf_.getUntrackedParameter<bool>("pfMETKSTest", false);
0061   metTests[2][0] = conf_.getUntrackedParameter<bool>("tcMETMeanTest", true);
0062   metTests[2][1] = conf_.getUntrackedParameter<bool>("tcMETKSTest", false);
0063 
0064   isHI = conf_.getUntrackedParameter<bool>("isHI", false);
0065 
0066   if (verbose_)
0067     std::cout << ">>> Constructor (DataCertificationJetMET) <<<" << std::endl;
0068 
0069   // -----------------------------------------
0070   //
0071 }
0072 
0073 DataCertificationJetMET::~DataCertificationJetMET() {
0074   // do anything here that needs to be done at desctruction time
0075   // (e.g. close files, deallocate resources etc.)
0076   if (verbose_)
0077     std::cout << ">>> Deconstructor (DataCertificationJetMET) <<<" << std::endl;
0078 }
0079 
0080 // ------------ method called right after a run ends ------------
0081 void DataCertificationJetMET::dqmEndJob(DQMStore::IBooker& ibook_, DQMStore::IGetter& iget_) {
0082   //put RECO vs MiniAODDir first ->first MET
0083   std::vector<std::string> subDirVecMET;
0084   std::string RunDirMET = "JetMET/MET/";
0085   iget_.setCurrentFolder(RunDirMET);
0086   subDirVecMET = iget_.getSubdirs();
0087   bool found_METreco_dir = false;
0088   bool found_METminiaod_dir = false;
0089   //check if proper directories are inside the files
0090   for (int i = 0; i < int(subDirVecMET.size()); i++) {
0091     ibook_.setCurrentFolder(subDirVecMET[i]);
0092     if ((subDirVecMET[i] + "/Cleaned") == (RunDirMET + inputMETLabelRECO_.label() + "/Cleaned")) {
0093       found_METreco_dir = true;
0094     }
0095     if (((subDirVecMET[i] + "/Uncleaned") == (RunDirMET + inputMETLabelRECOUncleaned_.label() + "/Uncleaned")) ||
0096         ((subDirVecMET[i] + "/Uncleaned") == (RunDirMET + inputMETLabelMiniAOD_.label() + "/Uncleaned"))) {
0097       //check filters in uncleaned directory
0098       std::string rundirMET_reco = "";
0099       if ((subDirVecMET[i] + "/Uncleaned") == (RunDirMET + inputMETLabelRECOUncleaned_.label() + "/Uncleaned")) {
0100         rundirMET_reco = RunDirMET + inputMETLabelRECOUncleaned_.label() + "/Uncleaned";
0101       } else {
0102         rundirMET_reco = RunDirMET + inputMETLabelMiniAOD_.label() + "/Uncleaned";
0103       }
0104       MonitorElement* mMET_Reco = iget_.get(rundirMET_reco + "/" + "MET");
0105       MonitorElement* mMET_Reco_HBHENoiseFilter = iget_.get(rundirMET_reco + "/" + "MET_HBHENoiseFilter");
0106       MonitorElement* mMET_Reco_CSCTightHaloFilter = iget_.get(rundirMET_reco + "/" + "MET_CSCTightHaloFilter");
0107       MonitorElement* mMET_Reco_eeBadScFilter = iget_.get(rundirMET_reco + "/" + "MET_eeBadScFilter");
0108       MonitorElement* mMET_Reco_HBHEIsoNoiseFilter = iget_.get(rundirMET_reco + "/" + "MET_HBHEIsoNoiseFilter");
0109       MonitorElement* mMET_Reco_CSCTightHalo2015Filter = iget_.get(rundirMET_reco + "/" + "MET_CSCTightHalo2015Filter");
0110       MonitorElement* mMET_Reco_EcalDeadCellTriggerFilter =
0111           iget_.get(rundirMET_reco + "/" + "MET_EcalDeadCellTriggerFilter");
0112       MonitorElement* mMET_Reco_EcalDeadCellBoundaryFilter =
0113           iget_.get(rundirMET_reco + "/" + "MET_EcalDeadCellBoundaryFilter");
0114       MonitorElement* mMET_Reco_HcalStripHaloFilter = iget_.get(rundirMET_reco + "/" + "MET_HcalStripHaloFilter");
0115       ibook_.setCurrentFolder(rundirMET_reco);
0116       mMET_EffHBHENoiseFilter =
0117           ibook_.book1D("MET_EffHBHENoiseFilter", (TH1F*)mMET_Reco_HBHENoiseFilter->getRootObject());
0118       for (int i = 0; i <= (mMET_Reco->getNbinsX() + 1); i++) {
0119         if (mMET_Reco->getBinContent(i) != 0) {
0120           mMET_EffHBHENoiseFilter->setBinContent(
0121               i, mMET_Reco_HBHENoiseFilter->getBinContent(i) / mMET_Reco->getBinContent(i));
0122         } else {
0123           mMET_EffHBHENoiseFilter->setBinContent(i, 0);
0124         }
0125       }
0126       mMET_EffCSCTightHaloFilter =
0127           ibook_.book1D("MET_EffCSCTightHaloFilter", (TH1F*)mMET_Reco_CSCTightHaloFilter->getRootObject());
0128       for (int i = 0; i <= (mMET_Reco->getNbinsX() + 1); i++) {
0129         if (mMET_Reco->getBinContent(i) != 0) {
0130           mMET_EffCSCTightHaloFilter->setBinContent(
0131               i, mMET_Reco_CSCTightHaloFilter->getBinContent(i) / mMET_Reco->getBinContent(i));
0132         } else {
0133           mMET_EffCSCTightHaloFilter->setBinContent(i, 0);
0134         }
0135       }
0136       mMET_EffeeBadScFilter = ibook_.book1D("MET_EffeeBadScFilter", (TH1F*)mMET_Reco_eeBadScFilter->getRootObject());
0137       for (int i = 0; i <= (mMET_Reco->getNbinsX() + 1); i++) {
0138         if (mMET_Reco->getBinContent(i) != 0) {
0139           mMET_EffeeBadScFilter->setBinContent(i,
0140                                                mMET_Reco_eeBadScFilter->getBinContent(i) / mMET_Reco->getBinContent(i));
0141         } else {
0142           mMET_EffeeBadScFilter->setBinContent(i, 0);
0143         }
0144       }
0145       mMET_EffHBHEIsoNoiseFilter =
0146           ibook_.book1D("MET_EffHBHEIsoNoiseFilter", (TH1F*)mMET_Reco_HBHEIsoNoiseFilter->getRootObject());
0147       for (int i = 0; i <= (mMET_Reco->getNbinsX() + 1); i++) {
0148         if (mMET_Reco->getBinContent(i) != 0) {
0149           mMET_EffHBHEIsoNoiseFilter->setBinContent(
0150               i, mMET_Reco_HBHEIsoNoiseFilter->getBinContent(i) / mMET_Reco->getBinContent(i));
0151         } else {
0152           mMET_EffHBHEIsoNoiseFilter->setBinContent(i, 0);
0153         }
0154       }
0155       mMET_EffCSCTightHalo2015Filter =
0156           ibook_.book1D("MET_EffCSCTightHalo2015Filter", (TH1F*)mMET_Reco_CSCTightHalo2015Filter->getRootObject());
0157       for (int i = 0; i <= (mMET_Reco->getNbinsX() + 1); i++) {
0158         if (mMET_Reco->getBinContent(i) != 0) {
0159           mMET_EffCSCTightHalo2015Filter->setBinContent(
0160               i, mMET_Reco_CSCTightHalo2015Filter->getBinContent(i) / mMET_Reco->getBinContent(i));
0161         } else {
0162           mMET_EffCSCTightHalo2015Filter->setBinContent(i, 0);
0163         }
0164       }
0165       mMET_EffEcalDeadCellTriggerFilter = ibook_.book1D("MET_EffEcalDeadCellTriggerFilter",
0166                                                         (TH1F*)mMET_Reco_EcalDeadCellTriggerFilter->getRootObject());
0167       for (int i = 0; i <= (mMET_Reco->getNbinsX() + 1); i++) {
0168         if (mMET_Reco->getBinContent(i) != 0) {
0169           mMET_EffEcalDeadCellTriggerFilter->setBinContent(
0170               i, mMET_Reco_EcalDeadCellTriggerFilter->getBinContent(i) / mMET_Reco->getBinContent(i));
0171         } else {
0172           mMET_EffEcalDeadCellTriggerFilter->setBinContent(i, 0);
0173         }
0174       }
0175       mMET_EffEcalDeadCellBoundaryFilter = ibook_.book1D("MET_EffEcalDeadCellBoundaryFilter",
0176                                                          (TH1F*)mMET_Reco_EcalDeadCellBoundaryFilter->getRootObject());
0177       for (int i = 0; i <= (mMET_Reco->getNbinsX() + 1); i++) {
0178         if (mMET_Reco->getBinContent(i) != 0) {
0179           mMET_EffEcalDeadCellBoundaryFilter->setBinContent(
0180               i, mMET_Reco_EcalDeadCellBoundaryFilter->getBinContent(i) / mMET_Reco->getBinContent(i));
0181         } else {
0182           mMET_EffEcalDeadCellBoundaryFilter->setBinContent(i, 0);
0183         }
0184       }
0185       mMET_EffHcalStripHaloFilter =
0186           ibook_.book1D("MET_EffHcalStripHaloFilter", (TH1F*)mMET_Reco_HcalStripHaloFilter->getRootObject());
0187       for (int i = 0; i <= (mMET_Reco->getNbinsX() + 1); i++) {
0188         if (mMET_Reco->getBinContent(i) != 0) {
0189           mMET_EffHcalStripHaloFilter->setBinContent(
0190               i, mMET_Reco_HcalStripHaloFilter->getBinContent(i) / mMET_Reco->getBinContent(i));
0191         } else {
0192           mMET_EffHcalStripHaloFilter->setBinContent(i, 0);
0193         }
0194       }
0195     }
0196     if ((subDirVecMET[i] + "/Cleaned") == (RunDirMET + inputMETLabelMiniAOD_.label() + "/Cleaned")) {
0197       found_METminiaod_dir = true;
0198     }
0199   }
0200   if (found_METreco_dir && found_METminiaod_dir) {
0201     std::string rundirMET_reco = RunDirMET + inputMETLabelRECO_.label() + "/Cleaned";
0202     std::string rundirMET_miniaod = RunDirMET + inputMETLabelMiniAOD_.label() + "/Cleaned";
0203     MonitorElement* mMET_Reco = iget_.get(rundirMET_reco + "/" + "MET");
0204     MonitorElement* mMEy_Reco = iget_.get(rundirMET_reco + "/" + "MEy");
0205     MonitorElement* mSumET_Reco = iget_.get(rundirMET_reco + "/" + "SumET");
0206     MonitorElement* mMETPhi_Reco = iget_.get(rundirMET_reco + "/" + "METPhi");
0207     MonitorElement* mMET_logx_Reco = iget_.get(rundirMET_reco + "/" + "MET_logx");
0208     MonitorElement* mSumET_logx_Reco = iget_.get(rundirMET_reco + "/" + "SumET_logx");
0209     MonitorElement* mChargedHadronEtFraction_Reco = iget_.get(rundirMET_reco + "/" + "PfChargedHadronEtFraction");
0210     MonitorElement* mNeutralHadronEtFraction_Reco = iget_.get(rundirMET_reco + "/" + "PfNeutralHadronEtFraction");
0211     MonitorElement* mPhotonEtFraction_Reco = iget_.get(rundirMET_reco + "/" + "PfPhotonEtFraction");
0212     MonitorElement* mHFHadronEtFraction_Reco = iget_.get(rundirMET_reco + "/" + "PfHFHadronEtFraction");
0213     MonitorElement* mHFEMEtFraction_Reco = iget_.get(rundirMET_reco + "/" + "PfHFEMEtFraction");
0214     MonitorElement* mMET_nVtx_profile_Reco = iget_.get(rundirMET_reco + "/" + "MET_profile");
0215     MonitorElement* mSumET_nVtx_profile_Reco = iget_.get(rundirMET_reco + "/" + "SumET_profile");
0216     MonitorElement* mChargedHadronEtFraction_nVtx_profile_Reco =
0217         iget_.get(rundirMET_reco + "/" + "PfChargedHadronEtFraction_profile");
0218     MonitorElement* mNeutralHadronEtFraction_nVtx_profile_Reco =
0219         iget_.get(rundirMET_reco + "/" + "PfNeutralHadronEtFraction_profile");
0220     MonitorElement* mPhotonEtFraction_nVtx_profile_Reco =
0221         iget_.get(rundirMET_reco + "/" + "PfPhotonEtFraction_profile");
0222 
0223     std::vector<MonitorElement*> me_MET_Reco;
0224     me_MET_Reco.push_back(mMET_Reco);
0225     me_MET_Reco.push_back(mMEy_Reco);
0226     me_MET_Reco.push_back(mSumET_Reco);
0227     me_MET_Reco.push_back(mMETPhi_Reco);
0228     me_MET_Reco.push_back(mMET_logx_Reco);
0229     me_MET_Reco.push_back(mSumET_logx_Reco);
0230     me_MET_Reco.push_back(mChargedHadronEtFraction_Reco);
0231     me_MET_Reco.push_back(mNeutralHadronEtFraction_Reco);
0232     me_MET_Reco.push_back(mPhotonEtFraction_Reco);
0233     me_MET_Reco.push_back(mHFHadronEtFraction_Reco);
0234     me_MET_Reco.push_back(mHFEMEtFraction_Reco);
0235     me_MET_Reco.push_back(mMET_nVtx_profile_Reco);
0236     me_MET_Reco.push_back(mSumET_nVtx_profile_Reco);
0237     me_MET_Reco.push_back(mChargedHadronEtFraction_nVtx_profile_Reco);
0238     me_MET_Reco.push_back(mNeutralHadronEtFraction_nVtx_profile_Reco);
0239     me_MET_Reco.push_back(mPhotonEtFraction_nVtx_profile_Reco);
0240 
0241     MonitorElement* mMET_MiniAOD = iget_.get(rundirMET_miniaod + "/" + "MET");
0242     MonitorElement* mMEy_MiniAOD = iget_.get(rundirMET_miniaod + "/" + "MEy");
0243     MonitorElement* mSumET_MiniAOD = iget_.get(rundirMET_miniaod + "/" + "SumET");
0244     MonitorElement* mMETPhi_MiniAOD = iget_.get(rundirMET_miniaod + "/" + "METPhi");
0245     MonitorElement* mMET_logx_MiniAOD = iget_.get(rundirMET_miniaod + "/" + "MET_logx");
0246     MonitorElement* mSumET_logx_MiniAOD = iget_.get(rundirMET_miniaod + "/" + "SumET_logx");
0247     MonitorElement* mChargedHadronEtFraction_MiniAOD = iget_.get(rundirMET_miniaod + "/" + "PfChargedHadronEtFraction");
0248     MonitorElement* mNeutralHadronEtFraction_MiniAOD = iget_.get(rundirMET_miniaod + "/" + "PfNeutralHadronEtFraction");
0249     MonitorElement* mPhotonEtFraction_MiniAOD = iget_.get(rundirMET_miniaod + "/" + "PfPhotonEtFraction");
0250     MonitorElement* mHFHadronEtFraction_MiniAOD = iget_.get(rundirMET_miniaod + "/" + "PfHFHadronEtFraction");
0251     MonitorElement* mHFEMEtFraction_MiniAOD = iget_.get(rundirMET_miniaod + "/" + "PfHFEMEtFraction");
0252     MonitorElement* mMET_nVtx_profile_MiniAOD = iget_.get(rundirMET_miniaod + "/" + "MET_profile");
0253     MonitorElement* mSumET_nVtx_profile_MiniAOD = iget_.get(rundirMET_miniaod + "/" + "SumET_profile");
0254     MonitorElement* mChargedHadronEtFraction_nVtx_profile_MiniAOD =
0255         iget_.get(rundirMET_miniaod + "/" + "PfChargedHadronEtFraction_profile");
0256     MonitorElement* mNeutralHadronEtFraction_nVtx_profile_MiniAOD =
0257         iget_.get(rundirMET_miniaod + "/" + "PfNeutralHadronEtFraction_profile");
0258     MonitorElement* mPhotonEtFraction_nVtx_profile_MiniAOD =
0259         iget_.get(rundirMET_miniaod + "/" + "PfPhotonEtFraction_profile");
0260 
0261     std::vector<MonitorElement*> me_MET_MiniAOD;
0262     me_MET_MiniAOD.push_back(mMET_MiniAOD);
0263     me_MET_MiniAOD.push_back(mMEy_MiniAOD);
0264     me_MET_MiniAOD.push_back(mSumET_MiniAOD);
0265     me_MET_MiniAOD.push_back(mMETPhi_MiniAOD);
0266     me_MET_MiniAOD.push_back(mMET_logx_MiniAOD);
0267     me_MET_MiniAOD.push_back(mSumET_logx_MiniAOD);
0268     me_MET_MiniAOD.push_back(mChargedHadronEtFraction_MiniAOD);
0269     me_MET_MiniAOD.push_back(mNeutralHadronEtFraction_MiniAOD);
0270     me_MET_MiniAOD.push_back(mPhotonEtFraction_MiniAOD);
0271     me_MET_MiniAOD.push_back(mHFHadronEtFraction_MiniAOD);
0272     me_MET_MiniAOD.push_back(mHFEMEtFraction_MiniAOD);
0273     me_MET_MiniAOD.push_back(mMET_nVtx_profile_MiniAOD);
0274     me_MET_MiniAOD.push_back(mSumET_nVtx_profile_MiniAOD);
0275     me_MET_MiniAOD.push_back(mChargedHadronEtFraction_nVtx_profile_MiniAOD);
0276     me_MET_MiniAOD.push_back(mNeutralHadronEtFraction_nVtx_profile_MiniAOD);
0277     me_MET_MiniAOD.push_back(mPhotonEtFraction_nVtx_profile_MiniAOD);
0278 
0279     ibook_.setCurrentFolder(RunDirMET + "MiniAOD_over_RECO");
0280     mMET_MiniAOD_over_Reco = ibook_.book1D("MET_MiniAOD_over_RECO", (TH1F*)mMET_Reco->getRootObject());
0281     mMEy_MiniAOD_over_Reco = ibook_.book1D("MEy_MiniAOD_over_RECO", (TH1F*)mMEy_Reco->getRootObject());
0282     mSumET_MiniAOD_over_Reco = ibook_.book1D("SumET_MiniAOD_over_RECO", (TH1F*)mSumET_Reco->getRootObject());
0283     mMETPhi_MiniAOD_over_Reco = ibook_.book1D("METPhi_MiniAOD_over_RECO", (TH1F*)mMETPhi_Reco->getRootObject());
0284     mMET_logx_MiniAOD_over_Reco = ibook_.book1D("MET_logx_MiniAOD_over_RECO", (TH1F*)mMET_logx_Reco->getRootObject());
0285     mSumET_logx_MiniAOD_over_Reco =
0286         ibook_.book1D("SumET_logx_MiniAOD_over_RECO", (TH1F*)mSumET_logx_Reco->getRootObject());
0287     mChargedHadronEtFraction_MiniAOD_over_Reco = ibook_.book1D("PfChargedHadronEtFraction_MiniAOD_over_RECO",
0288                                                                (TH1F*)mChargedHadronEtFraction_Reco->getRootObject());
0289     mNeutralHadronEtFraction_MiniAOD_over_Reco = ibook_.book1D("PfNeutralHadronEtFraction_MiniAOD_over_RECO",
0290                                                                (TH1F*)mNeutralHadronEtFraction_Reco->getRootObject());
0291     mPhotonEtFraction_MiniAOD_over_Reco =
0292         ibook_.book1D("PfPhotonEtFraction_MiniAOD_over_RECO", (TH1F*)mPhotonEtFraction_Reco->getRootObject());
0293     mHFHadronEtFraction_MiniAOD_over_Reco =
0294         ibook_.book1D("PfHFHadronEtFraction_MiniAOD_over_RECO", (TH1F*)mHFHadronEtFraction_Reco->getRootObject());
0295     mHFEMEtFraction_MiniAOD_over_Reco =
0296         ibook_.book1D("PfHFEMEtFraction_MiniAOD_over_RECO", (TH1F*)mHFEMEtFraction_Reco->getRootObject());
0297     //use same parameters defining X-Axis of the profiles
0298     mMET_nVtx_profile_MiniAOD_over_Reco =
0299         ibook_.book1D("MET_profile_MiniAOD_over_RECO", "MET_vs_nVtx", nbinsPV_, nPVMin_, nPVMax_);
0300     mSumET_nVtx_profile_MiniAOD_over_Reco =
0301         ibook_.book1D("SumET_profile_MiniAOD_over_RECO", "SumET_vs_nVtx", nbinsPV_, nPVMin_, nPVMax_);
0302     mChargedHadronEtFraction_nVtx_profile_MiniAOD_over_Reco =
0303         ibook_.book1D("PfChargedHadronEtFraction_profile_MiniAOD_over_RECO",
0304                       "PfChargedHadronEtFraction_vs_nVtx",
0305                       nbinsPV_,
0306                       nPVMin_,
0307                       nPVMax_);
0308     mNeutralHadronEtFraction_nVtx_profile_MiniAOD_over_Reco =
0309         ibook_.book1D("PfNeutralHadronEtFraction_profile_MiniAOD_over_RECO",
0310                       "PfNeutralHadronEtFraction_vs_nVtx",
0311                       nbinsPV_,
0312                       nPVMin_,
0313                       nPVMax_);
0314     mPhotonEtFraction_nVtx_profile_MiniAOD_over_Reco = ibook_.book1D(
0315         "PfPhotonEtFraction_profile_MiniAOD_over_RECO", "PfPhotonEtFraction_vs_nVtx", nbinsPV_, nPVMin_, nPVMax_);
0316 
0317     std::vector<MonitorElement*> me_MET_MiniAOD_over_Reco;
0318     me_MET_MiniAOD_over_Reco.push_back(mMET_MiniAOD_over_Reco);
0319     me_MET_MiniAOD_over_Reco.push_back(mMEy_MiniAOD_over_Reco);
0320     me_MET_MiniAOD_over_Reco.push_back(mSumET_MiniAOD_over_Reco);
0321     me_MET_MiniAOD_over_Reco.push_back(mMETPhi_MiniAOD_over_Reco);
0322     me_MET_MiniAOD_over_Reco.push_back(mMET_logx_MiniAOD_over_Reco);
0323     me_MET_MiniAOD_over_Reco.push_back(mSumET_logx_MiniAOD_over_Reco);
0324     me_MET_MiniAOD_over_Reco.push_back(mChargedHadronEtFraction_MiniAOD_over_Reco);
0325     me_MET_MiniAOD_over_Reco.push_back(mNeutralHadronEtFraction_MiniAOD_over_Reco);
0326     me_MET_MiniAOD_over_Reco.push_back(mPhotonEtFraction_MiniAOD_over_Reco);
0327     me_MET_MiniAOD_over_Reco.push_back(mHFHadronEtFraction_MiniAOD_over_Reco);
0328     me_MET_MiniAOD_over_Reco.push_back(mHFEMEtFraction_MiniAOD_over_Reco);
0329     me_MET_MiniAOD_over_Reco.push_back(mMET_nVtx_profile_MiniAOD_over_Reco);
0330     me_MET_MiniAOD_over_Reco.push_back(mSumET_nVtx_profile_MiniAOD_over_Reco);
0331     me_MET_MiniAOD_over_Reco.push_back(mChargedHadronEtFraction_nVtx_profile_MiniAOD_over_Reco);
0332     me_MET_MiniAOD_over_Reco.push_back(mNeutralHadronEtFraction_nVtx_profile_MiniAOD_over_Reco);
0333     me_MET_MiniAOD_over_Reco.push_back(mPhotonEtFraction_nVtx_profile_MiniAOD_over_Reco);
0334 
0335     for (unsigned int j = 0; j < me_MET_MiniAOD_over_Reco.size(); j++) {
0336       MonitorElement* monMETReco = me_MET_Reco[j];
0337       if (monMETReco && monMETReco->getRootObject()) {
0338         MonitorElement* monMETMiniAOD = me_MET_MiniAOD[j];
0339         if (monMETMiniAOD && monMETMiniAOD->getRootObject()) {
0340           MonitorElement* monMETMiniAOD_over_RECO = me_MET_MiniAOD_over_Reco[j];
0341           if (monMETMiniAOD_over_RECO && monMETMiniAOD_over_RECO->getRootObject()) {
0342             for (int i = 0; i <= (monMETMiniAOD_over_RECO->getNbinsX() + 1); i++) {
0343               if (monMETReco->getBinContent(i) != 0) {
0344                 monMETMiniAOD_over_RECO->setBinContent(i,
0345                                                        monMETMiniAOD->getBinContent(i) / monMETReco->getBinContent(i));
0346               } else if (monMETMiniAOD->getBinContent(i) != 0) {
0347                 monMETMiniAOD_over_RECO->setBinContent(i, -0.5);
0348               }
0349             }
0350           }
0351         }
0352       }
0353     }
0354   }  //check for RECO and MiniAOD directories
0355 
0356   //put RECO vs MiniAODDir first ->second Jets
0357   std::vector<std::string> subDirVecJet;
0358   //go only for cleaned directory
0359   std::string RunDirJet = "JetMET/Jet/";
0360   iget_.setCurrentFolder(RunDirJet);
0361   subDirVecJet = iget_.getSubdirs();
0362   bool found_Jetreco_dir = false;
0363   bool found_Jetminiaod_dir = false;
0364   for (int i = 0; i < int(subDirVecJet.size()); i++) {
0365     ibook_.setCurrentFolder(subDirVecJet[i]);
0366     if (subDirVecJet[i] == (RunDirJet + "Cleaned" + inputJetLabelRECO_.label())) {
0367       found_Jetreco_dir = true;
0368     }
0369     if (subDirVecJet[i] == (RunDirJet + "Cleaned" + inputJetLabelMiniAOD_.label())) {
0370       found_Jetminiaod_dir = true;
0371     }
0372   }
0373   if (found_Jetreco_dir && found_Jetminiaod_dir) {
0374     std::string rundirJet_reco = RunDirJet + "Cleaned" + inputJetLabelRECO_.label();
0375     std::string rundirJet_miniaod = RunDirJet + "Cleaned" + inputJetLabelMiniAOD_.label();
0376 
0377     MonitorElement* mPt_Reco = iget_.get(rundirJet_reco + "/" + "Pt");
0378     MonitorElement* mEta_Reco = iget_.get(rundirJet_reco + "/" + "Eta");
0379     MonitorElement* mPhi_Reco = iget_.get(rundirJet_reco + "/" + "Phi");
0380     MonitorElement* mNjets_Reco = iget_.get(rundirJet_reco + "/" + "NJets");
0381     MonitorElement* mPt_uncor_Reco = iget_.get(rundirJet_reco + "/" + "Pt_uncor");
0382     MonitorElement* mEta_uncor_Reco = iget_.get(rundirJet_reco + "/" + "Eta_uncor");
0383     MonitorElement* mPhi_uncor_Reco = iget_.get(rundirJet_reco + "/" + "Phi_uncor");
0384     MonitorElement* mJetEnergyCorr_Reco = iget_.get(rundirJet_reco + "/" + "JetEnergyCorr");
0385     MonitorElement* mJetEnergyCorrVSeta_Reco = iget_.get(rundirJet_reco + "/" + "JetEnergyCorrVSEta");
0386     MonitorElement* mDPhi_Reco = iget_.get(rundirJet_reco + "/" + "DPhi");
0387     MonitorElement* mLooseJIDPassFractionVSeta_Reco = iget_.get(rundirJet_reco + "/" + "JetIDPassFractionVSeta");
0388     MonitorElement* mPt_Barrel_Reco = iget_.get(rundirJet_reco + "/" + "Pt_Barrel");
0389     MonitorElement* mPt_EndCap_Reco = iget_.get(rundirJet_reco + "/" + "Pt_EndCap");
0390     MonitorElement* mPt_Forward_Reco = iget_.get(rundirJet_reco + "/" + "Pt_Forward");
0391     MonitorElement* mMVAPUJIDDiscriminant_lowPt_Barrel_Reco =
0392         iget_.get(rundirJet_reco + "/" + "MVAPUJIDDiscriminant_lowPt_Barrel");
0393     MonitorElement* mMVAPUJIDDiscriminant_lowPt_EndCap_Reco =
0394         iget_.get(rundirJet_reco + "/" + "MVAPUJIDDiscriminant_lowPt_EndCap");
0395     MonitorElement* mMVAPUJIDDiscriminant_lowPt_Forward_Reco =
0396         iget_.get(rundirJet_reco + "/" + "MVAPUJIDDiscriminant_lowPt_Forward");
0397     MonitorElement* mMVAPUJIDDiscriminant_mediumPt_EndCap_Reco =
0398         iget_.get(rundirJet_reco + "/" + "MVAPUJIDDiscriminant_mediumPt_EndCap");
0399     MonitorElement* mMVAPUJIDDiscriminant_highPt_Barrel_Reco =
0400         iget_.get(rundirJet_reco + "/" + "MVAPUJIDDiscriminant_highPt_Barrel");
0401     MonitorElement* mCHFracVSpT_Barrel_Reco = iget_.get(rundirJet_reco + "/" + "CHFracVSpT_Barrel");
0402     MonitorElement* mNHFracVSpT_EndCap_Reco = iget_.get(rundirJet_reco + "/" + "NHFracVSpT_EndCap");
0403     MonitorElement* mPhFracVSpT_Barrel_Reco = iget_.get(rundirJet_reco + "/" + "PhFracVSpT_Barrel");
0404     MonitorElement* mHFHFracVSpT_Forward_Reco = iget_.get(rundirJet_reco + "/" + "HFHFracVSpT_Forward");
0405     MonitorElement* mHFEFracVSpT_Forward_Reco = iget_.get(rundirJet_reco + "/" + "HFEFracVSpT_Forward");
0406     MonitorElement* mCHFrac_Reco = iget_.get(rundirJet_reco + "/DiJet/" + "CHFrac");
0407     MonitorElement* mNHFrac_Reco = iget_.get(rundirJet_reco + "/DiJet/" + "NHFrac");
0408     MonitorElement* mPhFrac_Reco = iget_.get(rundirJet_reco + "/DiJet/" + "PhFrac");
0409     MonitorElement* mChargedMultiplicity_Reco = iget_.get(rundirJet_reco + "/DiJet/" + "ChargedMultiplicity");
0410     MonitorElement* mNeutralMultiplicity_Reco = iget_.get(rundirJet_reco + "/DiJet/" + "NeutralMultiplicity");
0411     MonitorElement* mMuonMultiplicity_Reco = iget_.get(rundirJet_reco + "/DiJet/" + "MuonMultiplicity");
0412     MonitorElement* mNeutralFraction_Reco = iget_.get(rundirJet_reco + "/DiJet/" + "NeutralConstituentsFraction");
0413 
0414     std::vector<MonitorElement*> me_Jet_Reco;
0415     me_Jet_Reco.push_back(mPt_Reco);
0416     me_Jet_Reco.push_back(mEta_Reco);
0417     me_Jet_Reco.push_back(mPhi_Reco);
0418     me_Jet_Reco.push_back(mNjets_Reco);
0419     me_Jet_Reco.push_back(mPt_uncor_Reco);
0420     me_Jet_Reco.push_back(mEta_uncor_Reco);
0421     me_Jet_Reco.push_back(mPhi_uncor_Reco);
0422     me_Jet_Reco.push_back(mJetEnergyCorr_Reco);
0423     me_Jet_Reco.push_back(mJetEnergyCorrVSeta_Reco);
0424     me_Jet_Reco.push_back(mDPhi_Reco);
0425     me_Jet_Reco.push_back(mLooseJIDPassFractionVSeta_Reco);
0426     me_Jet_Reco.push_back(mPt_Barrel_Reco);
0427     me_Jet_Reco.push_back(mPt_EndCap_Reco);
0428     me_Jet_Reco.push_back(mPt_Forward_Reco);
0429     me_Jet_Reco.push_back(mMVAPUJIDDiscriminant_lowPt_Barrel_Reco);
0430     me_Jet_Reco.push_back(mMVAPUJIDDiscriminant_lowPt_EndCap_Reco);
0431     me_Jet_Reco.push_back(mMVAPUJIDDiscriminant_lowPt_Forward_Reco);
0432     me_Jet_Reco.push_back(mMVAPUJIDDiscriminant_mediumPt_EndCap_Reco);
0433     me_Jet_Reco.push_back(mMVAPUJIDDiscriminant_highPt_Barrel_Reco);
0434     me_Jet_Reco.push_back(mCHFracVSpT_Barrel_Reco);
0435     me_Jet_Reco.push_back(mNHFracVSpT_EndCap_Reco);
0436     me_Jet_Reco.push_back(mPhFracVSpT_Barrel_Reco);
0437     me_Jet_Reco.push_back(mHFHFracVSpT_Forward_Reco);
0438     me_Jet_Reco.push_back(mHFEFracVSpT_Forward_Reco);
0439     me_Jet_Reco.push_back(mCHFrac_Reco);
0440     me_Jet_Reco.push_back(mNHFrac_Reco);
0441     me_Jet_Reco.push_back(mPhFrac_Reco);
0442     me_Jet_Reco.push_back(mChargedMultiplicity_Reco);
0443     me_Jet_Reco.push_back(mNeutralMultiplicity_Reco);
0444     me_Jet_Reco.push_back(mMuonMultiplicity_Reco);
0445     me_Jet_Reco.push_back(mNeutralFraction_Reco);
0446 
0447     MonitorElement* mPt_MiniAOD = iget_.get(rundirJet_miniaod + "/" + "Pt");
0448     MonitorElement* mEta_MiniAOD = iget_.get(rundirJet_miniaod + "/" + "Eta");
0449     MonitorElement* mPhi_MiniAOD = iget_.get(rundirJet_miniaod + "/" + "Phi");
0450     MonitorElement* mNjets_MiniAOD = iget_.get(rundirJet_miniaod + "/" + "NJets");
0451     MonitorElement* mPt_uncor_MiniAOD = iget_.get(rundirJet_miniaod + "/" + "Pt_uncor");
0452     MonitorElement* mEta_uncor_MiniAOD = iget_.get(rundirJet_miniaod + "/" + "Eta_uncor");
0453     MonitorElement* mPhi_uncor_MiniAOD = iget_.get(rundirJet_miniaod + "/" + "Phi_uncor");
0454     MonitorElement* mJetEnergyCorr_MiniAOD = iget_.get(rundirJet_miniaod + "/" + "JetEnergyCorr");
0455     MonitorElement* mJetEnergyCorrVSeta_MiniAOD = iget_.get(rundirJet_miniaod + "/" + "JetEnergyCorrVSEta");
0456     MonitorElement* mDPhi_MiniAOD = iget_.get(rundirJet_miniaod + "/" + "DPhi");
0457     MonitorElement* mLooseJIDPassFractionVSeta_MiniAOD = iget_.get(rundirJet_miniaod + "/" + "JetIDPassFractionVSeta");
0458     MonitorElement* mPt_Barrel_MiniAOD = iget_.get(rundirJet_miniaod + "/" + "Pt_Barrel");
0459     MonitorElement* mPt_EndCap_MiniAOD = iget_.get(rundirJet_miniaod + "/" + "Pt_EndCap");
0460     MonitorElement* mPt_Forward_MiniAOD = iget_.get(rundirJet_miniaod + "/" + "Pt_Forward");
0461     MonitorElement* mMVAPUJIDDiscriminant_lowPt_Barrel_MiniAOD =
0462         iget_.get(rundirJet_miniaod + "/" + "MVAPUJIDDiscriminant_lowPt_Barrel");
0463     MonitorElement* mMVAPUJIDDiscriminant_lowPt_EndCap_MiniAOD =
0464         iget_.get(rundirJet_miniaod + "/" + "MVAPUJIDDiscriminant_lowPt_EndCap");
0465     MonitorElement* mMVAPUJIDDiscriminant_lowPt_Forward_MiniAOD =
0466         iget_.get(rundirJet_miniaod + "/" + "MVAPUJIDDiscriminant_lowPt_Forward");
0467     MonitorElement* mMVAPUJIDDiscriminant_mediumPt_EndCap_MiniAOD =
0468         iget_.get(rundirJet_miniaod + "/" + "MVAPUJIDDiscriminant_mediumPt_EndCap");
0469     MonitorElement* mMVAPUJIDDiscriminant_highPt_Barrel_MiniAOD =
0470         iget_.get(rundirJet_miniaod + "/" + "MVAPUJIDDiscriminant_highPt_Barrel");
0471     MonitorElement* mCHFracVSpT_Barrel_MiniAOD = iget_.get(rundirJet_miniaod + "/" + "CHFracVSpT_Barrel");
0472     MonitorElement* mNHFracVSpT_EndCap_MiniAOD = iget_.get(rundirJet_miniaod + "/" + "NHFracVSpT_EndCap");
0473     MonitorElement* mPhFracVSpT_Barrel_MiniAOD = iget_.get(rundirJet_miniaod + "/" + "PhFracVSpT_Barrel");
0474     MonitorElement* mHFHFracVSpT_Forward_MiniAOD = iget_.get(rundirJet_miniaod + "/" + "HFHFracVSpT_Forward");
0475     MonitorElement* mHFEFracVSpT_Forward_MiniAOD = iget_.get(rundirJet_miniaod + "/" + "HFEFracVSpT_Forward");
0476     MonitorElement* mCHFrac_MiniAOD = iget_.get(rundirJet_miniaod + "/DiJet/" + "CHFrac");
0477     MonitorElement* mNHFrac_MiniAOD = iget_.get(rundirJet_miniaod + "/DiJet/" + "NHFrac");
0478     MonitorElement* mPhFrac_MiniAOD = iget_.get(rundirJet_miniaod + "/DiJet/" + "PhFrac");
0479     MonitorElement* mChargedMultiplicity_MiniAOD = iget_.get(rundirJet_miniaod + "/DiJet/" + "ChargedMultiplicity");
0480     MonitorElement* mNeutralMultiplicity_MiniAOD = iget_.get(rundirJet_miniaod + "/DiJet/" + "NeutralMultiplicity");
0481     MonitorElement* mMuonMultiplicity_MiniAOD = iget_.get(rundirJet_miniaod + "/DiJet/" + "MuonMultiplicity");
0482     MonitorElement* mNeutralFraction_MiniAOD = iget_.get(rundirJet_miniaod + "/DiJet/" + "NeutralConstituentsFraction");
0483 
0484     std::vector<MonitorElement*> me_Jet_MiniAOD;
0485     me_Jet_MiniAOD.push_back(mPt_MiniAOD);
0486     me_Jet_MiniAOD.push_back(mEta_MiniAOD);
0487     me_Jet_MiniAOD.push_back(mPhi_MiniAOD);
0488     me_Jet_MiniAOD.push_back(mNjets_MiniAOD);
0489     me_Jet_MiniAOD.push_back(mPt_uncor_MiniAOD);
0490     me_Jet_MiniAOD.push_back(mEta_uncor_MiniAOD);
0491     me_Jet_MiniAOD.push_back(mPhi_uncor_MiniAOD);
0492     me_Jet_MiniAOD.push_back(mJetEnergyCorr_MiniAOD);
0493     me_Jet_MiniAOD.push_back(mJetEnergyCorrVSeta_MiniAOD);
0494     me_Jet_MiniAOD.push_back(mDPhi_MiniAOD);
0495     me_Jet_MiniAOD.push_back(mLooseJIDPassFractionVSeta_MiniAOD);
0496     me_Jet_MiniAOD.push_back(mPt_Barrel_MiniAOD);
0497     me_Jet_MiniAOD.push_back(mPt_EndCap_MiniAOD);
0498     me_Jet_MiniAOD.push_back(mPt_Forward_MiniAOD);
0499     me_Jet_MiniAOD.push_back(mMVAPUJIDDiscriminant_lowPt_Barrel_MiniAOD);
0500     me_Jet_MiniAOD.push_back(mMVAPUJIDDiscriminant_lowPt_EndCap_MiniAOD);
0501     me_Jet_MiniAOD.push_back(mMVAPUJIDDiscriminant_lowPt_Forward_MiniAOD);
0502     me_Jet_MiniAOD.push_back(mMVAPUJIDDiscriminant_mediumPt_EndCap_MiniAOD);
0503     me_Jet_MiniAOD.push_back(mMVAPUJIDDiscriminant_highPt_Barrel_MiniAOD);
0504     me_Jet_MiniAOD.push_back(mCHFracVSpT_Barrel_MiniAOD);
0505     me_Jet_MiniAOD.push_back(mNHFracVSpT_EndCap_MiniAOD);
0506     me_Jet_MiniAOD.push_back(mPhFracVSpT_Barrel_MiniAOD);
0507     me_Jet_MiniAOD.push_back(mHFHFracVSpT_Forward_MiniAOD);
0508     me_Jet_MiniAOD.push_back(mHFEFracVSpT_Forward_MiniAOD);
0509     me_Jet_MiniAOD.push_back(mCHFrac_MiniAOD);
0510     me_Jet_MiniAOD.push_back(mNHFrac_MiniAOD);
0511     me_Jet_MiniAOD.push_back(mPhFrac_MiniAOD);
0512     me_Jet_MiniAOD.push_back(mChargedMultiplicity_MiniAOD);
0513     me_Jet_MiniAOD.push_back(mNeutralMultiplicity_MiniAOD);
0514     me_Jet_MiniAOD.push_back(mMuonMultiplicity_MiniAOD);
0515     me_Jet_MiniAOD.push_back(mNeutralFraction_MiniAOD);
0516 
0517     ibook_.setCurrentFolder(RunDirJet + "MiniAOD_over_RECO");
0518     mPt_MiniAOD_over_Reco = ibook_.book1D("Pt_MiniAOD_over_RECO", (TH1F*)mPt_Reco->getRootObject());
0519     mEta_MiniAOD_over_Reco = ibook_.book1D("Eta_MiniAOD_over_RECO", (TH1F*)mEta_Reco->getRootObject());
0520     mPhi_MiniAOD_over_Reco = ibook_.book1D("Phi_MiniAOD_over_RECO", (TH1F*)mPhi_Reco->getRootObject());
0521     mNjets_MiniAOD_over_Reco = ibook_.book1D("NJets_MiniAOD_over_RECO", (TH1F*)mNjets_Reco->getRootObject());
0522     mPt_uncor_MiniAOD_over_Reco = ibook_.book1D("Pt_uncor_MiniAOD_over_RECO", (TH1F*)mPt_uncor_Reco->getRootObject());
0523     mEta_uncor_MiniAOD_over_Reco =
0524         ibook_.book1D("Eta_uncor_MiniAOD_over_RECO", (TH1F*)mEta_uncor_Reco->getRootObject());
0525     mPhi_uncor_MiniAOD_over_Reco =
0526         ibook_.book1D("Phi_uncor_MiniAOD_over_RECO", (TH1F*)mPhi_uncor_Reco->getRootObject());
0527     mJetEnergyCorr_MiniAOD_over_Reco =
0528         ibook_.book1D("JetEnergyCorr_MiniAOD_over_RECO", (TH1F*)mJetEnergyCorr_Reco->getRootObject());
0529     mJetEnergyCorrVSeta_MiniAOD_over_Reco = ibook_.book1D(
0530         "JetEnergyCorrVSEta_MiniAOD_over_RECO", "jet energy correction factor VS eta", etaBin_, etaMin_, etaMax_);
0531     mDPhi_MiniAOD_over_Reco = ibook_.book1D("DPhi_MiniAOD_over_RECO", (TH1F*)mDPhi_Reco->getRootObject());
0532     mLooseJIDPassFractionVSeta_MiniAOD_over_Reco =
0533         ibook_.book1D("JetIDPassFractionVSeta_MiniAOD_over_RECO", "JetIDPassFractionVSeta", etaBin_, etaMin_, etaMax_);
0534     mPt_Barrel_MiniAOD_over_Reco =
0535         ibook_.book1D("Pt_Barrel_MiniAOD_over_RECO", (TH1F*)mPt_Barrel_Reco->getRootObject());
0536     mPt_EndCap_MiniAOD_over_Reco =
0537         ibook_.book1D("Pt_EndCap_MiniAOD_over_RECO", (TH1F*)mPt_EndCap_Reco->getRootObject());
0538     mPt_Forward_MiniAOD_over_Reco =
0539         ibook_.book1D("Pt_Forward_MiniAOD_over_RECO", (TH1F*)mPt_Forward_Reco->getRootObject());
0540     mMVAPUJIDDiscriminant_lowPt_Barrel_MiniAOD_over_Reco =
0541         ibook_.book1D("MVAPUJIDDiscriminant_lowPt_Barrel_MiniAOD_over_RECO",
0542                       (TH1F*)mMVAPUJIDDiscriminant_lowPt_Barrel_Reco->getRootObject());
0543     mMVAPUJIDDiscriminant_lowPt_EndCap_MiniAOD_over_Reco =
0544         ibook_.book1D("MVAPUJIDDiscriminant_lowPt_EndCap_MiniAOD_over_RECO",
0545                       (TH1F*)mMVAPUJIDDiscriminant_lowPt_EndCap_Reco->getRootObject());
0546     mMVAPUJIDDiscriminant_lowPt_Forward_MiniAOD_over_Reco =
0547         ibook_.book1D("MVAPUJIDDiscriminant_lowPt_Forward_MiniAOD_over_RECO",
0548                       (TH1F*)mMVAPUJIDDiscriminant_lowPt_Forward_Reco->getRootObject());
0549     mMVAPUJIDDiscriminant_mediumPt_EndCap_MiniAOD_over_Reco =
0550         ibook_.book1D("MVAPUJIDDiscriminant_mediumPt_EndCap_MiniAOD_over_RECO",
0551                       (TH1F*)mMVAPUJIDDiscriminant_mediumPt_EndCap_Reco->getRootObject());
0552     mMVAPUJIDDiscriminant_highPt_Barrel_MiniAOD_over_Reco =
0553         ibook_.book1D("MVAPUJIDDiscriminant_highPt_Barrel_MiniAOD_over_RECO",
0554                       (TH1F*)mMVAPUJIDDiscriminant_highPt_Barrel_Reco->getRootObject());
0555     mCHFracVSpT_Barrel_MiniAOD_over_Reco =
0556         ibook_.book1D("CHFracVSpT_Barrel_MiniAOD_over_RECO", "CHFracVSpT_Barrel", ptBin_, ptMin_, ptMax_);
0557     mNHFracVSpT_EndCap_MiniAOD_over_Reco =
0558         ibook_.book1D("NHFracVSpT_EndCap_MiniAOD_over_RECO", "NHFracVSpT_EndCap", ptBin_, ptMin_, ptMax_);
0559     mPhFracVSpT_Barrel_MiniAOD_over_Reco =
0560         ibook_.book1D("PhFracVSpT_Barrel_MiniAOD_over_RECO", "PhFracVSpT_Barrel", ptBin_, ptMin_, ptMax_);
0561     mHFHFracVSpT_Forward_MiniAOD_over_Reco =
0562         ibook_.book1D("HFHFracVSpT_Forward_MiniAOD_over_RECO", "HFHFracVSpT_Forward", ptBin_, ptMin_, ptMax_);
0563     mHFEFracVSpT_Forward_MiniAOD_over_Reco =
0564         ibook_.book1D("HFEFracVSpT_Forward_MiniAOD_over_RECO", "HFEFracVSpT_Forward", ptBin_, ptMin_, ptMax_);
0565     ibook_.setCurrentFolder(RunDirJet + "MiniAOD_over_RECO" + "/" + "DiJet");
0566     mCHFrac_MiniAOD_over_Reco = ibook_.book1D("CHFrac_MiniAOD_over_RECO", (TH1F*)mCHFrac_Reco->getRootObject());
0567     mNHFrac_MiniAOD_over_Reco = ibook_.book1D("NHFrac_MiniAOD_over_RECO", (TH1F*)mNHFrac_Reco->getRootObject());
0568     mPhFrac_MiniAOD_over_Reco = ibook_.book1D("PhFrac_MiniAOD_over_RECO", (TH1F*)mPhFrac_Reco->getRootObject());
0569     mChargedMultiplicity_MiniAOD_over_Reco =
0570         ibook_.book1D("ChargedMultiplicity_MiniAOD_over_RECO", (TH1F*)mChargedMultiplicity_Reco->getRootObject());
0571     mNeutralMultiplicity_MiniAOD_over_Reco =
0572         ibook_.book1D("NeutralMultiplicity_MiniAOD_over_RECO", (TH1F*)mNeutralMultiplicity_Reco->getRootObject());
0573     mMuonMultiplicity_MiniAOD_over_Reco =
0574         ibook_.book1D("MuonMultiplicity_MiniAOD_over_RECO", (TH1F*)mMuonMultiplicity_Reco->getRootObject());
0575     mNeutralFraction_MiniAOD_over_Reco =
0576         ibook_.book1D("NeutralConstituentsFraction_MiniAOD_over_RECO", (TH1F*)mNeutralFraction_Reco->getRootObject());
0577 
0578     std::vector<MonitorElement*> me_Jet_MiniAOD_over_Reco;
0579     me_Jet_MiniAOD_over_Reco.push_back(mPt_MiniAOD_over_Reco);
0580     me_Jet_MiniAOD_over_Reco.push_back(mEta_MiniAOD_over_Reco);
0581     me_Jet_MiniAOD_over_Reco.push_back(mPhi_MiniAOD_over_Reco);
0582     me_Jet_MiniAOD_over_Reco.push_back(mNjets_MiniAOD_over_Reco);
0583     me_Jet_MiniAOD_over_Reco.push_back(mPt_uncor_MiniAOD_over_Reco);
0584     me_Jet_MiniAOD_over_Reco.push_back(mEta_uncor_MiniAOD_over_Reco);
0585     me_Jet_MiniAOD_over_Reco.push_back(mPhi_uncor_MiniAOD_over_Reco);
0586     me_Jet_MiniAOD_over_Reco.push_back(mJetEnergyCorr_MiniAOD_over_Reco);
0587     me_Jet_MiniAOD_over_Reco.push_back(mJetEnergyCorrVSeta_MiniAOD_over_Reco);
0588     me_Jet_MiniAOD_over_Reco.push_back(mDPhi_MiniAOD_over_Reco);
0589     me_Jet_MiniAOD_over_Reco.push_back(mLooseJIDPassFractionVSeta_MiniAOD_over_Reco);
0590     me_Jet_MiniAOD_over_Reco.push_back(mPt_Barrel_MiniAOD_over_Reco);
0591     me_Jet_MiniAOD_over_Reco.push_back(mPt_EndCap_MiniAOD_over_Reco);
0592     me_Jet_MiniAOD_over_Reco.push_back(mPt_Forward_MiniAOD_over_Reco);
0593     me_Jet_MiniAOD_over_Reco.push_back(mMVAPUJIDDiscriminant_lowPt_Barrel_MiniAOD_over_Reco);
0594     me_Jet_MiniAOD_over_Reco.push_back(mMVAPUJIDDiscriminant_lowPt_EndCap_MiniAOD_over_Reco);
0595     me_Jet_MiniAOD_over_Reco.push_back(mMVAPUJIDDiscriminant_lowPt_Forward_MiniAOD_over_Reco);
0596     me_Jet_MiniAOD_over_Reco.push_back(mMVAPUJIDDiscriminant_mediumPt_EndCap_MiniAOD_over_Reco);
0597     me_Jet_MiniAOD_over_Reco.push_back(mMVAPUJIDDiscriminant_highPt_Barrel_MiniAOD_over_Reco);
0598     me_Jet_MiniAOD_over_Reco.push_back(mCHFracVSpT_Barrel_MiniAOD_over_Reco);
0599     me_Jet_MiniAOD_over_Reco.push_back(mNHFracVSpT_EndCap_MiniAOD_over_Reco);
0600     me_Jet_MiniAOD_over_Reco.push_back(mPhFracVSpT_Barrel_MiniAOD_over_Reco);
0601     me_Jet_MiniAOD_over_Reco.push_back(mHFHFracVSpT_Forward_MiniAOD_over_Reco);
0602     me_Jet_MiniAOD_over_Reco.push_back(mHFEFracVSpT_Forward_MiniAOD_over_Reco);
0603     me_Jet_MiniAOD_over_Reco.push_back(mCHFrac_MiniAOD_over_Reco);
0604     me_Jet_MiniAOD_over_Reco.push_back(mNHFrac_MiniAOD_over_Reco);
0605     me_Jet_MiniAOD_over_Reco.push_back(mPhFrac_MiniAOD_over_Reco);
0606     me_Jet_MiniAOD_over_Reco.push_back(mChargedMultiplicity_MiniAOD_over_Reco);
0607     me_Jet_MiniAOD_over_Reco.push_back(mNeutralMultiplicity_MiniAOD_over_Reco);
0608     me_Jet_MiniAOD_over_Reco.push_back(mMuonMultiplicity_MiniAOD_over_Reco);
0609     me_Jet_MiniAOD_over_Reco.push_back(mNeutralFraction_MiniAOD_over_Reco);
0610 
0611     for (unsigned int j = 0; j < me_Jet_MiniAOD_over_Reco.size(); j++) {
0612       MonitorElement* monJetReco = me_Jet_Reco[j];
0613       if (monJetReco && monJetReco->getRootObject()) {
0614         MonitorElement* monJetMiniAOD = me_Jet_MiniAOD[j];
0615         if (monJetMiniAOD && monJetMiniAOD->getRootObject()) {
0616           MonitorElement* monJetMiniAOD_over_RECO = me_Jet_MiniAOD_over_Reco[j];
0617           if (monJetMiniAOD_over_RECO && monJetMiniAOD_over_RECO->getRootObject()) {
0618             for (int i = 0; i <= (monJetMiniAOD_over_RECO->getNbinsX() + 1); i++) {
0619               if (monJetReco->getBinContent(i) != 0) {
0620                 monJetMiniAOD_over_RECO->setBinContent(i,
0621                                                        monJetMiniAOD->getBinContent(i) / monJetReco->getBinContent(i));
0622               } else if (monJetMiniAOD->getBinContent(i) != 0) {
0623                 monJetMiniAOD_over_RECO->setBinContent(i, -0.5);
0624               }
0625             }
0626           }
0627         }
0628       }
0629     }
0630   }  //check for RECO and MiniAOD directories
0631 
0632   if (verbose_)
0633     std::cout << ">>> EndRun (DataCertificationJetMET) <<<" << std::endl;
0634 
0635   std::vector<std::string> subDirVec;
0636   std::string RunDir;
0637 
0638   if (verbose_)
0639     std::cout << "InMemory_           = " << InMemory_ << std::endl;
0640 
0641   ibook_.setCurrentFolder(folderName);
0642   reportSummary = ibook_.bookFloat("reportSummary");
0643   CertificationSummary = ibook_.bookFloat("CertificationSummary");
0644 
0645   reportSummaryMap = ibook_.book2D("reportSummaryMap", "reportSummaryMap", 3, 0, 3, 5, 0, 5);
0646   CertificationSummaryMap = ibook_.book2D("CertificationSummaryMap", "CertificationSummaryMap", 3, 0, 3, 5, 0, 5);
0647 
0648   reportSummary = iget_.get(folderName + "/" + "reportSummary");
0649   CertificationSummary = iget_.get(folderName + "/" + "CertificationSummary");
0650   reportSummaryMap = iget_.get(folderName + "/" + "reportSummaryMap");
0651   CertificationSummaryMap = iget_.get(folderName + "/" + "CertificationSummaryMap");
0652 
0653   if (reportSummaryMap && reportSummaryMap->getRootObject()) {
0654     reportSummaryMap->getTH2F()->SetStats(kFALSE);
0655     reportSummaryMap->setOption("colz");
0656     reportSummaryMap->setBinLabel(1, "CaloTower");
0657     reportSummaryMap->setBinLabel(2, "MET");
0658     reportSummaryMap->setBinLabel(3, "Jet");
0659   }
0660   if (CertificationSummaryMap && CertificationSummaryMap->getRootObject()) {
0661     CertificationSummaryMap->getTH2F()->SetStats(kFALSE);
0662     CertificationSummaryMap->setOption("colz");
0663     CertificationSummaryMap->setBinLabel(1, "CaloTower");
0664     CertificationSummaryMap->setBinLabel(2, "MET");
0665     CertificationSummaryMap->setBinLabel(3, "Jet");
0666   }
0667 
0668   reportSummary->Fill(1.);
0669   CertificationSummary->Fill(1.);
0670 
0671   if (RunDir == "Reference")
0672     RunDir = "";
0673   if (verbose_)
0674     std::cout << RunDir << std::endl;
0675   ibook_.setCurrentFolder("JetMET/EventInfo/CertificationSummaryContents/");
0676 
0677   std::string refHistoName;
0678   std::string newHistoName;
0679 
0680   //-----------------------------
0681   // Jet DQM Data Certification
0682   //-----------------------------
0683   //we have 4 types anymore: PF (barrel,endcap,forward) and calojets
0684   MonitorElement* meJetPt[4];
0685   MonitorElement* meJetEta[4];
0686   MonitorElement* meJetPhi[4];
0687   MonitorElement* meJetEMFrac[4];
0688   MonitorElement* meJetConstituents[4];
0689   RunDir = "";
0690   if (RunDir.empty())
0691     newHistoName = "JetMET/Jet/";
0692   else
0693     newHistoName = RunDir + "/JetMET/Runsummary/Jet/";
0694   std::string cleaningdir = "";
0695   cleaningdir = "Cleaned";
0696 
0697   // Read different histograms for PbPb and pp collisions
0698 
0699   if (isHI) {  // Histograms for heavy ions
0700 
0701     newHistoName = "JetMET/HIJetValidation/";
0702     cleaningdir = "";
0703 
0704     //Jet Phi histos
0705     meJetPhi[0] = iget_.get(newHistoName + cleaningdir + jetAlgo + "Cs4PFJets/Phi");
0706     meJetPhi[1] = iget_.get(newHistoName + cleaningdir + jetAlgo + "Pu3PFJets/Phi");
0707     meJetPhi[2] = iget_.get(newHistoName + cleaningdir + jetAlgo + "Pu4PFJets/Phi");
0708     meJetPhi[3] = iget_.get(newHistoName + cleaningdir + jetAlgo + "Pu4CaloJets/Phi");
0709 
0710     //Jet Eta histos
0711     meJetEta[0] = iget_.get(newHistoName + cleaningdir + jetAlgo + "Cs4PFJets/Eta");
0712     meJetEta[1] = iget_.get(newHistoName + cleaningdir + jetAlgo + "Pu3PFJets/Eta");
0713     meJetEta[2] = iget_.get(newHistoName + cleaningdir + jetAlgo + "Pu4PFJets/Eta");
0714     meJetEta[3] = iget_.get(newHistoName + cleaningdir + jetAlgo + "Pu4CaloJets/Eta");
0715 
0716     //Jet Pt histos
0717     meJetPt[0] = iget_.get(newHistoName + cleaningdir + jetAlgo + "Cs4PFJets/Pt");
0718     meJetPt[1] = iget_.get(newHistoName + cleaningdir + jetAlgo + "Pu3PFJets/Pt");
0719     meJetPt[2] = iget_.get(newHistoName + cleaningdir + jetAlgo + "Pu4PFJets/Pt");
0720     meJetPt[3] = iget_.get(newHistoName + cleaningdir + jetAlgo + "Pu4CaloJets/Pt");
0721 
0722     //Jet Constituents histos
0723     meJetConstituents[0] = iget_.get(newHistoName + cleaningdir + jetAlgo + "Cs4PFJets/Constituents");
0724     meJetConstituents[1] = iget_.get(newHistoName + cleaningdir + jetAlgo + "Pu3PFJets/Constituents");
0725     meJetConstituents[2] = iget_.get(newHistoName + cleaningdir + jetAlgo + "Pu4PFJets/Constituents");
0726     meJetConstituents[3] = iget_.get(newHistoName + cleaningdir + jetAlgo + "Pu4CaloJets/Constituents");
0727 
0728     //There are no jet EMFrac histograms for HI. Dummy paths will pass the tests by default
0729     meJetEMFrac[0] = iget_.get(newHistoName + cleaningdir + jetAlgo + "dummy/dummy");
0730     meJetEMFrac[1] = iget_.get(newHistoName + cleaningdir + jetAlgo + "dummy/dummy");
0731     meJetEMFrac[2] = iget_.get(newHistoName + cleaningdir + jetAlgo + "dummy/dummy");
0732     meJetEMFrac[3] = iget_.get(newHistoName + cleaningdir + jetAlgo + "dummy/dummy");
0733 
0734   } else {  // Histograms for protons
0735 
0736     //Jet Phi histos
0737     meJetPhi[0] = iget_.get(newHistoName + cleaningdir + jetAlgo + "PFJets/Phi_Barrel");
0738     meJetPhi[1] = iget_.get(newHistoName + cleaningdir + jetAlgo + "PFJets/Phi_EndCap");
0739     meJetPhi[2] = iget_.get(newHistoName + cleaningdir + jetAlgo + "PFJets/Phi_Forward");
0740     meJetPhi[3] = iget_.get(newHistoName + cleaningdir + jetAlgo + "CaloJets/Phi");
0741     //meJetPhi[4] = iget_.get(newHistoName+cleaningdir+"JetPlusTrackZSPCorJetAntiKt5/Phi");
0742 
0743     //Jet Eta histos
0744     meJetEta[0] = iget_.get(newHistoName + cleaningdir + jetAlgo + "PFJets/Eta");
0745     meJetEta[1] = iget_.get(newHistoName + cleaningdir + jetAlgo + "PFJets/Eta");
0746     meJetEta[2] = iget_.get(newHistoName + cleaningdir + jetAlgo + "PFJets/EtaFirst");
0747     meJetEta[3] = iget_.get(newHistoName + cleaningdir + jetAlgo + "CaloJets/Eta");
0748     //meJetEta[4] = iget_.get(newHistoName+cleaningdir+"JetPlusTrackZSPCorJetAntiKt5/Eta");
0749 
0750     //Jet Pt histos
0751     meJetPt[0] = iget_.get(newHistoName + cleaningdir + jetAlgo + "PFJets/Pt_Barrel");
0752     meJetPt[1] = iget_.get(newHistoName + cleaningdir + jetAlgo + "PFJets/Pt_EndCap");
0753     meJetPt[2] = iget_.get(newHistoName + cleaningdir + jetAlgo + "PFJets/Pt_Forward");
0754     meJetPt[3] = iget_.get(newHistoName + cleaningdir + jetAlgo + "CaloJets/Pt_2");
0755 
0756     //Jet Constituents histos
0757     meJetConstituents[0] = iget_.get(newHistoName + cleaningdir + jetAlgo + "PFJets/Constituents_Barrel");
0758     meJetConstituents[1] = iget_.get(newHistoName + cleaningdir + jetAlgo + "PFJets/Constituents_EndCap");
0759     meJetConstituents[2] = iget_.get(newHistoName + cleaningdir + jetAlgo + "PFJets/Constituents_Forward");
0760     meJetConstituents[3] = iget_.get(newHistoName + cleaningdir + jetAlgo + "CaloJets/Constituents");
0761 
0762     //Jet EMFrac histos
0763     meJetEMFrac[0] = iget_.get(newHistoName + cleaningdir + jetAlgo + "PFJets/EFrac_Barrel");
0764     meJetEMFrac[1] = iget_.get(newHistoName + cleaningdir + jetAlgo + "PFJets/EFrac_EndCap");
0765     meJetEMFrac[2] = iget_.get(newHistoName + cleaningdir + jetAlgo + "PFJets/EFrac_Forward");
0766     meJetEMFrac[3] = iget_.get(newHistoName + cleaningdir + jetAlgo + "CaloJets/EFrac");
0767   }
0768 
0769   //------------------------------------------------------------------------------
0770   //--- Extract quality test results and fill data certification results for Jets
0771   //--- Tests for Calo Barrel, EndCap and Forward, as well as PF and JPT jets
0772   //--- For Calo and PF jets:
0773   //--- Look at mean of Constituents, EM Frac and Pt
0774   //--- Look at Kolmogorov result for Eta, Phi, and Pt
0775   //--- For JPT jets:
0776   //--- Look at mean of Pt, AllPionsTrackNHits?, nTracks,
0777   //--- Look at Kolmogorov result for Eta, Phi, and Pt
0778   //------------------------------------------------------------------------------
0779 
0780   // Four types of jets {AK5 Barrel, AK5 EndCap, AK5 Forward, PF}, removed JPT which is 5th type of jets
0781   //----------------------------------------------------------------------------
0782   // Kolmogorov (KS) tests
0783   const QReport* QReport_JetEta[4] = {nullptr};
0784   const QReport* QReport_JetPhi[4] = {nullptr};
0785   // Mean and KS tests for Calo and PF jets
0786   const QReport* QReport_JetConstituents[4][2] = {{nullptr}};
0787   const QReport* QReport_JetEFrac[4][2] = {{nullptr}};
0788   const QReport* QReport_JetPt[4][2] = {{nullptr}};
0789 
0790   // Mean and KS tests for JPT jets
0791   //const QReport* QReport_JetNTracks[2] = {0, 0};
0792   float qr_Jet_Eta[4] = {-1};
0793   float qr_Jet_Phi[4] = {-1};
0794   float dc_Jet[4] = {-1};
0795 
0796   float qr_Jet_Constituents[4][2] = {{-1}};
0797   float qr_Jet_EFrac[4][2] = {{-1}};
0798   float qr_Jet_Pt[4][2] = {{-1}};
0799 
0800   // Loop
0801   //----------------------------------------------------------------------------
0802   for (int jtyp = 0; jtyp < 4; ++jtyp) {
0803     // Mean test results
0804 
0805     if (meJetConstituents[jtyp] && meJetConstituents[jtyp]->getRootObject()) {
0806       QReport_JetConstituents[jtyp][0] = meJetConstituents[jtyp]->getQReport("meanJetConstituentsTest");
0807       QReport_JetConstituents[jtyp][1] = meJetConstituents[jtyp]->getQReport("KolmogorovTest");
0808     }
0809     if (meJetEMFrac[jtyp] && meJetEMFrac[jtyp]->getRootObject()) {
0810       QReport_JetEFrac[jtyp][0] = meJetEMFrac[jtyp]->getQReport("meanEMFractionTest");
0811       QReport_JetEFrac[jtyp][1] = meJetEMFrac[jtyp]->getQReport("KolmogorovTest");
0812     }
0813     if (meJetPt[jtyp] && meJetPt[jtyp]->getRootObject()) {
0814       QReport_JetPt[jtyp][0] = meJetPt[jtyp]->getQReport("meanJetPtTest");
0815       QReport_JetPt[jtyp][1] = meJetPt[jtyp]->getQReport("KolmogorovTest");
0816     }
0817     if (meJetPhi[jtyp] && meJetPhi[jtyp]->getRootObject()) {
0818       QReport_JetPhi[jtyp] = meJetPhi[jtyp]->getQReport("KolmogorovTest");
0819     }
0820     if (meJetEta[jtyp] && meJetEta[jtyp]->getRootObject()) {
0821       QReport_JetEta[jtyp] = meJetEta[jtyp]->getQReport("KolmogorovTest");
0822     }
0823 
0824     //Jet Pt test
0825     if (QReport_JetPt[jtyp][0]) {
0826       //std::cout<<"jet type test pt "<<jtyp<<"/"<<QReport_JetPt[jtyp][0]->getStatus()<<std::endl;
0827       if (QReport_JetPt[jtyp][0]->getStatus() == 100 || QReport_JetPt[jtyp][0]->getStatus() == 200)
0828         qr_Jet_Pt[jtyp][0] = 1;
0829       else if (QReport_JetPt[jtyp][0]->getStatus() == 300)
0830         qr_Jet_Pt[jtyp][0] = 0;
0831       else
0832         qr_Jet_Pt[jtyp][0] = -1;
0833     } else {
0834       qr_Jet_Pt[jtyp][0] = -2;
0835       //std::cout<<"qreport is REALLY NULL type test pt "<<jtyp<<" 0 "<<std::endl;
0836     }
0837     if (QReport_JetPt[jtyp][1]) {
0838       if (QReport_JetPt[jtyp][1]->getStatus() == 100 || QReport_JetPt[jtyp][1]->getStatus() == 200)
0839         qr_Jet_Pt[jtyp][1] = 1;
0840       else if (QReport_JetPt[jtyp][1]->getStatus() == 300)
0841         qr_Jet_Pt[jtyp][1] = 0;
0842       else
0843         qr_Jet_Pt[jtyp][1] = -1;
0844     } else {
0845       qr_Jet_Pt[jtyp][1] = -2;
0846     }
0847 
0848     //Jet Phi test
0849     if (QReport_JetPhi[jtyp]) {
0850       if (QReport_JetPhi[jtyp]->getStatus() == 100 || QReport_JetPhi[jtyp]->getStatus() == 200)
0851         qr_Jet_Phi[jtyp] = 1;
0852       else if (QReport_JetPhi[jtyp]->getStatus() == 300)
0853         qr_Jet_Phi[jtyp] = 0;
0854       else
0855         qr_Jet_Phi[jtyp] = -1;
0856     } else {
0857       qr_Jet_Phi[jtyp] = -2;
0858     }
0859     //Jet Eta test
0860     if (QReport_JetEta[jtyp]) {
0861       if (QReport_JetEta[jtyp]->getStatus() == 100 || QReport_JetEta[jtyp]->getStatus() == 200)
0862         qr_Jet_Eta[jtyp] = 1;
0863       else if (QReport_JetEta[jtyp]->getStatus() == 300)
0864         qr_Jet_Eta[jtyp] = 0;
0865       else
0866         qr_Jet_Eta[jtyp] = -1;
0867     } else {
0868       qr_Jet_Eta[jtyp] = -2;
0869     }
0870     //Jet Constituents test
0871     if (QReport_JetConstituents[jtyp][0]) {
0872       if (QReport_JetConstituents[jtyp][0]->getStatus() == 100 || QReport_JetConstituents[jtyp][0]->getStatus() == 200)
0873         qr_Jet_Constituents[jtyp][0] = 1;
0874       else if (QReport_JetConstituents[jtyp][0]->getStatus() == 300)
0875         qr_Jet_Constituents[jtyp][0] = 0;
0876       else
0877         qr_Jet_Constituents[jtyp][0] = -1;
0878     } else {
0879       qr_Jet_Constituents[jtyp][0] = -2;
0880     }
0881 
0882     if (QReport_JetConstituents[jtyp][1]) {
0883       if (QReport_JetConstituents[jtyp][1]->getStatus() == 100 || QReport_JetConstituents[jtyp][1]->getStatus() == 200)
0884         qr_Jet_Constituents[jtyp][1] = 1;
0885       else if (QReport_JetConstituents[jtyp][1]->getStatus() == 300)
0886         qr_Jet_Constituents[jtyp][1] = 0;
0887       else
0888         qr_Jet_Constituents[jtyp][1] = -1;
0889     } else {
0890       qr_Jet_Constituents[jtyp][1] = -2;
0891     }
0892     //Jet EMFrac test
0893     if (QReport_JetEFrac[jtyp][0]) {
0894       if (QReport_JetEFrac[jtyp][0]->getStatus() == 100 || QReport_JetEFrac[jtyp][0]->getStatus() == 200)
0895         qr_Jet_EFrac[jtyp][0] = 1;
0896       else if (QReport_JetEFrac[jtyp][0]->getStatus() == 300)
0897         qr_Jet_EFrac[jtyp][0] = 0;
0898       else
0899         qr_Jet_EFrac[jtyp][0] = -1;
0900     } else {
0901       qr_Jet_EFrac[jtyp][0] = -2;
0902     }
0903 
0904     if (QReport_JetEFrac[jtyp][1]) {
0905       if (QReport_JetEFrac[jtyp][1]->getStatus() == 100 || QReport_JetEFrac[jtyp][1]->getStatus() == 200)
0906         qr_Jet_EFrac[jtyp][1] = 1;
0907       else if (QReport_JetEFrac[jtyp][1]->getStatus() == 300)
0908         qr_Jet_EFrac[jtyp][1] = 0;
0909       else
0910         qr_Jet_EFrac[jtyp][1] = -1;
0911     } else {
0912       qr_Jet_EFrac[jtyp][1] = -2;
0913     }
0914 
0915     if (verbose_) {
0916       printf("====================Jet Type %d QTest Report Summary========================\n", jtyp);
0917       printf("Eta:    Phi:   Pt 1:    2:    Const/Ntracks 1:    2:    EFrac/tracknhits 1:    2:\n");
0918 
0919       printf("%2.2f    %2.2f    %2.2f    %2.2f    %2.2f    %2.2f    %2.2f    %2.2f\n",
0920              qr_Jet_Eta[jtyp],
0921              qr_Jet_Phi[jtyp],
0922              qr_Jet_Pt[jtyp][0],
0923              qr_Jet_Pt[jtyp][1],
0924              qr_Jet_Constituents[jtyp][0],
0925              qr_Jet_Constituents[jtyp][1],
0926              qr_Jet_EFrac[jtyp][0],
0927              qr_Jet_EFrac[jtyp][1]);
0928     }
0929     //certification result for Jet
0930 
0931     //Only apply certain tests, as defined in the config
0932     for (int ttyp = 0; ttyp < 2; ++ttyp) {
0933       if (!jetTests[jtyp][ttyp]) {
0934         qr_Jet_Pt[jtyp][ttyp] = 1;
0935         if (ttyp == 1) {
0936           qr_Jet_Eta[jtyp] = 1;
0937           qr_Jet_Phi[jtyp] = 1;
0938         }
0939         qr_Jet_EFrac[jtyp][ttyp] = 1;
0940         qr_Jet_Constituents[jtyp][ttyp] = 1;
0941       }
0942     }
0943 
0944     if ((qr_Jet_EFrac[jtyp][0] == 0) || (qr_Jet_EFrac[jtyp][1] == 0) || (qr_Jet_Constituents[jtyp][1] == 0) ||
0945         (qr_Jet_Constituents[jtyp][0] == 0) || (qr_Jet_Eta[jtyp] == 0) || (qr_Jet_Phi[jtyp] == 0) ||
0946         (qr_Jet_Pt[jtyp][0] == 0) || (qr_Jet_Pt[jtyp][1] == 0))
0947       dc_Jet[jtyp] = 0;
0948     else if ((qr_Jet_EFrac[jtyp][0] == -1) && (qr_Jet_EFrac[jtyp][1] == -1) && (qr_Jet_Constituents[jtyp][1] == -1) &&
0949              (qr_Jet_Constituents[jtyp][0] == -1) && (qr_Jet_Eta[jtyp] == -1) && (qr_Jet_Phi[jtyp] == -1) &&
0950              (qr_Jet_Pt[jtyp][0] == -1) && (qr_Jet_Pt[jtyp][1] == -1))
0951       dc_Jet[jtyp] = -1;
0952     else if ((qr_Jet_EFrac[jtyp][0] == -2) && (qr_Jet_EFrac[jtyp][1] == -2) && (qr_Jet_Constituents[jtyp][1] == -2) &&
0953              (qr_Jet_Constituents[jtyp][0] == -2) && (qr_Jet_Eta[jtyp] == -2) && (qr_Jet_Phi[jtyp] == -2) &&
0954              (qr_Jet_Pt[jtyp][0] == -2) && (qr_Jet_Pt[jtyp][1] == -2))
0955       dc_Jet[jtyp] = -2;
0956     else
0957       dc_Jet[jtyp] = 1;
0958 
0959     if (verbose_)
0960       std::cout << "Certifying Jet algo: " << jtyp << " with value: " << dc_Jet[jtyp] << std::endl;
0961 
0962     CertificationSummaryMap->Fill(2, 4 - jtyp, dc_Jet[jtyp]);
0963     reportSummaryMap->Fill(2, 4 - jtyp, dc_Jet[jtyp]);
0964   }
0965 
0966   // There is nothing on the first row for HI, so mark the unfilled
0967   if (isHI) {
0968     CertificationSummaryMap->Fill(2, 0, -2);
0969     reportSummaryMap->Fill(2, 0, -2);
0970   }
0971 
0972   //-----------------------------
0973   // MET DQM Data Certification
0974   //-----------------------------
0975   //
0976   // Prepare test histograms
0977   //
0978   MonitorElement* meMExy[2][2];
0979   MonitorElement* meMEt[2];
0980   MonitorElement* meSumEt[2];
0981   MonitorElement* meMETPhi[2];
0982 
0983   RunDir = "";
0984   if (RunDir.empty())
0985     newHistoName = "JetMET/MET/";
0986   else
0987     newHistoName = RunDir + "/JetMET/Runsummary/MET/";
0988 
0989   metFolder = "Cleaned";
0990 
0991   //MEx/MEy monitor elements
0992   meMExy[0][0] = iget_.get(newHistoName + "met/" + metFolder + "/MEx");
0993   meMExy[0][1] = iget_.get(newHistoName + "met/" + metFolder + "/MEy");
0994   meMExy[1][0] = iget_.get(newHistoName + "pfMet/" + metFolder + "/MEx");
0995   meMExy[1][1] = iget_.get(newHistoName + "pfMet/" + metFolder + "/MEy");
0996 
0997   //MET Phi monitor elements
0998   meMETPhi[0] = iget_.get(newHistoName + "met/" + metFolder + "/METPhi");
0999   meMETPhi[1] = iget_.get(newHistoName + "pfMet/" + metFolder + "/METPhi");
1000   //MET monitor elements
1001   meMEt[0] = iget_.get(newHistoName + "met/" + metFolder + "/MET");
1002   meMEt[1] = iget_.get(newHistoName + "pfMet/" + metFolder + "/MET");
1003   //SumET monitor elements
1004   meSumEt[0] = iget_.get(newHistoName + "met/" + metFolder + "/SumET");
1005   meSumEt[1] = iget_.get(newHistoName + "pfMet/" + metFolder + "/SumET");
1006 
1007   //----------------------------------------------------------------------------
1008   //--- Extract quality test results and fill data certification results for MET
1009   //----------------------------------------------------------------------------
1010 
1011   // 2 types of MET {CaloMET, PfMET}  // It is 5 if CaloMETNoHF is included, 4 for MuonCorMET
1012   // removed 3rd type of TcMET
1013   // 2 types of tests Mean test/Kolmogorov test
1014   const QReport* QReport_MExy[2][2][2] = {{{nullptr}}};
1015   const QReport* QReport_MEt[2][2] = {{nullptr}};
1016   const QReport* QReport_SumEt[2][2] = {{nullptr}};
1017   //2 types of tests phiQTest and Kolmogorov test
1018   const QReport* QReport_METPhi[2][2] = {{nullptr}};
1019 
1020   float qr_MET_MExy[2][2][2] = {{{-999.}}};
1021   float qr_MET_MEt[2][2] = {{-999.}};
1022   float qr_MET_SumEt[2][2] = {{-999.}};
1023   float qr_MET_METPhi[2][2] = {{-999.}};
1024   float dc_MET[2] = {-999.};
1025 
1026   // J.Piedra, 27/02/212
1027   // removed MuCorrMET & TcMET --> loop up to 2 instead of 4, remove already from definition
1028   for (int mtyp = 0; mtyp < 2; ++mtyp) {
1029     //Mean test results
1030     if (meMExy[mtyp][0] && meMExy[mtyp][0]->getRootObject()) {
1031       QReport_MExy[mtyp][0][0] = meMExy[mtyp][0]->getQReport("meanMExyTest");
1032       QReport_MExy[mtyp][1][0] = meMExy[mtyp][0]->getQReport("KolmogorovTest");
1033     }
1034     if (meMExy[mtyp][1] && meMExy[mtyp][1]->getRootObject()) {
1035       QReport_MExy[mtyp][0][1] = meMExy[mtyp][1]->getQReport("meanMExyTest");
1036       QReport_MExy[mtyp][1][1] = meMExy[mtyp][1]->getQReport("KolmogorovTest");
1037     }
1038     if (meMEt[mtyp] && meMEt[mtyp]->getRootObject()) {
1039       QReport_MEt[mtyp][0] = meMEt[mtyp]->getQReport("meanMETTest");
1040       QReport_MEt[mtyp][1] = meMEt[mtyp]->getQReport("KolmogorovTest");
1041     }
1042 
1043     if (meSumEt[mtyp] && meSumEt[mtyp]->getRootObject()) {
1044       QReport_SumEt[mtyp][0] = meSumEt[mtyp]->getQReport("meanSumETTest");
1045       QReport_SumEt[mtyp][1] = meSumEt[mtyp]->getQReport("KolmogorovTest");
1046     }
1047 
1048     if (meMETPhi[mtyp] && meMETPhi[mtyp]->getRootObject()) {
1049       QReport_METPhi[mtyp][0] = meMETPhi[mtyp]->getQReport("phiQTest");
1050       QReport_METPhi[mtyp][1] = meMETPhi[mtyp]->getQReport("KolmogorovTest");
1051     }
1052     for (int testtyp = 0; testtyp < 2; ++testtyp) {
1053       //MEx test
1054       if (QReport_MExy[mtyp][testtyp][0]) {
1055         if (QReport_MExy[mtyp][testtyp][0]->getStatus() == 100 || QReport_MExy[mtyp][testtyp][0]->getStatus() == 200)
1056           qr_MET_MExy[mtyp][testtyp][0] = 1;
1057         else if (QReport_MExy[mtyp][testtyp][0]->getStatus() == 300)
1058           qr_MET_MExy[mtyp][testtyp][0] = 0;
1059         else
1060           qr_MET_MExy[mtyp][testtyp][0] = -1;
1061       } else
1062         qr_MET_MExy[mtyp][testtyp][0] = -2;
1063       //MEy test
1064       if (QReport_MExy[mtyp][testtyp][1]) {
1065         if (QReport_MExy[mtyp][testtyp][1]->getStatus() == 100 || QReport_MExy[mtyp][testtyp][1]->getStatus() == 200)
1066           qr_MET_MExy[mtyp][testtyp][1] = 1;
1067         else if (QReport_MExy[mtyp][testtyp][1]->getStatus() == 300)
1068           qr_MET_MExy[mtyp][testtyp][1] = 0;
1069         else
1070           qr_MET_MExy[mtyp][testtyp][1] = -1;
1071       } else
1072         qr_MET_MExy[mtyp][testtyp][1] = -2;
1073 
1074       //MEt test
1075       if (QReport_MEt[mtyp][testtyp]) {
1076         if (QReport_MEt[mtyp][testtyp]->getStatus() == 100 || QReport_MEt[mtyp][testtyp]->getStatus() == 200)
1077           qr_MET_MEt[mtyp][testtyp] = 1;
1078         else if (QReport_MEt[mtyp][testtyp]->getStatus() == 300)
1079           qr_MET_MEt[mtyp][testtyp] = 0;
1080         else
1081           qr_MET_MEt[mtyp][testtyp] = -1;
1082       } else {
1083         qr_MET_MEt[mtyp][testtyp] = -2;
1084       }
1085       //SumEt test
1086       if (QReport_SumEt[mtyp][testtyp]) {
1087         if (QReport_SumEt[mtyp][testtyp]->getStatus() == 100 || QReport_SumEt[mtyp][testtyp]->getStatus() == 200)
1088           qr_MET_SumEt[mtyp][testtyp] = 1;
1089         else if (QReport_SumEt[mtyp][testtyp]->getStatus() == 300)
1090           qr_MET_SumEt[mtyp][testtyp] = 0;
1091         else
1092           qr_MET_SumEt[mtyp][testtyp] = -1;
1093       } else {
1094         qr_MET_SumEt[mtyp][testtyp] = -2;
1095       }
1096       //METPhi test
1097       if (QReport_METPhi[mtyp][testtyp]) {
1098         if (QReport_METPhi[mtyp][testtyp]->getStatus() == 100 || QReport_METPhi[mtyp][testtyp]->getStatus() == 200)
1099           qr_MET_METPhi[mtyp][testtyp] = 1;
1100         else if (QReport_METPhi[mtyp][testtyp]->getStatus() == 300)
1101           qr_MET_METPhi[mtyp][testtyp] = 0;
1102         else
1103           qr_MET_METPhi[mtyp][testtyp] = -1;
1104       } else {
1105         qr_MET_METPhi[mtyp][testtyp] = -2;
1106       }
1107     }
1108 
1109     if (verbose_) {
1110       //certification result for MET
1111       printf("====================MET Type %d QTest Report Summary========================\n", mtyp);
1112       printf("MEx test    MEy test    MEt test:    SumEt test:    METPhi test:\n");
1113       for (int tt = 0; tt < 2; ++tt) {
1114         printf("%2.2f    %2.2f    %2.2f    %2.2f    %2.2f\n",
1115                qr_MET_MExy[mtyp][tt][0],
1116                qr_MET_MExy[mtyp][tt][1],
1117                qr_MET_MEt[mtyp][tt],
1118                qr_MET_SumEt[mtyp][tt],
1119                qr_MET_METPhi[mtyp][tt]);
1120       }
1121       printf("===========================================================================\n");
1122     }
1123 
1124     //Only apply certain tests, as defined in the config
1125     for (int ttyp = 0; ttyp < 2; ++ttyp) {
1126       if (!metTests[mtyp][ttyp]) {
1127         qr_MET_MExy[mtyp][ttyp][0] = 1;
1128         qr_MET_MExy[mtyp][ttyp][1] = 1;
1129         qr_MET_MEt[mtyp][ttyp] = 1;
1130         qr_MET_SumEt[mtyp][ttyp] = 1;
1131         qr_MET_METPhi[mtyp][ttyp] = 1;
1132       }
1133     }
1134 
1135     if ((qr_MET_MExy[mtyp][0][0] == 0) || (qr_MET_MExy[mtyp][0][1] == 0) || (qr_MET_MEt[mtyp][0] == 0) ||
1136         (qr_MET_SumEt[mtyp][0] == 0) || (qr_MET_METPhi[mtyp][0] == 0) || (qr_MET_MExy[mtyp][1][0] == 0) ||
1137         (qr_MET_MExy[mtyp][1][1] == 0) || (qr_MET_MEt[mtyp][1] == 0) || (qr_MET_SumEt[mtyp][1] == 0) ||
1138         (qr_MET_METPhi[mtyp][1] == 0))
1139       dc_MET[mtyp] = 0;
1140     else if ((qr_MET_MExy[mtyp][0][0] == -1) && (qr_MET_MExy[mtyp][0][1] == -1) && (qr_MET_MEt[mtyp][0] == -1) &&
1141              (qr_MET_SumEt[mtyp][0] == -1) && (qr_MET_METPhi[mtyp][0] == -1) && (qr_MET_MExy[mtyp][1][0] == -1) &&
1142              (qr_MET_MExy[mtyp][1][1] == -1) && (qr_MET_MEt[mtyp][1] == -1) && (qr_MET_SumEt[mtyp][1] == -1) &&
1143              (qr_MET_METPhi[mtyp][1] == -1))
1144       dc_MET[mtyp] = -1;
1145     else if ((qr_MET_MExy[mtyp][0][0] == -2) && (qr_MET_MExy[mtyp][0][1] == -2) && (qr_MET_MEt[mtyp][0] == -2) &&
1146              (qr_MET_SumEt[mtyp][0] == -2) && (qr_MET_METPhi[mtyp][0] == -2) && (qr_MET_MExy[mtyp][1][0] == -2) &&
1147              (qr_MET_MExy[mtyp][1][1] == -2) && (qr_MET_MEt[mtyp][1] == -2) && (qr_MET_SumEt[mtyp][1] == -2) &&
1148              (qr_MET_METPhi[mtyp][1] == -2))
1149       dc_MET[mtyp] = -2;
1150     else
1151       dc_MET[mtyp] = 1;
1152 
1153     if (verbose_)
1154       std::cout << "Certifying MET algo: " << mtyp << " with value: " << dc_MET[mtyp] << std::endl;
1155     CertificationSummaryMap->Fill(1, 4 - mtyp, dc_MET[mtyp]);
1156     reportSummaryMap->Fill(1, 4 - mtyp, dc_MET[mtyp]);
1157   }
1158 
1159   // There is nothing on the first three rows for HI, so mark them unfilled
1160   if (isHI) {
1161     for (int i = 0; i < 3; i++) {
1162       CertificationSummaryMap->Fill(1, i, -2);
1163       reportSummaryMap->Fill(1, i, -2);
1164     }
1165   }
1166 
1167   //----------------------------------------------------------------------------
1168   //--- Extract quality test results and fill data certification results for MET
1169   //----------------------------------------------------------------------------
1170   // Commenting out unused but initialized variables. [Suchandra Dutta]
1171   float dc_CT[3] = {-2.};
1172   dc_CT[0] = -2.;
1173   dc_CT[1] = -2.;
1174   dc_CT[2] = -2.;
1175 
1176   for (int cttyp = 0; cttyp < 3; ++cttyp) {
1177     if (verbose_)
1178       std::cout << "Certifying CaloTowers with value: " << dc_CT[cttyp] << std::endl;
1179     CertificationSummaryMap->Fill(0, 4 - cttyp, dc_CT[cttyp]);
1180     reportSummaryMap->Fill(0, 4 - cttyp, dc_CT[cttyp]);
1181   }
1182   ibook_.setCurrentFolder("");
1183 }
1184 
1185 //define this as a plug-in
1186 //DEFINE_FWK_MODULE(DataCertificationJetMET);