CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/DQM/HcalMonitorClient/src/HcalRecHitClient.cc

Go to the documentation of this file.
00001 #include "DQM/HcalMonitorClient/interface/HcalRecHitClient.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 <iostream>
00010 
00011 /*
00012  * \file HcalRecHitClient.cc
00013  * 
00014  * $Date: 2010/11/17 19:17:43 $
00015  * $Revision: 1.51 $
00016  * \author J. Temple
00017  * \brief Dead Cell Client class
00018  */
00019 
00020 HcalRecHitClient::HcalRecHitClient(std::string myname)
00021 {
00022   name_=myname;
00023 }
00024 
00025 HcalRecHitClient::HcalRecHitClient(std::string myname, const edm::ParameterSet& ps)
00026 {
00027   name_=myname;
00028   enableCleanup_         = ps.getUntrackedParameter<bool>("enableCleanup",false);
00029   debug_                 = ps.getUntrackedParameter<int>("debug",0);
00030   prefixME_              = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
00031   if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
00032     prefixME_.append("/");
00033   subdir_                = ps.getUntrackedParameter<std::string>("RecHitFolder","RecHitMonitor_Hcal/"); // RecHitMonitor_Hcal  
00034   if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
00035     subdir_.append("/");
00036   subdir_=prefixME_+subdir_;
00037 
00038   validHtmlOutput_       = ps.getUntrackedParameter<bool>("RecHit_validHtmlOutput",true);
00039   cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
00040   badChannelStatusMask_   = ps.getUntrackedParameter<int>("RecHit_BadChannelStatusMask",
00041                                                           ps.getUntrackedParameter<int>("BadChannelStatusMask",
00042                                                                                         0)); // identify channel status values to mask
00043 
00044   minerrorrate_ = ps.getUntrackedParameter<double>("RecHit_minerrorrate",
00045                                                    ps.getUntrackedParameter<double>("minerrorrate",0.01));
00046   minevents_    = ps.getUntrackedParameter<int>("RecHit_minevents",
00047                                                 ps.getUntrackedParameter<int>("minevents",1));
00048   enoughevents_=false;
00049   ProblemCellsByDepth=0;
00050 }
00051 
00052 void HcalRecHitClient::analyze()
00053 {
00054   if (debug_>2) std::cout <<"\tHcalRecHitClient::analyze()"<<std::endl;
00055  
00056   TH2F* OccupancyByDepth[4];
00057   TH2F* SumEnergyByDepth[4];
00058   TH2F* SumTimeByDepth[4];
00059   TH2F* SqrtSumEnergy2ByDepth[4];
00060 
00061   TH2F* OccupancyThreshByDepth[4];
00062   TH2F* SumEnergyThreshByDepth[4];
00063   TH2F* SumTimeThreshByDepth[4];
00064   TH2F* SqrtSumEnergy2ThreshByDepth[4];
00065 
00066   std::vector<std::string> name = HcalEtaPhiHistNames();
00067 
00068   MonitorElement* me;
00069   bool gotHistos=true;
00070 
00071   for (int i=0;i<4;++i)
00072     {
00073       std::string s=subdir_+"Distributions_AllRecHits/"+name[i]+"RecHit Occupancy";
00074       me=dqmStore_->get(s.c_str());
00075       if (me==0) {if (debug_>0) std::cout <<"Could not get histogram "<<s<<std::endl; gotHistos=false; break;}
00076       OccupancyByDepth[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, OccupancyByDepth[i], debug_);
00077       s=subdir_+"Distributions_AllRecHits/sumplots/"+name[i]+"RecHit Summed Energy GeV";
00078       me=dqmStore_->get(s.c_str());
00079       if (me==0) {if (debug_>0) std::cout <<"Could not get histogram "<<s<<std::endl; gotHistos=false; break;}
00080       SumEnergyByDepth[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, SumEnergyByDepth[i], debug_);
00081       s=subdir_+"Distributions_AllRecHits/sumplots/"+name[i]+"RecHit Summed Time nS";
00082       me=dqmStore_->get(s.c_str());
00083       if (me==0) {if (debug_>0) std::cout <<"Could not get histogram "<<s<<std::endl; gotHistos=false; break;}
00084       SumTimeByDepth[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, SumTimeByDepth[i], debug_);
00085       s=subdir_+"Distributions_AllRecHits/sumplots/"+name[i]+"RecHit Sqrt Summed Energy2 GeV";
00086       me=dqmStore_->get(s.c_str());
00087       if (me==0) {if (debug_>0) std::cout <<"Could not get histogram "<<s<<std::endl; gotHistos=false; break;}
00088       SqrtSumEnergy2ByDepth[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, SqrtSumEnergy2ByDepth[i], debug_);
00089 
00090       // Threshold histograms
00091       s=subdir_+"Distributions_PassedMinBias/"+name[i]+"Above Threshold RecHit Occupancy";
00092       me=dqmStore_->get(s.c_str());
00093       if (me==0) {if (debug_>0) std::cout <<"Could not get histogram "<<s<<std::endl; gotHistos=false; break;}
00094       OccupancyThreshByDepth[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, OccupancyThreshByDepth[i], debug_);
00095       s=subdir_+"Distributions_PassedMinBias/sumplots/"+name[i]+"Above Threshold RecHit Summed Energy GeV";
00096       me=dqmStore_->get(s.c_str());
00097       if (me==0) {if (debug_>0) std::cout <<"Could not get histogram "<<s<<std::endl; gotHistos=false; break;}
00098       SumEnergyThreshByDepth[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, SumEnergyThreshByDepth[i], debug_);
00099       s=subdir_+"Distributions_PassedMinBias/sumplots/"+name[i]+"Above Threshold RecHit Summed Time nS";
00100       me=dqmStore_->get(s.c_str());
00101       if (me==0) {if (debug_>0) std::cout <<"Could not get histogram "<<s<<std::endl; gotHistos=false; break;}
00102       SumTimeThreshByDepth[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, SumTimeThreshByDepth[i], debug_);
00103       s=subdir_+"Distributions_PassedMinBias/sumplots/"+name[i]+"Above Threshold RecHit Sqrt Summed Energy2 GeV";
00104       me=dqmStore_->get(s.c_str());
00105       if (me==0) {if (debug_>0) std::cout <<"Could not get histogram "<<s<<std::endl; gotHistos=false; break;}
00106       SqrtSumEnergy2ThreshByDepth[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, SqrtSumEnergy2ThreshByDepth[i], debug_);
00107     }
00108   if (gotHistos==false)
00109     {
00110       if (debug_>0) std::cout <<"<HcalRecHitClient::calculateProblems()> Not all histograms could be found; skipping normalization"<<std::endl;
00111       return;
00112     }
00113 
00114   // Clear histograms before re-filling
00115   meHBEnergy_1D->Reset();
00116   meHBEnergyRMS_1D->Reset();
00117   meHEEnergy_1D->Reset();
00118   meHEEnergyRMS_1D->Reset();
00119   meHOEnergy_1D->Reset();
00120   meHOEnergyRMS_1D->Reset();
00121   meHFEnergy_1D->Reset();
00122   meHFEnergyRMS_1D->Reset();
00123   meHBEnergyThresh_1D->Reset();
00124   meHBEnergyRMSThresh_1D->Reset();
00125   meHEEnergyThresh_1D->Reset();
00126   meHEEnergyRMSThresh_1D->Reset();
00127   meHOEnergyThresh_1D->Reset();
00128   meHOEnergyRMSThresh_1D->Reset();
00129   meHFEnergyThresh_1D->Reset();
00130   meHFEnergyRMSThresh_1D->Reset();
00131 
00132   for (int mydepth=0;mydepth<4;++mydepth)
00133     {
00134       for (int eta=0;eta<OccupancyByDepth[mydepth]->GetNbinsX();++eta)
00135         {
00136           // eta+1=1:  ieta = -42
00137           // eta+1=13: ieta = -29
00138 
00139           for (int phi=0;phi<72;++phi)
00140             {
00141               if (OccupancyByDepth[mydepth]->GetBinContent(eta+1, phi+1)>0)
00142                 {
00143                   // fill 1D plots
00144                   if (isHB(eta,mydepth+1)) 
00145                     {
00146                       if (validDetId(HcalBarrel, CalcIeta(HcalBarrel, eta, mydepth+1), phi+1, mydepth+1))
00147                         {
00148                           meHBEnergy_1D->Fill(SumEnergyByDepth[mydepth]->GetBinContent(eta+1, phi+1)/OccupancyByDepth[mydepth]->GetBinContent(eta+1, phi+1));
00149                           meHBEnergyRMS_1D->Fill(sqrt(pow(SqrtSumEnergy2ByDepth[mydepth]->GetBinContent(eta+1, phi+1),2)/OccupancyByDepth[mydepth]->GetBinContent(eta+1, phi+1)-pow(SumEnergyByDepth[mydepth]->GetBinContent(eta+1, phi+1)/OccupancyByDepth[mydepth]->GetBinContent(eta+1, phi+1),2)));
00150                         }
00151                     } 
00152                   else if (isHE(eta,mydepth+1)) 
00153                     {
00154                       if (validDetId(HcalEndcap, CalcIeta(HcalEndcap, eta, mydepth+1), phi+1, mydepth+1)) 
00155                         {
00156                           
00157                           meHEEnergy_1D->Fill(SumEnergyByDepth[mydepth]->GetBinContent(eta+1, phi+1)/OccupancyByDepth[mydepth]->GetBinContent(eta+1, phi+1));
00158                           meHEEnergyRMS_1D->Fill(sqrt(pow(SqrtSumEnergy2ByDepth[mydepth]->GetBinContent(eta+1, phi+1),2)/OccupancyByDepth[mydepth]->GetBinContent(eta+1, phi+1)-pow(SumEnergyByDepth[mydepth]->GetBinContent(eta+1, phi+1)/OccupancyByDepth[mydepth]->GetBinContent(eta+1, phi+1),2)));
00159                         }
00160                     }
00161                   else if (isHO(eta,mydepth+1)) 
00162                     {
00163                       if (validDetId(HcalOuter, CalcIeta(HcalOuter, eta, mydepth+1), phi+1, mydepth+1)) 
00164                         {
00165                           meHOEnergy_1D->Fill(SumEnergyByDepth[mydepth]->GetBinContent(eta+1, phi+1)/OccupancyByDepth[mydepth]->GetBinContent(eta+1, phi+1));
00166                           meHOEnergyRMS_1D->Fill(sqrt(pow(SqrtSumEnergy2ByDepth[mydepth]->GetBinContent(eta+1, phi+1),2)/OccupancyByDepth[mydepth]->GetBinContent(eta+1, phi+1)-pow(SumEnergyByDepth[mydepth]->GetBinContent(eta+1, phi+1)/OccupancyByDepth[mydepth]->GetBinContent(eta+1, phi+1),2)));
00167                         }
00168                     } 
00169                   else if (isHF(eta,mydepth+1)) 
00170                     {
00171                       if (validDetId(HcalForward, CalcIeta(HcalForward, eta, mydepth+1), phi+1, mydepth+1)) 
00172                         {
00173                           meHFEnergy_1D->Fill(SumEnergyByDepth[mydepth]->GetBinContent(eta+1, phi+1)/OccupancyByDepth[mydepth]->GetBinContent(eta+1, phi+1));
00174                           meHFEnergyRMS_1D->Fill(sqrt(pow(SqrtSumEnergy2ByDepth[mydepth]->GetBinContent(eta+1, phi+1),2)/OccupancyByDepth[mydepth]->GetBinContent(eta+1, phi+1)-pow(SumEnergyByDepth[mydepth]->GetBinContent(eta+1, phi+1)/OccupancyByDepth[mydepth]->GetBinContent(eta+1, phi+1),2)));
00175                         }
00176                     }
00177                   // normalize 2D plots by number of events
00178                  
00179                   meEnergyByDepth->depth[mydepth]->setBinContent(eta+1, phi+1, SumEnergyByDepth[mydepth]->GetBinContent(eta+1, phi+1)/OccupancyByDepth[mydepth]->GetBinContent(eta+1, phi+1));
00180                   meTimeByDepth->depth[mydepth]->setBinContent(eta+1, phi+1, SumTimeByDepth[mydepth]->GetBinContent(eta+1, phi+1)/OccupancyByDepth[mydepth]->GetBinContent(eta+1, phi+1));
00181                 } // (OccupancyByDepth[mydepth]->GetBinContent(eta+1,phi+1)>0)
00182                 
00183               if (OccupancyThreshByDepth[mydepth]==0) continue;
00184               if (OccupancyThreshByDepth[mydepth]->GetBinContent(eta+1, phi+1)>0)
00185                 {
00186                   // fill 1D plots
00187                   if (isHB(eta,mydepth+1)) 
00188                     {
00189                       if (validDetId(HcalBarrel, CalcIeta(HcalBarrel, eta, mydepth+1), phi+1, mydepth+1))
00190                         {
00191                           meHBEnergyThresh_1D->Fill(SumEnergyThreshByDepth[mydepth]->GetBinContent(eta+1, phi+1)/OccupancyThreshByDepth[mydepth]->GetBinContent(eta+1, phi+1));
00192                           double RMS=pow(SqrtSumEnergy2ThreshByDepth[mydepth]->GetBinContent(eta+1, phi+1),2)/OccupancyThreshByDepth[mydepth]->GetBinContent(eta+1,phi+1)-pow(SumEnergyThreshByDepth[mydepth]->GetBinContent(eta+1, phi+1)/OccupancyThreshByDepth[mydepth]->GetBinContent(eta+1, phi+1),2);
00193                           RMS=pow(fabs(RMS),0.5);
00194                           meHBEnergyRMSThresh_1D->Fill(RMS);
00195                         }
00196                     } 
00197                   else if (isHE(eta,mydepth+1)) 
00198                     {
00199                       if (validDetId(HcalEndcap, CalcIeta(HcalEndcap, eta, mydepth+1), phi+1, mydepth+1)) 
00200                         {
00201                           
00202                           meHEEnergyThresh_1D->Fill(SumEnergyThreshByDepth[mydepth]->GetBinContent(eta+1, phi+1)/OccupancyThreshByDepth[mydepth]->GetBinContent(eta+1, phi+1));
00203                           double RMS=pow(SqrtSumEnergy2ThreshByDepth[mydepth]->GetBinContent(eta+1, phi+1),2)/OccupancyThreshByDepth[mydepth]->GetBinContent(eta+1,phi+1)-pow(SumEnergyThreshByDepth[mydepth]->GetBinContent(eta+1, phi+1)/OccupancyThreshByDepth[mydepth]->GetBinContent(eta+1, phi+1),2);
00204                           RMS=pow(fabs(RMS),0.5);
00205                           meHEEnergyRMSThresh_1D->Fill(RMS);
00206                         }
00207                     }
00208                   else if (isHO(eta,mydepth+1)) 
00209                     {
00210                       if (validDetId(HcalOuter, CalcIeta(HcalOuter, eta, mydepth+1), phi+1, mydepth+1)) 
00211                         {
00212                           meHOEnergyThresh_1D->Fill(SumEnergyThreshByDepth[mydepth]->GetBinContent(eta+1, phi+1)/OccupancyThreshByDepth[mydepth]->GetBinContent(eta+1, phi+1));
00213                           double RMS=pow(SqrtSumEnergy2ThreshByDepth[mydepth]->GetBinContent(eta+1, phi+1),2)/OccupancyThreshByDepth[mydepth]->GetBinContent(eta+1,phi+1)-pow(SumEnergyThreshByDepth[mydepth]->GetBinContent(eta+1, phi+1)/OccupancyThreshByDepth[mydepth]->GetBinContent(eta+1, phi+1),2);
00214                           RMS=pow(fabs(RMS),0.5);
00215                           meHOEnergyRMSThresh_1D->Fill(RMS);
00216                         }
00217                     } 
00218                   else if (isHF(eta,mydepth+1)) 
00219                     {
00220                       if (validDetId(HcalForward, CalcIeta(HcalForward, eta, mydepth+1), phi+1, mydepth+1)) 
00221                         {
00222                           meHFEnergyThresh_1D->Fill(SumEnergyThreshByDepth[mydepth]->GetBinContent(eta+1, phi+1)/OccupancyThreshByDepth[mydepth]->GetBinContent(eta+1, phi+1));
00223                           double RMS=pow(SqrtSumEnergy2ThreshByDepth[mydepth]->GetBinContent(eta+1, phi+1),2)/OccupancyThreshByDepth[mydepth]->GetBinContent(eta+1,phi+1)-pow(SumEnergyThreshByDepth[mydepth]->GetBinContent(eta+1, phi+1)/OccupancyThreshByDepth[mydepth]->GetBinContent(eta+1, phi+1),2);
00224                           RMS=pow(fabs(RMS),0.5);
00225                           meHFEnergyRMSThresh_1D->Fill(RMS);              
00226                         }
00227                     }
00228                   // fill 2D plots
00229                   meEnergyThreshByDepth->depth[mydepth]->setBinContent(eta+1, phi+1, SumEnergyThreshByDepth[mydepth]->GetBinContent(eta+1, phi+1)/OccupancyThreshByDepth[mydepth]->GetBinContent(eta+1, phi+1));
00230                   meTimeThreshByDepth->depth[mydepth]->setBinContent(eta+1, phi+1, SumTimeThreshByDepth[mydepth]->GetBinContent(eta+1, phi+1)/OccupancyThreshByDepth[mydepth]->GetBinContent(eta+1, phi+1));
00231                 }
00232             } // for (int phi=0;phi<72;++phi)
00233         } // for (int eta=0;eta<OccupancyByDepth->..;++eta)
00234     } // for (int mydepth=0;...)
00235 
00236   FillUnphysicalHEHFBins(*meEnergyByDepth);
00237   FillUnphysicalHEHFBins(*meTimeByDepth);
00238   FillUnphysicalHEHFBins(*meEnergyThreshByDepth);
00239   FillUnphysicalHEHFBins(*meTimeThreshByDepth);
00240 
00241   calculateProblems();
00242 }
00243 
00244 void HcalRecHitClient::calculateProblems()
00245 {
00246  if (debug_>2) std::cout <<"\t\tHcalRecHitClient::calculateProblems()"<<std::endl;
00247   if(!dqmStore_) return;
00248   double totalevents=0;
00249   int etabins=0, phibins=0, zside=0;
00250   double problemvalue=0;
00251   std::vector<std::string> name = HcalEtaPhiHistNames(); // use this to get EtaPhiHistograms that feed problem calculation, once they exist (see analyze function for example usage of HcalEtaPhiHistNames())
00252 
00253   // Get histograms used in determining rechit problem rate, 
00254   // and get totalevents from their underflow bins.
00255   // No such problem histograms are defined so far.
00256   
00257   enoughevents_=true;
00258 
00259   if (totalevents==0)
00260     return;
00261 
00262   // Clear away old problems
00263   if (ProblemCells!=0)
00264     {
00265       ProblemCells->Reset();
00266       (ProblemCells->getTH2F())->SetMaximum(1.05);
00267       (ProblemCells->getTH2F())->SetMinimum(0.);
00268     }
00269   for  (unsigned int d=0;d<ProblemCellsByDepth->depth.size();++d)
00270     {
00271       if (ProblemCellsByDepth->depth[d]!=0) 
00272         {
00273           ProblemCellsByDepth->depth[d]->Reset();
00274           (ProblemCellsByDepth->depth[d]->getTH2F())->SetMaximum(1.05);
00275           (ProblemCellsByDepth->depth[d]->getTH2F())->SetMinimum(0.);
00276         }
00277     }
00278   
00279   for (unsigned int d=0;d<ProblemCellsByDepth->depth.size();++d)
00280     {
00281       if (ProblemCellsByDepth->depth[d]==0) continue;
00282 
00283       // Get total events from some future histogram
00284       //totalevents=DigiPresentByDepth[d]->GetBinContent(0); // get totalevents from each depth, in case they differ
00285       if (totalevents==0 || totalevents<minevents_) continue;
00286       etabins=(ProblemCellsByDepth->depth[d]->getTH2F())->GetNbinsX();
00287       phibins=(ProblemCellsByDepth->depth[d]->getTH2F())->GetNbinsY();
00288       problemvalue=0;
00289       for (int eta=0;eta<etabins;++eta)
00290         {
00291           int ieta=CalcIeta(eta,d+1);
00292           if (ieta==-9999) continue;
00293           for (int phi=0;phi<phibins;++phi)
00294             {
00295               problemvalue=0;
00296               // Add histograms here when rechit testing decided upon
00297               /*if (DigiPresentByDepth[d]!=0 && DigiPresentByDepth[d]->GetBinContent(eta+1,phi+1)>0) 
00298                 problemvalue=totalevents; */
00299               
00300               if (problemvalue==0) continue;
00301               problemvalue/=totalevents; // problem value is a rate; should be between 0 and 1
00302               problemvalue = std::min(1.,problemvalue);
00303               
00304               zside=0;
00305               if (isHF(eta,d+1)) // shift ieta by 1 for HF
00306                 ieta<0 ? zside = -1 : zside = 1;
00307               
00308               // For problem cells that exceed our allowed rate,
00309               // set the values to 999 if the cells are already marked in the status database
00310               if (problemvalue>minerrorrate_)
00311                 {
00312                   HcalSubdetector subdet=HcalEmpty;
00313                   if (isHB(eta,d+1))subdet=HcalBarrel;
00314                   else if (isHE(eta,d+1)) subdet=HcalEndcap;
00315                   else if (isHF(eta,d+1)) subdet=HcalForward;
00316                   else if (isHO(eta,d+1)) subdet=HcalOuter;
00317                   HcalDetId hcalid(subdet, ieta, phi+1, (int)(d+1));
00318                   if (badstatusmap.find(hcalid)!=badstatusmap.end())
00319                     problemvalue=999;
00320                 }
00321               
00322               
00323               ProblemCellsByDepth->depth[d]->setBinContent(eta+1,phi+1,problemvalue);
00324               if (ProblemCells!=0) ProblemCells->Fill(ieta+zside,phi+1,problemvalue);
00325             } // loop on phi
00326         } // loop on eta
00327     } // loop on depth
00328 
00329   if (ProblemCells==0)
00330     {
00331       if (debug_>0) std::cout <<"<HcalRecHitClient::analyze> ProblemCells histogram does not exist!"<<std::endl;
00332       return;
00333     }
00334 
00335   // Normalization of ProblemCell plot, in the case where there are errors in multiple depths
00336   etabins=(ProblemCells->getTH2F())->GetNbinsX();
00337   phibins=(ProblemCells->getTH2F())->GetNbinsY();
00338   for (int eta=0;eta<etabins;++eta)
00339     {
00340       for (int phi=0;phi<phibins;++phi)
00341         {
00342           if (ProblemCells->getBinContent(eta+1,phi+1)>1. && ProblemCells->getBinContent(eta+1,phi+1)<999)
00343             ProblemCells->setBinContent(eta+1,phi+1,1.);
00344         }
00345     }
00346   FillUnphysicalHEHFBins(*ProblemCellsByDepth);
00347   FillUnphysicalHEHFBins(ProblemCells);
00348   return;
00349 
00350 }
00351 
00352 void HcalRecHitClient::beginJob()
00353 {
00354   dqmStore_ = edm::Service<DQMStore>().operator->();
00355   if (debug_>0) 
00356     {
00357       std::cout <<"<HcalRecHitClient::beginJob()>  Displaying dqmStore directory structure:"<<std::endl;
00358       dqmStore_->showDirStructure();
00359     }
00360 }
00361 void HcalRecHitClient::endJob(){}
00362 
00363 void HcalRecHitClient::beginRun(void)
00364 {
00365   if (debug_>1)  std::cout <<"<HcalRecHitClient::endRun>"<<std::endl;
00366 
00367   if (!dqmStore_) 
00368     {
00369       if (debug_>0) std::cout <<"<HcalRecHitClient::beginRun> dqmStore does not exist!"<<std::endl;
00370       return;
00371     }
00372   dqmStore_->setCurrentFolder(subdir_);
00373   problemnames_.clear();
00374   ProblemCells=dqmStore_->book2D(" ProblemRecHits",
00375                                  "Problem RecHit Rate for all HCAL;ieta;iphi",
00376                                  85,-42.5,42.5,
00377                                  72,0.5,72.5);
00378   problemnames_.push_back(ProblemCells->getName());
00379   if (debug_>1)
00380     std::cout << "Tried to create ProblemCells Monitor Element in directory "<<subdir_<<"  \t  Failed?  "<<(ProblemCells==0)<<std::endl;
00381   dqmStore_->setCurrentFolder(subdir_+"problem_rechits");
00382   ProblemCellsByDepth=new EtaPhiHists();
00383   ProblemCellsByDepth->setup(dqmStore_," Problem RecHit Rate");
00384   for (unsigned int i=0; i<ProblemCellsByDepth->depth.size();++i)
00385     problemnames_.push_back(ProblemCellsByDepth->depth[i]->getName());
00386 
00387   nevts_=0;
00388 
00389   dqmStore_->setCurrentFolder(subdir_+"Distributions_AllRecHits");
00390   meEnergyByDepth = new EtaPhiHists();
00391   meEnergyByDepth->setup(dqmStore_,"RecHit Average Energy","GeV");
00392   meTimeByDepth = new EtaPhiHists();
00393   meTimeByDepth->setup(dqmStore_,"RecHit Average Time","nS");
00394   // set all average times to -1000 by default (so that they don't show up on plots
00395   for (unsigned int i=0;i<meTimeByDepth->depth.size();++i)
00396     {
00397       (meTimeByDepth->depth[i]->getTH2F())->SetMinimum(-150);
00398       (meTimeByDepth->depth[i]->getTH2F())->SetMaximum(150);
00399       int etabins=(meTimeByDepth->depth[i]->getTH2F())->GetNbinsX();
00400       int phibins=(meTimeByDepth->depth[i]->getTH2F())->GetNbinsY();
00401       for (int x=1;x<=etabins;++x)
00402         for (int y=1;y<=phibins;++y)
00403           meTimeByDepth->depth[i]->setBinContent(x,y,-1000);
00404     }
00405 
00406   dqmStore_->setCurrentFolder(subdir_+"Distributions_PassedMinBias");
00407   meEnergyThreshByDepth = new EtaPhiHists();
00408   meEnergyThreshByDepth->setup(dqmStore_,"Above Threshold RecHit Average Energy","GeV");
00409   meTimeThreshByDepth = new EtaPhiHists();
00410   meTimeThreshByDepth->setup(dqmStore_,"Above Threshold RecHit Average Time","nS");
00411  // set all average times to -1000 by default (so that they don't show up on plots
00412   for (unsigned int i=0;i<meTimeThreshByDepth->depth.size();++i)
00413     {
00414       (meTimeThreshByDepth->depth[i]->getTH2F())->SetMinimum(-150);
00415       (meTimeThreshByDepth->depth[i]->getTH2F())->SetMaximum(150);
00416       int etabins=(meTimeThreshByDepth->depth[i]->getTH2F())->GetNbinsX();
00417       int phibins=(meTimeThreshByDepth->depth[i]->getTH2F())->GetNbinsY();
00418       for (int x=1;x<=etabins;++x)
00419         for (int y=1;y<=phibins;++y)
00420           meTimeThreshByDepth->depth[i]->setBinContent(x,y,-1000);
00421     }
00422 
00423   dqmStore_->setCurrentFolder(subdir_+"Distributions_AllRecHits/rechit_1D_plots/");
00424   meHBEnergy_1D=dqmStore_->book1D("HB_energy_1D","HB Average Energy Per RecHit;Energy (GeV)",400,-5,15);
00425   meHEEnergy_1D=dqmStore_->book1D("HE_energy_1D","HE Average Energy Per RecHit;Energy (GeV)",400,-5,15);
00426   meHOEnergy_1D=dqmStore_->book1D("HO_energy_1D","HO Average Energy Per RecHit;Energy (GeV)",600,-10,20);
00427   meHFEnergy_1D=dqmStore_->book1D("HF_energy_1D","HF Average Energy Per RecHit;Energy (GeV)",400,-5,15);
00428 
00429   meHBEnergyRMS_1D=dqmStore_->book1D("HB_energy_RMS_1D","HB Energy RMS Per RecHit;Energy (GeV)",500,0,5);
00430   meHEEnergyRMS_1D=dqmStore_->book1D("HE_energy_RMS_1D","HE Energy RMS Per RecHit;Energy (GeV)",500,0,5);
00431   meHOEnergyRMS_1D=dqmStore_->book1D("HO_energy_RMS_1D","HO Energy RMS Per RecHit;Energy (GeV)",500,0,5);
00432   meHFEnergyRMS_1D=dqmStore_->book1D("HF_energy_RMS_1D","HF Energy RMS Per RecHit;Energy (GeV)",500,0,5);
00433 
00434   dqmStore_->setCurrentFolder(subdir_+"Distributions_PassedMinBias/rechit_1D_plots/");
00435   meHBEnergyThresh_1D=dqmStore_->book1D("HB_energyThresh_1D","HB Average Energy Per RecHit Above Threshold;Energy (GeV)",400,-5,35);
00436   meHEEnergyThresh_1D=dqmStore_->book1D("HE_energyThresh_1D","HE Average Energy Per RecHit Above Threshold;Energy (GeV)",400,-5,35);
00437   meHOEnergyThresh_1D=dqmStore_->book1D("HO_energyThresh_1D","HO Average Energy Per RecHit Above Threshold;Energy (GeV)",600,-10,50);
00438   meHFEnergyThresh_1D=dqmStore_->book1D("HF_energyThresh_1D","HF Average Energy Per RecHit Above Threshold;Energy (GeV)",400,-5,95);
00439 
00440   meHBEnergyRMSThresh_1D=dqmStore_->book1D("HB_energy_RMSThresh_1D","HB Energy RMS Per RecHit Above Threshold;Energy (GeV)",500,0,10);
00441   meHEEnergyRMSThresh_1D=dqmStore_->book1D("HE_energy_RMSThresh_1D","HE Energy RMS Per RecHit Above Threshold;Energy (GeV)",500,0,10);
00442   meHOEnergyRMSThresh_1D=dqmStore_->book1D("HO_energy_RMSThresh_1D","HO Energy RMS Per RecHit Above Threshold;Energy (GeV)",500,0,10);
00443   meHFEnergyRMSThresh_1D=dqmStore_->book1D("HF_energy_RMSThresh_1D","HF Energy RMS Per RecHit Above Threshold;Energy (GeV)",500,0,20);
00444 }
00445 
00446 void HcalRecHitClient::endRun(void)
00447 {
00448   if (debug_>1)  std::cout <<"<HcalRecHitClient::endRun>"<<std::endl;
00449   analyze();
00450 }
00451 
00452 void HcalRecHitClient::setup(void){}
00453 void HcalRecHitClient::cleanup(void){}
00454 
00455 bool HcalRecHitClient::hasErrors_Temp(void)
00456 {
00457   if (!ProblemCells)
00458     {
00459       if (debug_>1) std::cout <<"<HcalRecHitClient::hasErrors_Temp>  ProblemCells histogram does not exist!"<<std::endl;
00460       return false;
00461     }
00462   int problemcount=0;
00463   int ieta=-9999;
00464 
00465   for (int depth=0;depth<4; ++depth)
00466     {
00467       int etabins  = (ProblemCells->getTH2F())->GetNbinsX();
00468       int phibins  = (ProblemCells->getTH2F())->GetNbinsY();
00469       for (int hist_eta=0;hist_eta<etabins;++hist_eta)
00470         {
00471           for (int hist_phi=0; hist_phi<phibins;++hist_phi)
00472             {
00473               ieta=CalcIeta(hist_eta,depth+1);
00474               if (ieta==-9999) continue;
00475               if (ProblemCellsByDepth->depth[depth]==0)
00476                 continue;
00477               if (ProblemCellsByDepth->depth[depth]->getBinContent(hist_eta,hist_phi)>minerrorrate_)
00478                 ++problemcount;
00479             } // for (int hist_phi=1;...)
00480         } // for (int hist_eta=1;...)
00481     } // for (int depth=0;...)
00482 
00483   if (problemcount>0) return true;
00484   return false;
00485 }
00486 
00487 bool HcalRecHitClient::hasWarnings_Temp(void){return false;}
00488 bool HcalRecHitClient::hasOther_Temp(void){return false;}
00489 bool HcalRecHitClient::test_enabled(void){return true;}
00490 
00491 
00492 
00493 void HcalRecHitClient::updateChannelStatus(std::map<HcalDetId, unsigned int>& myqual)
00494 {
00495   // rechit quality not used to update channel status yet; see dead cell client for example
00496 
00497 
00498 
00499 } //void HcalRecHitClient::updateChannelStatus
00500 
00501