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 "FWCore/Framework/interface/EDAnalyzer.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 HLTOverallSummary : public edm::EDAnalyzer {
0052 public:
0053   typedef dqm::legacy::MonitorElement MonitorElement;
0054   typedef dqm::legacy::DQMStore DQMStore;
0055 
0056   explicit HLTOverallSummary(const edm::ParameterSet& pset);
0057   ~HLTOverallSummary() override;
0058 
0059   void analyze(const edm::Event&, const edm::EventSetup&) override;
0060   void beginRun(const edm::Run&, const edm::EventSetup&) override;
0061   void endRun(const edm::Run&, const edm::EventSetup&) override;
0062 
0063 private:
0064   DQMStore* dbe_;
0065   edm::ParameterSet parameters_;
0066 
0067   bool verbose_;
0068 
0069   // ----------member data ---------------------------
0070 };
0071 
0072 HLTOverallSummary::HLTOverallSummary(const edm::ParameterSet& pset)
0073 
0074 {
0075   using namespace edm;
0076   dbe_ = nullptr;
0077   dbe_ = edm::Service<DQMStore>().operator->();
0078   if (!dbe_) {
0079     LogInfo("HLTMuonVal") << "Can't find DQMStore, no results will be saved" << endl;
0080   }
0081 
0082   parameters_ = pset;
0083   verbose_ = parameters_.getUntrackedParameter<bool>("verbose", false);
0084 
0085   if (verbose_)
0086     LogInfo("HLTMuonVal") << ">>> Constructor (HLTOverallSummary) <<<" << endl;
0087 }
0088 
0089 HLTOverallSummary::~HLTOverallSummary() = default;
0090 
0091 //
0092 // member functions
0093 //
0094 
0095 // ------------ method called to for each event  ------------
0096 void HLTOverallSummary::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0097   using namespace edm;
0098 
0099   if (verbose_)
0100     LogInfo("HLTMuonVal") << ">>> Analyze (HLTOverallSummary) <<<" << std::endl;
0101 }
0102 
0103 // ------------ method called just before starting a new run  ------------
0104 void HLTOverallSummary::beginRun(const edm::Run& run, const edm::EventSetup& c) {
0105   using namespace edm;
0106   if (verbose_)
0107     LogInfo("HLTMuonVal") << ">>> BeginRun (HLTOverallSummary) <<<" << std::endl;
0108   if (verbose_)
0109     LogInfo("HLTMuonVal") << ">>> " << run.id() << std::endl;
0110 }
0111 
0112 // ------------ method called right after a run ends ------------
0113 void HLTOverallSummary::endRun(const edm::Run& run, const edm::EventSetup& c) {
0114   using namespace edm;
0115   if (verbose_)
0116     LogInfo("HLTMuonVal") << ">>> EndRun (HLTOverallSummary) <<<" << std::endl;
0117 
0118   if (!dbe_) {
0119     LogInfo("HLTMuonVal") << "No dqmstore... skipping processing step" << endl;
0120     return;
0121   }
0122 
0123   std::vector<string> histoNameVector;
0124 
0125   //booking histograms according to naming conventions
0126 
0127   float defaultValueIfNotFound = 1.0;
0128 
0129   dbe_->setCurrentFolder("HLT/EventInfo/reportSummaryContent");
0130 
0131   //============ Unpack information ==========
0132 
0133   MonitorElement* muonQualityBit = nullptr;
0134   muonQualityBit = dbe_->get("HLT_Muon");
0135 
0136   if (!muonQualityBit) {
0137     LogInfo("HLTMuonVal") << "Can't find muonQuality bit... making a bit, setting it to zero" << endl;
0138 
0139     muonQualityBit = dbe_->bookFloat("HLT_Muon");
0140     muonQualityBit->Fill(defaultValueIfNotFound);
0141   }
0142 
0143   MonitorElement* eleQualityBit = nullptr;
0144   eleQualityBit = dbe_->get("HLT_Electron");
0145 
0146   if (!eleQualityBit) {
0147     LogInfo("HLTMuonVal") << "Can't find eleQuality bit... making a bit, setting it to zero" << endl;
0148 
0149     eleQualityBit = dbe_->bookFloat("HLT_Electron");
0150     eleQualityBit->Fill(defaultValueIfNotFound);
0151   }
0152 
0153   MonitorElement* photonQualityBit = nullptr;
0154   photonQualityBit = dbe_->get("HLT_Photon");
0155 
0156   if (!photonQualityBit) {
0157     LogInfo("HLTMuonVal") << "Can't find photonQuality bit... making a bit, setting it to zero" << endl;
0158 
0159     photonQualityBit = dbe_->bookFloat("HLT_Photon");
0160     photonQualityBit->Fill(defaultValueIfNotFound);
0161   }
0162 
0163   //============ Book new storage locations =============
0164 
0165   dbe_->setCurrentFolder("HLT/EventInfo");
0166   MonitorElement* hltQualityBit = dbe_->bookFloat("reportSummary");
0167 
0168   MonitorElement* hltQualitySummaryWord = dbe_->bookInt("HLT_SUMMARY_WORD");
0169 
0170   //for now these will hold values from eta/phi tests for spikes/holes
0171   MonitorElement* reportSummaryMap =
0172       dbe_->book2D("reportSummaryMap", "HLT: ReportSummaryMap", 3, -0.5, 2.5, 1, -0.5, 0.5);
0173   MonitorElement* CertificationSummaryMap =
0174       dbe_->book2D("certificationSummaryMap", "HLT: CertificationSummaryMap", 3, -0.5, 2.5, 1, -0.5, 0.5);
0175 
0176   TH2* reportSummaryMapTH2 = reportSummaryMap->getTH2F();
0177 
0178   reportSummaryMapTH2->GetXaxis()->SetBinLabel(1, "Muon");
0179   reportSummaryMapTH2->GetXaxis()->SetBinLabel(2, "Electron");
0180   reportSummaryMapTH2->GetXaxis()->SetBinLabel(3, "Photon");
0181 
0182   reportSummaryMapTH2->GetYaxis()->SetBinLabel(1, "Quality");
0183 
0184   TH2* CertificationSummaryMapTH2 = CertificationSummaryMap->getTH2F();
0185 
0186   CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(1, "Muon");
0187   CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(2, "Electron");
0188   CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(3, "Photon");
0189   CertificationSummaryMapTH2->GetYaxis()->SetBinLabel(1, "Quality");
0190 
0191   //=================== Interpret bits and store result
0192 
0193   float photonValue = photonQualityBit->getFloatValue();
0194 
0195   float electronValue = eleQualityBit->getFloatValue();
0196 
0197   float muonValue = muonQualityBit->getFloatValue();
0198 
0199   float hltOverallValue = 1.0;
0200 
0201   if ((photonValue > 0.99) && (electronValue > 0.99) && (muonValue > 0.99)) {
0202     hltOverallValue = 1.0;
0203 
0204   } else {
0205     hltOverallValue = 0.0;
0206   }
0207 
0208   hltQualityBit->Fill(hltOverallValue);
0209 
0210   unsigned int hltSummaryValue = 0x0;  //
0211 
0212   unsigned int ELECTRON_MASK = 0x1;
0213   unsigned int PHOTON_MASK = 0x2;
0214   unsigned int MUON_MASK = 0x4;
0215 
0216   if (electronValue > 0.99)
0217     hltSummaryValue = hltSummaryValue | ELECTRON_MASK;
0218   if (photonValue > 0.99)
0219     hltSummaryValue = hltSummaryValue | PHOTON_MASK;
0220   if (muonValue > 0.99)
0221     hltSummaryValue = hltSummaryValue | MUON_MASK;
0222 
0223   hltQualitySummaryWord->Fill(hltSummaryValue);
0224 
0225   reportSummaryMapTH2->SetBinContent(reportSummaryMapTH2->GetBin(1, 1), muonValue);
0226   reportSummaryMapTH2->SetBinContent(reportSummaryMapTH2->GetBin(2, 1), electronValue);
0227   reportSummaryMapTH2->SetBinContent(reportSummaryMapTH2->GetBin(3, 1), photonValue);
0228 
0229   CertificationSummaryMapTH2->SetBinContent(CertificationSummaryMapTH2->GetBin(1, 1), muonValue);
0230   CertificationSummaryMapTH2->SetBinContent(CertificationSummaryMapTH2->GetBin(2, 1), electronValue);
0231   CertificationSummaryMapTH2->SetBinContent(CertificationSummaryMapTH2->GetBin(3, 1), photonValue);
0232 }
0233 
0234 DEFINE_FWK_MODULE(HLTOverallSummary);