CMS 3D CMS Logo

HcalCaloTowerClient.cc

Go to the documentation of this file.
00001 #include <DQM/HcalMonitorClient/interface/HcalCaloTowerClient.h>
00002 #include <DQM/HcalMonitorClient/interface/HcalClientUtils.h>
00003 #include "DQMServices/Core/interface/DQMStore.h"
00004 #include "DQMServices/Core/interface/MonitorElement.h"
00005 
00006 HcalCaloTowerClient::HcalCaloTowerClient(){}
00007 
00008 void HcalCaloTowerClient::init(const ParameterSet& ps, DQMStore* dbe, string clientName){
00009   //Call the base class first
00010   HcalBaseClient::init(ps,dbe,clientName);
00011   ievt_ = 0;
00012   jevt_ = 0;
00013   occ_=0;
00014   energy_=0;
00015 
00016 }
00017 
00018 HcalCaloTowerClient::~HcalCaloTowerClient(){
00019   this->cleanup();
00020 }
00021 
00022 void HcalCaloTowerClient::beginJob(void){
00023 
00024   if ( debug_ ) cout << "HcalCaloTowerClient: beginJob" << endl;
00025 
00026   ievt_ = 0;
00027   jevt_ = 0;
00028 
00029   this->setup();
00030   this->resetAllME();
00031   return;
00032 }
00033 
00034 void HcalCaloTowerClient::beginRun(void){
00035 
00036   if ( debug_ ) cout << "HcalCaloTowerClient: beginRun" << endl;
00037 
00038   jevt_ = 0;
00039   this->setup();
00040   this->resetAllME();
00041   return;
00042 }
00043 
00044 void HcalCaloTowerClient::endJob(void) {
00045 
00046   if ( debug_ ) cout << "HcalCaloTowerClient: endJob, ievt = " << ievt_ << endl;
00047 
00048   this->cleanup(); 
00049   return;
00050 }
00051 
00052 void HcalCaloTowerClient::endRun(void) {
00053 
00054   if ( debug_ ) cout << "HcalCaloTowerClient: endRun, jevt = " << jevt_ << endl;
00055 
00056   this->cleanup();
00057   return;
00058 }
00059 
00060 void HcalCaloTowerClient::setup(void) {
00061   return;
00062 }
00063 
00064 void HcalCaloTowerClient::cleanup(void) {
00065   
00066   if(cloneME_)
00067     {
00068       if(occ_) delete occ_;
00069       if(energy_) delete energy_;
00070     }    
00071 
00072   
00073   occ_=0; 
00074   energy_=0;
00075   
00076   dqmReportMapErr_.clear(); dqmReportMapWarn_.clear(); dqmReportMapOther_.clear();
00077   dqmQtests_.clear();
00078   
00079   return;
00080 }
00081 
00082 
00083 void HcalCaloTowerClient::report(){
00084   if(!dbe_) return;
00085   if ( debug_ ) cout << "HcalCaloTowerClient: report" << endl;
00086   this->setup();
00087 
00088   char name[256];
00089   sprintf(name, "%sHcal/CaloTowerMonitor/CaloTower Event Number",process_.c_str());
00090   MonitorElement* me = dbe_->get(name); 
00091   if ( me ) {
00092     string s = me->valueString();
00093     ievt_ = -1;
00094     sscanf((s.substr(2,s.length()-2)).c_str(), "%d", &ievt_);
00095     if ( debug_ ) cout << "Found '" << name << "'" << endl;
00096   }
00097   getHistograms();
00098 
00099   return;
00100 }
00101 
00102 void HcalCaloTowerClient::analyze(void){
00103 
00104   jevt_++;
00105   int updates = 0;
00106 
00107   if ( updates % 10 == 0 ) {
00108     if ( debug_ ) cout << "HcalCaloTowerClient: " << updates << " updates" << endl;
00109   }
00110 
00111   return;
00112 }
00113 
00114 void HcalCaloTowerClient::getHistograms(){
00115   if(!dbe_) return;
00116   char name[150];    
00117   sprintf(name,"CaloTowerMonitor/CaloTowerOccupancy");
00118   occ_=getHisto2(name,process_,dbe_, debug_,cloneME_);
00119   sprintf(name,"CaloTowerMonitor/CaloTowerEnergy");
00120   energy_=getHisto2(name,process_,dbe_, debug_,cloneME_);
00121 
00122   return;
00123 }
00124 
00125 void HcalCaloTowerClient::resetAllME(){
00126   if(!dbe_) return;
00127   Char_t name[150];
00128   
00129   sprintf(name,"%sHcal/CaloTowerMonitor/CaloTowerOccupancy",process_.c_str());
00130   resetME(name,dbe_);
00131   sprintf(name,"%sHcal/CaloTowerMonitor/CaloTowerEnergyy",process_.c_str());
00132   resetME(name,dbe_);
00133 
00134 
00135   return;
00136 }
00137 
00138 
00139 void HcalCaloTowerClient::htmlOutput(int runNo, string htmlDir, string htmlName){
00140 
00141   cout << "Preparing HcalCaloTowerClient html output ..." << endl;
00142   string client = "CaloTowerMonitor";
00143   htmlErrors(runNo,htmlDir,client,process_,dbe_,dqmReportMapErr_,dqmReportMapWarn_,dqmReportMapOther_);
00144   
00145   ofstream htmlFile;
00146   htmlFile.open((htmlDir + htmlName).c_str());
00147 
00148   // html page header
00149   htmlFile << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">  " << endl;
00150   htmlFile << "<html>  " << endl;
00151   htmlFile << "<head>  " << endl;
00152   htmlFile << "  <meta content=\"text/html; charset=ISO-8859-1\"  " << endl;
00153   htmlFile << " https-equiv=\"content-type\">  " << endl;
00154   htmlFile << "  <title>Monitor: Hcal CaloTower Task output</title> " << endl;
00155   htmlFile << "</head>  " << endl;
00156   htmlFile << "<style type=\"text/css\"> td { font-weight: bold } </style>" << endl;
00157   htmlFile << "<body>  " << endl;
00158   htmlFile << "<br>  " << endl;
00159   htmlFile << "<h2>Run:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << endl;
00160   htmlFile << "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span " << endl;
00161   htmlFile << " style=\"color: rgb(0, 0, 153);\">" << runNo << "</span></h2>" << endl;
00162   htmlFile << "<h2>Monitoring task:&nbsp;&nbsp;&nbsp;&nbsp; <span " << endl;
00163   htmlFile << " style=\"color: rgb(0, 0, 153);\">Hcal CaloTowers</span></h2> " << endl;
00164   htmlFile << "<h2>Events processed:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << endl;
00165   htmlFile << "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span " << endl;
00166   htmlFile << " style=\"color: rgb(0, 0, 153);\">" << ievt_ << "</span></h2>" << endl;
00167   htmlFile << "<hr>" << endl;
00168   htmlFile << "<table  width=100% border=1><tr>" << endl;
00169   if(hasErrors())htmlFile << "<td bgcolor=red><a href=\"CaloTowerMonitorErrors.html\">Errors in this task</a></td>" << endl;
00170   else htmlFile << "<td bgcolor=lime>No Errors</td>" << endl;
00171   if(hasWarnings()) htmlFile << "<td bgcolor=yellow><a href=\"CaloTowerMonitorWarnings.html\">Warnings in this task</a></td>" << endl;
00172   else htmlFile << "<td bgcolor=lime>No Warnings</td>" << endl;
00173   if(hasOther()) htmlFile << "<td bgcolor=aqua><a href=\"CaloTowerMonitorMessages.html\">Messages in this task</a></td>" << endl;
00174   else htmlFile << "<td bgcolor=lime>No Messages</td>" << endl;
00175   htmlFile << "</tr></table>" << endl;
00176   htmlFile << "<hr>" << endl;
00177 
00178   htmlFile << "<h2><strong>Hcal CaloTower Histograms</strong></h2>" << endl;
00179   htmlFile << "<h3>" << endl;
00180   /*
00181   if(subDetsOn_[0]) htmlFile << "<a href=\"#HB_Plots\">HB Plots </a></br>" << endl;
00182   if(subDetsOn_[1]) htmlFile << "<a href=\"#HE_Plots\">HE Plots </a></br>" << endl;
00183   if(subDetsOn_[2]) htmlFile << "<a href=\"#HF_Plots\">HF Plots </a></br>" << endl;
00184   if(subDetsOn_[3]) htmlFile << "<a href=\"#HO_Plots\">HO Plots </a></br>" << endl;
00185   */
00186   htmlFile << "</h3>" << endl;
00187   htmlFile << "<hr>" << endl;
00188 
00189   htmlFile << "<table border=\"0\" cellspacing=\"0\" " << endl;
00190   htmlFile << "cellpadding=\"10\"> " << endl;
00191   
00192   htmlFile << "<td>&nbsp;&nbsp;&nbsp;<h3>Global Histograms</h3></td></tr>" << endl;
00193   htmlFile << "<tr align=\"left\">" << endl;
00194   histoHTML2(runNo,occ_,"iEta","iPhi", 92, htmlFile,htmlDir);
00195   histoHTML2(runNo,energy_,"iEta","iPhi", 100, htmlFile,htmlDir);
00196   htmlFile << "</tr>" << endl;
00197   htmlFile<<"</table>"<<endl;
00198   htmlFile << "<br>" << endl;
00199 
00200   // html page footer
00201   htmlFile << "</body> " << endl;
00202   htmlFile << "</html> " << endl;
00203 
00204   htmlFile.close();
00205 
00206   return;
00207 }
00208 
00209 
00210 void HcalCaloTowerClient::createTests(){
00211   if(!dbe_) return;
00212 
00213   if(debug_) printf("Creating CaloTower tests...\n"); 
00214   
00215   return;
00216 }
00217 
00218 
00219 void HcalCaloTowerClient::loadHistograms(TFile* infile){
00220 
00221   // Don't currently use event number
00222   TNamed* tnd = (TNamed*)infile->Get("DQMData/Hcal/CaloTowerMonitor/CaloTower Event Number");
00223   if(tnd){
00224     string s =tnd->GetTitle();
00225     ievt_ = -1;
00226     sscanf((s.substr(2,s.length()-2)).c_str(), "%d", &ievt_);
00227   }
00228 
00229   char name[150];    
00230   sprintf(name,"DQMData/Hcal/CaloTowerMonitor/CaloTowerOccupancy");      
00231   occ_= (TH2F*)infile->Get(name);
00232   sprintf(name,"DQMData/Hcal/CaloTowerMonitor/CaloTowerEnergy");      
00233   energy_= (TH2F*)infile->Get(name);
00234 
00235   return;
00236 }

Generated on Tue Jun 9 17:32:55 2009 for CMSSW by  doxygen 1.5.4