CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/DQM/HcalMonitorClient/src/HcalDataCertification.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    DQMO/HcalMonitorClient/HcalDataCertification
00004 // Class:      HcalDataCertification
00005 // 
00013 //
00014 // Original Author:  "Igor Vodopiyanov"
00015 //         Created:  Nov-21 2008
00016 // $Id: HcalDataCertification.cc,v 1.13 2010/08/12 21:09:45 temple Exp $
00017 //
00018 //
00019 
00020 // system include files
00021 #include <memory>
00022 #include <stdio.h>
00023 #include <math.h>
00024 #include <sstream>
00025 #include <fstream>
00026 #include <exception>
00027 #include <string>
00028 
00029 // user include files
00030 #include "FWCore/Framework/interface/Frameworkfwd.h"
00031 #include "FWCore/Framework/interface/EDAnalyzer.h"
00032 
00033 #include "FWCore/Framework/interface/Event.h"
00034 #include "FWCore/Framework/interface/MakerMacros.h"
00035 #include "FWCore/Framework/interface/LuminosityBlock.h"
00036 
00037 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00038 #include "DQMServices/Core/interface/DQMStore.h"
00039 #include "DQMServices/Core/interface/MonitorElement.h"
00040 #include "FWCore/ServiceRegistry/interface/Service.h"
00041 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00042 
00043 //
00044 // class declaration
00045 //
00046 
00047 class HcalDataCertification : public edm::EDAnalyzer {
00048    public:
00049       explicit HcalDataCertification(const edm::ParameterSet&);
00050       ~HcalDataCertification();
00051 
00052    private:
00053       virtual void beginJob() ;
00054       virtual void analyze(const edm::Event&, const edm::EventSetup&);
00055       virtual void endJob() ;
00056       virtual void beginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) ;
00057       virtual void endLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) ;
00058       void endRun(const edm::Run & r, const edm::EventSetup & c);
00059   void CertifyHcal();
00060 
00061    // ----------member data ---------------------------
00062 
00063    edm::ParameterSet conf_;
00064    DQMStore * dbe_;
00065    MonitorElement* CertificationSummary;
00066    MonitorElement* CertificationSummaryMap;
00067    MonitorElement* Hcal_HB;
00068    MonitorElement* Hcal_HE;
00069    MonitorElement* Hcal_HF;
00070    MonitorElement* Hcal_HO;
00071    MonitorElement* Hcal_HFlumi;
00072    MonitorElement* Hcal_HO0;
00073    MonitorElement* Hcal_HO12;
00074    int debug_;
00075    std::string rootFolder_;
00076 };
00077 
00078 //
00079 // constants, enums and typedefs
00080 //
00081 
00082 //
00083 // static data member definitions
00084 //
00085 
00086 //
00087 // constructors and destructor
00088 //
00089 
00090 HcalDataCertification::HcalDataCertification(const edm::ParameterSet& iConfig)
00091 {
00092   // now do what ever initialization is needed
00093   debug_ = iConfig.getUntrackedParameter<int>("debug",0);
00094   rootFolder_ = iConfig.getUntrackedParameter<std::string>("subSystemFolder","Hcal");
00095   dbe_ = edm::Service<DQMStore>().operator->();  
00096 }
00097 
00098 HcalDataCertification::~HcalDataCertification()
00099 { 
00100    // do anything here that needs to be done at desctruction time
00101    // (e.g. close files, deallocate resources etc.)
00102 }
00103 
00104 //
00105 // member functions
00106 //
00107 
00108 // ------------ method called to for each event  ------------
00109 void
00110 HcalDataCertification::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {}
00111 
00112 // ------------ method called once each job just before starting event loop  ------------
00113 void 
00114 HcalDataCertification::beginJob()
00115 {
00116   if (debug_>0) std::cout<<"<HcalDataCertification> beginJob"<< std::endl;
00117 
00118   dbe_->setCurrentFolder(rootFolder_);
00119   std::string currDir = dbe_->pwd();
00120   if (debug_>0) std::cout << "--- Current Directory " << currDir << std::endl;
00121   std::vector<MonitorElement*> mes = dbe_->getAllContents("");
00122   if (debug_>0) std::cout << "found " << mes.size() << " monitoring elements:" << std::endl;
00123 
00124   dbe_->setCurrentFolder(rootFolder_+"/EventInfo/");
00125 
00126   CertificationSummary = dbe_->bookFloat("CertificationSummary");
00127 
00128   CertificationSummaryMap = dbe_->book2D("CertificationSummaryMap","HcalCertificationSummaryMap",7,0.,7.,1,0.,1.);
00129   CertificationSummaryMap->setAxisRange(-1,1,3);
00130   CertificationSummaryMap->setBinLabel(1,"HB");
00131   CertificationSummaryMap->setBinLabel(2,"HE");
00132   CertificationSummaryMap->setBinLabel(3,"HO");
00133   CertificationSummaryMap->setBinLabel(4,"HF");
00134   CertificationSummaryMap->setBinLabel(5,"H00");
00135   CertificationSummaryMap->setBinLabel(6,"H012");
00136   CertificationSummaryMap->setBinLabel(7,"HFlumi");
00137   CertificationSummaryMap->setBinLabel(1,"Status",2);
00138 
00139   dbe_->setCurrentFolder(rootFolder_+"/EventInfo/CertificationContents/");
00140   Hcal_HB = dbe_->bookFloat("Hcal_HB");
00141   Hcal_HE = dbe_->bookFloat("Hcal_HE");
00142   Hcal_HF = dbe_->bookFloat("Hcal_HF");
00143   Hcal_HO = dbe_->bookFloat("Hcal_HO");
00144   Hcal_HFlumi = dbe_->bookFloat("Hcal_HFlumi");
00145   Hcal_HO0    = dbe_->bookFloat("Hcal_HO0");
00146   Hcal_HO12   = dbe_->bookFloat("Hcal_HO12");
00147 
00148 }
00149 
00150 // ------------ method called once each job just after ending the event loop  ------------
00151 void 
00152 HcalDataCertification::endJob() 
00153 {
00154   if (debug_>0) std::cout << "<HcalDataCertification> endJob " << std::endl;
00155 }
00156 
00157 // ------------ method called just before starting a new run  ------------
00158 void 
00159 HcalDataCertification::beginLuminosityBlock(const edm::LuminosityBlock& run, const edm::EventSetup& c)
00160 {
00161   if (debug_>0) std::cout<<"<HcalDataCertification> beginLuminosityBlock"<<std::endl;
00162 }
00163 
00164 // ------------ method called right after a run ends ------------
00165 void 
00166 HcalDataCertification::endLuminosityBlock(const edm::LuminosityBlock& run, const edm::EventSetup& c)
00167 {
00168   CertifyHcal();
00169 }
00170 
00171 void HcalDataCertification::endRun(const edm::Run & r, const edm::EventSetup & c)
00172 {
00173   CertifyHcal();
00174 }
00175 
00176 void HcalDataCertification::CertifyHcal()
00177 {
00178 
00179   float hcalFrac,reportFrac,dcsFrac,daqFrac;
00180   float fracHCAL[7][3];
00181   float certHcal[7];
00182 
00183   if (debug_>0) {
00184     dbe_->setCurrentFolder(rootFolder_);
00185     std::string currDir = dbe_->pwd();
00186     std::cout << "<HcalDataCertification::endLuminosityBlock> --- Current Directory " << currDir << std::endl;
00187     std::vector<MonitorElement*> mes = dbe_->getAllContents("");
00188     std::cout << "found " << mes.size() << " monitoring elements:" << std::endl;
00189   }
00190 
00191   if (dbe_->get(rootFolder_+"/EventInfo/DCSSummary")) {
00192     dcsFrac = (dbe_->get(rootFolder_+"/EventInfo/DCSSummary"))->getFloatValue();
00193   }
00194   else dcsFrac = -1;
00195 
00196   if (dbe_->get(rootFolder_+"/EventInfo/DAQSummary")) {
00197     daqFrac = (dbe_->get(rootFolder_+"/EventInfo/DAQSummary"))->getFloatValue();
00198   }
00199   else daqFrac = -1;
00200 
00201   if (dbe_->get(rootFolder_+"/EventInfo/reportSummary")) {
00202     reportFrac = (dbe_->get(rootFolder_+"/EventInfo/reportSummary"))->getFloatValue();
00203   }
00204   else reportFrac = -1;
00205 
00206   hcalFrac = 99.;
00207   hcalFrac = TMath::Min(hcalFrac,reportFrac);
00208   hcalFrac = TMath::Min(hcalFrac,daqFrac);
00209   hcalFrac = TMath::Min(hcalFrac,dcsFrac);
00210   if (debug_>0) {
00211     std::cout<<"dcsFrac= "<<dcsFrac<<std::endl;
00212     std::cout<<"daqFrac= "<<daqFrac<<std::endl;
00213     std::cout<<"reportFrac= "<<reportFrac<<std::endl;
00214     std::cout<<"CertificationSummary= "<<hcalFrac<<std::endl;
00215   }
00216 
00217   // reportSummary
00218 
00219   if (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HB")) {
00220     fracHCAL[0][0] = (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HB"))->getFloatValue();
00221   }
00222   else fracHCAL[0][0] = -1;
00223 
00224   if (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HE")) {
00225     fracHCAL[1][0] = (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HE"))->getFloatValue();
00226   }
00227   else fracHCAL[1][0] = -1;
00228 
00229   if (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HO")) {
00230     fracHCAL[2][0] = (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HO"))->getFloatValue();
00231   }
00232   else fracHCAL[2][0] = -1;
00233 
00234   if (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HF")) {
00235     fracHCAL[3][0] = (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HF"))->getFloatValue();
00236   }
00237   else fracHCAL[3][0] = -1;
00238 
00239   if (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HO0")) {
00240     fracHCAL[4][0] = (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HO0"))->getFloatValue();
00241   }
00242   else fracHCAL[4][0] = -1;
00243 
00244   if (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HO12")) {
00245     fracHCAL[5][0] = (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HO12"))->getFloatValue();
00246   }
00247   else fracHCAL[5][0] = -1;
00248 
00249 
00250   if (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HFlumi")) {
00251     fracHCAL[6][0] = (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HFlumi"))->getFloatValue();
00252   }
00253   else fracHCAL[6][0] = -1;
00254 
00255   // DAQ
00256 
00257   if (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HB")) {
00258     fracHCAL[0][1] = (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HB"))->getFloatValue();
00259   }
00260   else fracHCAL[0][1] = -1;
00261 
00262   if (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HE")) {
00263     fracHCAL[1][1] = (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HE"))->getFloatValue();
00264   }
00265   else fracHCAL[1][1] = -1;
00266 
00267   if (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HO")) {
00268     fracHCAL[2][1] = (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HO"))->getFloatValue();
00269   }
00270   else fracHCAL[2][1] = -1;
00271 
00272   if (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HF")) {
00273     fracHCAL[3][1] = (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HF"))->getFloatValue();
00274   }
00275   else fracHCAL[3][1] = -1;
00276 
00277   if (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HO0")) {
00278     fracHCAL[4][1] = (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HO0"))->getFloatValue();
00279   }
00280   else fracHCAL[4][1] = -1;
00281 
00282   if (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HO12")) {
00283     fracHCAL[5][1] = (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HO12"))->getFloatValue();
00284   }
00285   else fracHCAL[5][1] = -1;
00286 
00287   if (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HFlumi")) {
00288     fracHCAL[6][1] = (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HFlumi"))->getFloatValue();
00289   }
00290   else fracHCAL[6][1] = -1;
00291 
00292   // DCS
00293 
00294   if (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HB")) {
00295     fracHCAL[0][2] = (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HB"))->getFloatValue();
00296   }
00297   else fracHCAL[0][2] = -1;
00298 
00299   if (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HE")) {
00300     fracHCAL[1][2] = (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HE"))->getFloatValue();
00301   }
00302   else fracHCAL[1][2] = -1;
00303 
00304   if (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HO")) {
00305     fracHCAL[2][2] = (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HO"))->getFloatValue();
00306   }
00307   else fracHCAL[2][2] = -1;
00308 
00309   if (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HF")) {
00310     fracHCAL[3][2] = (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HF"))->getFloatValue();
00311   }
00312   else fracHCAL[3][2] = -1;
00313 
00314   if (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HO0")) {
00315     fracHCAL[4][2] = (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HO0"))->getFloatValue();
00316   }
00317   else fracHCAL[4][2] = -1;
00318 
00319   if (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HO12")) {
00320     fracHCAL[5][2] = (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HO12"))->getFloatValue();
00321   }
00322   else fracHCAL[5][2] = -1;
00323 
00324 
00325   if (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HFlumi")) {
00326     fracHCAL[6][2] = (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HFlumi"))->getFloatValue();
00327   }
00328   else fracHCAL[6][2] = -1;
00329 
00330   for (int ii=0;ii<7;ii++) {
00331     certHcal[ii] = 99.0;
00332     for (int jj=0; jj<2;jj++) certHcal[ii] = TMath::Min(certHcal[ii],fracHCAL[ii][jj]);
00333     CertificationSummaryMap->setBinContent(ii+1,1,certHcal[ii]);
00334     if (debug_>0) std::cout<<"certFrac["<<ii<<"]= "<<certHcal[ii]<<std::endl;
00335   }
00336 
00337   CertificationSummary->Fill(hcalFrac);
00338   Hcal_HB->Fill(certHcal[0]);
00339   Hcal_HE->Fill(certHcal[1]);
00340   Hcal_HO->Fill(certHcal[2]);
00341   Hcal_HF->Fill(certHcal[3]);
00342   Hcal_HO0->Fill(certHcal[4]);
00343   Hcal_HO12->Fill(certHcal[5]);
00344   Hcal_HFlumi->Fill(certHcal[6]);
00345 
00346 // ---------------------- end of certification
00347   if (debug_>0) std::cout << "<HcalDataCertification::MEfilled= " << std::endl;
00348 
00349 }
00350 
00351 //define this as a plug-in
00352 DEFINE_FWK_MODULE(HcalDataCertification);