CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/DQM/HcalMonitorClient/src/HcalDetDiagLEDClient.cc

Go to the documentation of this file.
00001 #include "DQM/HcalMonitorClient/interface/HcalDetDiagLEDClient.h"
00002 #include "DQM/HcalMonitorClient/interface/HcalClientUtils.h"
00003 #include "DQM/HcalMonitorClient/interface/HcalHistoUtils.h"
00004 
00005 #include "CondFormats/HcalObjects/interface/HcalChannelStatus.h"
00006 #include "CondFormats/HcalObjects/interface/HcalChannelQuality.h"
00007 #include "CondFormats/HcalObjects/interface/HcalCondObjectContainer.h"
00008 
00009 #include "CondFormats/HcalObjects/interface/HcalLogicalMap.h"
00010 
00011 #include <iostream>
00012 
00013 /*
00014  * \file HcalDetDiagLEDClient.cc
00015  * 
00016  * $Date: 2012/11/12 23:26:19 $
00017  * $Revision: 1.11 $
00018  * \author J. Temple
00019  * \brief Hcal DetDiagLED Client class
00020  */
00021 
00022 HcalDetDiagLEDClient::HcalDetDiagLEDClient(std::string myname){
00023   name_=myname;  status=0;
00024   needLogicalMap_=true;
00025 }
00026 
00027 HcalDetDiagLEDClient::HcalDetDiagLEDClient(std::string myname, const edm::ParameterSet& ps){
00028   name_=myname;
00029   enableCleanup_         = ps.getUntrackedParameter<bool>("enableCleanup",false);
00030   debug_                 = ps.getUntrackedParameter<int>("debug",0);
00031   prefixME_              = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
00032   if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
00033     prefixME_.append("/");
00034   subdir_                = ps.getUntrackedParameter<std::string>("DetDiagLEDFolder","DetDiagLEDMonitor_Hcal/");
00035   if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
00036     subdir_.append("/");
00037   subdir_=prefixME_+subdir_;
00038 
00039   validHtmlOutput_       = ps.getUntrackedParameter<bool>("DetDiagLED_validHtmlOutput",true);
00040   cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
00041   badChannelStatusMask_   = ps.getUntrackedParameter<int>("DetDiagLED_BadChannelStatusMask",
00042                             ps.getUntrackedParameter<int>("BadChannelStatusMask",(1<<HcalChannelStatus::HcalCellDead)));
00043   needLogicalMap_=true;
00044 }
00045 
00046 void HcalDetDiagLEDClient::analyze(){
00047   if (debug_>2) std::cout <<"\tHcalDetDiagLEDClient::analyze()"<<std::endl;
00048   calculateProblems();
00049 }
00050 
00051 void HcalDetDiagLEDClient::calculateProblems(){}
00052 void HcalDetDiagLEDClient::updateChannelStatus(std::map<HcalDetId, unsigned int>& myqual){
00053   // This gets called by HcalMonitorClient
00054   // trigger primitives don't yet contribute to channel status (though they could...)
00055   // see dead or hot cell code for an example
00056 
00057 }
00058 
00059 void HcalDetDiagLEDClient::beginJob(){
00060   dqmStore_ = edm::Service<DQMStore>().operator->();
00061   if (debug_>0){
00062     std::cout <<"<HcalDetDiagLEDClient::beginJob()>  Displaying dqmStore directory structure:"<<std::endl;
00063     dqmStore_->showDirStructure();
00064   }
00065 }
00066 void HcalDetDiagLEDClient::endJob(){}
00067 
00068 void HcalDetDiagLEDClient::beginRun(void){
00069   if (!dqmStore_) 
00070     {
00071       if (debug_>0) std::cout <<"<HcalDetDiagLEDClient::beginRun> dqmStore does not exist!"<<std::endl;
00072       return;
00073     }
00074   dqmStore_->setCurrentFolder(subdir_);
00075   problemnames_.clear();
00076 
00077   // Put the appropriate name of your problem summary here
00078   ProblemCells=dqmStore_->book2D(" ProblemDetDiagLED",
00079                                  " Problem DetDiagLED Rate for all HCAL;ieta;iphi",
00080                                  85,-42.5,42.5,
00081                                  72,0.5,72.5);
00082   problemnames_.push_back(ProblemCells->getName());
00083   if (debug_>1)
00084     std::cout << "Tried to create ProblemCells Monitor Element in directory "<<subdir_<<"  \t  Failed?  "<<(ProblemCells==0)<<std::endl;
00085   dqmStore_->setCurrentFolder(subdir_+"problem_DetDiagLED");
00086   ProblemCellsByDepth = new EtaPhiHists();
00087   ProblemCellsByDepth->setup(dqmStore_," Problem DetDiagLED Rate");
00088   for (unsigned int i=0; i<ProblemCellsByDepth->depth.size();++i)
00089     problemnames_.push_back(ProblemCellsByDepth->depth[i]->getName());
00090   nevts_=0;
00091 }
00092 void HcalDetDiagLEDClient::endRun(void){analyze();}
00093 void HcalDetDiagLEDClient::setup(void){}
00094 void HcalDetDiagLEDClient::cleanup(void){}
00095 
00096 bool HcalDetDiagLEDClient::hasErrors_Temp(void){
00097     if(status&2) return true;
00098     return false;
00099 }
00100 bool HcalDetDiagLEDClient::hasWarnings_Temp(void){
00101    if(status&1) return true;
00102    return false;
00103 }
00104 bool HcalDetDiagLEDClient::hasOther_Temp(void){return false;}
00105 bool HcalDetDiagLEDClient::test_enabled(void){return true;}
00106 
00107 bool HcalDetDiagLEDClient::validHtmlOutput(){
00108   std::string s=subdir_+"HcalDetDiagLEDMonitor Event Number";
00109   MonitorElement *me = dqmStore_->get(s.c_str());
00110   int n=0;
00111   if ( me ) {
00112     s = me->valueString();
00113     sscanf((s.substr(2,s.length()-2)).c_str(), "%d", &n);
00114   }
00115   if(n<100) return false;
00116   return true;
00117 }
00118 static void printTableHeader(ofstream& file,std::string header){
00119      file << "</html><html xmlns=\"http://www.w3.org/1999/xhtml\">"<< std::endl;
00120      file << "<head>"<< std::endl;
00121      file << "<meta http-equiv=\"Content-Type\" content=\"text/html\"/>"<< std::endl;
00122      file << "<title>"<< header <<"</title>"<< std::endl;
00123      file << "<style type=\"text/css\">"<< std::endl;
00124      file << " body,td{ background-color: #FFFFCC; font-family: arial, arial ce, helvetica; font-size: 12px; }"<< std::endl;
00125      file << "   td.s0 { font-family: arial, arial ce, helvetica; }"<< std::endl;
00126      file << "   td.s1 { font-family: arial, arial ce, helvetica; font-weight: bold; background-color: #FFC169; text-align: center;}"<< std::endl;
00127      file << "   td.s2 { font-family: arial, arial ce, helvetica; background-color: #eeeeee; }"<< std::endl;
00128      file << "   td.s3 { font-family: arial, arial ce, helvetica; background-color: #d0d0d0; }"<< std::endl;
00129      file << "   td.s4 { font-family: arial, arial ce, helvetica; background-color: #FFC169; }"<< std::endl;
00130      file << "</style>"<< std::endl;
00131      file << "<body>"<< std::endl;
00132      file << "<table>"<< std::endl;
00133 }
00134 static void printTableLine(ofstream& file,int ind,HcalDetId& detid,HcalFrontEndId& lmap_entry,HcalElectronicsId &emap_entry, std::string comment=""){
00135    if(ind==0){
00136      file << "<tr>";
00137      file << "<td class=\"s4\" align=\"center\">#</td>"    << std::endl;
00138      file << "<td class=\"s1\" align=\"center\">ETA</td>"  << std::endl;
00139      file << "<td class=\"s1\" align=\"center\">PHI</td>"  << std::endl;
00140      file << "<td class=\"s1\" align=\"center\">DEPTH</td>"<< std::endl;
00141      file << "<td class=\"s1\" align=\"center\">RBX</td>"  << std::endl;
00142      file << "<td class=\"s1\" align=\"center\">RM</td>"   << std::endl;
00143      file << "<td class=\"s1\" align=\"center\">PIXEL</td>"   << std::endl;
00144      file << "<td class=\"s1\" align=\"center\">RM_FIBER</td>"   << std::endl;
00145      file << "<td class=\"s1\" align=\"center\">FIBER_CH</td>"   << std::endl;
00146      file << "<td class=\"s1\" align=\"center\">QIE</td>"   << std::endl;
00147      file << "<td class=\"s1\" align=\"center\">ADC</td>"   << std::endl;
00148      file << "<td class=\"s1\" align=\"center\">CRATE</td>"   << std::endl;
00149      file << "<td class=\"s1\" align=\"center\">DCC</td>"   << std::endl;
00150      file << "<td class=\"s1\" align=\"center\">SPIGOT</td>"   << std::endl;
00151      file << "<td class=\"s1\" align=\"center\">HTR_FIBER</td>"   << std::endl;
00152      file << "<td class=\"s1\" align=\"center\">HTR_SLOT</td>"   << std::endl;
00153      file << "<td class=\"s1\" align=\"center\">HTR_FPGA</td>"   << std::endl;
00154      if(comment[0]!=0) file << "<td class=\"s1\" align=\"center\">Comment</td>"   << std::endl;
00155      file << "</tr>"   << std::endl;
00156    }
00157    std::string raw_class;
00158    file << "<tr>"<< std::endl;
00159    if((ind%2)==1){
00160       raw_class="<td class=\"s2\" align=\"center\">";
00161    }else{
00162       raw_class="<td class=\"s3\" align=\"center\">";
00163    }
00164    file << "<td class=\"s4\" align=\"center\">" << ind+1 <<"</td>"<< std::endl;
00165    file << raw_class<< detid.ieta()<<"</td>"<< std::endl;
00166    file << raw_class<< detid.iphi()<<"</td>"<< std::endl;
00167    file << raw_class<< detid.depth() <<"</td>"<< std::endl;
00168    file << raw_class<< lmap_entry.rbx()<<"</td>"<< std::endl;
00169    file << raw_class<< lmap_entry.rm() <<"</td>"<< std::endl;
00170    file << raw_class<< lmap_entry.pixel()<<"</td>"<< std::endl;
00171    file << raw_class<< lmap_entry.rmFiber() <<"</td>"<< std::endl;
00172    file << raw_class<< lmap_entry.fiberChannel()<<"</td>"<< std::endl;
00173    file << raw_class<< lmap_entry.qieCard() <<"</td>"<< std::endl;
00174    file << raw_class<< lmap_entry.adc()<<"</td>"<< std::endl;
00175    file << raw_class<< emap_entry.readoutVMECrateId()<<"</td>"<< std::endl;
00176    file << raw_class<< emap_entry.dccid()<<"</td>"<< std::endl;
00177    file << raw_class<< emap_entry.spigot()<<"</td>"<< std::endl;
00178    file << raw_class<< emap_entry.fiberIndex()<<"</td>"<< std::endl;
00179    file << raw_class<< emap_entry.htrSlot()<<"</td>"<< std::endl;
00180    file << raw_class<< emap_entry.htrTopBottom()<<"</td>"<< std::endl;
00181    if(comment[0]!=0) file << raw_class<< comment<<"</td>"<< std::endl;
00182 }
00183 static void printTableTail(ofstream& file){
00184      file << "</table>"<< std::endl;
00185      file << "</body>"<< std::endl;
00186      file << "</html>"<< std::endl;
00187 }
00188 double HcalDetDiagLEDClient::get_channel_status(std::string subdet,int eta,int phi,int depth,int type){
00189    int subdetval=-1;
00190    if (subdet.compare("HB")==0) subdetval=(int)HcalBarrel;
00191    else if (subdet.compare("HE")==0) subdetval=(int)HcalEndcap;
00192    else if (subdet.compare("HO")==0) subdetval=(int)HcalOuter;
00193    else if (subdet.compare("HF")==0) subdetval=(int)HcalForward;
00194    else return -1.0;
00195    int ietabin=CalcEtaBin(subdetval, eta, depth)+1;
00196    if(type==1) return ChannelStatusMissingChannels[depth-1]->GetBinContent(ietabin,phi);
00197    if(type==2) return ChannelStatusUnstableChannels[depth-1]->GetBinContent(ietabin,phi);
00198    if(type==3) return ChannelStatusUnstableLEDsignal[depth-1]->GetBinContent(ietabin,phi);
00199    if(type==4) return ChannelStatusLEDMean[depth-1]->GetBinContent(ietabin,phi);
00200    if(type==5) return ChannelStatusLEDRMS[depth-1]->GetBinContent(ietabin,phi);
00201    if(type==6) return ChannelStatusTimeMean[depth-1]->GetBinContent(ietabin,phi);
00202    if(type==7) return ChannelStatusTimeRMS[depth-1]->GetBinContent(ietabin,phi);
00203    return -1.0;
00204 }
00205 double HcalDetDiagLEDClient::get_energy(std::string subdet,int eta,int phi,int depth,int type){
00206    int subdetval=-1;
00207    if (subdet.compare("HB")==0) subdetval=(int)HcalBarrel;
00208    else if (subdet.compare("HE")==0) subdetval=(int)HcalEndcap;
00209    else if (subdet.compare("HO")==0) subdetval=(int)HcalOuter;
00210    else if (subdet.compare("HF")==0) subdetval=(int)HcalForward;
00211    else return -1.0;
00212    int ietabin=CalcEtaBin(subdetval, eta, depth)+1;
00213    if(type==1) return ChannelsLEDEnergy[depth-1]->GetBinContent(ietabin,phi);
00214    if(type==2) return ChannelsLEDEnergyRef[depth-1]->GetBinContent(ietabin,phi);
00215    return -1.0;
00216 }
00217 void HcalDetDiagLEDClient::htmlOutput(std::string htmlDir){
00218 MonitorElement* me;
00219 int  MissingCnt=0;
00220 int  UnstableCnt=0;
00221 int  UnstableLEDCnt=0;
00222 int  BadTimingCnt=0;
00223 int  HBP[7]={0,0,0,0,0,0,0},newHBP[7]={0,0,0,0,0,0,0};  
00224 int  HBM[7]={0,0,0,0,0,0,0},newHBM[7]={0,0,0,0,0,0,0};  
00225 int  HEP[7]={0,0,0,0,0,0,0},newHEP[7]={0,0,0,0,0,0,0}; 
00226 int  HEM[7]={0,0,0,0,0,0,0},newHEM[7]={0,0,0,0,0,0,0};  
00227 int  HFP[7]={0,0,0,0,0,0,0},newHFP[7]={0,0,0,0,0,0,0}; 
00228 int  HFM[7]={0,0,0,0,0,0,0},newHFM[7]={0,0,0,0,0,0,0}; 
00229 int  HO[7] ={0,0,0,0,0,0,0},newHO[7] ={0,0,0,0,0,0,0};  
00230 std::string subdet[4]={"HB","HE","HO","HF"};
00231 
00232    if (debug_>0) std::cout << "<HcalDetDiagLEDClient::htmlOutput> Preparing  html output ..." << std::endl;
00233    if(!dqmStore_) return;
00234    HcalElectronicsMap emap=logicalMap_->generateHcalElectronicsMap();
00235    std::vector<std::string> name = HcalEtaPhiHistNames();
00236 
00237    for(int i=0;i<4;++i){
00238       ChannelsLEDEnergy[i]=ChannelsLEDEnergyRef[i]=ChannelStatusMissingChannels[i]=ChannelStatusUnstableChannels[i]=0;
00239       ChannelStatusUnstableLEDsignal[i]=ChannelStatusLEDMean[i]=ChannelStatusLEDRMS[i]=ChannelStatusTimeMean[i]=0;
00240       ChannelStatusTimeRMS[i]=0;
00241       std::string s;
00242       s=subdir_+"channel status/"+name[i]+" Missing Channels";
00243       me=dqmStore_->get(s.c_str());
00244       if (me!=0) ChannelStatusMissingChannels[i]=HcalUtilsClient::getHisto<TH2F*>(me,cloneME_,ChannelStatusMissingChannels[i],debug_); else return;  
00245       s=subdir_+"channel status/"+name[i]+" Unstable Channels";
00246       me=dqmStore_->get(s.c_str());
00247       if (me!=0) ChannelStatusUnstableChannels[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, ChannelStatusUnstableChannels[i], debug_); else return;  
00248       s=subdir_+"channel status/"+name[i]+" Unstable LED";
00249       me=dqmStore_->get(s.c_str());
00250       if (me!=0) ChannelStatusUnstableLEDsignal[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, ChannelStatusUnstableLEDsignal[i], debug_); else return;  
00251       s=subdir_+"channel status/"+name[i]+" LED Mean";
00252       me=dqmStore_->get(s.c_str());
00253       if (me!=0) ChannelStatusLEDMean[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, ChannelStatusLEDMean[i], debug_); else return;  
00254       s=subdir_+"channel status/"+name[i]+" LED RMS";
00255       me=dqmStore_->get(s.c_str());
00256       if (me!=0) ChannelStatusLEDRMS[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, ChannelStatusLEDRMS[i], debug_); else return;  
00257       s=subdir_+"channel status/"+name[i]+" Time Mean";
00258       me=dqmStore_->get(s.c_str());
00259       if (me!=0) ChannelStatusTimeMean[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, ChannelStatusTimeMean[i], debug_); else return;  
00260       s=subdir_+"channel status/"+name[i]+" Time RMS";
00261       me=dqmStore_->get(s.c_str());
00262       if (me!=0) ChannelStatusTimeRMS[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, ChannelStatusTimeRMS[i], debug_); else return;  
00263       s=subdir_+"Summary Plots/"+name[i]+" Channel LED Energy";
00264       me=dqmStore_->get(s.c_str());
00265       if (me!=0) ChannelsLEDEnergy[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, ChannelsLEDEnergy[i], debug_); else return;  
00266       s=subdir_+"Summary Plots/"+name[i]+" Channel LED Energy Reference";
00267       me=dqmStore_->get(s.c_str());
00268       if (me!=0) ChannelsLEDEnergyRef[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, ChannelsLEDEnergyRef[i], debug_); else return;
00269   }
00270 
00271   // check how many problems we have:
00272   for(int sd=0;sd<4;sd++){
00273      int feta=0,teta=0,fdepth=0,tdepth=0; 
00274      if(sd==0){ feta=-16; teta=16 ;fdepth=1; tdepth=2; } 
00275      if(sd==1){ feta=-29; teta=29 ;fdepth=1; tdepth=3; } 
00276      if(sd==2){ feta=-15; teta=15 ;fdepth=4; tdepth=4; } 
00277      if(sd==3){ feta=-42; teta=42 ;fdepth=1; tdepth=2; } 
00278      for(int phi=1;phi<=72;phi++) for(int depth=fdepth;depth<=tdepth;depth++) for(int eta=feta;eta<=teta;eta++){
00279         if(sd==3 && eta>-29 && eta<29) continue;
00280         double problem[7]={0,0,0,0,0,0,0}; 
00281         for(int i=0;i<6;i++){
00282            problem[i] =get_channel_status(subdet[sd],eta,phi,depth,i+1);
00283            if(problem[i]!=0){
00284               HcalSubdetector SD=HcalEmpty;
00285               if(sd==0)SD=HcalBarrel;
00286               else if(sd==1) SD=HcalEndcap;
00287               else if(sd==2) SD=HcalOuter;
00288               else if(sd==3) SD=HcalForward;
00289               HcalDetId hcalid(SD, eta, phi, depth);
00290               if(sd==0){  if(eta>0){ 
00291                   HBP[i]++; 
00292                   if(badstatusmap.find(hcalid)==badstatusmap.end())newHBP[i]++;
00293               }else{ 
00294                   HBM[i]++; 
00295                   if(badstatusmap.find(hcalid)==badstatusmap.end())newHBM[i]++;
00296               }} 
00297               if(sd==1){  if(eta>0){ 
00298                   HEP[i]++; 
00299                   if(badstatusmap.find(hcalid)==badstatusmap.end())newHEP[i]++;
00300               }else{ 
00301                   HEM[i]++; 
00302                   if(badstatusmap.find(hcalid)==badstatusmap.end())newHEM[i]++;
00303               }}
00304               if(sd==2){
00305                   HO[i]++; 
00306                   if(badstatusmap.find(hcalid)==badstatusmap.end())newHO[i]++;
00307               }
00308               if(sd==3){  if(eta>0){ 
00309                   HFP[i]++;
00310                   if(badstatusmap.find(hcalid)==badstatusmap.end())newHFP[i]++;
00311               }else{
00312                   HFM[i]++; 
00313                   if(badstatusmap.find(hcalid)==badstatusmap.end())newHFM[i]++;
00314               }}
00315            }
00316         }
00317      }
00318   }
00319   // missing channels list
00320   ofstream Missing;
00321   Missing.open((htmlDir + "Missing.html").c_str());
00322   printTableHeader(Missing,"Missing Channels list");
00323   // Bad timing channels list
00324   ofstream BadTiming;
00325   BadTiming.open((htmlDir + "BadTiming.html").c_str());
00326   printTableHeader(BadTiming,"Bad Timing Channels list");
00327   // unstable channels list
00328   ofstream Unstable;
00329   Unstable.open((htmlDir + "Unstable.html").c_str());
00330   printTableHeader(Unstable,"Low LED signal Channels list");
00331   // unstable LED signal list
00332   ofstream BadLED;
00333   BadLED.open((htmlDir + "UnstableLED.html").c_str());
00334   printTableHeader(BadLED,"Unstable LED signal channels list");
00335 
00336   for(int sd=0;sd<4;sd++){
00337       int cnt=0;
00338       if(sd==0 && ((HBM[0]+HBP[0])==0 || (HBM[0]+HBP[0])==(1296*2))) continue;
00339       if(sd==1 && ((HEM[0]+HEP[0])==0 || (HEM[0]+HEP[0])==(1296*2))) continue;
00340       if(sd==2 && ((HO[0])==0 || HO[0]==2160))                      continue;
00341       if(sd==3 && ((HFM[0]+HFP[0])==0 || (HFM[0]+HFP[0])==(864*2))) continue;
00342       Missing << "<tr><td align=\"center\"><h3>"<< subdet[sd] <<"</h3></td></tr>" << std::endl;
00343       int feta=0,teta=0,fdepth=0,tdepth=0;
00344       if(sd==0){ feta=-16; teta=16 ;fdepth=1; tdepth=2; if(HBM[0]==1296) feta=0; if(HBP[0]==1296) teta=0;}
00345       if(sd==1){ feta=-29; teta=29 ;fdepth=1; tdepth=3; if(HEM[0]==1296) feta=0; if(HEP[0]==1296) teta=0;} 
00346       if(sd==2){ feta=-15; teta=15 ;fdepth=4; tdepth=4; if(HO[0] ==2160) {feta=0; teta=0; }} 
00347       if(sd==3){ feta=-42; teta=42 ;fdepth=1; tdepth=2; if(HFM[0]==864)  feta=0; if(HFP[0]==864)  teta=0; } 
00348       for(int phi=1;phi<=72;phi++) for(int depth=fdepth;depth<=tdepth;depth++) for(int eta=feta;eta<=teta;eta++){
00349          if(sd==3 && eta>-29 && eta<29) continue;
00350          double missing =get_channel_status(subdet[sd],eta,phi,depth,1);
00351          if(missing>0){
00352                HcalDetId *detid=0;
00353                if(sd==0) detid=new HcalDetId(HcalBarrel,eta,phi,depth);
00354                if(sd==1) detid=new HcalDetId(HcalEndcap,eta,phi,depth);
00355                if(sd==2) detid=new HcalDetId(HcalOuter,eta,phi,depth);
00356                if(sd==3) detid=new HcalDetId(HcalForward,eta,phi,depth);
00357                HcalFrontEndId    lmap_entry=logicalMap_->getHcalFrontEndId(*detid);
00358                HcalElectronicsId emap_entry=emap.lookup(*detid);
00359                std::string s=" ";
00360                if(badstatusmap.find(*detid)!=badstatusmap.end()){ s="Known problem"; }  
00361                printTableLine(Missing,cnt++,*detid,lmap_entry,emap_entry,s); MissingCnt++;
00362                delete detid;
00363          }
00364       } 
00365   }
00366 
00367   for(int sd=0;sd<4;sd++){
00368       int cnt=0;
00369       if(sd==0 && (HBM[5]+HBP[5])==0) continue;
00370       if(sd==1 && (HEM[5]+HEP[5])==0) continue;
00371       if(sd==2 && (HO[5])==0)         continue;
00372       if(sd==3 && (HFM[5]+HFP[5])==0) continue;
00373       BadTiming << "<tr><td align=\"center\"><h3>"<< subdet[sd] <<"</h3></td></tr>" << std::endl;
00374       int feta=0,teta=0,fdepth=0,tdepth=0;
00375       if(sd==0){ feta=-16; teta=16 ;fdepth=1; tdepth=2; if(HBM[0]==1296) feta=0; if(HBP[0]==1296) teta=0;}
00376       if(sd==1){ feta=-29; teta=29 ;fdepth=1; tdepth=3; if(HEM[0]==1296) feta=0; if(HEP[0]==1296) teta=0;} 
00377       if(sd==2){ feta=-15; teta=15 ;fdepth=4; tdepth=4; if(HO[0] ==2160) {feta=0; teta=0; }} 
00378       if(sd==3){ feta=-42; teta=42 ;fdepth=1; tdepth=2; if(HFM[0]==864)  feta=0; if(HFP[0]==864)  teta=0; } 
00379       for(int phi=1;phi<=72;phi++) for(int depth=fdepth;depth<=tdepth;depth++) for(int eta=feta;eta<=teta;eta++){
00380          if(sd==3 && eta>-29 && eta<29) continue;
00381          double badtiming =get_channel_status(subdet[sd],eta,phi,depth,6);
00382          if(badtiming!=0){
00383             try{
00384                char comment[100]; sprintf(comment,"Time-mean=%.1f\n",badtiming);
00385                HcalDetId *detid=0;
00386                if(sd==0) detid=new HcalDetId(HcalBarrel,eta,phi,depth);
00387                if(sd==1) detid=new HcalDetId(HcalEndcap,eta,phi,depth);
00388                if(sd==2) detid=new HcalDetId(HcalOuter,eta,phi,depth);
00389                if(sd==3) detid=new HcalDetId(HcalForward,eta,phi,depth);
00390                HcalFrontEndId    lmap_entry=logicalMap_->getHcalFrontEndId(*detid);
00391                HcalElectronicsId emap_entry=emap.lookup(*detid);
00392                printTableLine(BadTiming,cnt++,*detid,lmap_entry,emap_entry,comment); BadTimingCnt++;
00393                delete detid;
00394             }catch(cms::Exception &){ continue;}
00395          }
00396       } 
00397   }
00398   
00399   for(int sd=0;sd<4;sd++){
00400       int cnt=0;
00401       if(sd==0 && (HBM[1]+HBP[1])==0) continue;
00402       if(sd==1 && (HEM[1]+HEP[1])==0) continue;
00403       if(sd==2 && (HO[1])==0)         continue;
00404       if(sd==3 && (HFM[1]+HFP[1])==0) continue;
00405       Unstable << "<tr><td align=\"center\"><h3>"<< subdet[sd] <<"</h3></td></tr>" << std::endl;
00406       int feta=0,teta=0,fdepth=0,tdepth=0;
00407       if(sd==0){ feta=-16; teta=16 ;fdepth=1; tdepth=2;}
00408       if(sd==1){ feta=-29; teta=29 ;fdepth=1; tdepth=3;} 
00409       if(sd==2){ feta=-15; teta=15 ;fdepth=4; tdepth=4;} 
00410       if(sd==3){ feta=-42; teta=42 ;fdepth=1; tdepth=2;} 
00411       for(int phi=1;phi<=72;phi++) for(int depth=fdepth;depth<=tdepth;depth++) for(int eta=feta;eta<=teta;eta++){
00412          if(sd==3 && eta>-29 && eta<29) continue;
00413          double unstable =get_channel_status(subdet[sd],eta,phi,depth,2);
00414          if(unstable>0){
00415             try{
00416                char comment[100]; sprintf(comment,"%.3f%%\n",(1.0-unstable)*100.0);
00417                HcalDetId *detid=0;
00418                if(sd==0) detid=new HcalDetId(HcalBarrel,eta,phi,depth);
00419                if(sd==1) detid=new HcalDetId(HcalEndcap,eta,phi,depth);
00420                if(sd==2) detid=new HcalDetId(HcalOuter,eta,phi,depth);
00421                if(sd==3) detid=new HcalDetId(HcalForward,eta,phi,depth);
00422                HcalFrontEndId    lmap_entry=logicalMap_->getHcalFrontEndId(*detid);
00423                HcalElectronicsId emap_entry=emap.lookup(*detid);
00424                printTableLine(Unstable,cnt++,*detid,lmap_entry,emap_entry,comment); UnstableCnt++;
00425                delete detid;
00426             }catch(cms::Exception &){ continue;}
00427          }
00428       } 
00429   }
00430   
00431   for(int sd=0;sd<4;sd++){
00432       int cnt=0;
00433       if(sd==0 && (HBM[2]+HBP[2])==0) continue;
00434       if(sd==1 && (HEM[2]+HEP[2])==0) continue;
00435       if(sd==2 &&  (HO[2])==0)        continue;
00436       if(sd==3 && (HFM[2]+HFP[2])==0) continue;
00437       BadLED << "<tr><td align=\"center\"><h3>"<< subdet[sd] <<"</h3></td></tr>" << std::endl;
00438       int feta=0,teta=0,fdepth=0,tdepth=0;
00439       if(sd==0){ feta=-16; teta=16 ;fdepth=1; tdepth=2;}
00440       if(sd==1){ feta=-29; teta=29 ;fdepth=1; tdepth=3;} 
00441       if(sd==2){ feta=-15; teta=15 ;fdepth=4; tdepth=4;} 
00442       if(sd==3){ feta=-42; teta=42 ;fdepth=1; tdepth=2;} 
00443       for(int phi=1;phi<=72;phi++) for(int depth=fdepth;depth<=tdepth;depth++) for(int eta=feta;eta<=teta;eta++){
00444          if(sd==3 && eta>-29 && eta<29) continue;
00445          double badled =get_channel_status(subdet[sd],eta,phi,depth,3);
00446          if(badled>0){
00447             try{
00448                char comment[100]; sprintf(comment,"%.3f%%\n",(badled)*100.0);
00449                HcalDetId *detid=0;
00450                if(sd==0) detid=new HcalDetId(HcalBarrel,eta,phi,depth);
00451                if(sd==1) detid=new HcalDetId(HcalEndcap,eta,phi,depth);
00452                if(sd==2) detid=new HcalDetId(HcalOuter,eta,phi,depth);
00453                if(sd==3) detid=new HcalDetId(HcalForward,eta,phi,depth);
00454                HcalFrontEndId    lmap_entry=logicalMap_->getHcalFrontEndId(*detid);
00455                HcalElectronicsId emap_entry=emap.lookup(*detid);
00456                std::string s=" ";
00457                if(badstatusmap.find(*detid)!=badstatusmap.end()){ s="Known problem"; }  
00458                printTableLine(BadLED,cnt++,*detid,lmap_entry,emap_entry,s); UnstableLEDCnt++;
00459                delete detid;
00460             }catch(cms::Exception &){ continue;}
00461          }
00462       } 
00463   }
00464   printTableTail(Missing);
00465   Missing.close();
00466   printTableTail(BadTiming);
00467   BadTiming.close();
00468   printTableTail(Unstable);
00469   Unstable.close();
00470   printTableTail(BadLED);
00471   BadLED.close();
00473   int ievt_ = -1,runNo=-1;
00474   std::string ref_run;
00475   std::string s=subdir_+"HcalDetDiagLEDMonitor Event Number";
00476   me = dqmStore_->get(s.c_str());
00477   if ( me ) {
00478     s = me->valueString();
00479     sscanf((s.substr(2,s.length()-2)).c_str(), "%d", &ievt_);
00480   }
00481   s=subdir_+"HcalDetDiagLEDMonitor Run Number";
00482   me = dqmStore_->get(s.c_str());
00483   if ( me ) {
00484     s = me->valueString();
00485     sscanf((s.substr(2,s.length()-2)).c_str(), "%d", &runNo);
00486   } 
00487   s=subdir_+"HcalDetDiagLEDMonitor Reference Run";
00488   me = dqmStore_->get(s.c_str());
00489   if(me) {
00490     std::string s=me->valueString();
00491     char str[200]; 
00492     sscanf((s.substr(2,s.length()-2)).c_str(), "%s", str);
00493     ref_run=str;
00494   }
00495   TH1F *Energy=0,*Timing=0,*EnergyHF=0,*TimingHF=0,*EnergyRMS=0,*TimingRMS=0,*EnergyRMSHF=0,*TimingRMSHF=0;
00496   TH2F *Time2Dhbhehf=0,*Time2Dho=0,*Energy2Dhbhehf=0,*Energy2Dho=0;
00497   TH2F *HBPphi=0,*HBMphi=0,*HEPphi=0,*HEMphi=0,*HFPphi=0,*HFMphi=0,*HO0phi=0,*HO1Pphi=0,*HO2Pphi=0,*HO1Mphi=0,*HO2Mphi=0;
00498 
00499   s=subdir_+"Summary Plots/HBHEHO LED Energy Distribution"; me=dqmStore_->get(s.c_str());
00500   if(me!=0) Energy=HcalUtilsClient::getHisto<TH1F*>(me, cloneME_, Energy, debug_); else return;
00501   s=subdir_+"Summary Plots/HBHEHO LED Timing Distribution"; me=dqmStore_->get(s.c_str());
00502   if(me!=0) Timing=HcalUtilsClient::getHisto<TH1F*>(me, cloneME_, Timing, debug_); else return;
00503   s=subdir_+"Summary Plots/HBHEHO LED Energy RMS_div_Energy Distribution"; me=dqmStore_->get(s.c_str());
00504   if(me!=0) EnergyRMS=HcalUtilsClient::getHisto<TH1F*>(me, cloneME_, EnergyRMS, debug_); else return;
00505   s=subdir_+"Summary Plots/HBHEHO LED Timing RMS Distribution"; me=dqmStore_->get(s.c_str());
00506   if(me!=0) TimingRMS=HcalUtilsClient::getHisto<TH1F*>(me, cloneME_, TimingRMS, debug_); else return;
00507   s=subdir_+"Summary Plots/HF LED Energy Distribution"; me=dqmStore_->get(s.c_str());
00508   if(me!=0) EnergyHF=HcalUtilsClient::getHisto<TH1F*>(me, cloneME_, EnergyHF, debug_); else return;
00509   s=subdir_+"Summary Plots/HF LED Timing Distribution"; me=dqmStore_->get(s.c_str());
00510   if(me!=0) TimingHF=HcalUtilsClient::getHisto<TH1F*>(me, cloneME_, TimingHF, debug_); else return;
00511   s=subdir_+"Summary Plots/HF LED Energy RMS_div_Energy Distribution"; me=dqmStore_->get(s.c_str());
00512   if(me!=0) EnergyRMSHF=HcalUtilsClient::getHisto<TH1F*>(me, cloneME_, EnergyRMSHF, debug_); else return;
00513   s=subdir_+"Summary Plots/HF LED Timing RMS Distribution"; me=dqmStore_->get(s.c_str());
00514   if(me!=0) TimingRMSHF=HcalUtilsClient::getHisto<TH1F*>(me, cloneME_, TimingRMSHF, debug_); else return;
00515 
00516   s=subdir_+"Summary Plots/LED Timing HBHEHF"; me=dqmStore_->get(s.c_str());
00517   if(me!=0) Time2Dhbhehf=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, Time2Dhbhehf, debug_); else return;
00518   s=subdir_+"Summary Plots/LED Timing HO"; me=dqmStore_->get(s.c_str());
00519   if(me!=0) Time2Dho=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, Time2Dho, debug_); else return;
00520   s=subdir_+"Summary Plots/LED Energy HBHEHF"; me=dqmStore_->get(s.c_str());
00521   if(me!=0) Energy2Dhbhehf=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, Energy2Dhbhehf, debug_); else return;
00522   s=subdir_+"Summary Plots/LED Energy HO"; me=dqmStore_->get(s.c_str());
00523   if(me!=0) Energy2Dho=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, Energy2Dho, debug_); else return;
00524 
00525   s=subdir_+"Summary Plots/HBP Average over HPD LED Ref"; me=dqmStore_->get(s.c_str());
00526   if(me!=0) HBPphi=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, HBPphi, debug_); else return;
00527   s=subdir_+"Summary Plots/HBM Average over HPD LED Ref"; me=dqmStore_->get(s.c_str());
00528   if(me!=0) HBMphi=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, HBMphi, debug_); else return;
00529   s=subdir_+"Summary Plots/HEP Average over HPD LED Ref"; me=dqmStore_->get(s.c_str());
00530   if(me!=0) HEPphi=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, HEPphi, debug_); else return;
00531   s=subdir_+"Summary Plots/HEM Average over HPD LED Ref"; me=dqmStore_->get(s.c_str());
00532   if(me!=0) HEMphi=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, HEMphi, debug_); else return;
00533   s=subdir_+"Summary Plots/HFP Average over RM LED Ref"; me=dqmStore_->get(s.c_str());
00534   if(me!=0) HFPphi=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, HFPphi, debug_); else return;
00535   s=subdir_+"Summary Plots/HFM Average over RM LED Ref"; me=dqmStore_->get(s.c_str());
00536   if(me!=0) HFMphi=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, HFMphi, debug_); else return;
00537 
00538   s=subdir_+"Summary Plots/HO0 Average over HPD LED Ref"; me=dqmStore_->get(s.c_str());
00539   if(me!=0) HO0phi=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, HO0phi, debug_); else return;
00540   s=subdir_+"Summary Plots/HO1P Average over HPD LED Ref"; me=dqmStore_->get(s.c_str());
00541   if(me!=0) HO1Pphi=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, HO1Pphi, debug_); else return;
00542   s=subdir_+"Summary Plots/HO2P Average over HPD LED Ref"; me=dqmStore_->get(s.c_str());
00543   if(me!=0) HO2Pphi=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, HO2Pphi, debug_); else return;
00544   s=subdir_+"Summary Plots/HO1M Average over HPD LED Ref"; me=dqmStore_->get(s.c_str());
00545   if(me!=0) HO1Mphi=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, HO1Mphi, debug_); else return;
00546   s=subdir_+"Summary Plots/HO2M Average over HPD LED Ref"; me=dqmStore_->get(s.c_str());
00547   if(me!=0) HO2Mphi=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, HO2Mphi, debug_); else return;
00548 
00549   gROOT->SetBatch(true);
00550   gStyle->SetCanvasColor(0);
00551   gStyle->SetPadColor(0);
00552   gStyle->SetOptStat(111110);
00553   gStyle->SetPalette(1);
00554  
00555   TCanvas *can=new TCanvas("HcalDetDiagLEDClient","HcalDetDiagLEDClient",0,0,500,350);
00556   can->SetGridy(); 
00557   can->SetGridx(); 
00558   can->cd();
00559 
00560   ofstream htmlFile;
00561   std::string outfile=htmlDir+name_+".html";
00562   htmlFile.open(outfile.c_str());
00563   // html page header
00564   htmlFile << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">  " << std::endl;
00565   htmlFile << "<html>  " << std::endl;
00566   htmlFile << "<head>  " << std::endl;
00567   htmlFile << "  <meta content=\"text/html; charset=ISO-8859-1\"  " << std::endl;
00568   htmlFile << " http-equiv=\"content-type\">  " << std::endl;
00569   htmlFile << "  <title>Detector Diagnostics LED Monitor</title> " << std::endl;
00570   htmlFile << "</head>  " << std::endl;
00571   htmlFile << "<style type=\"text/css\"> td { font-weight: bold } </style>" << std::endl;
00572   htmlFile << "<style type=\"text/css\">"<< std::endl;
00573   htmlFile << "   td.s0 { font-family: arial, arial ce, helvetica; font-weight: bold; background-color: #FF7700; text-align: center;}"<< std::endl;
00574   htmlFile << "   td.s1 { font-family: arial, arial ce, helvetica; font-weight: bold; background-color: #FFC169; text-align: center;}"<< std::endl;
00575   htmlFile << "   td.s2 { font-family: arial, arial ce, helvetica; background-color: red; }"<< std::endl;
00576   htmlFile << "   td.s3 { font-family: arial, arial ce, helvetica; background-color: yellow; }"<< std::endl;
00577   htmlFile << "   td.s4 { font-family: arial, arial ce, helvetica; background-color: green; }"<< std::endl;
00578   htmlFile << "   td.s5 { font-family: arial, arial ce, helvetica; background-color: silver; }"<< std::endl;
00579   std::string state[4]={"<td class=\"s2\" align=\"center\">",
00580                   "<td class=\"s3\" align=\"center\">",
00581                   "<td class=\"s4\" align=\"center\">",
00582                   "<td class=\"s5\" align=\"center\">"};
00583   htmlFile << "</style>"<< std::endl;
00584   htmlFile << "<body>  " << std::endl;
00585   htmlFile << "<br>  " << std::endl;
00586   htmlFile << "<h2>Run:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << std::endl;
00587   htmlFile << "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span " << std::endl;
00588   htmlFile << " style=\"color: rgb(0, 0, 153);\">" << runNo << "</span></h2>" << std::endl;
00589   htmlFile << "<h2>Monitoring task:&nbsp;&nbsp;&nbsp;&nbsp; <span " << std::endl;
00590   htmlFile << " style=\"color: rgb(0, 0, 153);\">Detector Diagnostics LED Monitor</span></h2> " << std::endl;
00591   htmlFile << "<h2>Events processed:&nbsp;&nbsp;&nbsp;&nbsp;<span " << std::endl;
00592   htmlFile << " style=\"color: rgb(0, 0, 153);\">" << ievt_ << "</span></h2>" << std::endl;
00593   htmlFile << "<hr>" << std::endl;
00595   htmlFile << "<table width=100% border=1>" << std::endl;
00596   htmlFile << "<tr>" << std::endl;
00597   htmlFile << "<td class=\"s0\" width=15% align=\"center\">SebDet</td>" << std::endl;
00598   htmlFile << "<td class=\"s0\" width=17% align=\"center\">Missing</td>" << std::endl;
00599   htmlFile << "<td class=\"s0\" width=17% align=\"center\">Unstable</td>" << std::endl;
00600   htmlFile << "<td class=\"s0\" width=17% align=\"center\">low/no LED signal</td>" << std::endl;
00601   htmlFile << "<td class=\"s0\" width=17% align=\"center\">Bad Timing</td>" << std::endl;
00602   htmlFile << "<td class=\"s0\" width=17% align=\"center\">Bad LED signal</td>" << std::endl;
00603   htmlFile << "</tr><tr>" << std::endl;
00604   int ind1=0,ind2=0,ind3=0,ind4=0,ind5=0;
00605   htmlFile << "<td class=\"s1\" align=\"center\">HB+</td>" << std::endl;
00606   ind1=3; if(newHBP[0]==0) ind1=2; if(newHBP[0]>0 && newHBP[0]<=12) ind1=1; if(newHBP[0]>=12 && HBP[0]<1296) ind1=0; 
00607   ind2=3; if(newHBP[1]==0) ind2=2; if(newHBP[1]>0)  ind2=1; if(newHBP[1]>21)  ind2=0; 
00608   ind3=3; if(newHBP[2]==0) ind3=2; if(newHBP[2]>0)  ind3=1; if(newHBP[2]>21)  ind3=0;
00609   ind4=3; if((newHBP[3]+newHBP[4])==0) ind4=2; if((newHBP[3]+newHBP[4])>0)  ind4=1; if((newHBP[3]+newHBP[4])>21)  ind4=0;
00610   ind5=3; if((newHBP[5]+newHBP[6])==0) ind5=2; if((newHBP[5]+newHBP[6])>0)  ind5=1; if((newHBP[5]+newHBP[6])>21)  ind5=0;
00611   if(ind1==3) ind2=ind3=ind4=ind5=3;  
00612   if(ind1==0 || ind2==0 || ind3==0 || ind4==0) status|=2; else if(ind1==1 || ind2==1 || ind3==1 || ind4==1) status|=1; 
00613   htmlFile << state[ind1] << HBP[0] <<" (1296)</td>" << std::endl;
00614   htmlFile << state[ind2] << HBP[1] <<"</td>" << std::endl;
00615   htmlFile << state[ind3] << HBP[2] <<"</td>" << std::endl;
00616   htmlFile << state[ind5] << HBP[5]+HBP[6] <<"</td>" << std::endl;
00617   htmlFile << state[ind4] << HBP[3]+HBP[4] <<"</td>" << std::endl;
00618   
00619   htmlFile << "</tr><tr>" << std::endl;
00620   htmlFile << "<td class=\"s1\" align=\"center\">HB-</td>" << std::endl;
00621   ind1=3; if(newHBM[0]==0) ind1=2; if(newHBM[0]>0 && newHBM[0]<=12) ind1=1; if(newHBM[0]>=12 && HBM[0]<1296) ind1=0; 
00622   ind2=3; if(newHBM[1]==0) ind2=2; if(newHBM[1]>0)  ind2=1; if(newHBM[1]>21)  ind2=0; 
00623   ind3=3; if(newHBM[2]==0) ind3=2; if(newHBM[2]>0)  ind3=1; if(newHBM[2]>21)  ind3=0;
00624   ind4=3; if((newHBM[3]+newHBM[4])==0) ind4=2; if((newHBM[3]+newHBM[4])>0)  ind4=1; if((newHBM[3]+newHBM[4])>21)  ind4=0;
00625   ind5=3; if((newHBM[5]+newHBM[6])==0) ind5=2; if((newHBM[5]+newHBM[6])>0)  ind5=1; if((newHBM[5]+newHBM[6])>21)  ind5=0;
00626   if(ind1==3) ind2=ind3=ind4=ind5=3;
00627   if(ind1==0 || ind2==0 || ind3==0 || ind4==0) status|=2; else if(ind1==1 || ind2==1 || ind3==1 || ind4==1)status|=1; 
00628   htmlFile << state[ind1] << HBM[0] <<" (1296)</td>" << std::endl;
00629   htmlFile << state[ind2] << HBM[1] <<"</td>" << std::endl;
00630   htmlFile << state[ind3] << HBM[2] <<"</td>" << std::endl;
00631   htmlFile << state[ind5] << HBM[5]+HBM[6] <<"</td>" << std::endl;
00632   htmlFile << state[ind4] << HBM[3]+HBM[4] <<"</td>" << std::endl;
00633   
00634   htmlFile << "</tr><tr>" << std::endl;
00635   htmlFile << "<td class=\"s1\" align=\"center\">HE+</td>" << std::endl;
00636   ind1=3; if(newHEP[0]==0) ind1=2; if(newHEP[0]>0 && newHEP[0]<=12) ind1=1; if(newHEP[0]>=12 && HEP[0]<1296) ind1=0; 
00637   ind2=3; if(newHEP[1]==0) ind2=2; if(newHEP[1]>0)  ind2=1; if(newHEP[1]>21)  ind2=0; 
00638   ind3=3; if(newHEP[2]==0) ind3=2; if(newHEP[2]>0)  ind3=1; if(newHEP[2]>21)  ind3=0;
00639   ind4=3; if((newHEP[3]+newHEP[4])==0) ind4=2; if((newHEP[3]+newHEP[4])>0)  ind4=1; if((newHEP[3]+newHEP[4])>21)  ind4=0;
00640   ind5=3; if((newHEP[5]+newHEP[6])==0) ind5=2; if((newHEP[5]+newHEP[6])>0)  ind5=1; if((newHEP[5]+newHEP[6])>21)  ind5=0;
00641   if(ind1==3) ind2=ind3=ind4=ind5=3;
00642   if(ind1==0 || ind2==0 || ind3==0 || ind4==0) status|=2; else if(ind1==1 || ind2==1 || ind3==1 || ind4==1)status|=1; 
00643   htmlFile << state[ind1] << HEP[0] <<" (1296)</td>" << std::endl;
00644   htmlFile << state[ind2] << HEP[1] <<"</td>" << std::endl;
00645   htmlFile << state[ind3] << HEP[2] <<"</td>" << std::endl;
00646   htmlFile << state[ind5] << HEP[5]+HEP[6] <<"</td>" << std::endl;
00647   htmlFile << state[ind4] << HEP[3]+HEP[4] <<"</td>" << std::endl;
00648   
00649   htmlFile << "</tr><tr>" << std::endl;
00650   htmlFile << "<td class=\"s1\" align=\"center\">HE-</td>" << std::endl;
00651   ind1=3; if(newHEM[0]==0) ind1=2; if(newHEM[0]>0 && newHEM[0]<=12) ind1=1; if(newHEM[0]>=12 && HEM[0]<1296) ind1=0; 
00652   ind2=3; if(newHEM[1]==0) ind2=2; if(newHEM[1]>0)  ind2=1; if(newHEM[1]>21)  ind2=0; 
00653   ind3=3; if(newHEM[2]==0) ind3=2; if(newHEM[2]>0)  ind3=1; if(newHEM[2]>21)  ind3=0;
00654   ind4=3; if((newHEM[3]+newHEM[4])==0) ind4=2; if((newHEM[3]+newHEM[4])>0)  ind4=1; if((newHEM[3]+newHEM[4])>21)  ind4=0;
00655   ind5=3; if((newHEM[5]+newHEM[6])==0) ind5=2; if((newHEM[5]+newHEM[6])>0)  ind5=1; if((newHEM[5]+newHEM[6])>21)  ind5=0;
00656   if(ind1==3) ind2=ind3=ind4=ind5=3;
00657   if(ind1==0 || ind2==0 || ind3==0 || ind4==0) status|=2; else if(ind1==1 || ind2==1 || ind3==1 || ind4==1)status|=1; 
00658   htmlFile << state[ind1] << HEM[0] <<" (1296)</td>" << std::endl;
00659   htmlFile << state[ind2] << HEM[1] <<"</td>" << std::endl;
00660   htmlFile << state[ind3] << HEM[2] <<"</td>" << std::endl;
00661   htmlFile << state[ind5] << HEM[5]+HEM[6] <<"</td>" << std::endl;
00662   htmlFile << state[ind4] << HEM[3]+HEM[4] <<"</td>" << std::endl;
00663   
00664   htmlFile << "</tr><tr>" << std::endl;
00665   htmlFile << "<td class=\"s1\" align=\"center\">HF+</td>" << std::endl;
00666   ind1=3; if(newHFP[0]==0) ind1=2; if(newHFP[0]>0 && newHFP[0]<=12) ind1=1; if(newHFP[0]>=12 && HFP[0]<864) ind1=0; 
00667   ind2=3; if(newHFP[1]==0) ind2=2; if(newHFP[1]>0)  ind2=1; if(newHFP[1]>21)  ind2=0; 
00668   ind3=3; if(newHFP[2]==0) ind3=2; if(newHFP[2]>0)  ind3=1; if(newHFP[2]>21)  ind3=0;
00669   ind4=3; if((newHFP[3]+newHFP[4])==0) ind4=2; if((newHFP[3]+newHFP[4])>0)  ind4=1; if((newHFP[3]+newHFP[4])>21)  ind4=0;
00670   ind5=3; if((newHFP[5]+newHFP[6])==0) ind5=2; if((newHFP[5]+newHFP[6])>0)  ind5=1; if((newHFP[5]+newHFP[6])>21)  ind5=0;
00671   if(ind1==3) ind2=ind3=ind4=ind5=3;
00672   if(ind1==0 || ind2==0 || ind3==0 || ind4==0) status|=2; else if(ind1==1 || ind2==1 || ind3==1 || ind4==1)status|=1; 
00673   htmlFile << state[ind1] << HFP[0] <<" (864)</td>" << std::endl;
00674   htmlFile << state[ind2] << HFP[1] <<"</td>" << std::endl;
00675   htmlFile << state[ind3] << HFP[2] <<"</td>" << std::endl;
00676   htmlFile << state[ind5] << HFP[5]+HFP[6] <<"</td>" << std::endl;
00677   htmlFile << state[ind4] << HFP[3]+HFP[4] <<"</td>" << std::endl;
00678   
00679   htmlFile << "</tr><tr>" << std::endl;
00680   htmlFile << "<td class=\"s1\" align=\"center\">HF-</td>" << std::endl;
00681   ind1=3; if(newHFM[0]==0) ind1=2; if(newHFM[0]>0 && newHFM[0]<=12) ind1=1; if(newHFM[0]>=12 && HFM[0]<864) ind1=0; 
00682   ind2=3; if(newHFM[1]==0) ind2=2; if(newHFM[1]>0)  ind2=1; if(newHFM[1]>21)  ind2=0; 
00683   ind3=3; if(newHFM[2]==0) ind3=2; if(newHFM[2]>0)  ind3=1; if(newHFM[2]>21)  ind3=0;
00684   ind4=3; if((HFM[3]+HFM[4])==0) ind4=2; if((HFM[3]+HFM[4])>0)  ind4=1; if((HFM[3]+HFM[4])>21)  ind4=0;
00685   ind5=3; if((HFM[5]+HFM[6])==0) ind5=2; if((HFM[5]+HFM[6])>0)  ind5=1; if((HFM[5]+HFM[6])>21)  ind5=0;
00686   if(ind1==3) ind2=ind3=ind4=ind5=3;
00687   if(ind1==0 || ind2==0 || ind3==0 || ind4==0) status|=2; else if(ind1==1 || ind2==1 || ind3==1 || ind4==1)status|=1; 
00688   htmlFile << state[ind1] << HFM[0] <<" (864)</td>" << std::endl;
00689   htmlFile << state[ind2] << HFM[1] <<"</td>" << std::endl;
00690   htmlFile << state[ind3] << HFM[2] <<"</td>" << std::endl;
00691   htmlFile << state[ind5] << HFM[5]+HFM[6] <<"</td>" << std::endl;
00692   htmlFile << state[ind4] << HFM[3]+HFM[4] <<"</td>" << std::endl;
00693    
00694   htmlFile << "</tr><tr>" << std::endl;
00695   htmlFile << "<td class=\"s1\" align=\"center\">HO</td>" << std::endl;
00696   ind1=3; if(newHO[0]==0) ind1=2; if(newHO[0]>0 && newHO[0]<=12) ind1=1; if(newHO[0]>=12 && HO[0]<2160) ind1=0; 
00697   ind2=3; if(newHO[1]==0) ind2=2; if(newHO[1]>0)  ind2=1; if(newHO[1]>21)  ind2=0; 
00698   ind3=3; if(newHO[2]==0) ind3=2; if(newHO[2]>0)  ind3=1; if(newHO[2]>21)  ind3=0;
00699   ind4=3; if((newHO[3]+newHO[4])==0) ind4=2; if((newHO[3]+newHO[4])>0)  ind4=1; if((newHO[3]+newHO[4])>21)  ind4=0;
00700   ind5=3; if((newHO[5]+newHO[6])==0) ind5=2; if((newHO[5]+newHO[6])>0)  ind5=1; if((newHO[5]+newHO[6])>21)  ind5=0;
00701   if(ind1==3) ind2=ind3=ind4=ind5=3;
00702   if(ind1==0 || ind2==0 || ind3==0 || ind4==0) status|=2; else if(ind1==1 || ind2==1 || ind3==1 || ind4==1)status|=1; 
00703 
00704   htmlFile << state[ind1] << HO[0] <<" (2160)</td>" << std::endl;
00705   htmlFile << state[ind2] << HO[1] <<"</td>" << std::endl;
00706   htmlFile << state[ind3] << HO[2] <<"</td>" << std::endl;
00707   htmlFile << state[ind5] << HO[5]+HO[6] <<"</td>" << std::endl;
00708   htmlFile << state[ind4] << HO[3]+HO[4] <<"</td>" << std::endl;
00709   
00710   htmlFile << "</tr></table>" << std::endl;
00711   htmlFile << "<hr>" << std::endl;
00713   if((MissingCnt+UnstableCnt+UnstableLEDCnt+BadTimingCnt)>0){
00714       htmlFile << "<table width=100% border=1><tr>" << std::endl;
00715       if(MissingCnt>0)    htmlFile << "<td><a href=\"" << "Missing.html" <<"\">list of missing channels</a></td>";
00716       if(UnstableCnt>0)   htmlFile << "<td><a href=\"" << "Unstable.html" <<"\">list of unstable channels</a></td>";
00717       if(UnstableLEDCnt>0)htmlFile << "<td><a href=\"" << "UnstableLED.html" <<"\">list of low LED signal channels</a></td>";
00718       if(BadTimingCnt>0)htmlFile << "<td><a href=\"" << "BadTiming.html" <<"\">list of Bad Timing channels</a></td>";
00719       htmlFile << "</tr></table>" << std::endl;
00720   }
00722 
00724   htmlFile << "<h2 align=\"center\">Summary LED plots</h2>" << std::endl;
00725   htmlFile << "<table width=100% border=0><tr>" << std::endl;
00726   htmlFile << "<tr align=\"left\">" << std::endl;
00727   Time2Dhbhehf->SetMaximum(6);
00728   Time2Dho->SetMaximum(6);
00729   Time2Dhbhehf->SetNdivisions(36,"Y");
00730   Time2Dho->SetNdivisions(36,"Y");
00731   Time2Dhbhehf->SetStats(0);
00732   Time2Dho->SetStats(0);
00733   Time2Dhbhehf->Draw("COLZ");    can->SaveAs((htmlDir + "led_timing_hbhehf.gif").c_str());
00734   Time2Dho->Draw("COLZ");        can->SaveAs((htmlDir + "led_timing_ho.gif").c_str());
00735   htmlFile << "<td align=\"center\"><img src=\"led_timing_hbhehf.gif\" alt=\"led timing distribution\">   </td>" << std::endl;
00736   htmlFile << "<td align=\"center\"><img src=\"led_timing_ho.gif\" alt=\"led timing distribution\">   </td>" << std::endl;
00737   htmlFile << "</tr>" << std::endl;
00738   
00739   htmlFile << "<tr align=\"left\">" << std::endl;
00740   Energy2Dhbhehf->SetStats(0);
00741   Energy2Dho->SetStats(0);
00742   Energy2Dhbhehf->SetNdivisions(36,"Y");
00743   Energy2Dho->SetNdivisions(36,"Y");
00744   Energy2Dhbhehf->Draw("COLZ");    can->SaveAs((htmlDir + "led_energy_hbhehf.gif").c_str());
00745   Energy2Dho->Draw("COLZ");        can->SaveAs((htmlDir + "led_energy_ho.gif").c_str());
00746   htmlFile << "<td align=\"center\"><img src=\"led_energy_hbhehf.gif\" alt=\"led energy distribution\">   </td>" << std::endl;
00747   htmlFile << "<td align=\"center\"><img src=\"led_energy_ho.gif\" alt=\"led energy distribution\">   </td>" << std::endl;
00748   htmlFile << "</tr>" << std::endl;
00749   
00750   can->SetGridy(false);
00751   htmlFile << "<tr align=\"left\">" << std::endl;
00752   Energy->Draw();    can->SaveAs((htmlDir + "led_energy_distribution.gif").c_str());
00753   EnergyRMS->Draw(); can->SaveAs((htmlDir + "led_energy_rms_distribution.gif").c_str());
00754   htmlFile << "<td align=\"center\"><img src=\"led_energy_distribution.gif\" alt=\"led energy distribution\">   </td>" << std::endl;
00755   htmlFile << "<td align=\"center\"><img src=\"led_energy_rms_distribution.gif\" alt=\"led energy rms distribution\">   </td>" << std::endl;
00756   htmlFile << "</tr>" << std::endl;
00757   htmlFile << "<tr align=\"left\">" << std::endl;
00758   Timing->Draw();    can->SaveAs((htmlDir + "led_timing_distribution.gif").c_str());
00759   TimingRMS->Draw(); can->SaveAs((htmlDir + "led_timing_rms_distribution.gif").c_str());
00760   htmlFile << "<td align=\"center\"><img src=\"led_timing_distribution.gif\" alt=\"led timing distribution\">   </td>" << std::endl;
00761   htmlFile << "<td align=\"center\"><img src=\"led_timing_rms_distribution.gif\" alt=\"led timing rms distribution\">   </td>" << std::endl;
00762   htmlFile << "</tr>" << std::endl;
00763   htmlFile << "<tr align=\"left\">" << std::endl;
00764   EnergyHF->Draw();    can->SaveAs((htmlDir + "led_energyhf_distribution.gif").c_str());
00765   EnergyRMSHF->Draw(); can->SaveAs((htmlDir + "led_energyhf_rms_distribution.gif").c_str());
00766   htmlFile << "<td align=\"center\"><img src=\"led_energyhf_distribution.gif\" alt=\"hf led energy distribution\">   </td>" << std::endl;
00767   htmlFile << "<td align=\"center\"><img src=\"led_energyhf_rms_distribution.gif\" alt=\"hf led energy rms distribution\">   </td>" << std::endl;
00768   htmlFile << "</tr>" << std::endl;
00769   htmlFile << "<tr align=\"left\">" << std::endl;
00770   TimingHF->Draw();    can->SaveAs((htmlDir + "led_timinghf_distribution.gif").c_str());
00771   TimingRMSHF->Draw(); can->SaveAs((htmlDir + "led_timinghf_rms_distribution.gif").c_str());
00772   htmlFile << "<td align=\"center\"><img src=\"led_timinghf_distribution.gif\" alt=\"hf led timing distribution\">   </td>" << std::endl;
00773   htmlFile << "<td align=\"center\"><img src=\"led_timinghf_rms_distribution.gif\" alt=\"hf led timing rms distribution\">   </td>" << std::endl;
00774   htmlFile << "</tr>" << std::endl;
00775   htmlFile << "</table>" << std::endl;
00776   
00778   htmlFile << "<h2 align=\"center\">Stability LED plots (Reference run "<<ref_run<<")</h2>" << std::endl;
00779   htmlFile << "<table width=100% border=0><tr>" << std::endl;
00780   htmlFile << "<tr align=\"left\">" << std::endl;
00781   HBPphi->GetXaxis()->SetNdivisions(418,kFALSE);
00782   HBMphi->GetXaxis()->SetNdivisions(418,kFALSE);
00783   HEPphi->GetXaxis()->SetNdivisions(418,kFALSE);
00784   HEMphi->GetXaxis()->SetNdivisions(418,kFALSE);
00785   
00786   HBPphi->SetMarkerColor(kRed);
00787   HBPphi->SetMarkerStyle(23);
00788   HBPphi->SetXTitle("HPD Index = RBX*4+RM");
00789   HBMphi->SetMarkerColor(kRed);
00790   HBMphi->SetMarkerStyle(23);
00791   HBMphi->SetXTitle("HPD Index = RBX*4+RM");
00792   HBPphi->Draw();    can->SaveAs((htmlDir + "led_hbp_distribution.gif").c_str());
00793   HBMphi->Draw();    can->SaveAs((htmlDir + "led_hbm_distribution.gif").c_str());
00794   htmlFile << "<td align=\"center\"><img src=\"led_hbp_distribution.gif\" alt=\"led hbp distribution\">   </td>" << std::endl;
00795   htmlFile << "<td align=\"center\"><img src=\"led_hbm_distribution.gif\" alt=\"led hbm distribution\">   </td>" << std::endl;
00796   htmlFile << "</tr>" << std::endl;
00797   
00798   htmlFile << "<tr align=\"left\">" << std::endl;
00799   HEPphi->SetMarkerColor(kRed);
00800   HEPphi->SetMarkerStyle(23);
00801   HEPphi->SetXTitle("HPD Index = RBX*4+RM");
00802   HEMphi->SetMarkerColor(kRed);
00803   HEMphi->SetMarkerStyle(23);
00804   HEMphi->SetXTitle("HPD Index = RBX*4+RM");
00805   HEPphi->Draw();    can->SaveAs((htmlDir + "led_hep_distribution.gif").c_str());
00806   HEMphi->Draw();    can->SaveAs((htmlDir + "led_hem_distribution.gif").c_str());
00807   htmlFile << "<td align=\"center\"><img src=\"led_hep_distribution.gif\" alt=\"led hep distribution\">   </td>" << std::endl;
00808   htmlFile << "<td align=\"center\"><img src=\"led_hem_distribution.gif\" alt=\"led hem distribution\">   </td>" << std::endl;
00809   htmlFile << "</tr>" << std::endl;
00810   
00811   htmlFile << "<tr align=\"left\">" << std::endl;
00812   HFPphi->SetMarkerColor(kRed);
00813   HFPphi->SetMarkerStyle(23);
00814   HFPphi->SetXTitle("RM Index = RoBox*3+RM");
00815   HFMphi->SetMarkerColor(kRed);
00816   HFMphi->SetMarkerStyle(23);
00817   HFPphi->GetXaxis()->SetNdivisions(312,kFALSE);
00818   HFMphi->GetXaxis()->SetNdivisions(312,kFALSE);
00819 
00820   HFMphi->SetXTitle("RM Index = RoBox*3+RM");
00821   HFPphi->Draw();    can->SaveAs((htmlDir + "led_hfp_distribution.gif").c_str());
00822   HFMphi->Draw();    can->SaveAs((htmlDir + "led_hfm_distribution.gif").c_str());
00823   htmlFile << "<td align=\"center\"><img src=\"led_hfp_distribution.gif\" alt=\"led hfp distribution\">   </td>" << std::endl;
00824   htmlFile << "<td align=\"center\"><img src=\"led_hfm_distribution.gif\" alt=\"led hfm distribution\">   </td>" << std::endl;
00825   htmlFile << "</tr>" << std::endl; 
00826 
00827   htmlFile << "<tr align=\"left\">" << std::endl;
00828   HO1Pphi->SetMarkerColor(kRed);
00829   HO1Pphi->SetMarkerStyle(23);
00830   HO1Pphi->SetXTitle("HPD Index = RBX*4+RM");
00831   HO1Mphi->SetMarkerColor(kRed);
00832   HO1Mphi->SetMarkerStyle(23);
00833   HO1Mphi->GetXaxis()->SetNdivisions(412,kFALSE);
00834   HO1Pphi->GetXaxis()->SetNdivisions(412,kFALSE);
00835 
00836   HO1Mphi->SetXTitle("HPD Index = RBX*4+RM");
00837   HO1Pphi->Draw();    can->SaveAs((htmlDir + "led_ho1p_distribution.gif").c_str());
00838   HO1Mphi->Draw();    can->SaveAs((htmlDir + "led_ho1m_distribution.gif").c_str());
00839   htmlFile << "<td align=\"center\"><img src=\"led_ho1p_distribution.gif\" alt=\"led ho1p distribution\">   </td>" << std::endl;
00840   htmlFile << "<td align=\"center\"><img src=\"led_ho1m_distribution.gif\" alt=\"led ho1m distribution\">   </td>" << std::endl;
00841   htmlFile << "</tr>" << std::endl;
00842    
00843   htmlFile << "<tr align=\"left\">" << std::endl;
00844   HO2Pphi->SetMarkerColor(kRed);
00845   HO2Pphi->SetMarkerStyle(23);
00846   HO2Pphi->SetXTitle("HPD Index = RBX*4+RM");
00847   HO2Mphi->SetMarkerColor(kRed);
00848   HO2Mphi->SetMarkerStyle(23);
00849   HO2Mphi->GetXaxis()->SetNdivisions(412,kFALSE);
00850   HO2Pphi->GetXaxis()->SetNdivisions(412,kFALSE);
00851 
00852   HO2Mphi->SetXTitle("HPD Index = RBX*4+RM");
00853   HO2Pphi->Draw();    can->SaveAs((htmlDir + "led_ho2p_distribution.gif").c_str());
00854   HO2Mphi->Draw();    can->SaveAs((htmlDir + "led_ho2m_distribution.gif").c_str());
00855   htmlFile << "<td align=\"center\"><img src=\"led_ho2p_distribution.gif\" alt=\"led ho2p distribution\">   </td>" << std::endl;
00856   htmlFile << "<td align=\"center\"><img src=\"led_ho2m_distribution.gif\" alt=\"led ho2m distribution\">   </td>" << std::endl;
00857   htmlFile << "</tr>" << std::endl;
00858   
00859   htmlFile << "<tr align=\"left\">" << std::endl;
00860   HO0phi->SetMarkerColor(kRed);
00861   HO0phi->SetMarkerStyle(23);
00862   HO0phi->SetXTitle("HPD Index = RBX*4+RM");
00863   HO0phi->GetXaxis()->SetNdivisions(412,kFALSE);
00864   HO0phi->Draw();    can->SaveAs((htmlDir + "led_ho0_distribution.gif").c_str());
00865   htmlFile << "<td align=\"center\"><img src=\"led_ho0_distribution.gif\" alt=\"led ho0 distribution\">   </td>" << std::endl;
00866   htmlFile << "</tr>" << std::endl;
00867   
00868   htmlFile << "</table>" << std::endl;
00869 
00870   htmlFile << "</body> " << std::endl;
00871   htmlFile << "</html> " << std::endl;
00872   htmlFile.close();
00873   can->Close();
00874 }
00875 
00876 HcalDetDiagLEDClient::~HcalDetDiagLEDClient()
00877 {}