Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DQMOffline/Trigger/interface/DQMOfflineHLTEventInfoClient.h"
0002 
0003 #include "FWCore/ServiceRegistry/interface/Service.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "FWCore/Framework/interface/ESHandle.h"
0006 #include "FWCore/Framework/interface/EventSetup.h"
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 #include "DQMServices/Core/interface/DQMStore.h"
0009 #include <cstdio>
0010 #include <sstream>
0011 #include <cmath>
0012 #include <TProfile.h>
0013 #include <TProfile2D.h>
0014 #include <memory>
0015 #include <iostream>
0016 #include <iomanip>
0017 #include <map>
0018 #include <vector>
0019 #include <string>
0020 #include <fstream>
0021 #include "TROOT.h"
0022 #include "TRandom.h"
0023 #include <TH1F.h>
0024 #include <TH2F.h>
0025 
0026 using namespace edm;
0027 using namespace std;
0028 
0029 /*
0030 class DQMOfflineHLTEventInfoClient: public edm::EDAnalyzer {
0031 
0032 public:
0033 
0034   /// Constructor
0035   DQMOfflineHLTEventInfoClient(const edm::ParameterSet& ps);
0036   
0037   /// Destructor
0038   virtual ~DQMOfflineHLTEventInfoClient();
0039  
0040 protected:
0041 
0042   /// BeginJob
0043   void beginJob();
0044 
0045   /// BeginRun
0046   void beginRun(const edm::Run& r, const edm::EventSetup& c);
0047 
0048   /// Fake Analyze
0049   void analyze(const edm::Event& e, const edm::EventSetup& c) ;
0050 
0051   void beginLuminosityBlock(const edm::LuminosityBlock& lumiSeg, 
0052                             const edm::EventSetup& context) ;
0053 
0054   /// DQM Client Diagnostic
0055   void endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, 
0056                           const edm::EventSetup& c);
0057 
0058   /// EndRun
0059   void endRun(const edm::Run& r, const edm::EventSetup& c);
0060 
0061 private:
0062 
0063   void initialize();
0064   edm::ParameterSet parameters_;
0065 
0066   DQMStore* dbe_;  
0067   bool verbose_;
0068   int counterLS_;      ///counter
0069   int counterEvt_;     ///counter
0070   int prescaleLS_;     ///units of lumi sections
0071   int prescaleEvt_;    ///prescale on number of events
0072   // -------- member data --------
0073 
0074   MonitorElement * reportSummary_;
0075   std::vector<MonitorElement*> reportSummaryContent_;
0076   MonitorElement * reportSummaryMap_;
0077 
0078 
0079 };
0080 */
0081 
0082 DQMOfflineHLTEventInfoClient::DQMOfflineHLTEventInfoClient(const edm::ParameterSet& ps) {
0083   parameters_ = ps;
0084   initialize();
0085 }
0086 
0087 DQMOfflineHLTEventInfoClient::~DQMOfflineHLTEventInfoClient() {
0088   if (verbose_)
0089     cout << "[TriggerDQM]: ending... " << endl;
0090 }
0091 
0092 //--------------------------------------------------------
0093 void DQMOfflineHLTEventInfoClient::initialize() {
0094   counterLS_ = 0;
0095   counterEvt_ = 0;
0096 
0097   // get back-end interface
0098   dbe_ = Service<DQMStore>().operator->();
0099 
0100   // base folder for the contents of this job
0101   verbose_ = parameters_.getUntrackedParameter<bool>("verbose", false);
0102 
0103   prescaleLS_ = parameters_.getUntrackedParameter<int>("prescaleLS", -1);
0104   if (verbose_)
0105     cout << "DQM lumi section prescale = " << prescaleLS_ << " lumi section(s)" << endl;
0106 
0107   prescaleEvt_ = parameters_.getUntrackedParameter<int>("prescaleEvt", -1);
0108   if (verbose_)
0109     cout << "DQM event prescale = " << prescaleEvt_ << " events(s)" << endl;
0110   /*
0111   */
0112 }
0113 
0114 //--------------------------------------------------------
0115 void DQMOfflineHLTEventInfoClient::beginJob() {
0116   if (verbose_)
0117     cout << "[TriggerDQM]: Begin Job" << endl;
0118   // get backendinterface
0119   dbe_ = Service<DQMStore>().operator->();
0120 
0121   dbe_->setCurrentFolder("HLT/EventInfo");
0122 
0123   reportSummary_ = dbe_->bookFloat("reportSummary");
0124   //initialize reportSummary to 1
0125   if (reportSummary_)
0126     reportSummary_->Fill(1);
0127 
0128   // CertificationSummary
0129   CertificationSummary_ = dbe_->bookFloat("CertificationSummary");
0130   //initialize CertificationSummary to 1
0131   if (CertificationSummary_)
0132     CertificationSummary_->Fill(1);
0133 
0134   //initialize reportSummary to 1
0135   if (reportSummary_)
0136     reportSummary_->Fill(1);
0137 
0138   //  OK HERE
0139 
0140   // reportSummaryMap
0141   dbe_->setCurrentFolder("HLT/EventInfo");
0142 
0143   reportSummaryMap_ = dbe_->book2D("reportSummaryMap", "reportSummaryMap", 1, 1, 2, 6, 1, 7);
0144   reportSummaryMap_->setAxisTitle("", 1);
0145   reportSummaryMap_->setAxisTitle("", 2);
0146   reportSummaryMap_->setBinLabel(1, "Muon", 2);
0147   reportSummaryMap_->setBinLabel(2, "Electron", 2);
0148   reportSummaryMap_->setBinLabel(3, "Photon", 2);
0149   reportSummaryMap_->setBinLabel(4, "JetMET", 2);
0150   reportSummaryMap_->setBinLabel(5, "BJet", 2);
0151   reportSummaryMap_->setBinLabel(6, "Tau", 2);
0152   reportSummaryMap_->setBinLabel(1, " ", 1);
0153 
0154   CertificationSummaryMap_ = dbe_->book2D("CertificationSummaryMap", "CertificationSummaryMap", 1, 1, 2, 6, 1, 7);
0155   CertificationSummaryMap_->setAxisTitle("", 1);
0156   CertificationSummaryMap_->setAxisTitle("", 2);
0157   CertificationSummaryMap_->setBinLabel(1, "Muon", 2);
0158   CertificationSummaryMap_->setBinLabel(2, "Electron", 2);
0159   CertificationSummaryMap_->setBinLabel(3, "Photon", 2);
0160   CertificationSummaryMap_->setBinLabel(4, "JetMET", 2);
0161   CertificationSummaryMap_->setBinLabel(5, "BJet", 2);
0162   CertificationSummaryMap_->setBinLabel(6, "Tau", 2);
0163   CertificationSummaryMap_->setBinLabel(1, " ", 1);
0164 }
0165 
0166 //--------------------------------------------------------
0167 void DQMOfflineHLTEventInfoClient::beginRun(const Run& r, const EventSetup& context) {}
0168 
0169 //--------------------------------------------------------
0170 
0171 //--------------------------------------------------------
0172 void DQMOfflineHLTEventInfoClient::analyze(const Event& e, const EventSetup& context) {
0173   counterEvt_++;
0174   if (prescaleEvt_ < 1)
0175     return;
0176   if (prescaleEvt_ > 0 && counterEvt_ % prescaleEvt_ != 0)
0177     return;
0178 
0179   if (verbose_)
0180     cout << "DQMOfflineHLTEventInfoClient::analyze" << endl;
0181 }
0182 
0183 //--------------------------------------------------------
0184 void DQMOfflineHLTEventInfoClient::endRun(const Run& r, const EventSetup& context) {
0185   float summarySum = 0;
0186   float reportSummary = 0;
0187 
0188   dbe_->setCurrentFolder("HLT/EventInfo/reportSummaryContents");
0189   MonitorElement* HLT_Muon = dbe_->get("HLT_Muon");
0190   if (HLT_Muon)
0191     reportSummaryContent_.push_back(HLT_Muon);
0192 
0193   MonitorElement* HLT_Electron = dbe_->get("HLT_Electron");
0194   if (HLT_Electron)
0195     reportSummaryContent_.push_back(HLT_Electron);
0196 
0197   MonitorElement* HLT_Photon = dbe_->get("HLT_Photon");
0198   if (HLT_Photon)
0199     reportSummaryContent_.push_back(HLT_Photon);
0200 
0201   MonitorElement* HLT_Tau = dbe_->get("HLT_Tau");
0202   if (HLT_Tau)
0203     reportSummaryContent_.push_back(HLT_Tau);
0204 
0205   int nSubsystems = reportSummaryContent_.size();
0206 
0207   for (int m = 0; m < nSubsystems; m++) {
0208     summarySum += (reportSummaryContent_[m])->getFloatValue();
0209   }
0210 
0211   if (nSubsystems > 0) {
0212     reportSummary = summarySum / nSubsystems;
0213     ;
0214   } else {
0215     reportSummary = 1;
0216   }
0217 
0218   reportSummary_->Fill(reportSummary);
0219   CertificationSummary_->Fill(reportSummary);
0220 
0221   float muonValue = 1;
0222   if (HLT_Muon)
0223     muonValue = HLT_Muon->getFloatValue();
0224 
0225   float electronValue = 1;
0226   if (HLT_Electron)
0227     electronValue = HLT_Electron->getFloatValue();
0228 
0229   float photonValue = 1;
0230   if (HLT_Photon)
0231     photonValue = HLT_Photon->getFloatValue();
0232 
0233   float tauValue = 1;
0234   if (HLT_Tau)
0235     tauValue = HLT_Tau->getFloatValue();
0236 
0237   reportSummaryMap_->setBinContent(1, 1, muonValue);      //Muon
0238   reportSummaryMap_->setBinContent(1, 2, electronValue);  //Electron
0239   reportSummaryMap_->setBinContent(1, 3, photonValue);    //Photon
0240   reportSummaryMap_->setBinContent(1, 4, 1);              //JetMET
0241   reportSummaryMap_->setBinContent(1, 5, 1);              //BJet
0242   reportSummaryMap_->setBinContent(1, 6, tauValue);       //Tau
0243 
0244   CertificationSummaryMap_->setBinContent(1, 1, muonValue);      //Muon
0245   CertificationSummaryMap_->setBinContent(1, 2, electronValue);  //Electron
0246   CertificationSummaryMap_->setBinContent(1, 3, photonValue);    //Photon
0247   CertificationSummaryMap_->setBinContent(1, 4, 1);              //JetMET
0248   CertificationSummaryMap_->setBinContent(1, 5, 1);              //BJet
0249   CertificationSummaryMap_->setBinContent(1, 6, tauValue);       //Tau
0250 }