CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/DQM/HcalMonitorClient/src/HcalDetDiagPedestalClient.cc

Go to the documentation of this file.
00001 #include "DQM/HcalMonitorClient/interface/HcalDetDiagPedestalClient.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 "CalibCalorimetry/HcalAlgos/interface/HcalLogicalMapGenerator.h"
00010 #include "CondFormats/HcalObjects/interface/HcalLogicalMap.h"
00011 
00012 #include <iostream>
00013 
00014 /*
00015  * \file HcalDetDiagPedestalClient.cc
00016  * 
00017  * $Date: 2011/04/12 18:25:42 $
00018  * $Revision: 1.11 $
00019  * \author J. Temple
00020  * \brief Hcal DetDiagPedestal Client class
00021  */
00022 
00023 
00024 HcalDetDiagPedestalClient::HcalDetDiagPedestalClient(std::string myname)
00025 {
00026   name_=myname;   status=0;
00027 }
00028 
00029 HcalDetDiagPedestalClient::HcalDetDiagPedestalClient(std::string myname, const edm::ParameterSet& ps)
00030 {
00031   name_=myname;
00032   enableCleanup_         = ps.getUntrackedParameter<bool>("enableCleanup",false);
00033   debug_                 = ps.getUntrackedParameter<int>("debug",0);
00034   prefixME_              = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
00035   if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
00036     prefixME_.append("/");
00037   subdir_                = ps.getUntrackedParameter<std::string>("DetDiagPedestalFolder","DetDiagPedestalMonitor_Hcal/"); // DetDiagPedestalMonitor_Hcal/
00038   if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
00039     subdir_.append("/");
00040   subdir_=prefixME_+subdir_;
00041 
00042   validHtmlOutput_       = ps.getUntrackedParameter<bool>("DetDiagPedestal_validHtmlOutput",true);
00043   cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
00044   badChannelStatusMask_   = ps.getUntrackedParameter<int>("DetDiagPedestal_BadChannelStatusMask",
00045                            ps.getUntrackedParameter<int>("BadChannelStatusMask",(1<<HcalChannelStatus::HcalCellDead)));
00046   
00047   minerrorrate_ = ps.getUntrackedParameter<double>("DetDiagPedestal_minerrorrate",
00048                                                    ps.getUntrackedParameter<double>("minerrorrate",0.05));
00049   minevents_    = ps.getUntrackedParameter<int>("DetDiagPedestal_minevents",
00050                                                 ps.getUntrackedParameter<int>("minevents",1));
00051   Online_                = ps.getUntrackedParameter<bool>("online",false);
00052 
00053   ProblemCells=0;
00054   ProblemCellsByDepth=0;
00055 }
00056 
00057 void HcalDetDiagPedestalClient::analyze()
00058 {
00059   if (debug_>2) std::cout <<"\tHcalDetDiagPedestalClient::analyze()"<<std::endl;
00060   calculateProblems();
00061 }
00062 
00063 void HcalDetDiagPedestalClient::calculateProblems()
00064 {
00065  if (debug_>2) std::cout <<"\t\tHcalDetDiagPedestalClient::calculateProblems()"<<std::endl;
00066   if(!dqmStore_) return;
00067   double totalevents=0;
00068   int etabins=0, phibins=0, zside=0;
00069   double problemvalue=0;
00070 
00071   // Clear away old problems
00072   if (ProblemCells!=0)
00073     {
00074       ProblemCells->Reset();
00075       (ProblemCells->getTH2F())->SetMaximum(1.05);
00076       (ProblemCells->getTH2F())->SetMinimum(0.);
00077     }
00078   for  (unsigned int d=0;d<ProblemCellsByDepth->depth.size();++d)
00079     {
00080       if (ProblemCellsByDepth->depth[d]!=0) 
00081         {
00082           ProblemCellsByDepth->depth[d]->Reset();
00083           (ProblemCellsByDepth->depth[d]->getTH2F())->SetMaximum(1.05);
00084           (ProblemCellsByDepth->depth[d]->getTH2F())->SetMinimum(0.);
00085         }
00086     }
00087   enoughevents_=true;
00088   // Get histograms that are used in testing
00089   // currently none used,
00090 
00091   std::vector<std::string> name = HcalEtaPhiHistNames();
00092 
00093   // This is a sample of how to get a histogram from the task that can then be used for evaluation purposes
00094   TH2F* PedestalsMissing[4];
00095   TH2F* PedestalsUnstable[4];
00096   TH2F* PedestalsBadMean[4];
00097   TH2F* PedestalsBadRMS[4];
00098   MonitorElement* me;
00099   for (int i=0;i<4;++i)
00100     {
00101       // Assume that histograms aren't found
00102       PedestalsMissing[i]=0;
00103       PedestalsUnstable[i]=0;
00104       PedestalsBadMean[i]=0;
00105       PedestalsBadRMS[i]=0;
00106       std::string s=subdir_+name[i]+" Problem Missing Channels";
00107       me=dqmStore_->get(s.c_str());
00108       if (me!=0) PedestalsMissing[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, PedestalsMissing[i], debug_);
00109       else 
00110         {
00111           if (debug_>0) 
00112             std::cout <<"<HcalDetDiagPedestalClient::calcluateProblems> could not get histogram '"<<s<<"'"<<std::endl;
00113         }
00114 
00115       s=subdir_+name[i]+" Problem Unstable Channels";
00116       me=dqmStore_->get(s.c_str());
00117       if (me!=0) PedestalsUnstable[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, PedestalsUnstable[i], debug_);
00118       else if (debug_>0) std::cout <<"<HcalDetDiagPedestalClient::calculateProblems> could not get histogram '"<<s<<"'"<<std::endl;
00119       s=subdir_+name[i]+" Problem Bad Pedestal Value";
00120       me=dqmStore_->get(s.c_str());
00121       if (me!=0) PedestalsBadMean[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, PedestalsBadMean[i], debug_);
00122       else if (debug_>0) std::cout <<"<HcalDetDiagPedestalClient::calculateProblems> could not get histogram '"<<s<<"'"<<std::endl;
00123       s=subdir_+name[i]+" Problem Bad Rms Value";
00124       me=dqmStore_->get(s.c_str());
00125       if (me!=0) PedestalsBadRMS[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, PedestalsBadRMS[i], debug_);
00126       else if (debug_>0) std::cout <<"<HcalDetDiagPedestalClient::calculateProblems> could not get histogram '"<<s<<"'"<<std::endl;
00127     }      
00128 
00129   // Because we're clearing and re-forming the problem cell histogram here, we don't need to do any cute
00130   // setting of the underflow bin to 0, and we can plot results as a raw rate between 0-1.
00131   
00132   for (unsigned int d=0;d<ProblemCellsByDepth->depth.size();++d)
00133     {
00134       if (ProblemCellsByDepth->depth[d]==0) continue;
00135     
00136       //totalevents=DigiPresentByDepth[d]->GetBinContent(0);
00137       totalevents=0;
00138       // Check underflow bins for events processed
00139       if (PedestalsMissing[d]!=0) totalevents = PedestalsMissing[d]->GetBinContent(0);
00140       else if (PedestalsUnstable[d]!=0) totalevents = PedestalsUnstable[d]->GetBinContent(0);
00141       else if (PedestalsBadMean[d]!=0) totalevents = PedestalsBadMean[d]->GetBinContent(0);
00142       else if (PedestalsBadRMS[d]!=0) totalevents = PedestalsBadRMS[d]->GetBinContent(0);
00143       //if (totalevents==0 || totalevents<minevents_) continue;
00144       
00145       totalevents=1; // temporary value pending removal of normalization from task
00146       etabins=(ProblemCellsByDepth->depth[d]->getTH2F())->GetNbinsX();
00147       phibins=(ProblemCellsByDepth->depth[d]->getTH2F())->GetNbinsY();
00148       for (int eta=0;eta<etabins;++eta)
00149         {
00150           int ieta=CalcIeta(eta,d+1);
00151           if (ieta==-9999) continue;
00152           for (int phi=0;phi<phibins;++phi)
00153             {
00154               problemvalue=0;
00155               if (PedestalsMissing[d]!=0) problemvalue += PedestalsMissing[d]->GetBinContent(eta+1,phi+1)*1./totalevents;
00156               if (PedestalsUnstable[d]!=0) problemvalue += PedestalsUnstable[d]->GetBinContent(eta+1,phi+1)*1./totalevents;
00157               if (PedestalsBadMean[d]!=0) problemvalue += PedestalsBadMean[d]->GetBinContent(eta+1,phi+1)*1./totalevents;
00158               if (PedestalsBadRMS[d]!=0) problemvalue += PedestalsBadRMS[d]->GetBinContent(eta+1,phi+1)*1./totalevents;
00159 
00160               if (problemvalue==0) continue;
00161               // problem value is a rate; we can normalize it here
00162               problemvalue = std::min(1.,problemvalue);
00163               
00164               zside=0;
00165               if (isHF(eta,d+1)) // shift ieta by 1 for HF
00166                 ieta<0 ? zside = -1 : zside = 1;
00167 
00168               // For problem cells that exceed our allowed rate,
00169               // set the values to -1 if the cells are already marked in the status database
00170               if (problemvalue>minerrorrate_)
00171                 {
00172                   HcalSubdetector subdet=HcalEmpty;
00173                   if (isHB(eta,d+1))subdet=HcalBarrel;
00174                   else if (isHE(eta,d+1)) subdet=HcalEndcap;
00175                   else if (isHF(eta,d+1)) subdet=HcalForward;
00176                   else if (isHO(eta,d+1)) subdet=HcalOuter;
00177                   HcalDetId hcalid(subdet, ieta, phi+1, (int)(d+1));
00178                   if (badstatusmap.find(hcalid)!=badstatusmap.end())
00179                     problemvalue=999;
00180                 }
00181 
00182               ProblemCellsByDepth->depth[d]->setBinContent(eta+1,phi+1,problemvalue);
00183               if (ProblemCells!=0) ProblemCells->Fill(ieta+zside,phi+1,problemvalue);
00184             } // loop on phi
00185         } // loop on eta
00186     } // loop on depth
00187 
00188   if (ProblemCells==0)
00189     {
00190       if (debug_>0) std::cout <<"<HcalDetDiagPedestalClient::analyze> ProblemCells histogram does not exist!"<<std::endl;
00191       return;
00192     }
00193 
00194   // Normalization of ProblemCell plot, in the case where there are errors in multiple depths
00195   etabins=(ProblemCells->getTH2F())->GetNbinsX();
00196   phibins=(ProblemCells->getTH2F())->GetNbinsY();
00197   for (int eta=0;eta<etabins;++eta)
00198     {
00199       for (int phi=0;phi<phibins;++phi)
00200         {
00201           if (ProblemCells->getBinContent(eta+1,phi+1)>1. && ProblemCells->getBinContent(eta+1,phi+1)<999)
00202             ProblemCells->setBinContent(eta+1,phi+1,1.);
00203         }
00204     }
00205 
00206   FillUnphysicalHEHFBins(*ProblemCellsByDepth);
00207   FillUnphysicalHEHFBins(ProblemCells);
00208   return;
00209 }
00210 
00211 void HcalDetDiagPedestalClient::beginJob()
00212 {
00213   dqmStore_ = edm::Service<DQMStore>().operator->();
00214   if (debug_>0) 
00215     {
00216       std::cout <<"<HcalDetDiagPedestalClient::beginJob()>  Displaying dqmStore directory structure:"<<std::endl;
00217       dqmStore_->showDirStructure();
00218     }
00219 }
00220 void HcalDetDiagPedestalClient::endJob(){}
00221 
00222 void HcalDetDiagPedestalClient::beginRun(void)
00223 {
00224   enoughevents_=false;
00225   if (!dqmStore_) 
00226     {
00227       if (debug_>0) std::cout <<"<HcalDetDiagPedestalClient::beginRun> dqmStore does not exist!"<<std::endl;
00228       return;
00229     }
00230   dqmStore_->setCurrentFolder(subdir_);
00231   problemnames_.clear();
00232 
00233   // Put the appropriate name of your problem summary here
00234   ProblemCells=dqmStore_->book2D(" ProblemDetDiagPedestal",
00235                                  " Problem DetDiagPedestal Rate for all HCAL;ieta;iphi",
00236                                  85,-42.5,42.5,
00237                                  72,0.5,72.5);
00238   problemnames_.push_back(ProblemCells->getName());
00239   if (debug_>1)
00240     std::cout << "Tried to create ProblemCells Monitor Element in directory "<<subdir_<<"  \t  Failed?  "<<(ProblemCells==0)<<std::endl;
00241   dqmStore_->setCurrentFolder(subdir_+"problem_DetDiagPedestal");
00242   ProblemCellsByDepth = new EtaPhiHists();
00243   ProblemCellsByDepth->setup(dqmStore_," Problem DetDiagPedestal Rate");
00244   for (unsigned int i=0; i<ProblemCellsByDepth->depth.size();++i)
00245     problemnames_.push_back(ProblemCellsByDepth->depth[i]->getName());
00246   nevts_=0;
00247 }
00248 
00249 void HcalDetDiagPedestalClient::endRun(void){analyze();}
00250 
00251 void HcalDetDiagPedestalClient::setup(void){}
00252 void HcalDetDiagPedestalClient::cleanup(void){}
00253 
00254 bool HcalDetDiagPedestalClient::hasErrors_Temp(void)
00255 {
00256     if(status&2) return true;
00257     return false;
00258 
00259   if (!ProblemCells)
00260     {
00261       if (debug_>1) std::cout <<"<HcalDetDiagPedestalClient::hasErrors_Temp>  ProblemCells histogram does not exist!"<<std::endl;
00262       return false;
00263     }
00264   int problemcount=0;
00265   int ieta=-9999;
00266 
00267   for (int depth=0;depth<4; ++depth)
00268     {
00269       int etabins  = (ProblemCells->getTH2F())->GetNbinsX();
00270       int phibins  = (ProblemCells->getTH2F())->GetNbinsY();
00271       for (int hist_eta=0;hist_eta<etabins;++hist_eta)
00272         {
00273           for (int hist_phi=0; hist_phi<phibins;++hist_phi)
00274             {
00275               ieta=CalcIeta(hist_eta,depth+1);
00276               if (ieta==-9999) continue;
00277               if (ProblemCellsByDepth->depth[depth]==0)
00278                   continue;
00279               if (ProblemCellsByDepth->depth[depth]->getBinContent(hist_eta,hist_phi)>minerrorrate_)
00280                 ++problemcount;
00281 
00282             } // for (int hist_phi=1;...)
00283         } // for (int hist_eta=1;...)
00284     } // for (int depth=0;...)
00285 
00286   if (problemcount>0) return true;
00287   return false;
00288 }
00289 
00290 bool HcalDetDiagPedestalClient::hasWarnings_Temp(void){
00291    if(status&1) return true;
00292    return false;
00293 }
00294 bool HcalDetDiagPedestalClient::hasOther_Temp(void){return false;}
00295 bool HcalDetDiagPedestalClient::test_enabled(void){return true;}
00296 
00297 
00298 void HcalDetDiagPedestalClient::updateChannelStatus(std::map<HcalDetId, unsigned int>& myqual)
00299 {
00300   // This gets called by HcalMonitorClient
00301   // trigger primitives don't yet contribute to channel status (though they could...)
00302   // see dead or hot cell code for an example
00303 
00304 } //void HcalDetDiagPedestalClient::updateChannelStatus
00305 
00306 static void printTableHeader(ofstream& file,std::string  header){
00307   file << "</html><html xmlns=\"https://www.w3.org/1999/xhtml\">"<< std::endl;
00308      file << "<head>"<< std::endl;
00309      file << "<meta https-equiv=\"Content-Type\" content=\"text/html\"/>"<< std::endl;
00310      file << "<title>"<< header <<"</title>"<< std::endl;
00311      file << "<style type=\"text/css\">"<< std::endl;
00312      file << " body,td{ background-color: #FFFFCC; font-family: arial, arial ce, helvetica; font-size: 12px; }"<< std::endl;
00313      file << "   td.s0 { font-family: arial, arial ce, helvetica; }"<< std::endl;
00314      file << "   td.s1 { font-family: arial, arial ce, helvetica; font-weight: bold; background-color: #FFC169; text-align: center;}"<< std::endl;
00315      file << "   td.s2 { font-family: arial, arial ce, helvetica; background-color: #eeeeee; }"<< std::endl;
00316      file << "   td.s3 { font-family: arial, arial ce, helvetica; background-color: #d0d0d0; }"<< std::endl;
00317      file << "   td.s4 { font-family: arial, arial ce, helvetica; background-color: #FFC169; }"<< std::endl;
00318      file << "</style>"<< std::endl;
00319      file << "<body>"<< std::endl;
00320      file << "<table>"<< std::endl;
00321 }
00322 
00323 static void printTableLine(ofstream& file,int ind,HcalDetId& detid,HcalFrontEndId& lmap_entry,HcalElectronicsId &emap_entry,std::string comment=""){
00324    if(ind==0){
00325      file << "<tr>";
00326      file << "<td class=\"s4\" align=\"center\">#</td>"    << std::endl;
00327      file << "<td class=\"s1\" align=\"center\">ETA</td>"  << std::endl;
00328      file << "<td class=\"s1\" align=\"center\">PHI</td>"  << std::endl;
00329      file << "<td class=\"s1\" align=\"center\">DEPTH</td>"<< std::endl;
00330      file << "<td class=\"s1\" align=\"center\">RBX</td>"  << std::endl;
00331      file << "<td class=\"s1\" align=\"center\">RM</td>"   << std::endl;
00332      file << "<td class=\"s1\" align=\"center\">PIXEL</td>"   << std::endl;
00333      file << "<td class=\"s1\" align=\"center\">RM_FIBER</td>"   << std::endl;
00334      file << "<td class=\"s1\" align=\"center\">FIBER_CH</td>"   << std::endl;
00335      file << "<td class=\"s1\" align=\"center\">QIE</td>"   << std::endl;
00336      file << "<td class=\"s1\" align=\"center\">ADC</td>"   << std::endl;
00337      file << "<td class=\"s1\" align=\"center\">CRATE</td>"   << std::endl;
00338      file << "<td class=\"s1\" align=\"center\">DCC</td>"   << std::endl;
00339      file << "<td class=\"s1\" align=\"center\">SPIGOT</td>"   << std::endl;
00340      file << "<td class=\"s1\" align=\"center\">HTR_FIBER</td>"   << std::endl;
00341      file << "<td class=\"s1\" align=\"center\">HTR_SLOT</td>"   << std::endl;
00342      file << "<td class=\"s1\" align=\"center\">HTR_FPGA</td>"   << std::endl;
00343      if(comment[0]!=0) file << "<td class=\"s1\" align=\"center\">Comment</td>"   << std::endl;
00344      file << "</tr>"   << std::endl;
00345    }
00346    std::string raw_class;
00347    file << "<tr>"<< std::endl;
00348    if((ind%2)==1){
00349       raw_class="<td class=\"s2\" align=\"center\">";
00350    }else{
00351       raw_class="<td class=\"s3\" align=\"center\">";
00352    }
00353    file << "<td class=\"s4\" align=\"center\">" << ind+1 <<"</td>"<< std::endl;
00354    file << raw_class<< detid.ieta()<<"</td>"<< std::endl;
00355    file << raw_class<< detid.iphi()<<"</td>"<< std::endl;
00356    file << raw_class<< detid.depth() <<"</td>"<< std::endl;
00357    file << raw_class<< lmap_entry.rbx()<<"</td>"<< std::endl;
00358    file << raw_class<< lmap_entry.rm() <<"</td>"<< std::endl;
00359    file << raw_class<< lmap_entry.pixel()<<"</td>"<< std::endl;
00360    file << raw_class<< lmap_entry.rmFiber() <<"</td>"<< std::endl;
00361    file << raw_class<< lmap_entry.fiberChannel()<<"</td>"<< std::endl;
00362    file << raw_class<< lmap_entry.qieCard() <<"</td>"<< std::endl;
00363    file << raw_class<< lmap_entry.adc()<<"</td>"<< std::endl;
00364    file << raw_class<< emap_entry.readoutVMECrateId()<<"</td>"<< std::endl;
00365    file << raw_class<< emap_entry.dccid()<<"</td>"<< std::endl;
00366    file << raw_class<< emap_entry.spigot()<<"</td>"<< std::endl;
00367    file << raw_class<< emap_entry.fiberIndex()<<"</td>"<< std::endl;
00368    file << raw_class<< emap_entry.htrSlot()<<"</td>"<< std::endl;
00369    file << raw_class<< emap_entry.htrTopBottom()<<"</td>"<< std::endl;
00370    if(comment[0]!=0) file << raw_class<< comment<<"</td>"<< std::endl;
00371 }
00372 static void printTableTail(ofstream& file){
00373      file << "</table>"<< std::endl;
00374      file << "</body>"<< std::endl;
00375      file << "</html>"<< std::endl;
00376 }
00377 
00378 bool HcalDetDiagPedestalClient::validHtmlOutput(){
00379   std::string s=subdir_+"HcalDetDiagPedestalMonitor Event Number";
00380   MonitorElement *me = dqmStore_->get(s.c_str());
00381   int n=0;
00382   if ( me ) {
00383     s = me->valueString();
00384     sscanf((s.substr(2,s.length()-2)).c_str(), "%d", &n);
00385   }
00386   if(n<100) return false;
00387   return true;
00388 }
00389 
00390 void HcalDetDiagPedestalClient::htmlOutput(std::string htmlDir){
00391 int  MissingCnt=0,UnstableCnt=0,BadCnt=0; 
00392 int  HBP[4]={0,0,0,0},HBM[4]={0,0,0,0},HEP[4]={0,0,0,0},HEM[4]={0,0,0,0},HFP[4]={0,0,0,0},HFM[4]={0,0,0,0},HO[4] ={0,0,0,0}; 
00393 int  newHBP[4]={0,0,0,0},newHBM[4]={0,0,0,0},newHEP[4]={0,0,0,0},newHEM[4]={0,0,0,0};
00394 int  newHFP[4]={0,0,0,0},newHFM[4]={0,0,0,0},newHO[4] ={0,0,0,0}; 
00395  if (debug_>0) std::cout << "<HcalDetDiagPedestalClient::htmlOutput> Preparing  html output ..." << std::endl;
00396   if(!dqmStore_) return;
00397 
00398   HcalLogicalMapGenerator gen;
00399   HcalLogicalMap lmap(gen.createMap());
00400   HcalElectronicsMap emap=lmap.generateHcalElectronicsMap();
00401   TH2F *Missing_val[4],*Unstable_val[4],*BadPed_val[4],*BadRMS_val[4];
00402   MonitorElement* me;
00403 
00404 
00405   TH1F *PedestalsAve4HB=0;
00406   TH1F *PedestalsAve4HE=0;
00407   TH1F *PedestalsAve4HO=0;
00408   TH1F *PedestalsAve4HF=0;
00409   TH1F *PedestalsAve4Simp=0;
00410  
00411   TH1F *PedestalsAve4HBref=0;
00412   TH1F *PedestalsAve4HEref=0;
00413   TH1F *PedestalsAve4HOref=0;
00414   TH1F *PedestalsAve4HFref=0;
00415   TH1F *PedestalsRmsHB=0;
00416   TH1F *PedestalsRmsHE=0;
00417   TH1F *PedestalsRmsHO=0;
00418   TH1F *PedestalsRmsHF=0;
00419   TH1F *PedestalsRmsSimp=0;
00420   
00421   TH1F *PedestalsRmsHBref=0;
00422   TH1F *PedestalsRmsHEref=0;
00423   TH1F *PedestalsRmsHOref=0;
00424   TH1F *PedestalsRmsHFref=0;
00425   
00426   TH2F *Pedestals2DRmsHBHEHF=0;
00427   TH2F *Pedestals2DRmsHO=0;
00428   TH2F *Pedestals2DHBHEHF=0;
00429   TH2F *Pedestals2DHO=0;
00430   TH2F *Pedestals2DErrorHBHEHF=0;
00431   TH2F *Pedestals2DErrorHO=0;
00432 
00433   std::string s=subdir_+"Summary Plots/HB Pedestal Distribution (average over 4 caps)"; me=dqmStore_->get(s.c_str());
00434   if(me!=0) PedestalsAve4HB=HcalUtilsClient::getHisto<TH1F*>(me, cloneME_, PedestalsAve4HB, debug_); else return;
00435   s=subdir_+"Summary Plots/HE Pedestal Distribution (average over 4 caps)"; me=dqmStore_->get(s.c_str()); 
00436   if(me!=0) PedestalsAve4HE=HcalUtilsClient::getHisto<TH1F*>(me, cloneME_, PedestalsAve4HE, debug_);  else return; 
00437   s=subdir_+"Summary Plots/HO Pedestal Distribution (average over 4 caps)"; me=dqmStore_->get(s.c_str()); 
00438   if(me!=0) PedestalsAve4HO=HcalUtilsClient::getHisto<TH1F*>(me, cloneME_, PedestalsAve4HO, debug_);  else return; 
00439   s=subdir_+"Summary Plots/HF Pedestal Distribution (average over 4 caps)"; me=dqmStore_->get(s.c_str()); 
00440   if(me!=0) PedestalsAve4HF=HcalUtilsClient::getHisto<TH1F*>(me, cloneME_, PedestalsAve4HF, debug_);  else return; 
00441   s=subdir_+"Summary Plots/SIPM Pedestal Distribution (average over 4 caps)"; me=dqmStore_->get(s.c_str()); 
00442   if(me!=0) PedestalsAve4Simp=HcalUtilsClient::getHisto<TH1F*>(me, cloneME_, PedestalsAve4Simp, debug_); else return; 
00443  
00444   s=subdir_+"Summary Plots/HB Pedestal-Reference Distribution (average over 4 caps)"; me=dqmStore_->get(s.c_str()); 
00445   if(me!=0) PedestalsAve4HBref=HcalUtilsClient::getHisto<TH1F*>(me, cloneME_, PedestalsAve4HBref, debug_); else return;  
00446   s=subdir_+"Summary Plots/HE Pedestal-Reference Distribution (average over 4 caps)"; me=dqmStore_->get(s.c_str()); 
00447   if(me!=0) PedestalsAve4HEref=HcalUtilsClient::getHisto<TH1F*>(me, cloneME_, PedestalsAve4HEref, debug_); else return; 
00448   s=subdir_+"Summary Plots/HO Pedestal-Reference Distribution (average over 4 caps)"; me=dqmStore_->get(s.c_str()); 
00449   if(me!=0) PedestalsAve4HOref=HcalUtilsClient::getHisto<TH1F*>(me, cloneME_, PedestalsAve4HOref, debug_); else return;  
00450   s=subdir_+"Summary Plots/HF Pedestal-Reference Distribution (average over 4 caps)"; me=dqmStore_->get(s.c_str()); 
00451   if(me!=0) PedestalsAve4HFref=HcalUtilsClient::getHisto<TH1F*>(me, cloneME_, PedestalsAve4HFref, debug_); else return;  
00452    
00453   s=subdir_+"Summary Plots/HB Pedestal RMS Distribution (individual cap)"; me=dqmStore_->get(s.c_str()); 
00454   if(me!=0) PedestalsRmsHB=HcalUtilsClient::getHisto<TH1F*>(me, cloneME_, PedestalsRmsHB, debug_);  else return; 
00455   s=subdir_+"Summary Plots/HE Pedestal RMS Distribution (individual cap)"; me=dqmStore_->get(s.c_str()); 
00456   if(me!=0) PedestalsRmsHE=HcalUtilsClient::getHisto<TH1F*>(me, cloneME_, PedestalsRmsHE, debug_);  else return; 
00457   s=subdir_+"Summary Plots/HO Pedestal RMS Distribution (individual cap)"; me=dqmStore_->get(s.c_str()); 
00458   if(me!=0) PedestalsRmsHO=HcalUtilsClient::getHisto<TH1F*>(me, cloneME_, PedestalsRmsHO, debug_);  else return; 
00459   s=subdir_+"Summary Plots/HF Pedestal RMS Distribution (individual cap)"; me=dqmStore_->get(s.c_str()); 
00460   if(me!=0) PedestalsRmsHF=HcalUtilsClient::getHisto<TH1F*>(me, cloneME_, PedestalsRmsHF, debug_);  else return; 
00461   s=subdir_+"Summary Plots/SIPM Pedestal RMS Distribution (individual cap)"; me=dqmStore_->get(s.c_str()); 
00462   if(me!=0) PedestalsRmsSimp=HcalUtilsClient::getHisto<TH1F*>(me, cloneME_, PedestalsRmsSimp, debug_);  else return; 
00463    
00464   s=subdir_+"Summary Plots/HB Pedestal_rms-Reference_rms Distribution"; me=dqmStore_->get(s.c_str()); 
00465   if(me!=0) PedestalsRmsHBref=HcalUtilsClient::getHisto<TH1F*>(me, cloneME_, PedestalsRmsHBref, debug_);  else return; 
00466   s=subdir_+"Summary Plots/HE Pedestal_rms-Reference_rms Distribution"; me=dqmStore_->get(s.c_str()); 
00467   if(me!=0) PedestalsRmsHEref=HcalUtilsClient::getHisto<TH1F*>(me, cloneME_, PedestalsRmsHEref, debug_);  else return; 
00468   s=subdir_+"Summary Plots/HO Pedestal_rms-Reference_rms Distribution"; me=dqmStore_->get(s.c_str()); 
00469   if(me!=0) PedestalsRmsHOref=HcalUtilsClient::getHisto<TH1F*>(me, cloneME_, PedestalsRmsHOref, debug_);  else return; 
00470   s=subdir_+"Summary Plots/HF Pedestal_rms-Reference_rms Distribution"; me=dqmStore_->get(s.c_str()); 
00471   if(me!=0) PedestalsRmsHFref=HcalUtilsClient::getHisto<TH1F*>(me, cloneME_, PedestalsRmsHFref, debug_);  else return; 
00472      
00473   s=subdir_+"Summary Plots/HBHEHF pedestal mean map"; me=dqmStore_->get(s.c_str()); 
00474   if(me!=0) Pedestals2DHBHEHF=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, Pedestals2DHBHEHF, debug_); else return;  
00475   s=subdir_+"Summary Plots/HO pedestal mean map"; me=dqmStore_->get(s.c_str()); 
00476   if(me!=0) Pedestals2DHO=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, Pedestals2DHO, debug_);  else return; 
00477   s=subdir_+"Summary Plots/HBHEHF pedestal rms map"; me=dqmStore_->get(s.c_str()); 
00478   if(me!=0) Pedestals2DRmsHBHEHF=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, Pedestals2DRmsHBHEHF, debug_); else return;  
00479   s=subdir_+"Summary Plots/HO pedestal rms map"; me=dqmStore_->get(s.c_str()); 
00480   if(me!=0) Pedestals2DRmsHO=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, Pedestals2DRmsHO, debug_);  else return; 
00481   s=subdir_+"Summary Plots/HBHEHF pedestal problems map"; me=dqmStore_->get(s.c_str()); 
00482   if(me!=0) Pedestals2DErrorHBHEHF=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, Pedestals2DErrorHBHEHF, debug_);  else return; 
00483   s=subdir_+"Summary Plots/HO pedestal problems map"; me=dqmStore_->get(s.c_str()); 
00484   if(me!=0) Pedestals2DErrorHO=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, Pedestals2DErrorHO, debug_); else return;  
00485 
00486 
00487   std::vector<std::string> name = HcalEtaPhiHistNames();
00488   for(int i=0;i<4;++i){
00489       Missing_val[i]=Unstable_val[i]=BadPed_val[i]=BadRMS_val[i]=0;
00490       std::string s=subdir_+"Plots for client/"+name[i]+" Missing channels";
00491       me=dqmStore_->get(s.c_str());
00492       if (me!=0) Missing_val[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, Missing_val[i], debug_); else return;  
00493       s=subdir_+"Plots for client/"+name[i]+" Channel instability value";
00494       me=dqmStore_->get(s.c_str());
00495       if (me!=0) Unstable_val[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, Unstable_val[i], debug_); else return;  
00496       s=subdir_+"Plots for client/"+name[i]+" Bad Pedestal-Ref Value";
00497       me=dqmStore_->get(s.c_str());
00498       if (me!=0) BadPed_val[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, BadPed_val[i], debug_); else return;  
00499       s=subdir_+"Plots for client/"+name[i]+" Bad Rms-ref Value";
00500       me=dqmStore_->get(s.c_str());
00501       if (me!=0) BadRMS_val[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, BadRMS_val[i], debug_); else return;  
00502   }
00503   // Calculate problems 
00504   for(int d=0;d<4;++d){
00505       int etabins=Missing_val[d]->GetNbinsX();
00506       int phibins=Missing_val[d]->GetNbinsY();
00507       for(int phi=0;phi<phibins;++phi)for(int eta=0;eta<etabins;++eta){
00508           int ieta=CalcIeta(eta,d+1);
00509           if(ieta==-9999) continue;
00510           HcalSubdetector subdet=HcalEmpty;
00511           if(isHB(eta,d+1))subdet=HcalBarrel;
00512              else if (isHE(eta,d+1)) subdet=HcalEndcap;
00513              else if (isHF(eta,d+1)) subdet=HcalForward;
00514              else if (isHO(eta,d+1)) subdet=HcalOuter;
00515           HcalDetId hcalid(subdet, ieta, phi+1, (int)(d+1));
00516           float val=Missing_val[d]->GetBinContent(eta+1,phi+1);
00517           if(val!=0){
00518             if(subdet==HcalBarrel){
00519                if(ieta>0){ HBP[0]++;}else{ HBM[0]++;} MissingCnt++;
00520                if(badstatusmap.find(hcalid)==badstatusmap.end()){if(ieta>0){ newHBP[0]++;}else{ newHBM[0]++;}}
00521             }   
00522             if(subdet==HcalEndcap){
00523                if(ieta>0){ HEP[0]++;}else{ HEM[0]++;} MissingCnt++;
00524                if(badstatusmap.find(hcalid)==badstatusmap.end()){if(ieta>0){ newHEP[0]++;}else{ newHEM[0]++;}}
00525             }   
00526             if(subdet==HcalForward){
00527                if(ieta>0){ HFP[0]++;}else{ HFM[0]++;} MissingCnt++;
00528                if(badstatusmap.find(hcalid)==badstatusmap.end()){if(ieta>0){ newHFP[0]++;}else{ newHFM[0]++;}}
00529             }   
00530             if(subdet==HcalOuter){
00531                HO[0]++;MissingCnt++;
00532                if(badstatusmap.find(hcalid)==badstatusmap.end()){newHO[0]++;}
00533             }   
00534          }
00535          val=Unstable_val[d]->GetBinContent(eta+1,phi+1);
00536          if(val!=0){
00537             if(subdet==HcalBarrel){
00538                if(ieta>0){ HBP[1]++;}else{ HBM[1]++;} UnstableCnt++;
00539                if(badstatusmap.find(hcalid)==badstatusmap.end()){if(ieta>0){ newHBP[1]++;}else{ newHBM[1]++;}}
00540             }   
00541             if(subdet==HcalEndcap){
00542                if(ieta>0){ HEP[1]++;}else{ HEM[1]++;} UnstableCnt++;
00543                if(badstatusmap.find(hcalid)==badstatusmap.end()){if(ieta>0){ newHEP[1]++;}else{ newHEM[1]++;}}
00544             }   
00545             if(subdet==HcalForward){
00546                if(ieta>0){ HFP[1]++;}else{ HFM[1]++;} UnstableCnt++;
00547                if(badstatusmap.find(hcalid)==badstatusmap.end()){if(ieta>0){ newHFP[1]++;}else{ newHFM[1]++;}}
00548             }   
00549             if(subdet==HcalOuter){
00550                HO[1]++;UnstableCnt++;
00551                if(badstatusmap.find(hcalid)==badstatusmap.end()){newHO[1]++;}
00552             }   
00553          }
00554          val=BadPed_val[d]->GetBinContent(eta+1,phi+1);
00555          if(val!=0){
00556             if(subdet==HcalBarrel){
00557                if(ieta>0){ HBP[2]++;}else{ HBM[2]++;} BadCnt++;
00558                if(badstatusmap.find(hcalid)==badstatusmap.end()){if(ieta>0){ newHBP[2]++;}else{ newHBM[2]++;}}
00559             }   
00560             if(subdet==HcalEndcap){
00561                if(ieta>0){ HEP[2]++;}else{ HEM[2]++;} BadCnt++;
00562                if(badstatusmap.find(hcalid)==badstatusmap.end()){if(ieta>0){ newHEP[2]++;}else{ newHEM[2]++;}}
00563             }   
00564             if(subdet==HcalForward){
00565                if(ieta>0){ HFP[2]++;}else{ HFM[2]++;} BadCnt++;
00566                if(badstatusmap.find(hcalid)==badstatusmap.end()){if(ieta>0){ newHFP[2]++;}else{ newHFM[2]++;}}
00567             }   
00568             if(subdet==HcalOuter){
00569                HO[2]++;BadCnt++;
00570                if(badstatusmap.find(hcalid)==badstatusmap.end()){newHO[2]++;}
00571             }   
00572          }
00573          val=BadRMS_val[d]->GetBinContent(eta+1,phi+1);
00574          if(val!=0){
00575             if(subdet==HcalBarrel){
00576                if(ieta>0){ HBP[3]++;}else{ HBM[3]++;} BadCnt++;
00577                if(badstatusmap.find(hcalid)==badstatusmap.end()){if(ieta>0){ newHBP[3]++;}else{ newHBM[3]++;}}
00578             }   
00579             if(subdet==HcalEndcap){
00580                if(ieta>0){ HEP[3]++;}else{ HEM[3]++;} BadCnt++;
00581                if(badstatusmap.find(hcalid)==badstatusmap.end()){if(ieta>0){ newHEP[3]++;}else{ newHEM[3]++;}}
00582             }   
00583             if(subdet==HcalForward){
00584                if(ieta>0){ HFP[3]++;}else{ HFM[3]++;} BadCnt++;
00585                if(badstatusmap.find(hcalid)==badstatusmap.end()){if(ieta>0){ newHFP[3]++;}else{ newHFM[3]++;}}
00586             }   
00587             if(subdet==HcalOuter){
00588                HO[3]++;BadCnt++;
00589                if(badstatusmap.find(hcalid)==badstatusmap.end()){newHO[3]++;}
00590             }   
00591          }
00592       } 
00593   } 
00594 
00595 
00596   ofstream badMissing; 
00597   badMissing.open((htmlDir+"bad_missing_table.html").c_str());
00598   printTableHeader(badMissing,"Missing Channels list");
00599   ofstream badUnstable; 
00600   badUnstable.open((htmlDir+"bad_unstable_table.html").c_str());
00601   printTableHeader(badUnstable,"Unstable Channels list");
00602   ofstream badPedRMS; 
00603   badPedRMS.open((htmlDir+"bad_badpedrms_table.html").c_str());
00604   printTableHeader(badPedRMS,"Missing Channels list");
00605 
00606   int cnt=0;
00607   if((HBP[0]+HBP[0])>0 && (HBM[0]+HBP[0])!=(1296*2)){
00608     badMissing << "<tr><td align=\"center\"><h3>"<< "HB" <<"</h3></td></tr>" << std::endl;
00609     for(int d=0;d<4;++d){
00610       int etabins=Missing_val[d]->GetNbinsX();
00611       int phibins=Missing_val[d]->GetNbinsY();
00612       for(int phi=0;phi<phibins;++phi)for(int eta=0;eta<etabins;++eta){
00613           int ieta=CalcIeta(eta,d+1);
00614           if(ieta==-9999) continue;
00615           if(!isHB(eta,d+1)) continue;
00616           float val=Missing_val[d]->GetBinContent(eta+1,phi+1);
00617           if(val==0) continue;
00618           HcalDetId hcalid(HcalBarrel,ieta,phi+1,d+1);
00619           std::string s=" ";
00620           if(badstatusmap.find(hcalid)!=badstatusmap.end()){ s="Known problem";}        
00621           HcalFrontEndId    lmap_entry=lmap.getHcalFrontEndId(hcalid);
00622           HcalElectronicsId emap_entry=emap.lookup(hcalid);
00623           printTableLine(badMissing,cnt++,hcalid,lmap_entry,emap_entry,s);
00624       } 
00625     } 
00626   }
00627   cnt=0;
00628   if((HEP[0]+HEP[0])>0 && (HEM[0]+HEP[0])!=(1296*2)){
00629     badMissing << "<tr><td align=\"center\"><h3>"<< "HE" <<"</h3></td></tr>" << std::endl;
00630     for(int d=0;d<4;++d){
00631       int etabins=Missing_val[d]->GetNbinsX();
00632       int phibins=Missing_val[d]->GetNbinsY();
00633       for(int phi=0;phi<phibins;++phi)for(int eta=0;eta<etabins;++eta){
00634           int ieta=CalcIeta(eta,d+1);
00635           if(ieta==-9999) continue;
00636           if(!isHE(eta,d+1)) continue;
00637           float val=Missing_val[d]->GetBinContent(eta+1,phi+1);
00638           if(val==0) continue;
00639           HcalDetId hcalid(HcalEndcap,ieta,phi+1,d+1);
00640           std::string s=" ";
00641           if(badstatusmap.find(hcalid)!=badstatusmap.end()){ s="Known problem";}        
00642           HcalFrontEndId    lmap_entry=lmap.getHcalFrontEndId(hcalid);
00643           HcalElectronicsId emap_entry=emap.lookup(hcalid);
00644           printTableLine(badMissing,cnt++,hcalid,lmap_entry,emap_entry,s);
00645       } 
00646     } 
00647   }
00648   cnt=0;
00649   if(HO[0]>0 && HO[0]!=2160){
00650     badMissing << "<tr><td align=\"center\"><h3>"<< "HO" <<"</h3></td></tr>" << std::endl;
00651     for(int d=0;d<4;++d){
00652       int etabins=Missing_val[d]->GetNbinsX();
00653       int phibins=Missing_val[d]->GetNbinsY();
00654       for(int phi=0;phi<phibins;++phi)for(int eta=0;eta<etabins;++eta){
00655           int ieta=CalcIeta(eta,d+1);
00656           if(ieta==-9999) continue;
00657           if(!isHO(eta,d+1)) continue;
00658           float val=Missing_val[d]->GetBinContent(eta+1,phi+1);
00659           if(val==0) continue;
00660           HcalDetId hcalid(HcalOuter,ieta,phi+1,d+1);
00661           std::string s=" ";
00662           if(badstatusmap.find(hcalid)!=badstatusmap.end()){ s="Known problem";}
00663           HcalFrontEndId    lmap_entry=lmap.getHcalFrontEndId(hcalid);
00664           HcalElectronicsId emap_entry=emap.lookup(hcalid);
00665           printTableLine(badMissing,cnt++,hcalid,lmap_entry,emap_entry,s);
00666       } 
00667     } 
00668   }
00669   cnt=0;
00670   if((HFP[0]+HFP[0])>0 && (HFM[0]+HFP[0])!=(864*2)){
00671     badMissing << "<tr><td align=\"center\"><h3>"<< "HF" <<"</h3></td></tr>" << std::endl;
00672     for(int d=0;d<4;++d){
00673       int etabins=Missing_val[d]->GetNbinsX();
00674       int phibins=Missing_val[d]->GetNbinsY();
00675       for(int phi=0;phi<phibins;++phi)for(int eta=0;eta<etabins;++eta){
00676           int ieta=CalcIeta(eta,d+1);
00677           if(ieta==-9999) continue;
00678           if(!isHF(eta,d+1)) continue;
00679           float val=Missing_val[d]->GetBinContent(eta+1,phi+1);
00680           if(val==0) continue;
00681           HcalDetId hcalid(HcalForward,ieta,phi+1,d+1);
00682           std::string s=" ";
00683           if(badstatusmap.find(hcalid)!=badstatusmap.end()){ s="Known problem";}        
00684           HcalFrontEndId    lmap_entry=lmap.getHcalFrontEndId(hcalid);
00685           HcalElectronicsId emap_entry=emap.lookup(hcalid);
00686           printTableLine(badMissing,cnt++,hcalid,lmap_entry,emap_entry,s);
00687       } 
00688     } 
00689   }
00691   cnt=0;
00692   if((HBP[1]+HBP[1])>0){
00693     badUnstable << "<tr><td align=\"center\"><h3>"<< "HB" <<"</h3></td></tr>" << std::endl;
00694     for(int d=0;d<4;++d){
00695       int etabins=Unstable_val[d]->GetNbinsX();
00696       int phibins=Unstable_val[d]->GetNbinsY();
00697       for(int phi=0;phi<phibins;++phi)for(int eta=0;eta<etabins;++eta){
00698           int ieta=CalcIeta(eta,d+1);
00699           if(ieta==-9999) continue;
00700           if(!isHB(eta,d+1)) continue;
00701           float val=Unstable_val[d]->GetBinContent(eta+1,phi+1);
00702           if(val==0) continue;
00703           HcalDetId hcalid(HcalBarrel,ieta,phi+1,d+1);
00704           char comment[100]; sprintf(comment,"Missing in %.3f%% of events\n",(1.0-val)*100.0);
00705           std::string s=comment;
00706           if(badstatusmap.find(hcalid)!=badstatusmap.end()){ s+=",Known problem";}      
00707           HcalFrontEndId    lmap_entry=lmap.getHcalFrontEndId(hcalid);
00708           HcalElectronicsId emap_entry=emap.lookup(hcalid);
00709           printTableLine(badUnstable,cnt++,hcalid,lmap_entry,emap_entry,s);
00710       } 
00711     } 
00712   }
00713   cnt=0;
00714   if((HEP[1]+HEP[1])>0){
00715     badUnstable << "<tr><td align=\"center\"><h3>"<< "HE" <<"</h3></td></tr>" << std::endl;
00716     for(int d=0;d<4;++d){
00717       int etabins=Unstable_val[d]->GetNbinsX();
00718       int phibins=Unstable_val[d]->GetNbinsY();
00719       for(int phi=0;phi<phibins;++phi)for(int eta=0;eta<etabins;++eta){
00720           int ieta=CalcIeta(eta,d+1);
00721           if(ieta==-9999) continue;
00722           if(!isHE(eta,d+1)) continue;
00723           float val=Unstable_val[d]->GetBinContent(eta+1,phi+1);
00724           if(val==0) continue;
00725           HcalDetId hcalid(HcalEndcap,ieta,phi+1,d+1);
00726           char comment[100]; sprintf(comment,"Missing in %.3f%% of events\n",(1.0-val)*100.0);
00727           std::string s=comment;
00728           if(badstatusmap.find(hcalid)!=badstatusmap.end()){ s+=",Known problem";}      
00729           HcalFrontEndId    lmap_entry=lmap.getHcalFrontEndId(hcalid);
00730           HcalElectronicsId emap_entry=emap.lookup(hcalid);
00731           printTableLine(badUnstable,cnt++,hcalid,lmap_entry,emap_entry,s);
00732       } 
00733     } 
00734   }
00735   cnt=0;
00736   if(HO[1]>0){
00737     badUnstable << "<tr><td align=\"center\"><h3>"<< "HO" <<"</h3></td></tr>" << std::endl;
00738     for(int d=0;d<4;++d){
00739       int etabins=Unstable_val[d]->GetNbinsX();
00740       int phibins=Unstable_val[d]->GetNbinsY();
00741       for(int phi=0;phi<phibins;++phi)for(int eta=0;eta<etabins;++eta){
00742           int ieta=CalcIeta(eta,d+1);
00743           if(ieta==-9999) continue;
00744           if(!isHO(eta,d+1)) continue;
00745           float val=Unstable_val[d]->GetBinContent(eta+1,phi+1);
00746           if(val==0) continue;
00747           HcalDetId hcalid(HcalOuter,ieta,phi+1,d+1);
00748           char comment[100]; sprintf(comment,"Missing in %.3f%% of events\n",(1.0-val)*100.0);
00749           std::string s=comment;
00750           if(badstatusmap.find(hcalid)!=badstatusmap.end()){ s+=",Known problem";}
00751           HcalFrontEndId    lmap_entry=lmap.getHcalFrontEndId(hcalid);
00752           HcalElectronicsId emap_entry=emap.lookup(hcalid);
00753           printTableLine(badUnstable,cnt++,hcalid,lmap_entry,emap_entry,s);
00754       } 
00755     } 
00756   }
00757   cnt=0;
00758   if((HFP[1]+HFP[1])>0){
00759     badUnstable << "<tr><td align=\"center\"><h3>"<< "HF" <<"</h3></td></tr>" << std::endl;
00760     for(int d=0;d<4;++d){
00761       int etabins=Unstable_val[d]->GetNbinsX();
00762       int phibins=Unstable_val[d]->GetNbinsY();
00763       for(int phi=0;phi<phibins;++phi)for(int eta=0;eta<etabins;++eta){
00764           int ieta=CalcIeta(eta,d+1);
00765           if(ieta==-9999) continue;
00766           if(!isHF(eta,d+1)) continue;
00767           float val=Unstable_val[d]->GetBinContent(eta+1,phi+1);
00768           if(val==0) continue;
00769           HcalDetId hcalid(HcalForward,ieta,phi+1,d+1);
00770           char comment[100]; sprintf(comment,"Missing in %.3f%% of events\n",(1.0-val)*100.0);
00771           std::string s=comment;
00772           if(badstatusmap.find(hcalid)!=badstatusmap.end()){ s+=",Known problem";}      
00773           HcalFrontEndId    lmap_entry=lmap.getHcalFrontEndId(hcalid);
00774           HcalElectronicsId emap_entry=emap.lookup(hcalid);
00775           printTableLine(badUnstable,cnt++,hcalid,lmap_entry,emap_entry,s);
00776       } 
00777     } 
00778   }
00780   cnt=0;
00781   if((HBP[2]+HBP[2]+HBP[3]+HBP[3])>0){
00782     badPedRMS << "<tr><td align=\"center\"><h3>"<< "HB" <<"</h3></td></tr>" << std::endl;
00783     for(int d=0;d<4;++d){
00784       int etabins=BadPed_val[d]->GetNbinsX();
00785       int phibins=BadPed_val[d]->GetNbinsY();
00786       for(int phi=0;phi<phibins;++phi)for(int eta=0;eta<etabins;++eta){
00787           int ieta=CalcIeta(eta,d+1);
00788           if(ieta==-9999) continue;
00789           if(!isHB(eta,d+1)) continue;
00790           float val1=BadPed_val[d]->GetBinContent(eta+1,phi+1);
00791           float val2=BadRMS_val[d]->GetBinContent(eta+1,phi+1);
00792           if(val1==0 && val2==0) continue;
00793           HcalDetId hcalid(HcalBarrel,ieta,phi+1,d+1);
00794           char comment[100]; 
00795           if(val1!=0) sprintf(comment,"Ped-Ref=%.2f",val1);
00796           if(val2!=0) sprintf(comment,"Rms-Ref=%.2f",val2);
00797           if(val1!=0 && val2!=0) sprintf(comment,"Ped-Ref=%.2f,Rms-Ref=%.2f",val1,val2);
00798           std::string s=comment;
00799           if(badstatusmap.find(hcalid)!=badstatusmap.end()){ s+=",Known problem";}      
00800           HcalFrontEndId    lmap_entry=lmap.getHcalFrontEndId(hcalid);
00801           HcalElectronicsId emap_entry=emap.lookup(hcalid);
00802           printTableLine(badPedRMS,cnt++,hcalid,lmap_entry,emap_entry,s);
00803       } 
00804     } 
00805   }
00806   cnt=0;
00807   if((HEP[2]+HEP[2]+HEP[3]+HEP[3])>0){
00808     badPedRMS << "<tr><td align=\"center\"><h3>"<< "HE" <<"</h3></td></tr>" << std::endl;
00809     for(int d=0;d<4;++d){
00810       int etabins=BadPed_val[d]->GetNbinsX();
00811       int phibins=BadPed_val[d]->GetNbinsY();
00812       for(int phi=0;phi<phibins;++phi)for(int eta=0;eta<etabins;++eta){
00813           int ieta=CalcIeta(eta,d+1);
00814           if(ieta==-9999) continue;
00815           if(!isHE(eta,d+1)) continue;
00816           float val1=BadPed_val[d]->GetBinContent(eta+1,phi+1);
00817           float val2=BadRMS_val[d]->GetBinContent(eta+1,phi+1);
00818           if(val1==0 && val2==0) continue;
00819           HcalDetId hcalid(HcalEndcap,ieta,phi+1,d+1);
00820           char comment[100]; 
00821           if(val1!=0) sprintf(comment,"Ped-Ref=%.2f",val1);
00822           if(val2!=0) sprintf(comment,"Rms-Ref=%.2f",val2);
00823           if(val1!=0 && val2!=0) sprintf(comment,"Ped-Ref=%.2f,Rms-Ref=%.2f",val1,val2);
00824           std::string s=comment;
00825           if(badstatusmap.find(hcalid)!=badstatusmap.end()){ s+=",Known problem";}      
00826           HcalFrontEndId    lmap_entry=lmap.getHcalFrontEndId(hcalid);
00827           HcalElectronicsId emap_entry=emap.lookup(hcalid);
00828           printTableLine(badPedRMS,cnt++,hcalid,lmap_entry,emap_entry,s);
00829       } 
00830     } 
00831   }
00832   cnt=0;
00833   if((HO[2]+HO[3])>0){
00834     badPedRMS << "<tr><td align=\"center\"><h3>"<< "HO" <<"</h3></td></tr>" << std::endl;
00835     for(int d=0;d<4;++d){
00836       int etabins=BadPed_val[d]->GetNbinsX();
00837       int phibins=BadPed_val[d]->GetNbinsY();
00838       for(int phi=0;phi<phibins;++phi)for(int eta=0;eta<etabins;++eta){
00839           int ieta=CalcIeta(eta,d+1);
00840           if(ieta==-9999) continue;
00841           if(!isHO(eta,d+1)) continue;
00842           float val1=BadPed_val[d]->GetBinContent(eta+1,phi+1);
00843           float val2=BadRMS_val[d]->GetBinContent(eta+1,phi+1);
00844           if(val1==0 && val2==0) continue;
00845           HcalDetId hcalid(HcalOuter,ieta,phi+1,d+1);
00846           char comment[100]; 
00847           if(val1!=0) sprintf(comment,"Ped-Ref=%.2f",val1);
00848           if(val2!=0) sprintf(comment,"Rms-Ref=%.2f",val2);
00849           if(val1!=0 && val2!=0) sprintf(comment,"Ped-Ref=%.2f,Rms-Ref=%.2f",val1,val2);
00850           std::string s=comment;
00851           if(badstatusmap.find(hcalid)!=badstatusmap.end()){ s+=",Known problem";}
00852           HcalFrontEndId    lmap_entry=lmap.getHcalFrontEndId(hcalid);
00853           HcalElectronicsId emap_entry=emap.lookup(hcalid);
00854           printTableLine(badPedRMS,cnt++,hcalid,lmap_entry,emap_entry,s);
00855       } 
00856     } 
00857   }
00858   cnt=0;
00859   if((HFP[2]+HFP[2]+HFP[3]+HFP[3])>0){
00860     badPedRMS << "<tr><td align=\"center\"><h3>"<< "HF" <<"</h3></td></tr>" << std::endl;
00861     for(int d=0;d<4;++d){
00862       int etabins=BadPed_val[d]->GetNbinsX();
00863       int phibins=BadPed_val[d]->GetNbinsY();
00864       for(int phi=0;phi<phibins;++phi)for(int eta=0;eta<etabins;++eta){
00865           int ieta=CalcIeta(eta,d+1);
00866           if(ieta==-9999) continue;
00867           if(!isHF(eta,d+1)) continue;
00868           float val1=BadPed_val[d]->GetBinContent(eta+1,phi+1);
00869           float val2=BadRMS_val[d]->GetBinContent(eta+1,phi+1);
00870           if(val1==0 && val2==0) continue;
00871           HcalDetId hcalid(HcalForward,ieta,phi+1,d+1);
00872           char comment[100]; 
00873           if(val1!=0) sprintf(comment,"Ped-Ref=%.2f",val1);
00874           if(val2!=0) sprintf(comment,"Rms-Ref=%.2f",val2);
00875           if(val1!=0 && val2!=0) sprintf(comment,"Ped-Ref=%.2f,Rms-Ref=%.2f",val1,val2);
00876           std::string s=comment;
00877           if(badstatusmap.find(hcalid)!=badstatusmap.end()){ s+=",Known problem";}      
00878           HcalFrontEndId    lmap_entry=lmap.getHcalFrontEndId(hcalid);
00879           HcalElectronicsId emap_entry=emap.lookup(hcalid);
00880           printTableLine(badPedRMS,cnt++,hcalid,lmap_entry,emap_entry,s);
00881       } 
00882     } 
00883   }
00884 
00885   printTableTail(badMissing);
00886   badMissing.close();
00887   printTableTail(badUnstable);
00888   badUnstable.close();
00889   printTableTail(badPedRMS);
00890   badPedRMS.close();
00891 
00892   int ievt_ = -1,runNo=-1;
00893   std::string ref_run;
00894   s=subdir_+"HcalDetDiagPedestalMonitor Event Number";
00895   me = dqmStore_->get(s.c_str());
00896   if ( me ) {
00897     s = me->valueString();
00898     sscanf((s.substr(2,s.length()-2)).c_str(), "%d", &ievt_);
00899   }
00900   s=subdir_+"HcalDetDiagPedestalMonitor Run Number";
00901   me = dqmStore_->get(s.c_str());
00902   if ( me ) {
00903     s = me->valueString();
00904     sscanf((s.substr(2,s.length()-2)).c_str(), "%d", &runNo);
00905   } 
00906   s=subdir_+"HcalDetDiagLaserMonitor Reference Run";
00907   me = dqmStore_->get(s.c_str());
00908   if(me) {
00909     std::string s=me->valueString();
00910     char str[200]; 
00911     sscanf((s.substr(2,s.length()-2)).c_str(), "%s", str);
00912     ref_run=str;
00913   }
00914 
00915   gROOT->SetBatch(true);
00916   gStyle->SetCanvasColor(0);
00917   gStyle->SetPadColor(0);
00918   gStyle->SetOptStat(111110);
00919   gStyle->SetPalette(1);
00920  
00921   TCanvas *can=new TCanvas("HcalDetDiagPedestalClient","HcalDetDiagPedestalClient",0,0,500,350);
00922   can->cd();
00923 
00924   ofstream htmlFile;
00925   std::string outfile=htmlDir+name_+".html";
00926   htmlFile.open(outfile.c_str());
00927   // html page header
00928   htmlFile << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">  " << std::endl;
00929   htmlFile << "<html>  " << std::endl;
00930   htmlFile << "<head>  " << std::endl;
00931   htmlFile << "  <meta content=\"text/html; charset=ISO-8859-1\"  " << std::endl;
00932   htmlFile << " https-equiv=\"content-type\">  " << std::endl;
00933   htmlFile << "  <title>Detector Diagnostics Pedestal Monitor</title> " << std::endl;
00934   htmlFile << "</head>  " << std::endl;
00935   htmlFile << "<style type=\"text/css\"> td { font-weight: bold } </style>" << std::endl;
00936   htmlFile << "<style type=\"text/css\">"<< std::endl;
00937   htmlFile << "   td.s0 { font-family: arial, arial ce, helvetica; font-weight: bold; background-color: #FF7700; text-align: center;}"<< std::endl;
00938   htmlFile << "   td.s1 { font-family: arial, arial ce, helvetica; font-weight: bold; background-color: #FFC169; text-align: center;}"<< std::endl;
00939   htmlFile << "   td.s2 { font-family: arial, arial ce, helvetica; background-color: red; }"<< std::endl;
00940   htmlFile << "   td.s3 { font-family: arial, arial ce, helvetica; background-color: yellow; }"<< std::endl;
00941   htmlFile << "   td.s4 { font-family: arial, arial ce, helvetica; background-color: green; }"<< std::endl;
00942   htmlFile << "   td.s5 { font-family: arial, arial ce, helvetica; background-color: silver; }"<< std::endl;
00943   std::string state[4]={"<td class=\"s2\" align=\"center\">",
00944                         "<td class=\"s3\" align=\"center\">",
00945                         "<td class=\"s4\" align=\"center\">",
00946                         "<td class=\"s5\" align=\"center\">"};
00947   htmlFile << "</style>"<< std::endl;
00948   htmlFile << "<body>  " << std::endl;
00949   htmlFile << "<br>  " << std::endl;
00950   htmlFile << "<h2>Run:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << std::endl;
00951   htmlFile << "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span " << std::endl;
00952   htmlFile << " style=\"color: rgb(0, 0, 153);\">" << runNo << "</span></h2>" << std::endl;
00953   htmlFile << "<h2>Monitoring task:&nbsp;&nbsp;&nbsp;&nbsp; <span " << std::endl;
00954   htmlFile << " style=\"color: rgb(0, 0, 153);\">Detector Diagnostics Pedestal Monitor</span></h2> " << std::endl;
00955   htmlFile << "<h2>Events processed:&nbsp;&nbsp;&nbsp;&nbsp;<span " << std::endl;
00956   htmlFile << " style=\"color: rgb(0, 0, 153);\">" << ievt_ << "</span></h2>" << std::endl;
00957   htmlFile << "<hr>" << std::endl;
00959   htmlFile << "<table width=100% border=1>" << std::endl;
00960   htmlFile << "<tr>" << std::endl;
00961   htmlFile << "<td class=\"s0\" width=20% align=\"center\">SebDet</td>" << std::endl;
00962   htmlFile << "<td class=\"s0\" width=20% align=\"center\">Missing</td>" << std::endl;
00963   htmlFile << "<td class=\"s0\" width=20% align=\"center\">Unstable</td>" << std::endl;
00964   htmlFile << "<td class=\"s0\" width=20% align=\"center\">Bad |Ped-Ref|</td>" << std::endl;
00965   htmlFile << "<td class=\"s0\" width=20% align=\"center\">Bad |Rms-Ref|</td>" << std::endl;
00966   htmlFile << "</tr><tr>" << std::endl;
00967   int ind1=0,ind2=0,ind3=0,ind4=0;
00968   htmlFile << "<td class=\"s1\" align=\"center\">HB+</td>" << std::endl;
00969   ind1=3; if(newHBP[0]==0) ind1=2; if(newHBP[0]>0 && newHBP[0]<=12) ind1=1; if(newHBP[0]>=12 && newHBP[0]<1296) ind1=0; 
00970   ind2=3; if(newHBP[1]==0) ind2=2; if(newHBP[1]>0)  ind2=1; if(newHBP[1]>21)  ind2=0; 
00971   ind3=3; if(newHBP[2]==0) ind3=2; if(newHBP[2]>0)  ind3=1; if(newHBP[2]>21)  ind3=0;
00972   ind4=3; if(newHBP[3]==0) ind4=2; if(newHBP[3]>0)  ind4=1; if(newHBP[3]>21)  ind4=0;
00973   if(ind1==3) ind2=ind3=ind4=3;  
00974   if(ind1==0 || ind2==0 || ind3==0 || ind4==0) status|=2; else if(ind1==1 || ind2==1 || ind3==1 || ind4==1) status|=1; 
00975   htmlFile << state[ind1] << HBP[0] <<" (1296)</td>" << std::endl;
00976   htmlFile << state[ind2] << HBP[1] <<"</td>" << std::endl;
00977   htmlFile << state[ind3] << HBP[2] <<"</td>" << std::endl;
00978   htmlFile << state[ind4] << HBP[3] <<"</td>" << std::endl;
00979   
00980   htmlFile << "</tr><tr>" << std::endl;
00981   htmlFile << "<td class=\"s1\" align=\"center\">HB-</td>" << std::endl;
00982   ind1=3; if(newHBM[0]==0) ind1=2; if(newHBM[0]>0 && newHBM[0]<=12) ind1=1; if(newHBM[0]>=12 && newHBM[0]<1296) ind1=0; 
00983   ind2=3; if(newHBM[1]==0) ind2=2; if(newHBM[1]>0)  ind2=1; if(newHBM[1]>21)  ind2=0; 
00984   ind3=3; if(newHBM[2]==0) ind3=2; if(newHBM[2]>0)  ind3=1; if(newHBM[2]>21)  ind3=0;
00985   ind4=3; if(newHBM[3]==0) ind4=2; if(newHBM[3]>0)  ind4=1; if(newHBM[3]>21)  ind4=0;
00986   if(ind1==3) ind2=ind3=ind4=3;
00987   if(ind1==0 || ind2==0 || ind3==0 || ind4==0) status|=2; else if(ind1==1 || ind2==1 || ind3==1 || ind4==1) status|=1; 
00988   htmlFile << state[ind1] << HBM[0] <<" (1296)</td>" << std::endl;
00989   htmlFile << state[ind2] << HBM[1] <<"</td>" << std::endl;
00990   htmlFile << state[ind3] << HBM[2] <<"</td>" << std::endl;
00991   htmlFile << state[ind4] << HBM[3] <<"</td>" << std::endl;
00992   
00993   htmlFile << "</tr><tr>" << std::endl;
00994   htmlFile << "<td class=\"s1\" align=\"center\">HE+</td>" << std::endl;
00995   ind1=3; if(newHEP[0]==0) ind1=2; if(newHEP[0]>0 && newHEP[0]<=12) ind1=1; if(newHEP[0]>=12 && newHEP[0]<1296) ind1=0; 
00996   ind2=3; if(newHEP[1]==0) ind2=2; if(newHEP[1]>0)  ind2=1; if(newHEP[1]>21)  ind2=0; 
00997   ind3=3; if(newHEP[2]==0) ind3=2; if(newHEP[2]>0)  ind3=1; if(newHEP[2]>21)  ind3=0;
00998   ind4=3; if(newHEP[3]==0) ind4=2; if(newHEP[3]>0)  ind4=1; if(newHEP[3]>21)  ind4=0;
00999   if(ind1==3) ind2=ind3=ind4=3;
01000   if(ind1==0 || ind2==0 || ind3==0 || ind4==0) status|=2; else if(ind1==1 || ind2==1 || ind3==1 || ind4==1) status|=1; 
01001   htmlFile << state[ind1] << HEP[0] <<" (1296)</td>" << std::endl;
01002   htmlFile << state[ind2] << HEP[1] <<"</td>" << std::endl;
01003   htmlFile << state[ind3] << HEP[2] <<"</td>" << std::endl;
01004   htmlFile << state[ind4] << HEP[3] <<"</td>" << std::endl;
01005   
01006   htmlFile << "</tr><tr>" << std::endl;
01007   htmlFile << "<td class=\"s1\" align=\"center\">HE-</td>" << std::endl;
01008   ind1=3; if(newHEM[0]==0) ind1=2; if(newHEM[0]>0 && newHEM[0]<=12) ind1=1; if(newHEM[0]>=12 && newHEM[0]<1296) ind1=0; 
01009   ind2=3; if(newHEM[1]==0) ind2=2; if(newHEM[1]>0)  ind2=1; if(newHEM[1]>21)  ind2=0; 
01010   ind3=3; if(newHEM[2]==0) ind3=2; if(newHEM[2]>0)  ind3=1; if(newHEM[2]>21)  ind3=0;
01011   ind4=3; if(newHEM[3]==0) ind4=2; if(newHEM[3]>0)  ind4=1; if(newHEM[3]>21)  ind4=0;
01012   if(ind1==3) ind2=ind3=ind4=3;
01013   if(ind1==0 || ind2==0 || ind3==0 || ind4==0) status|=2; else if(ind1==1 || ind2==1 || ind3==1 || ind4==1) status|=1; 
01014   htmlFile << state[ind1] << HEM[0] <<" (1296)</td>" << std::endl;
01015   htmlFile << state[ind2] << HEM[1] <<"</td>" << std::endl;
01016   htmlFile << state[ind3] << HEM[2] <<"</td>" << std::endl;
01017   htmlFile << state[ind4] << HEM[3] <<"</td>" << std::endl;
01018   
01019   htmlFile << "</tr><tr>" << std::endl;
01020   htmlFile << "<td class=\"s1\" align=\"center\">HF+</td>" << std::endl;
01021   ind1=3; if(newHFP[0]==0) ind1=2; if(newHFP[0]>0 && newHFP[0]<=12) ind1=1; if(newHFP[0]>=12 && newHFP[0]<864) ind1=0; 
01022   ind2=3; if(newHFP[1]==0) ind2=2; if(newHFP[1]>0)  ind2=1; if(newHFP[1]>21)  ind2=0; 
01023   ind3=3; if(newHFP[2]==0) ind3=2; if(newHFP[2]>0)  ind3=1; if(newHFP[2]>21)  ind3=0;
01024   ind4=3; if(newHFP[3]==0) ind4=2; if(newHFP[3]>0)  ind4=1; if(newHFP[3]>21)  ind4=0;
01025   if(ind1==3) ind2=ind3=ind4=3;
01026   if(ind1==0 || ind2==0 || ind3==0 || ind4==0) status|=2; else if(ind1==1 || ind2==1 || ind3==1 || ind4==1) status|=1; 
01027   htmlFile << state[ind1] << HFP[0] <<" (864)</td>" << std::endl;
01028   htmlFile << state[ind2] << HFP[1] <<"</td>" << std::endl;
01029   htmlFile << state[ind3] << HFP[2] <<"</td>" << std::endl;
01030   htmlFile << state[ind4] << HFP[3] <<"</td>" << std::endl;
01031   
01032   htmlFile << "</tr><tr>" << std::endl;
01033   htmlFile << "<td class=\"s1\" align=\"center\">HF-</td>" << std::endl;
01034   ind1=3; if(newHFM[0]==0) ind1=2; if(newHFM[0]>0 && newHFM[0]<=12) ind1=1; if(newHFM[0]>=12 && newHFM[0]<864) ind1=0; 
01035   ind2=3; if(newHFM[1]==0) ind2=2; if(newHFM[1]>0)  ind2=1; if(newHFM[1]>21)  ind2=0; 
01036   ind3=3; if(newHFM[2]==0) ind3=2; if(newHFM[2]>0)  ind3=1; if(newHFM[2]>21)  ind3=0;
01037   ind4=3; if(newHFM[3]==0) ind4=2; if(newHFM[3]>0)  ind4=1; if(newHFM[3]>21)  ind4=0;
01038   if(ind1==3) ind2=ind3=ind4=3;
01039   if(ind1==0 || ind2==0 || ind3==0 || ind4==0) status|=2; else if(ind1==1 || ind2==1 || ind3==1 || ind4==1) status|=1; 
01040   htmlFile << state[ind1] << HFM[0] <<" (864)</td>" << std::endl;
01041   htmlFile << state[ind2] << HFM[1] <<"</td>" << std::endl;
01042   htmlFile << state[ind3] << HFM[2] <<"</td>" << std::endl;
01043   htmlFile << state[ind4] << HFM[3] <<"</td>" << std::endl;
01044   
01045   htmlFile << "</tr><tr>" << std::endl;
01046   htmlFile << "<td class=\"s1\" align=\"center\">HO</td>" << std::endl;
01047   ind1=3; if(newHO[0]==0) ind1=2; if(newHO[0]>0 && newHO[0]<=12) ind1=1; if(newHO[0]>=12 && newHO[0]<2160) ind1=0; 
01048   ind2=3; if(newHO[1]==0) ind2=2; if(newHO[1]>0)  ind2=1; if(newHO[1]>21)  ind2=0; 
01049   ind3=3; if(newHO[2]==0) ind3=2; if(newHO[2]>0)  ind3=1; if(newHO[2]>21)  ind3=0;
01050   ind4=3; if(newHO[3]==0) ind4=2; if(newHO[3]>0)  ind4=1; if(newHO[3]>21)  ind4=0;
01051   if(ind1==3) ind2=ind3=ind4=3;
01052   if(ind1==0 || ind2==0 || ind3==0 || ind4==0) status|=2; else if(ind1==1 || ind2==1 || ind3==1 || ind4==1) status|=1; 
01053   htmlFile << state[ind1] << HO[0] <<" (2160)</td>" << std::endl;
01054   htmlFile << state[ind2] << HO[1] <<"</td>" << std::endl;
01055   htmlFile << state[ind3] << HO[2] <<"</td>" << std::endl;
01056   htmlFile << state[ind4] << HO[3] <<"</td>" << std::endl;
01057 
01058   htmlFile << "</tr></table>" << std::endl;
01059   htmlFile << "<hr>" << std::endl;
01061   if((MissingCnt+UnstableCnt+BadCnt)>0){
01062       htmlFile << "<table width=100% border=1><tr>" << std::endl;
01063       if(MissingCnt>0)  htmlFile << "<td><a href=\"" << "bad_missing_table.html" <<"\">list of missing channels</a></td>";
01064       if(UnstableCnt>0) htmlFile << "<td><a href=\"" << "bad_unstable_table.html" <<"\">list of unstable channels</a></td>";
01065       if(BadCnt>0)      htmlFile << "<td><a href=\"" << "bad_badpedrms_table.html" <<"\">list of bad pedestal/rms channels</a></td>";
01066       htmlFile << "</tr></table>" << std::endl;
01067   }
01068   can->SetGridy();
01069   can->SetGridx();
01070   can->SetLogy(0); 
01071 
01072 
01073 
01075   htmlFile << "<h2 align=\"center\">Summary plots</h2>" << std::endl;
01076   htmlFile << "<table width=100% border=0><tr>" << std::endl;
01077   htmlFile << "<tr align=\"left\">" << std::endl;
01078   Pedestals2DHBHEHF->SetStats(0);
01079   Pedestals2DHBHEHF->SetMaximum(5);
01080   Pedestals2DHBHEHF->SetNdivisions(36,"Y");
01081   Pedestals2DHBHEHF->Draw("COLZ");
01082   can->SaveAs((htmlDir + "hbhehf_pedestal_map.gif").c_str());
01083   htmlFile << "<td><img src=\"hbhehf_pedestal_map.gif\" alt=\"hbhehf pedestal mean map\">   </td>" << std::endl;
01084   Pedestals2DHO->SetStats(0);
01085   Pedestals2DHO->SetMaximum(5);
01086   Pedestals2DHO->SetNdivisions(36,"Y");
01087   Pedestals2DHO->Draw("COLZ");
01088   can->SaveAs((htmlDir + "ho_pedestal_map.gif").c_str());
01089   htmlFile << "<td><img src=\"ho_pedestal_map.gif\" alt=\"ho pedestal mean map\">   </td>" << std::endl;
01090   htmlFile << "</tr>" << std::endl;
01091   
01092   htmlFile << "<tr align=\"left\">" << std::endl;
01093   Pedestals2DRmsHBHEHF->SetStats(0);
01094   Pedestals2DRmsHBHEHF->SetMaximum(2);
01095   Pedestals2DRmsHBHEHF->SetNdivisions(36,"Y");
01096   Pedestals2DRmsHBHEHF->Draw("COLZ");
01097   can->SaveAs((htmlDir + "hbhehf_rms_map.gif").c_str());
01098   htmlFile << "<td><img src=\"hbhehf_rms_map.gif\" alt=\"hbhehf pedestal rms map\">   </td>" << std::endl;
01099   Pedestals2DRmsHO->SetStats(0);
01100   Pedestals2DRmsHO->SetMaximum(2);
01101   Pedestals2DRmsHO->SetNdivisions(36,"Y");
01102   Pedestals2DRmsHO->Draw("COLZ");
01103   can->SaveAs((htmlDir + "ho_rms_map.gif").c_str());
01104   htmlFile << "<td><img src=\"ho_rms_map.gif\" alt=\"ho pedestal rms map\">   </td>" << std::endl;
01105   htmlFile << "</tr>" << std::endl;
01106   
01107   htmlFile << "<tr align=\"left\">" << std::endl;
01108   Pedestals2DErrorHBHEHF->SetStats(0);
01109   Pedestals2DErrorHBHEHF->SetNdivisions(36,"Y");
01110   Pedestals2DErrorHBHEHF->Draw("COLZ");
01111   can->SaveAs((htmlDir + "hbhehf_error_map.gif").c_str());
01112   htmlFile << "<td><img src=\"hbhehf_error_map.gif\" alt=\"hbhehf pedestal error map\">   </td>" << std::endl;
01113   Pedestals2DErrorHO->SetStats(0);
01114   Pedestals2DErrorHO->SetNdivisions(36,"Y");
01115   Pedestals2DErrorHO->Draw("COLZ");
01116   can->SaveAs((htmlDir + "ho_error_map.gif").c_str());
01117   htmlFile << "<td><img src=\"ho_error_map.gif\" alt=\"ho pedestal error map\">   </td>" << std::endl;
01118   htmlFile << "</tr>" << std::endl;
01119   htmlFile << "</table>" << std::endl;
01120   htmlFile << "<hr>" << std::endl;
01121   
01123   htmlFile << "<h2 align=\"center\">HB Pedestal plots (Reference run "<<ref_run<<")</h2>" << std::endl;
01124   htmlFile << "<table width=100% border=0><tr>" << std::endl;
01125   htmlFile << "<tr align=\"left\">" << std::endl;
01126   if(PedestalsAve4HB->GetMaximum()>0) can->SetLogy(1); else can->SetLogy(0); 
01127   PedestalsAve4HB->Draw();
01128   can->SaveAs((htmlDir + "hb_pedestal_distribution.gif").c_str());
01129   htmlFile << "<td><img src=\"hb_pedestal_distribution.gif\" alt=\"hb pedestal mean\">   </td>" << std::endl;
01130   if(PedestalsRmsHB->GetMaximum()>0) can->SetLogy(1); else can->SetLogy(0); 
01131   PedestalsRmsHB->Draw();
01132   can->SaveAs((htmlDir + "hb_pedestal_rms_distribution.gif").c_str());
01133   htmlFile << "<td><img src=\"hb_pedestal_rms_distribution.gif\" alt=\"hb pedestal rms mean\">   </td>" << std::endl;
01134   htmlFile << "</tr>" << std::endl;
01135   
01136   htmlFile << "<tr align=\"left\">" << std::endl;
01137   if(PedestalsAve4HBref->GetMaximum()>0) can->SetLogy(1); else can->SetLogy(0); 
01138   PedestalsAve4HBref->Draw();
01139   can->SaveAs((htmlDir + "hb_pedestal_ref_distribution.gif").c_str());
01140   htmlFile << "<td><img src=\"hb_pedestal_ref_distribution.gif\" alt=\"hb pedestal-reference mean\">   </td>" << std::endl;
01141   if(PedestalsRmsHBref->GetMaximum()>0) can->SetLogy(1); else can->SetLogy(0); 
01142   PedestalsRmsHBref->Draw();
01143   can->SaveAs((htmlDir + "hb_pedestal_rms_ref_distribution.gif").c_str());
01144   htmlFile << "<td><img src=\"hb_pedestal_rms_ref_distribution.gif\" alt=\"hb pedestal rms-reference mean\">   </td>" << std::endl;
01145   htmlFile << "</tr>" << std::endl;
01146   htmlFile << "</table>" << std::endl;
01148   htmlFile << "<h2 align=\"center\">HE Pedestal plots (Reference run "<<ref_run<<")</h2>" << std::endl;
01149   htmlFile << "<table width=100% border=0><tr>" << std::endl;
01150   htmlFile << "<tr align=\"left\">" << std::endl;
01151   if(PedestalsAve4HE->GetMaximum()>0) can->SetLogy(1); else can->SetLogy(0);  
01152   PedestalsAve4HE->Draw();
01153   can->SaveAs((htmlDir + "he_pedestal_distribution.gif").c_str());
01154   htmlFile << "<td><img src=\"he_pedestal_distribution.gif\" alt=\"he pedestal mean\">   </td>" << std::endl;
01155   if(PedestalsRmsHE->GetMaximum()>0) can->SetLogy(1); else can->SetLogy(0); 
01156   PedestalsRmsHE->Draw();
01157   can->SaveAs((htmlDir + "he_pedestal_rms_distribution.gif").c_str());
01158   htmlFile << "<td><img src=\"he_pedestal_rms_distribution.gif\" alt=\"he pedestal rms mean\">   </td>" << std::endl;
01159   htmlFile << "</tr>" << std::endl;
01160   
01161   htmlFile << "<tr align=\"left\">" << std::endl;
01162   if(PedestalsAve4HEref->GetMaximum()>0) can->SetLogy(1); else can->SetLogy(0); 
01163   PedestalsAve4HEref->Draw();
01164   can->SaveAs((htmlDir + "he_pedestal_ref_distribution.gif").c_str());
01165   htmlFile << "<td><img src=\"he_pedestal_ref_distribution.gif\" alt=\"he pedestal-reference mean\">   </td>" << std::endl;
01166   if(PedestalsRmsHEref->GetMaximum()>0) can->SetLogy(1); else can->SetLogy(0); 
01167   PedestalsRmsHEref->Draw();
01168   can->SaveAs((htmlDir + "he_pedestal_rms_ref_distribution.gif").c_str());
01169   htmlFile << "<td><img src=\"he_pedestal_rms_ref_distribution.gif\" alt=\"he pedestal rms-reference mean\">   </td>" << std::endl;
01170   htmlFile << "</tr>" << std::endl;
01171   htmlFile << "</table>" << std::endl;
01173   htmlFile << "<h2 align=\"center\">HO Pedestal plots (Reference run "<<ref_run<<")</h2>" << std::endl;
01174   htmlFile << "<table width=100% border=0><tr>" << std::endl;
01175   htmlFile << "<tr align=\"left\">" << std::endl;
01176   if(PedestalsAve4HO->GetMaximum()>0) can->SetLogy(1); else can->SetLogy(0); 
01177   PedestalsAve4HO->Draw();
01178   can->SaveAs((htmlDir + "ho_pedestal_distribution.gif").c_str());
01179   htmlFile << "<td><img src=\"ho_pedestal_distribution.gif\" alt=\"ho pedestal mean\">   </td>" << std::endl;
01180   if(PedestalsRmsHO->GetMaximum()>0) can->SetLogy(1); else can->SetLogy(0); 
01181   PedestalsRmsHO->Draw();
01182   can->SaveAs((htmlDir + "ho_pedestal_rms_distribution.gif").c_str());
01183   htmlFile << "<td><img src=\"ho_pedestal_rms_distribution.gif\" alt=\"ho pedestal rms mean\">   </td>" << std::endl;
01184   htmlFile << "</tr>" << std::endl;
01185   // SIMP
01186   htmlFile << "<tr align=\"left\">" << std::endl;
01187   if(PedestalsAve4Simp->GetMaximum()>0) can->SetLogy(1); else can->SetLogy(0); 
01188   PedestalsAve4Simp->Draw();
01189   can->SaveAs((htmlDir + "sipm_pedestal_distribution.gif").c_str());
01190   htmlFile << "<td><img src=\"sipm_pedestal_distribution.gif\" alt=\"sipm pedestal mean\">   </td>" << std::endl;
01191   if(PedestalsRmsSimp->GetMaximum()>0) can->SetLogy(1); else can->SetLogy(0); 
01192   PedestalsRmsSimp->Draw();
01193   can->SaveAs((htmlDir + "simp_pedestal_rms_distribution.gif").c_str());
01194   htmlFile << "<td><img src=\"simp_pedestal_rms_distribution.gif\" alt=\"sipm pedestal rms mean\">   </td>" << std::endl;
01195   htmlFile << "</tr>" << std::endl;
01196   // SIMP
01197   htmlFile << "<tr align=\"left\">" << std::endl;
01198   if(PedestalsAve4HOref->GetMaximum()>0) can->SetLogy(1); else can->SetLogy(0); 
01199   PedestalsAve4HOref->Draw();
01200   can->SaveAs((htmlDir + "ho_pedestal_ref_distribution.gif").c_str());
01201   htmlFile << "<td><img src=\"ho_pedestal_ref_distribution.gif\" alt=\"ho pedestal-reference mean\">   </td>" << std::endl;
01202   if(PedestalsRmsHOref->GetMaximum()>0) can->SetLogy(1); else can->SetLogy(0); 
01203   PedestalsRmsHOref->Draw();
01204   can->SaveAs((htmlDir + "ho_pedestal_rms_ref_distribution.gif").c_str());
01205   htmlFile << "<td><img src=\"ho_pedestal_rms_ref_distribution.gif\" alt=\"ho pedestal rms-reference mean\">   </td>" << std::endl;
01206   htmlFile << "</tr>" << std::endl;
01207   htmlFile << "</table>" << std::endl;
01209 
01210   htmlFile << "<h2 align=\"center\">HF Pedestal plots (Reference run "<<ref_run<<")</h2>" << std::endl;
01211   htmlFile << "<table width=100% border=0><tr>" << std::endl;
01212   htmlFile << "<tr align=\"left\">" << std::endl;
01213   if(PedestalsAve4HF->GetMaximum()>0) can->SetLogy(1); else can->SetLogy(0); 
01214   PedestalsAve4HF->Draw();
01215   can->SaveAs((htmlDir + "hf_pedestal_distribution.gif").c_str());
01216   htmlFile << "<td><img src=\"hf_pedestal_distribution.gif\" alt=\"hf pedestal mean\">   </td>" << std::endl;
01217   if(PedestalsRmsHF->GetMaximum()>0) can->SetLogy(1); else can->SetLogy(0); 
01218   PedestalsRmsHF->Draw();
01219   can->SaveAs((htmlDir + "hf_pedestal_rms_distribution.gif").c_str());
01220   htmlFile << "<td><img src=\"hf_pedestal_rms_distribution.gif\" alt=\"hf pedestal rms mean\">   </td>" << std::endl;
01221   htmlFile << "</tr>" << std::endl;
01222   
01223   htmlFile << "<tr align=\"left\">" << std::endl;
01224   if(PedestalsAve4HFref->GetMaximum()>0) can->SetLogy(1); else can->SetLogy(0); 
01225   PedestalsAve4HFref->Draw();
01226   can->SaveAs((htmlDir + "hf_pedestal_ref_distribution.gif").c_str());
01227   htmlFile << "<td><img src=\"hf_pedestal_ref_distribution.gif\" alt=\"hf pedestal-reference mean\">   </td>" << std::endl;
01228   if(PedestalsRmsHFref->GetMaximum()>0) can->SetLogy(1); else can->SetLogy(0); 
01229   PedestalsRmsHFref->Draw();
01230   can->SaveAs((htmlDir + "hf_pedestal_rms_ref_distribution.gif").c_str());
01231   htmlFile << "<td><img src=\"hf_pedestal_rms_ref_distribution.gif\" alt=\"hf pedestal rms-reference mean\">   </td>" << std::endl;
01232   htmlFile << "</tr>" << std::endl;
01233   htmlFile << "</table>" << std::endl;
01234   
01235 
01236   htmlFile << "</body> " << std::endl;
01237   htmlFile << "</html> " << std::endl;
01238   htmlFile.close();
01239   can->Close();
01240 }