Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include <iostream>
0002 
0003 /**\class PhotonDataCertification 
0004 */
0005 //
0006 // Original Author: Jason Slaunwhite
0007 //
0008 //         Created:  Thu Jan 22 13:42:28CET 2009
0009 //
0010 
0011 // system include files
0012 #include <memory>
0013 #include <vector>
0014 
0015 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0016 //
0017 #include "FWCore/Framework/interface/MakerMacros.h"
0018 #include "FWCore/Framework/interface/Run.h"
0019 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0020 #include "FWCore/Utilities/interface/Exception.h"
0021 #include "FWCore/ServiceRegistry/interface/Service.h"
0022 
0023 //root include files
0024 #include "TFile.h"
0025 #include "TH1.h"
0026 #include "TH2.h"
0027 #include "TTree.h"
0028 #include "TVector3.h"
0029 #include "TProfile.h"
0030 //
0031 
0032 // user include files
0033 #include "FWCore/Framework/interface/Frameworkfwd.h"
0034 #include "DQMServices/Core/interface/DQMEDHarvester.h"
0035 
0036 #include "FWCore/Framework/interface/Event.h"
0037 
0038 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0039 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0040 
0041 //DQM services
0042 #include "DQMServices/Core/interface/DQMStore.h"
0043 #include "FWCore/ServiceRegistry/interface/Service.h"
0044 
0045 using namespace std;
0046 
0047 //
0048 // class decleration
0049 //
0050 
0051 class HLTMuonCertSummary : public DQMEDHarvester {
0052 public:
0053   explicit HLTMuonCertSummary(const edm::ParameterSet& pset);
0054   ~HLTMuonCertSummary() override;
0055 
0056   void beginJob() override;
0057   void beginRun(const edm::Run&, const edm::EventSetup&) override;
0058   void dqmEndJob(DQMStore::IBooker&, DQMStore::IGetter&) override;
0059 
0060 private:
0061   edm::ParameterSet parameters_;
0062 
0063   bool verbose_;
0064 
0065   // ----------member data ---------------------------
0066 };
0067 
0068 HLTMuonCertSummary::HLTMuonCertSummary(const edm::ParameterSet& pset)
0069 
0070 {
0071   using namespace edm;
0072 
0073   parameters_ = pset;
0074   verbose_ = parameters_.getUntrackedParameter<bool>("verbose", false);
0075 
0076   if (verbose_)
0077     LogInfo("HLTMuonVal") << ">>> Constructor (HLTMuonCertSummary) <<<" << endl;
0078 }
0079 
0080 HLTMuonCertSummary::~HLTMuonCertSummary() = default;
0081 
0082 //
0083 // member functions
0084 //
0085 
0086 // ------------ method called once each job just before starting event loop  ------------
0087 void HLTMuonCertSummary::beginJob() {}
0088 
0089 // ------------ method called just before starting a new run  ------------
0090 void HLTMuonCertSummary::beginRun(const edm::Run& run, const edm::EventSetup& c) {
0091   using namespace edm;
0092   if (verbose_)
0093     LogInfo("HLTMuonVal") << ">>> BeginRun (HLTMuonCertSummary) <<<" << std::endl;
0094   if (verbose_)
0095     LogInfo("HLTMuonVal") << ">>> " << run.id() << std::endl;
0096 }
0097 
0098 // ------------ method called right after a run ends ------------
0099 void HLTMuonCertSummary::dqmEndJob(DQMStore::IBooker& iBooker, DQMStore::IGetter& iGetter) {
0100   using namespace edm;
0101   if (verbose_)
0102     LogInfo("HLTMuonVal") << ">>> EndRun (HLTMuonCertSummary) <<<" << std::endl;
0103 
0104   std::vector<string> histoNameVector;
0105 
0106   //booking histograms according to naming conventions
0107 
0108   iBooker.setCurrentFolder("HLT/EventInfo/muonQuality");
0109 
0110   MonitorElement* reportSummary = iBooker.bookFloat("HLT_MUON_REPORT_SUMMARY");
0111 
0112   int SummaryBitResult = 100;
0113 
0114   MonitorElement* CertificationSummary = iBooker.bookFloat("HLT_MUON_CERTIFICATION_SUMMARY");
0115 
0116   //for now these will hold values from eta/phi tests for spikes/holes
0117   MonitorElement* reportSummaryMap =
0118       iBooker.book2D("HLT_MUON_ReportSummaryMap", "HLT_MUON: ReportSummaryMap", 6, -0.5, 5.5, 1, -0.5, 0.5);
0119   MonitorElement* CertificationSummaryMap = iBooker.book2D(
0120       "HLT_MUON_CertificationSummaryMap", "HLT_MUON: CertificationSummaryMap", 6, -0.5, 5.5, 1, -0.5, 0.5);
0121 
0122   TH2* reportSummaryMapTH2 = reportSummaryMap->getTH2F();
0123 
0124   reportSummaryMapTH2->GetXaxis()->SetBinLabel(1, "PhiEtaOccAll");
0125   reportSummaryMapTH2->GetXaxis()->SetBinLabel(2, "PhiEtaOccMatch");
0126   reportSummaryMapTH2->GetXaxis()->SetBinLabel(3, "PhiEtaEff");
0127   reportSummaryMapTH2->GetXaxis()->SetBinLabel(4, "PhiEff");
0128   reportSummaryMapTH2->GetXaxis()->SetBinLabel(5, "EtaEff");
0129   reportSummaryMapTH2->GetXaxis()->SetBinLabel(6, "PtEff");
0130 
0131   reportSummaryMapTH2->GetYaxis()->SetBinLabel(1, "HLT_Mu5_allMuons");
0132 
0133   TH2* CertificationSummaryMapTH2 = CertificationSummaryMap->getTH2F();
0134 
0135   CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(1, "PhiEtaOccAll");
0136   CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(2, "PhiEtaOccMatch");
0137   CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(3, "PhiEtaEff");
0138   CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(4, "PhiEff");
0139   CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(5, "EtaEff");
0140   CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(6, "PtEff");
0141 
0142   CertificationSummaryMapTH2->GetYaxis()->SetBinLabel(1, "HLT_Mu5_allMuons");
0143 
0144   histoNameVector.emplace_back("HLT/Muon/Distributions/HLT_Mu5/allMuons/recPhiVsRecEta_All");
0145   histoNameVector.emplace_back("HLT/Muon/Distributions/HLT_Mu5/allMuons/recPhiVsRecEta_L3Filtered");
0146   histoNameVector.emplace_back("HLT/Muon/Distributions/HLT_Mu5/allMuons/recEffPhiVsEta_L3Filtered");
0147   histoNameVector.emplace_back("HLT/Muon/Distributions/HLT_Mu5/allMuons/recEffPt_L3Filtered");
0148   histoNameVector.emplace_back("HLT/Muon/Distributions/HLT_Mu5/allMuons/recEffPhi_L3Filtered");
0149   histoNameVector.emplace_back("HLT/Muon/Distributions/HLT_Mu5/allMuons/recEffEta_L3Filtered");
0150 
0151   // to do:  what do we want in certification contents?
0152   //  iBooker.setCurrentFolder("Egamma/EventInfo/CertificationContents/");
0153 
0154   //   //looping over histograms to be tested
0155   if (verbose_)
0156     LogInfo("HLTMuonVal") << "\n>>> looping over histograms to be tested <<<\n\n";
0157 
0158   for (auto& it : histoNameVector) {
0159     const string& HistoName = it;
0160     if (verbose_)
0161       LogInfo("HLTMuonVal") << ">>> " << HistoName;
0162 
0163     MonitorElement* TestHist = nullptr;
0164 
0165     TestHist = iGetter.get(HistoName);
0166 
0167     bool validMe = TestHist != nullptr;
0168     if (verbose_)
0169       LogInfo("HLTMuonVal") << " is valid? " << validMe << "\n";
0170     if (!validMe)
0171       continue;
0172 
0173     string histNameNoPath = TestHist->getName();
0174 
0175     if (verbose_)
0176       LogInfo("HLTMuonVal") << ">>> TestHist Name: " << histNameNoPath << "\n\n";
0177 
0178     //get QReports associated to each ME
0179     std::vector<QReport*> myQReports = TestHist->getQReports();
0180     if (verbose_)
0181       LogInfo("HLTMuonVal") << TestHist->getName() << ": myQReports.size() = " << myQReports.size() << "\n\n";
0182     for (uint i = 0; i != myQReports.size(); ++i) {
0183       std::string qtname = myQReports[i]->getQRName();  // get QT name
0184       float qtresult = myQReports[i]->getQTresult();    // get QT result value
0185       int qtstatus = myQReports[i]->getStatus();        // get QT status value
0186 
0187       if (verbose_)
0188         LogInfo("HLTMuonVal") << "\tTest " << i << ":  qtname: " << qtname << "\n";
0189       if (verbose_)
0190         LogInfo("HLTMuonVal") << "\tTest " << i << ":  qtresult: " << qtresult << std::endl;
0191       if (verbose_)
0192         LogInfo("HLTMuonVal") << "\tTest " << i << ":  qtstatus: " << qtstatus << "\n\n";
0193 
0194       //book and fill float for each test done
0195       iBooker.setCurrentFolder("HLT/EventInfo/muonQuality/");
0196       MonitorElement* qValueInt = iBooker.bookFloat(histNameNoPath + "_HLT_Mu5_" + qtname);
0197       qValueInt->Fill(qtstatus);
0198 
0199       // We're assuming that you want all of the bits to go into the decision
0200 
0201       if (HistoName.find("recPhiVsRecEta_All") != std::string::npos) {
0202         reportSummaryMapTH2->SetBinContent(reportSummaryMapTH2->GetBin(1, 1), qtstatus);
0203         CertificationSummaryMapTH2->SetBinContent(CertificationSummaryMapTH2->GetBin(1, 1), qtstatus);
0204         if ((qtstatus == 200) && (SummaryBitResult < 300))
0205           SummaryBitResult = 200;
0206         if (qtstatus == 300)
0207           SummaryBitResult = 300;
0208       }
0209 
0210       if (HistoName.find("recPhiVsRecEta_L3Filtered") != std::string::npos) {
0211         reportSummaryMapTH2->SetBinContent(reportSummaryMapTH2->GetBin(2, 1), qtstatus);
0212         CertificationSummaryMapTH2->SetBinContent(CertificationSummaryMapTH2->GetBin(2, 1), qtstatus);
0213         if ((qtstatus == 200) && (SummaryBitResult < 300))
0214           SummaryBitResult = 200;
0215         if (qtstatus == 300)
0216           SummaryBitResult = 300;
0217       }
0218 
0219       if (HistoName.find("recEffPhiVsEta_L3Filtered") != std::string::npos) {
0220         reportSummaryMapTH2->SetBinContent(reportSummaryMapTH2->GetBin(3, 1), qtstatus);
0221         CertificationSummaryMapTH2->SetBinContent(CertificationSummaryMapTH2->GetBin(3, 1), qtstatus);
0222         if ((qtstatus == 200) && (SummaryBitResult < 300))
0223           SummaryBitResult = 200;
0224         if (qtstatus == 300)
0225           SummaryBitResult = 300;
0226       }
0227 
0228       if (HistoName.find("recEffPhi_L3Filtered") != std::string::npos) {
0229         reportSummaryMapTH2->SetBinContent(reportSummaryMapTH2->GetBin(4, 1), qtstatus);
0230         CertificationSummaryMapTH2->SetBinContent(CertificationSummaryMapTH2->GetBin(4, 1), qtstatus);
0231       }
0232 
0233       if (HistoName.find("recEffEta_L3Filtered") != std::string::npos) {
0234         reportSummaryMapTH2->SetBinContent(reportSummaryMapTH2->GetBin(5, 1), qtstatus);
0235         CertificationSummaryMapTH2->SetBinContent(CertificationSummaryMapTH2->GetBin(5, 1), qtstatus);
0236       }
0237 
0238       if (HistoName.find("recEffPt_L3Filtered") != std::string::npos) {
0239         reportSummaryMapTH2->SetBinContent(reportSummaryMapTH2->GetBin(6, 1), qtstatus);
0240         CertificationSummaryMapTH2->SetBinContent(CertificationSummaryMapTH2->GetBin(6, 1), qtstatus);
0241       }
0242     }
0243   }
0244 
0245   reportSummary->Fill(SummaryBitResult);
0246   CertificationSummary->Fill(SummaryBitResult);
0247 
0248   // Set the final bits
0249 
0250   iBooker.setCurrentFolder("HLT/EventInfo/reportSummaryContents");
0251   MonitorElement* muonHLTQualityBinaryBit = iBooker.bookFloat("HLT_Muon");
0252 
0253   if (SummaryBitResult == 100) {
0254     muonHLTQualityBinaryBit->Fill(1);
0255   } else {
0256     muonHLTQualityBinaryBit->Fill(0);
0257   }
0258 }
0259 
0260 DEFINE_FWK_MODULE(HLTMuonCertSummary);