CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/DQM/EcalPreshowerMonitorClient/src/EcalPreshowerMonitorClient.cc

Go to the documentation of this file.
00001 #include <memory>
00002 #include <iostream>
00003 #include <fstream>
00004 #include <string>
00005 #include <vector>
00006 
00007 #include "FWCore/ServiceRegistry/interface/Service.h"
00008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00009 #include "FWCore/Framework/interface/MakerMacros.h"
00010 #include "FWCore/Framework/interface/Frameworkfwd.h"
00011 #include "FWCore/Framework/interface/LuminosityBlock.h"
00012 
00013 #include "DQMServices/Core/interface/MonitorElement.h"
00014 #include "DQMServices/Core/interface/DQMStore.h"
00015 
00016 #include "DQM/EcalPreshowerMonitorClient/interface/EcalPreshowerMonitorClient.h"
00017 #include "DQM/EcalPreshowerMonitorClient/interface/ESPedestalClient.h"
00018 #include "DQM/EcalPreshowerMonitorClient/interface/ESIntegrityClient.h"
00019 #include "DQM/EcalPreshowerMonitorClient/interface/ESSummaryClient.h"
00020 
00021 using namespace cms;
00022 using namespace edm;
00023 using namespace std;
00024 
00025 EcalPreshowerMonitorClient::EcalPreshowerMonitorClient(const edm::ParameterSet& ps) {
00026 
00027    verbose_    = ps.getUntrackedParameter<bool>("verbose", false);
00028    outputFile_ = ps.getUntrackedParameter<string>("OutputFile","");
00029    inputFile_  = ps.getUntrackedParameter<string>("InputFile","");
00030    prefixME_   = ps.getUntrackedParameter<string>("prefixME", "EcalPreshower");
00031    debug_      = ps.getUntrackedParameter<bool>("debug", false);
00032 
00033    prescaleFactor_ = ps.getUntrackedParameter<int>("prescaleFactor", 1);
00034 
00035    //Initial enabledClients
00036    enabledClients_.push_back("Integrity");
00037    enabledClients_.push_back("Pedestal");
00038    enabledClients_.push_back("Summary");
00039 
00040    enabledClients_ = ps.getUntrackedParameter<vector<string> >("enabledClients", enabledClients_);      
00041 
00042    if ( verbose_ ) {
00043       cout << " Enabled Clients:";
00044       for ( unsigned int i = 0; i < enabledClients_.size(); i++ ) {
00045          cout << " " << enabledClients_[i];
00046       }
00047       cout << endl;
00048    }
00049 
00050    //Setup Clients
00051    if ( find(enabledClients_.begin(), enabledClients_.end(), "Integrity" ) != enabledClients_.end() ){
00052       clients_.push_back( new ESIntegrityClient(ps) );
00053    }
00054 
00055    if ( find(enabledClients_.begin(), enabledClients_.end(), "Pedestal" ) != enabledClients_.end() ){
00056       clients_.push_back( new ESPedestalClient(ps) );
00057    }
00058 
00059    if ( find(enabledClients_.begin(), enabledClients_.end(), "Summary" ) != enabledClients_.end() ){
00060       clients_.push_back( new ESSummaryClient(ps) );
00061    }
00062 
00063    if(debug_){
00064       cout<<"PrescaleFactor = "<<prescaleFactor_<<endl; 
00065    }
00066 }
00067 
00068 EcalPreshowerMonitorClient::~EcalPreshowerMonitorClient() {
00069 
00070    if ( verbose_ ) cout << "Finish EcalPreshowerMonitorClient" << endl;
00071 
00072    for ( unsigned int i=0; i<clients_.size(); i++ ) {
00073       delete clients_[i];
00074    }
00075 
00076 }
00077 
00078 void EcalPreshowerMonitorClient::beginJob() {
00079 
00080    if(debug_){ 
00081       cout<<"EcalPreshowerMonitorClient: beginJob"<<endl;
00082    }
00083 
00084    ievt_ = 0;
00085    jevt_ = 0;
00086 
00087    // get hold of back-end interface
00088 
00089    dqmStore_ = Service<DQMStore>().operator->();
00090 
00091    if ( inputFile_.size() != 0 ) {
00092      if ( dqmStore_ ) {
00093        dqmStore_->open(inputFile_);
00094     }
00095   }
00096 
00097   for ( unsigned int i=0; i<clients_.size(); i++ ) {
00098     clients_[i]->beginJob(dqmStore_);
00099     clients_[i]->setup();
00100   }
00101 }
00102 
00103 void EcalPreshowerMonitorClient::beginRun(void) {
00104 
00105    if (debug_) { 
00106       cout << "EcalPreshowerMonitorClient: beginRun" << endl;
00107    }
00108 
00109    jevt_ = 0;
00110 
00111    begin_run_ = true;
00112    end_run_   = false;
00113 
00114    for ( unsigned int i=0; i<clients_.size(); i++ ) {
00115       clients_[i]->beginRun();
00116    }
00117 }
00118 
00119 void EcalPreshowerMonitorClient::beginRun(const edm::Run & r, const edm::EventSetup & c) {
00120 
00121    if (debug_) { 
00122       cout << "EcalPreshowerMonitorClient: beginRun" << endl;
00123    }
00124 
00125    jevt_ = 0;
00126 
00127    begin_run_ = true;
00128    end_run_   = false;
00129 
00130    for ( unsigned int i=0; i<clients_.size(); i++ ) {
00131       clients_[i]->beginRun();
00132    }
00133 }
00134 
00135 void EcalPreshowerMonitorClient::endJob(void) {
00136 
00137    if (debug_) { 
00138       cout << "EcalPreshowerMonitorClient: endJob, ievt = " << ievt_ << endl;
00139    }
00140 
00141    if ( ! end_run_ ) {
00142      this->analyze(); 
00143      this->endRun();
00144    }
00145    
00146    if ( outputFile_.size() != 0 ) {
00147      cout<<"Store Result in "<<outputFile_<<endl;
00148      dqmStore_->save(outputFile_);
00149    }
00150    
00151    for ( unsigned int i=0; i<clients_.size(); i++ ) {
00152      clients_[i]->endJob();
00153    }
00154 
00155 }
00156 
00157 void EcalPreshowerMonitorClient::endRun(void) {
00158 
00159    if(debug_){ 
00160       cout << "EcalPreshowerMonitorClient: endRun, jevt = " << jevt_ << endl;
00161    }
00162 
00163    begin_run_ = false;
00164    end_run_   = true;
00165 
00166    for ( unsigned int i=0; i<clients_.size(); i++ ) {
00167      clients_[i]->analyze();
00168      clients_[i]->endRun();
00169    }
00170    
00171 }
00172 
00173 void EcalPreshowerMonitorClient::endRun(const edm::Run & r, const edm::EventSetup & c) {
00174 
00175    if(debug_){ 
00176       cout << "EcalPreshowerMonitorClient: endRun, jevt = " << jevt_ << endl;
00177    }
00178 
00179    begin_run_ = false;
00180    end_run_   = true;
00181 
00182    for ( unsigned int i=0; i<clients_.size(); i++ ) {
00183      clients_[i]->analyze();
00184      clients_[i]->endRun();
00185    }
00186 
00187 }
00188 
00189 void EcalPreshowerMonitorClient::analyze(void) {
00190 
00191    if(debug_){ 
00192       cout << "EcalPreshowerMonitorClient: ievt/jevt = " << ievt_ << "/" << jevt_ << endl;
00193    }
00194 
00195    for ( unsigned int i=0; i<clients_.size(); i++ ) {
00196       clients_[i]->analyze();
00197    }
00198 }
00199 
00200 void EcalPreshowerMonitorClient::analyze(const Event & e, const EventSetup & c) {
00201 
00202    ievt_++;
00203    jevt_++;
00204 
00205    if(debug_) cout<<" analyze(const Event & e, const EventSetup & c) is called"<<endl;
00206 
00207    if ( prescaleFactor_ > 0 ) {
00208       if ( jevt_ % prescaleFactor_ == 0 ) this->analyze();
00209    }
00210 
00211 }
00212 
00213 void EcalPreshowerMonitorClient::beginLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup & c) {
00214 }
00215 
00216 void EcalPreshowerMonitorClient::endLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup & c) {
00217 
00218   for ( unsigned int i=0; i<clients_.size(); i++ ) {
00219     clients_[i]->endLumiAnalyze();
00220   }
00221    
00222 }
00223 
00224 void EcalPreshowerMonitorClient::htmlOutput(int run) {
00225 
00226    //Change runNum_ into run by Yeong-jyi 
00227 
00228    string border[2][10] = {
00229       {"style=\"border-top:solid white; border-left:solid white; border-bottom:solid white; border-right:solid white; border-width:1\"",
00230          "style=\"border-top:solid black; border-left:solid black; border-bottom:solid white; border-right:solid white; border-width:1\"",
00231          "style=\"border-top:solid black; border-left:solid white; border-bottom:solid white; border-right:solid black; border-width:1\"",
00232          "style=\"border-top:solid white; border-left:solid black; border-bottom:solid white; border-right:solid white; border-width:1\"",
00233          "style=\"border-top:solid white; border-left:solid white; border-bottom:solid white; border-right:solid black; border-width:1\"",
00234          "style=\"border-top:solid black; border-left:solid black; border-bottom:solid white; border-right:solid black; border-width:1\"",
00235          "style=\"border-top:solid white; border-left:solid black; border-bottom:solid black; border-right:solid black; border-width:1\"",
00236          "style=\"border-top:solid white; border-left:solid black; border-bottom:solid black; border-right:solid white; border-width:1\"",
00237          "style=\"border-top:solid white; border-left:solid white; border-bottom:solid black; border-right:solid black; border-width:1\"",
00238          "style=\"border-top:solid white; border-left:solid black; border-bottom:solid white; border-right:solid black; border-width:1\""},
00239 
00240       {"style=\"border-top:solid white; border-left:solid white; border-bottom:solid white; border-right:solid white; border-width:1\"",
00241          "style=\"border-top:solid black; border-left:solid black; border-bottom:solid white; border-right:solid white; border-width:1\"",
00242          "style=\"border-top:solid black; border-left:solid white; border-bottom:solid white; border-right:solid black; border-width:1\"",
00243          "style=\"border-top:solid black; border-left:solid white; border-bottom:solid white; border-right:solid white; border-width:1\"",
00244          "style=\"border-top:solid white; border-left:solid white; border-bottom:solid black; border-right:solid white; border-width:1\"",
00245          "style=\"border-top:solid black; border-left:solid black; border-bottom:solid black; border-right:solid white; border-width:1\"",
00246          "style=\"border-top:solid black; border-left:solid white; border-bottom:solid black; border-right:solid black; border-width:1\"",
00247          "style=\"border-top:solid white; border-left:solid black; border-bottom:solid black; border-right:solid white; border-width:1\"",
00248          "style=\"border-top:solid white; border-left:solid white; border-bottom:solid black; border-right:solid black; border-width:1\"",
00249          "style=\"border-top:solid black; border-left:solid white; border-bottom:solid black; border-right:solid white; border-width:1\""}
00250    };
00251 
00252    int iborder[2][40][40] = {
00253       {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
00254          {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
00255          {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 1, 2, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 1, 2, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
00256          {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0},
00257          {0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 3, 4, 3, 4, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 3, 4, 3, 4, 3, 4, 1, 2, 0, 0, 0, 0, 0, 0, 0},
00258          {0, 0, 0, 0, 0, 0, 0, 3, 4, 7, 8, 3, 4, 7, 8, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 7, 8, 3, 4, 7, 8, 3, 4, 0, 0, 0, 0, 0, 0, 0},
00259          {0, 0, 0, 0, 0, 0, 5, 3, 4, 1, 2, 7, 8, 1, 2, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 1, 2, 7, 8, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0},
00260          {0, 0, 0, 0, 0, 1, 4, 7, 8, 3, 4, 1, 2, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 1, 2, 3, 4, 7, 8, 3, 2, 0, 0, 0, 0, 0},
00261          {0, 0, 0, 0, 5, 3, 4, 1, 2, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 7, 8, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 1, 2, 3, 4, 5, 0, 0, 0, 0},
00262          {0, 0, 0, 1, 4, 7, 8, 3, 4, 3, 4, 3, 4, 7, 8, 7, 8, 7, 8, 1, 2, 7, 8, 7, 8, 7, 8, 3, 4, 3, 4, 3, 4, 7, 8, 3, 2, 0, 0, 0},
00263          {0, 0, 0, 3, 4, 1, 2, 3, 4, 7, 8, 3, 4, 1, 2, 1, 2, 3, 4, 3, 4, 1, 2, 1, 2, 3, 4, 3, 4, 7, 8, 3, 4, 1, 2, 3, 4, 0, 0, 0},
00264          {0, 0, 0, 7, 8, 3, 4, 7, 8, 1, 2, 7, 8, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 7, 8, 1, 2, 7, 8, 3, 4, 7, 8, 0, 0, 0},
00265          {0, 0, 5, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 3, 4, 3, 8, 7, 8, 7, 4, 3, 4, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 5, 0, 0},
00266          {0, 0, 9, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 7, 8, 3, 8, 6, 0, 0, 0, 0, 6, 7, 4, 7, 8, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 9, 0, 0},
00267          {0, 1, 4, 3, 4, 7, 8, 3, 4, 3, 4, 3, 4, 1, 2, 6, 0, 0, 0, 0, 0, 0, 0, 0, 6, 1, 2, 3, 4, 3, 4, 3, 4, 7, 8, 3, 4, 3, 2, 0},
00268          {0, 7, 8, 7, 8, 1, 2, 7, 8, 7, 8, 7, 8, 3, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 4, 7, 8, 7, 8, 7, 8, 1, 2, 7, 8, 7, 8, 0},
00269          {0, 1, 2, 1, 2, 3, 4, 1, 2, 1, 2, 1, 2, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 1, 2, 1, 2, 1, 2, 3, 4, 1, 2, 1, 2, 0},
00270          {0, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 0},
00271          {0, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 0},
00272          {0, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 0}, //
00273          {0, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0}, //
00274          {0, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 0},
00275          {0, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 0},
00276          {0, 7, 8, 7, 8, 3, 4, 7, 8, 7, 8, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 7, 8, 7, 8, 7, 8, 3, 4, 7, 8, 7, 8, 0},
00277          {0, 1, 2, 1, 2, 7, 8, 1, 2, 1, 2, 1, 2, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 1, 2, 1, 2, 1, 2, 7, 8, 1, 2, 1, 2, 0},
00278          {0, 7, 4, 3, 4, 1, 2, 3, 4, 3, 4, 3, 4, 7, 8, 5, 0, 0, 0, 0, 0, 0, 0, 0, 5, 7, 8, 3, 4, 3, 4, 3, 4, 1, 2, 3, 4, 3, 8, 0},
00279          {0, 0, 9, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 1, 2, 3, 2, 5, 0, 0, 0, 0, 5, 1, 4, 1, 2, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 9, 0, 0},
00280          {0, 0, 6, 7, 8, 3, 4, 7, 8, 3, 4, 7, 8, 3, 4, 3, 4, 3, 2, 1, 2, 1, 4, 3, 4, 3, 4, 7, 8, 3, 4, 7, 8, 3, 4, 7, 8, 6, 0, 0},
00281          {0, 0, 0, 1, 2, 3, 4, 1, 2, 7, 8, 1, 2, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 1, 2, 7, 8, 1, 2, 3, 4, 1, 2, 0, 0, 0},
00282          {0, 0, 0, 3, 4, 7, 8, 3, 4, 1, 2, 3, 4, 7, 8, 7, 8, 3, 4, 3, 4, 7, 8, 7, 8, 3, 4, 3, 4, 1, 2, 3, 4, 7, 8, 3, 4, 0, 0, 0},
00283          {0, 0, 0, 7, 4, 1, 2, 3, 4, 3, 4, 3, 4, 1, 2, 1, 2, 1, 2, 7, 8, 1, 2, 1, 2, 1, 2, 3, 4, 3, 4, 3, 4, 1, 2, 3, 8, 0, 0, 0},
00284          {0, 0, 0, 0, 6, 3, 4, 7, 8, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 1, 2, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 7, 8, 3, 4, 6, 0, 0, 0, 0},
00285          {0, 0, 0, 0, 0, 7, 4, 1, 2, 3, 4, 7, 8, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 7, 8, 3, 4, 1, 2, 3, 8, 0, 0, 0, 0, 0},
00286          {0, 0, 0, 0, 0, 0, 6, 3, 4, 7, 8, 1, 2, 7, 8, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 7, 8, 1, 2, 7, 8, 3, 4, 6, 0, 0, 0, 0, 0, 0},
00287          {0, 0, 0, 0, 0, 0, 0, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0},
00288          {0, 0, 0, 0, 0, 0, 0, 7, 8, 3, 4, 3, 4, 3, 4, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 4, 3, 4, 3, 4, 7, 8, 0, 0, 0, 0, 0, 0, 0},
00289          {0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0},
00290          {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 7, 8, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
00291          {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
00292          {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
00293 
00294       {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
00295          {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
00296          {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 9, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 9, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
00297          {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0},
00298          {0, 0, 0, 0, 0, 0, 0, 0, 5, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 6, 0, 0, 0, 0, 0, 0, 0, 0},
00299          {0, 0, 0, 0, 0, 0, 0, 1, 3, 2, 1, 3, 3, 3, 2, 1, 3, 3, 3, 2, 1, 3, 3, 3, 2, 1, 3, 3, 3, 2, 1, 3, 2, 0, 0, 0, 0, 0, 0, 0},
00300          {0, 0, 0, 0, 0, 0, 5, 4, 4, 8, 7, 4, 4, 4, 8, 7, 4, 4, 4, 8, 7, 4, 4, 4, 8, 7, 4, 4, 4, 8, 7, 4, 4, 6, 0, 0, 0, 0, 0, 0},
00301          {0, 0, 0, 0, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 0, 0, 0, 0},
00302          {0, 0, 0, 0, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 0, 0, 0, 0},
00303          {0, 0, 0, 1, 3, 2, 1, 3, 3, 3, 2, 1, 3, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 3, 2, 1, 3, 3, 3, 2, 1, 3, 2, 0, 0, 0},
00304          {0, 0, 5, 4, 4, 8, 7, 4, 4, 4, 8, 7, 4, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 4, 8, 7, 4, 4, 4, 8, 7, 4, 4, 6, 0, 0},
00305          {0, 0, 1, 3, 3, 3, 2, 1, 3, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 3, 2, 1, 3, 3, 3, 2, 0, 0},
00306          {0, 0, 7, 4, 4, 4, 8, 7, 4, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 4, 8, 7, 4, 4, 4, 8, 0, 0},
00307          {0, 1, 3, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 9, 6, 0, 0, 0, 0, 5, 9, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 3, 2, 0},
00308          {0, 7, 4, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 4, 8, 0},
00309          {1, 3, 3, 3, 2, 1, 3, 3, 3, 2, 1, 3, 3, 3, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 3, 3, 3, 2, 1, 3, 3, 3, 2, 1, 3, 3, 3, 2},
00310          {7, 4, 4, 4, 8, 7, 4, 4, 4, 8, 7, 4, 4, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 4, 4, 8, 7, 4, 4, 4, 8, 7, 4, 4, 4, 8},
00311          {1, 3, 3, 3, 2, 1, 3, 3, 3, 2, 1, 3, 3, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 3, 3, 2, 1, 3, 3, 3, 2, 1, 3, 3, 3, 2},
00312          {7, 4, 4, 4, 8, 7, 4, 4, 4, 8, 7, 4, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 4, 8, 7, 4, 4, 4, 8, 7, 4, 4, 4, 8},
00313          {1, 3, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 3, 2}, // 
00314          {7, 4, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 4, 8}, //
00315          {1, 3, 3, 3, 2, 1, 3, 3, 3, 2, 1, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 2, 1, 3, 3, 3, 2, 1, 3, 3, 3, 2},
00316          {7, 4, 4, 4, 8, 7, 4, 4, 4, 8, 7, 4, 4, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 4, 4, 8, 7, 4, 4, 4, 8, 7, 4, 4, 4, 8},
00317          {1, 3, 3, 3, 2, 1, 3, 3, 3, 2, 1, 3, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 3, 2, 1, 3, 3, 3, 2, 1, 3, 3, 3, 2},
00318          {7, 4, 4, 4, 8, 7, 4, 4, 4, 8, 7, 4, 4, 4, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 4, 4, 4, 8, 7, 4, 4, 4, 8, 7, 4, 4, 4, 8},
00319          {0, 1, 3, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 3, 2, 0},
00320          {0, 7, 4, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 9, 6, 0, 0, 0, 0, 5, 9, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 4, 8, 0},
00321          {0, 0, 1, 3, 3, 3, 2, 1, 3, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 3, 2, 1, 3, 3, 3, 2, 0, 0},
00322          {0, 0, 7, 4, 4, 4, 8, 7, 4, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 4, 8, 7, 4, 4, 4, 8, 0, 0},
00323          {0, 0, 5, 3, 3, 2, 1, 3, 3, 3, 2, 1, 3, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 3, 2, 1, 3, 3, 3, 2, 1, 3, 3, 6, 0, 0},
00324          {0, 0, 0, 7, 4, 8, 7, 4, 4, 4, 8, 7, 4, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 4, 8, 7, 4, 4, 4, 8, 7, 4, 8, 0, 0, 0},
00325          {0, 0, 0, 0, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 0, 0, 0, 0},
00326          {0, 0, 0, 0, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 0, 0, 0, 0},
00327          {0, 0, 0, 0, 0, 0, 5, 3, 3, 2, 1, 3, 3, 3, 2, 1, 3, 3, 3, 2, 1, 3, 3, 3, 2, 1, 3, 3, 3, 2, 1, 3, 3, 6, 0, 0, 0, 0, 0, 0},
00328          {0, 0, 0, 0, 0, 0, 0, 7, 4, 8, 7, 4, 4, 4, 8, 7, 4, 4, 4, 8, 7, 4, 4, 4, 8, 7, 4, 4, 4, 8, 7, 4, 8, 0, 0, 0, 0, 0, 0, 0},
00329          {0, 0, 0, 0, 0, 0, 0, 0, 5, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 3, 6, 0, 0, 0, 0, 0, 0, 0, 0},
00330          {0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 4, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0},
00331          {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 9, 3, 2, 1, 3, 3, 2, 1, 3, 3, 2, 1, 3, 9, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
00332          {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 7, 4, 4, 8, 7, 4, 4, 8, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
00333          {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
00334       }
00335    };
00336 
00337    // Make HTML
00338    if (runtype_ ==3) {
00339 
00340       Char_t run_s[50];
00341       sprintf(run_s, "/var/www/html/DQM/%08d", run);
00342       string htmlDir = run_s;
00343       system(("/bin/mkdir -m 777 -p " + htmlDir).c_str());
00344       sprintf(run_s, "/var/www/html/DQM/%08d/gif", run);
00345       string gifDir = run_s;
00346       system(("/bin/mkdir -m 777 -p " + gifDir).c_str());
00347       ofstream htmlFile;
00348       htmlFile.open((htmlDir+"/index.html").c_str(), ios::app);
00349 
00350       // Start to display ES planes 
00351       int iquad_M[2][40] = {{  5,  7, 10, 11, 13, 13, 14, 15, 16, 17,
00352          17, 17, 18, 18, 19, 19, 19, 19, 19, 19,
00353          19, 19, 19, 19, 19, 19, 18, 18, 17, 17,
00354          17, 16, 15, 14, 13, 13, 11, 10,  7,  5},
00355           {  0,  6,  8, 11, 12, 13, 14, 16, 16, 17,
00356              18, 18, 18, 19, 19, 20, 20, 20, 20, 20,  
00357              20, 20, 20, 20, 20, 19, 19, 18, 18, 18,
00358              17, 16, 16, 14, 13, 12, 11,  8,  6,  0}
00359       };
00360       int iquad_m[2][40] = {{1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
00361          1,  1,  1,  3,  5,  6,  7,  7,  8,  8,
00362          8,  8,  7,  7,  6,  5,  3,  1,  1,  1,
00363          1,  1,  1,  1,  1,  1,  1,  1,  1,  1},
00364           {1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
00365              1,  1,  1,  3,  5,  6,  7,  7,  8,  8,
00366              8,  8,  7,  7,  6,  5,  3,  1,  1,  1,
00367              1,  1,  1,  1,  1,  1,  1,  1,  1,  1}
00368       };
00369 
00370       htmlFile << "<table border=\"0\" bordercolor=\"white\" cellspacing=\"0\" style=\"float: left;\">" << endl;
00371       htmlFile << "<tr align=\"center\">" << endl;
00372       if (layer_==1) htmlFile << "<td colspan=\"40\"> ES- F <a href=\"../plotAll.php?run="<<run<<"&type="<<runtype_<<"\">(summary plots)</a></td>" << endl;
00373       else if (layer_==1) htmlFile << "<td colspan=\"40\"> ES- R <a href=\"../plotAll.php?run="<<run<<"&type="<<runtype_<<"\">(summary plots)</a></td>" << endl;
00374 
00375       //string color[6] = {"#C0C0C0", "#00FF00", "#FFFF00", "#F87217", "#FF0000", "#0000FF"};
00376       for (int i=0; i<40; ++i) {
00377          htmlFile << "<tr>" << endl;
00378          for (int j=0; j<40; ++j) {
00379             if ((iquad_m[layer_-1][i]-1) == 0) {
00380                if (j<=(19-iquad_M[layer_-1][i]) || j>(19+iquad_M[layer_-1][i])) 
00381                   htmlFile << "<td "<<border[layer_-1][iborder[layer_-1][i][j]]<<" > <img src=\"../0.png\" width=12 height=12 border=0> </img></td>" << endl;
00382                else {
00383                   htmlFile << "<td "<<border[layer_-1][iborder[layer_-1][i][j]]<<" ><a href=\"../plot.php?run="<<run<<"&type="<<runtype_<<"&iz="<<senZ_[0]<<"&ip="<<senP_[0]<<"&ix="<<j+1<<"&iy="<<39-i+1<<"&gain="<<gain_<<"&prec="<<precision_<<"\" STYLE=\"text-decoration:none\" target=_blank><img src=\"../"<< qt[j][39-i]<<".png\" width=12 height=12 border=0></img></a></td>" << endl;
00384                }
00385             } else {
00386                if (j>=(19-iquad_m[layer_-1][i]+2) && j<=(19+iquad_m[layer_-1][i]-1)) 
00387                   htmlFile << "<td "<<border[layer_-1][iborder[layer_-1][i][j]]<<" > <img src=\"../0.png\" width=12 height=12 border=0> </img></td>" << endl;
00388                else if (j<=(19-iquad_M[layer_-1][i]) || j>(19+iquad_M[layer_-1][i])) 
00389                   htmlFile << "<td "<<border[layer_-1][iborder[layer_-1][i][j]]<<" > <img src=\"../0.png\" width=12 height=12 border=0> </img></td>" << endl;
00390                else {
00391                   htmlFile << "<td "<<border[layer_-1][iborder[layer_-1][i][j]]<<" ><a href=\"../plot.php?run="<<run<<"&type="<<runtype_<<"&iz="<<senZ_[0]<<"&ip="<<senP_[0]<<"&ix="<<j+1<<"&iy="<<39-i+1<<"&gain="<<gain_<<"&prec="<<precision_<<"\" STYLE=\"text-decoration:none\" target=_blank><img src=\"../"<< qt[j][39-i]<<".png\" width=12 height=12 border=0></img></a></td>" << endl;
00392                }
00393             }
00394          }
00395          htmlFile << "</tr>" <<endl;
00396       }
00397       htmlFile << "</table>" <<endl;
00398       htmlFile << "<table border=\"1\">" <<endl;
00399       if (runtype_==3) {
00400          htmlFile << "<tr><td><img src=\"../2.png\" width=20 height=20 border=0> this sensor is not used for injection </img></td></tr>" << endl;
00401          htmlFile << "<tr><td><img src=\"../1.png\" width=20 height=20 border=0> the injection result for this sensor is OK </img></td></tr>" << endl;
00402          htmlFile << "<tr><td><img src=\"../4.png\" width=20 height=20 border=0> at least one strip has signal 10% higher than average </img></td></tr>" <<endl;
00403          htmlFile << "<tr><td><img src=\"../3.png\" width=20 height=20 border=0> at least one strip has signal 10% lower than average </img></td></tr>" <<endl;
00404          htmlFile << "<tr><td><img src=\"../7.png\" width=20 height=20 border=0> all strips have signal lower than "<< qtCriteria<<" ADC </img></td></tr>" <<endl;
00405          htmlFile << "<tr><td><img src=\"../6.png\" width=20 height=20 border=0> the order of time sample is wrong </img></td></tr>" <<endl;
00406          htmlFile << "<tr><td><img src=\"../5.png\" width=20 height=20 border=0> this sensor is used for data-taking, but does not deliver data  </img></td></tr>" <<endl;
00407       }
00408       htmlFile << "</table>" <<endl;
00409       htmlFile << "</body> " << endl;
00410       htmlFile << "</html> " << endl;
00411 
00412       htmlFile.close();
00413    }
00414 }
00415 
00416 
00417 //define this as a plug-in
00418 DEFINE_FWK_MODULE(EcalPreshowerMonitorClient);