Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:09:53

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   usesResource("DQMStore");
0084   parameters_ = ps;
0085   initialize();
0086 }
0087 
0088 DQMOfflineHLTEventInfoClient::~DQMOfflineHLTEventInfoClient() {
0089   if (verbose_)
0090     cout << "[TriggerDQM]: ending... " << endl;
0091 }
0092 
0093 //--------------------------------------------------------
0094 void DQMOfflineHLTEventInfoClient::initialize() {
0095   counterLS_ = 0;
0096   counterEvt_ = 0;
0097 
0098   // get back-end interface
0099   dbe_ = Service<DQMStore>().operator->();
0100 
0101   // base folder for the contents of this job
0102   verbose_ = parameters_.getUntrackedParameter<bool>("verbose", false);
0103 
0104   prescaleLS_ = parameters_.getUntrackedParameter<int>("prescaleLS", -1);
0105   if (verbose_)
0106     cout << "DQM lumi section prescale = " << prescaleLS_ << " lumi section(s)" << endl;
0107 
0108   prescaleEvt_ = parameters_.getUntrackedParameter<int>("prescaleEvt", -1);
0109   if (verbose_)
0110     cout << "DQM event prescale = " << prescaleEvt_ << " events(s)" << endl;
0111   /*
0112   */
0113 }
0114 
0115 //--------------------------------------------------------
0116 void DQMOfflineHLTEventInfoClient::beginJob() {
0117   if (verbose_)
0118     cout << "[TriggerDQM]: Begin Job" << endl;
0119   // get backendinterface
0120   dbe_ = Service<DQMStore>().operator->();
0121 
0122   dbe_->setCurrentFolder("HLT/EventInfo");
0123 
0124   reportSummary_ = dbe_->bookFloat("reportSummary");
0125   //initialize reportSummary to 1
0126   if (reportSummary_)
0127     reportSummary_->Fill(1);
0128 
0129   // CertificationSummary
0130   CertificationSummary_ = dbe_->bookFloat("CertificationSummary");
0131   //initialize CertificationSummary to 1
0132   if (CertificationSummary_)
0133     CertificationSummary_->Fill(1);
0134 
0135   //initialize reportSummary to 1
0136   if (reportSummary_)
0137     reportSummary_->Fill(1);
0138 
0139   //  OK HERE
0140 
0141   // reportSummaryMap
0142   dbe_->setCurrentFolder("HLT/EventInfo");
0143 
0144   reportSummaryMap_ = dbe_->book2D("reportSummaryMap", "reportSummaryMap", 1, 1, 2, 6, 1, 7);
0145   reportSummaryMap_->setAxisTitle("", 1);
0146   reportSummaryMap_->setAxisTitle("", 2);
0147   reportSummaryMap_->setBinLabel(1, "Muon", 2);
0148   reportSummaryMap_->setBinLabel(2, "Electron", 2);
0149   reportSummaryMap_->setBinLabel(3, "Photon", 2);
0150   reportSummaryMap_->setBinLabel(4, "JetMET", 2);
0151   reportSummaryMap_->setBinLabel(5, "BJet", 2);
0152   reportSummaryMap_->setBinLabel(6, "Tau", 2);
0153   reportSummaryMap_->setBinLabel(1, " ", 1);
0154 
0155   CertificationSummaryMap_ = dbe_->book2D("CertificationSummaryMap", "CertificationSummaryMap", 1, 1, 2, 6, 1, 7);
0156   CertificationSummaryMap_->setAxisTitle("", 1);
0157   CertificationSummaryMap_->setAxisTitle("", 2);
0158   CertificationSummaryMap_->setBinLabel(1, "Muon", 2);
0159   CertificationSummaryMap_->setBinLabel(2, "Electron", 2);
0160   CertificationSummaryMap_->setBinLabel(3, "Photon", 2);
0161   CertificationSummaryMap_->setBinLabel(4, "JetMET", 2);
0162   CertificationSummaryMap_->setBinLabel(5, "BJet", 2);
0163   CertificationSummaryMap_->setBinLabel(6, "Tau", 2);
0164   CertificationSummaryMap_->setBinLabel(1, " ", 1);
0165 }
0166 
0167 //--------------------------------------------------------
0168 void DQMOfflineHLTEventInfoClient::beginRun(const Run& r, const EventSetup& context) {}
0169 
0170 //--------------------------------------------------------
0171 
0172 //--------------------------------------------------------
0173 void DQMOfflineHLTEventInfoClient::analyze(const Event& e, const EventSetup& context) {
0174   counterEvt_++;
0175   if (prescaleEvt_ < 1)
0176     return;
0177   if (prescaleEvt_ > 0 && counterEvt_ % prescaleEvt_ != 0)
0178     return;
0179 
0180   if (verbose_)
0181     cout << "DQMOfflineHLTEventInfoClient::analyze" << endl;
0182 }
0183 
0184 //--------------------------------------------------------
0185 void DQMOfflineHLTEventInfoClient::endRun(const Run& r, const EventSetup& context) {
0186   float summarySum = 0;
0187   float reportSummary = 0;
0188 
0189   dbe_->setCurrentFolder("HLT/EventInfo/reportSummaryContents");
0190   MonitorElement* HLT_Muon = dbe_->get("HLT_Muon");
0191   if (HLT_Muon)
0192     reportSummaryContent_.push_back(HLT_Muon);
0193 
0194   MonitorElement* HLT_Electron = dbe_->get("HLT_Electron");
0195   if (HLT_Electron)
0196     reportSummaryContent_.push_back(HLT_Electron);
0197 
0198   MonitorElement* HLT_Photon = dbe_->get("HLT_Photon");
0199   if (HLT_Photon)
0200     reportSummaryContent_.push_back(HLT_Photon);
0201 
0202   MonitorElement* HLT_Tau = dbe_->get("HLT_Tau");
0203   if (HLT_Tau)
0204     reportSummaryContent_.push_back(HLT_Tau);
0205 
0206   int nSubsystems = reportSummaryContent_.size();
0207 
0208   for (int m = 0; m < nSubsystems; m++) {
0209     summarySum += (reportSummaryContent_[m])->getFloatValue();
0210   }
0211 
0212   if (nSubsystems > 0) {
0213     reportSummary = summarySum / nSubsystems;
0214     ;
0215   } else {
0216     reportSummary = 1;
0217   }
0218 
0219   reportSummary_->Fill(reportSummary);
0220   CertificationSummary_->Fill(reportSummary);
0221 
0222   float muonValue = 1;
0223   if (HLT_Muon)
0224     muonValue = HLT_Muon->getFloatValue();
0225 
0226   float electronValue = 1;
0227   if (HLT_Electron)
0228     electronValue = HLT_Electron->getFloatValue();
0229 
0230   float photonValue = 1;
0231   if (HLT_Photon)
0232     photonValue = HLT_Photon->getFloatValue();
0233 
0234   float tauValue = 1;
0235   if (HLT_Tau)
0236     tauValue = HLT_Tau->getFloatValue();
0237 
0238   reportSummaryMap_->setBinContent(1, 1, muonValue);      //Muon
0239   reportSummaryMap_->setBinContent(1, 2, electronValue);  //Electron
0240   reportSummaryMap_->setBinContent(1, 3, photonValue);    //Photon
0241   reportSummaryMap_->setBinContent(1, 4, 1);              //JetMET
0242   reportSummaryMap_->setBinContent(1, 5, 1);              //BJet
0243   reportSummaryMap_->setBinContent(1, 6, tauValue);       //Tau
0244 
0245   CertificationSummaryMap_->setBinContent(1, 1, muonValue);      //Muon
0246   CertificationSummaryMap_->setBinContent(1, 2, electronValue);  //Electron
0247   CertificationSummaryMap_->setBinContent(1, 3, photonValue);    //Photon
0248   CertificationSummaryMap_->setBinContent(1, 4, 1);              //JetMET
0249   CertificationSummaryMap_->setBinContent(1, 5, 1);              //BJet
0250   CertificationSummaryMap_->setBinContent(1, 6, tauValue);       //Tau
0251 }
0252 
0253 #include "FWCore/Framework/interface/MakerMacros.h"
0254 DEFINE_FWK_MODULE(DQMOfflineHLTEventInfoClient);