CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/DQM/HcalMonitorClient/src/HcalSummaryClient.cc

Go to the documentation of this file.
00001 #include "DQM/HcalMonitorClient/interface/HcalSummaryClient.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 "DQM/HcalMonitorClient/interface/HcalBaseDQClient.h"
00010 #include "DQM/HcalMonitorTasks/interface/HcalEtaPhiHists.h"
00011 #include "DQMServices/Core/interface/MonitorElement.h"
00012 
00013 #include <iostream>
00014 
00015 /*
00016  * \file HcalSummaryClient.cc
00017  * 
00018  * $Date: 2010/12/09 15:58:26 $
00019  * $Revision: 1.104 $
00020  * \author J. Temple
00021  * \brief Summary Client class
00022  */
00023 
00024 HcalSummaryClient::HcalSummaryClient(std::string myname)
00025 {
00026   name_=myname;
00027   SummaryMapByDepth=0;
00028   minevents_=0;
00029   minerrorrate_=0;
00030   badChannelStatusMask_=0;
00031   ProblemCells=0;
00032   ProblemCellsByDepth=0;
00033   StatusVsLS_=0;
00034   certificationMap_=0;
00035   reportMap_=0;
00036 }
00037 
00038 HcalSummaryClient::HcalSummaryClient(std::string myname, const edm::ParameterSet& ps)
00039 {
00040   name_=myname;
00041   enableCleanup_         = ps.getUntrackedParameter<bool>("enableCleanup",false);
00042   debug_                 = ps.getUntrackedParameter<int>("debug",0);
00043   prefixME_              = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
00044   if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
00045     prefixME_.append("/");
00046   subdir_                = ps.getUntrackedParameter<std::string>("SummaryFolder","EventInfo/"); // SummaryMonitor_Hcal  
00047   if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
00048     subdir_.append("/");
00049   subdir_=prefixME_+subdir_;
00050   cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
00051 
00052   NLumiBlocks_ = ps.getUntrackedParameter<int>("NLumiBlocks",4000);
00053   UseBadChannelStatusInSummary_ = ps.getUntrackedParameter<bool>("UseBadChannelStatusInSummary",false);
00054 
00055   // These aren't used in summary client, are they?
00056   badChannelStatusMask_   = ps.getUntrackedParameter<int>("Summary_BadChannelStatusMask",
00057                                                           ps.getUntrackedParameter<int>("BadChannelStatusMask",0));
00058   minerrorrate_ = ps.getUntrackedParameter<double>("Summary_minerrorrate",
00059                                                    ps.getUntrackedParameter<double>("minerrorrate",0));
00060   minevents_    = ps.getUntrackedParameter<int>("Summary_minevents",
00061                                                 ps.getUntrackedParameter<int>("minevents",0));
00062   SummaryMapByDepth=0;
00063   ProblemCells=0;
00064   ProblemCellsByDepth=0;
00065   StatusVsLS_=0;
00066   certificationMap_=0;
00067   reportMap_=0;
00068 }
00069 
00070 void HcalSummaryClient::analyze(int LS)
00071 { 
00072   if (debug_>2) std::cout <<"\tHcalSummaryClient::analyze()"<<std::endl;
00073 
00074   // 
00075 
00076   // Start with counters in 'unknown' status; they'll be set by analyze_everything routines 
00077   status_global_=-1; 
00078   status_HB_=-1; 
00079   status_HE_=-1; 
00080   status_HO_=-1; 
00081   status_HF_=-1; 
00082 
00083   status_HO0_=-1;
00084   status_HO12_=-1;
00085   status_HFlumi_=-1;
00086   status_global_=-1;
00087 
00088   if (EnoughEvents_!=0) EnoughEvents_->Reset();
00089   enoughevents_=true; // assume we have enough events for all tests to have run
00090   for (std::vector<HcalBaseDQClient*>::size_type i=0;i<clients_.size();++i)
00091     {
00092       if (debug_>2) std::cout <<"<HcalSummaryClient::analyze>  CLIENT = "<<clients_[i]->name_<<"  ENOUGH = "<<clients_[i]->enoughevents_<<std::endl;
00093       enoughevents_&=clients_[i]->enoughevents_;
00094       if (EnoughEvents_!=0) EnoughEvents_->setBinContent(i+1,clients_[i]->enoughevents_);
00095       {
00096         if (clients_[i]->enoughevents_==false && debug_>1)
00097           std::cout <<"Failed enoughevents test for monitor "<<clients_[i]->name()<<std::endl;
00098       }
00099     }
00100 
00101   // check to find which subdetectors are present -- need to do this prior to checking whether enoughevents_ == false!
00102   MonitorElement* temp_present;
00103   if (HBpresent_!=1)
00104     {
00105       temp_present=dqmStore_->get(prefixME_+"HcalInfo/HBpresent");
00106       if (temp_present!=0)
00107         HBpresent_=temp_present->getIntValue();
00108     }
00109   if (HEpresent_!=1)
00110     {
00111       temp_present=dqmStore_->get(prefixME_+"HcalInfo/HEpresent");
00112       if (temp_present!=0)
00113         HEpresent_=temp_present->getIntValue();
00114     }
00115   if (HOpresent_!=1)
00116     {
00117       temp_present=dqmStore_->get(prefixME_+"HcalInfo/HOpresent");
00118       if (temp_present!=0)
00119         HOpresent_=temp_present->getIntValue();
00120     }
00121   if (HFpresent_!=1)
00122     {
00123       temp_present=dqmStore_->get(prefixME_+"HcalInfo/HFpresent");
00124       if (temp_present!=0)
00125         HFpresent_=temp_present->getIntValue();
00126     }
00127 
00128   if (debug_>1) 
00129     std::cout <<"<HcalSummaryClient::analyze>  HB present = "<<HBpresent_<<" "<<"HE present = "<<HEpresent_<<" "<<"HO present = "<<HOpresent_<<" "<<"HF present = "<<HFpresent_<<std::endl;
00130   
00131   if (enoughevents_==false)
00132     {
00133       if (debug_>0) std::cout <<"<HcalSummaryClient::analyze>  Not enough events processed to evaluate summary status!"<<std::endl;
00134       
00135       // 'HXpresent_' values are set to -1 by default. 
00136       // They are set to +1 when a channel is present.
00137       // I don't think there are any cases where values =0,
00138       // but I'm not positive of this yet -- Jeff, 10 Aug 2010
00139 
00140       // Check whether any events are found for each subdetector
00141       if (HBpresent_>0) status_HB_=1;
00142       else status_HB_=-1;  // HB not present or unknown
00143       if (HEpresent_>0) status_HE_=1;
00144       else status_HE_=-1;  // HE not present or unknown
00145       if (HOpresent_>0) status_HO_=1;
00146       else status_HO_=-1;  // HO not present or unknown
00147       if (HFpresent_>0) status_HF_=1;
00148       else status_HF_=-1;  // HF not present or unknown
00149 
00150       // Update this in the future?  Use '||' instead of '&&'?
00151       if (HBpresent_<=0 && HEpresent_<=0 && HOpresent_<=0 && HFpresent_<=0)
00152         status_global_=-1;
00153       else
00154         status_global_=1;
00155       
00156       // Set other statuses based on subdetectors
00157       status_HO0_    = status_HO_;
00158       status_HO12_   = status_HO_;
00159       status_HFlumi_ = status_HF_;
00160       
00161       if (debug_>1)
00162         {
00163           std::cout <<"Insufficient events processed.  Subdetector status is:"<<std::endl;
00164           std::cout<<"\tHB: "<<status_HB_<<std::endl;
00165           std::cout<<"\tHE: "<<status_HE_<<std::endl;
00166           std::cout<<"\tHO: "<<status_HO_<<std::endl;
00167           std::cout<<"\tHF: "<<status_HF_<<std::endl;
00168           std::cout<<"\tHO0: "<<status_HO0_<<std::endl;
00169           std::cout<<"\tHO12: "<<status_HO12_<<std::endl;
00170           std::cout<<"\tHFlumi: "<<status_HFlumi_<<std::endl;
00171         }
00172 
00173       fillReportSummary(LS);
00174       return;
00175     }
00176   if (EnoughEvents_!=0) EnoughEvents_->setBinContent(clients_.size()+1,1); // summary is good to go!
00177 
00178   // set status to 0 if subdetector is present (or assumed present)
00179   if (HBpresent_>0) status_HB_=0;
00180   if (HEpresent_>0) status_HE_=0;
00181   if (HOpresent_>0) {status_HO_=0; status_HO0_=0; status_HO12_=0;}
00182   if (HFpresent_>0) {status_HF_=0; status_HFlumi_=0;}
00183 
00184   if (HBpresent_>0 || HEpresent_>0 ||
00185       HOpresent_>0 || HFpresent_>0 ) 
00186     status_global_=0;
00187 
00188   // don't want to fool with variable-sized arrays at the moment; revisit later
00189   //const unsigned int csize=clients_.size();
00190   double localHB[20]={0};
00191   double localHE[20]={0};
00192   double localHF[20]={0};
00193   double localHO[20]={0};
00194   double localHFlumi[20]={0};
00195   double localHO0[20]={0};
00196   double localHO12[20]={0};
00197 
00198   // reset all depth histograms
00199   if (SummaryMapByDepth==0)
00200     {
00201       if (debug_>0)
00202         std::cout <<"<HcalSummaryClient::analyze>  ERROR:  SummaryMapByDepth can't be found!"<<std::endl;
00203     }
00204   else 
00205     {
00206       for (unsigned int i=0;i<(SummaryMapByDepth->depth).size();++i)
00207         SummaryMapByDepth->depth[i]->Reset();
00208  
00209       int etabins=-9999;
00210       int phibins=-9999;
00211   
00212       // Get Channel Status histograms here
00213       std::vector<MonitorElement*> chStat;
00214       chStat.push_back(dqmStore_->get(prefixME_+"HcalInfo/ChannelStatus/HB HE HF Depth 1 ChannelStatus"));
00215       chStat.push_back(dqmStore_->get(prefixME_+"HcalInfo/ChannelStatus/HB HE HF Depth 2 ChannelStatus"));
00216       chStat.push_back(dqmStore_->get(prefixME_+"HcalInfo/ChannelStatus/HE Depth 3 ChannelStatus"));
00217       chStat.push_back(dqmStore_->get(prefixME_+"HcalInfo/ChannelStatus/HO Depth 4 ChannelStatus"));
00218 
00219 
00220       for (int d=0;d<4;++d)
00221         {
00222           etabins=(SummaryMapByDepth->depth[d])->getNbinsX();
00223           phibins=(SummaryMapByDepth->depth[d])->getNbinsY();
00224           for (int eta=1;eta<=etabins;++eta)
00225             {
00226               int ieta=CalcIeta(eta-1,d+1);
00227               for (int phi=1;phi<=phibins;++phi)
00228                 {
00229                   // local phi counter is the same as iphi
00230                   // for |ieta|>20, iphi%2==0 cells are unphysical; skip 'em
00231                   // for |ieta|>39, iphi%4!=3 cells are unphysical
00232                   if (abs(ieta)>20 && phi%2==0) continue;
00233                   if (abs(ieta)>39 && phi%4!=3) continue;
00234 
00235                   // First loop calculates "local" error rates for each individual client
00236                   // This must be done separately from the SummaryMap overall loop, because that loop issues a
00237                   // 'break' the first time an error is found (to avoid double-counting multiple errors in a single channel).
00238                   for (unsigned int cl=0;cl<clients_.size();++cl)
00239                     {
00240                       if (clients_[cl]->ProblemCellsByDepth==0) continue;
00241 
00242                       if ((clients_[cl]->ProblemCellsByDepth)->depth[d]==0) continue;
00243                       if ((clients_[cl]->ProblemCellsByDepth)->depth[d]->getBinContent(eta,phi)>clients_[cl]->minerrorrate_)
00244                         {
00245                           if (isHF(eta-1,d+1)) 
00246                             {
00247                               ++localHF[cl];
00248                               if ((d==0 && (abs(ieta)==33 || abs(ieta)==34)) ||   // depth 1, rings 33,34
00249                                   (d==1 && (abs(ieta)==35 || abs(ieta)==36)))     // depth 2, rings 35,36
00250                                 ++localHFlumi[cl]; 
00251                             }
00252                           else if (isHO(eta-1,d+1)) 
00253                             {
00254                               ++localHO[cl];
00255                               if (abs(ieta)<5) ++localHO0[cl]; 
00256                               else ++localHO12[cl]; 
00257                             }
00258                           else if (isHB(eta-1,d+1)) ++localHB[cl];
00259                           else if (isHE(eta-1,d+1)) ++localHE[cl];
00260                         }
00261                     } // for (loop on clients_.size() to determine individual client error rates)
00262 
00263                   // Check for certification errors -- do we want to add some extra warnings (filling channel status db plot with new value, etc?) in this case?
00264 
00265                   if (UseBadChannelStatusInSummary_ && chStat[d]!=0)
00266                     {
00267                       double chanStat=chStat[d]->getBinContent(eta,phi);
00268                       // chanStat<0 indicates original status from database was <0; this is counted as an error,
00269                       // since such values should never appear in the database.
00270                       if (chanStat<0)
00271                         {
00272                           if (isHF(eta-1,d+1))
00273                             {
00274                               ++status_HF_;
00275                               if ((d==0 && (abs(ieta)==33 || abs(ieta)==34)) ||   // depth 1, rings 33,34
00276                               (d==1 && (abs(ieta)==35 || abs(ieta)==36)))     // depth 2, rings 35,36
00277                                 {
00278                               ++status_HFlumi_; 
00279                                 }
00280                               continue; // don't bother looking at individual clients for results; channel status is already corrupted
00281                             }
00282                           else if (isHO(eta-1,d+1))
00283                             {
00284                               ++status_HO_;
00285                               if (abs(ieta)<5) 
00286                                 ++status_HO0_; 
00287                               else ++status_HO12_; 
00288                               continue;
00289                             }
00290                           else if (isHB(eta-1,d+1))
00291                             {
00292                               ++status_HB_;
00293                               continue;
00294                             }
00295                           else if (isHE(eta-1,d+1))
00296                             {
00297                               ++status_HE_;
00298                               continue;
00299                             }
00300                         } // if (chanStat<0)
00301                     } // if (UseBadChannelStatusInSummary_)
00302 
00303                   // loop over all client tests
00304                  
00305                   // SummaryMapByDepth is slightly different from previous version -- it now just shows cells
00306                   // that contribute as "problems", rather than giving good channels a status of 1, and bad a status of 0
00307                   for (unsigned int cl=0;cl<clients_.size();++cl)
00308                     {
00309                       // Best way to handle this?  
00310                       // We know that first element is HcalMonitorModule info, which has
00311                       // no problem cells defined.  Create some, or start counting from cl=1?
00312                       if (debug_>4 && eta==1 && phi==1) std::cout <<"Checking summary for client "<<clients_[cl]->name()<<std::endl;
00313                       if (clients_[cl]->ProblemCellsByDepth==0) continue;
00314 
00315                       if ((clients_[cl]->ProblemCellsByDepth)->depth[d]==0) continue;
00316                       if ((clients_[cl]->ProblemCellsByDepth)->depth[d]->getBinContent(eta,phi)>clients_[cl]->minerrorrate_)
00317                         {
00318                           if ((clients_[cl]->ProblemCellsByDepth)->depth[d]->getBinContent(eta,phi)<999)
00319                             SummaryMapByDepth->depth[d]->setBinContent(eta,phi,1);
00320                           else 
00321                             SummaryMapByDepth->depth[d]->setBinContent(eta,phi,999); // known problems filled with a value of 999
00322                           if (isHF(eta-1,d+1)) 
00323                             {
00324                               ++status_HF_;
00325                               if ((d==0 && (abs(ieta)==33 || abs(ieta)==34)) ||   // depth 1, rings 33,34
00326                                   (d==1 && (abs(ieta)==35 || abs(ieta)==36)))     // depth 2, rings 35,36
00327                                 {
00328                                   ++status_HFlumi_; 
00329                                 }
00330                             }
00331                           else if (isHO(eta-1,d+1)) 
00332                             {
00333                               ++status_HO_;
00334                               if (abs(ieta)<5) 
00335                                   ++status_HO0_; 
00336                               else ++status_HO12_; 
00337                             }
00338                           else if (isHB(eta-1,d+1)) ++status_HB_;
00339                           else if (isHE(eta-1,d+1)) ++status_HE_;
00340                           break; // man, this break causes problems for certificationMap!!! -- Jason;   WHY?  -- Jeff
00341                         }
00342                     } // for (main loop on clients_.size() to calculate reportSummary statuses)
00343                 }
00344             }
00345         } // for (int d=0;d<4;++d)
00346 
00347       FillUnphysicalHEHFBins(*SummaryMapByDepth);
00348     } // else (SummaryMapByDepth exists)
00349 
00350   // We've checked all problems; now compute overall status
00351   int totalcells=0;
00352   std::map<std::string, int>::const_iterator it;
00353 
00354   if (HBpresent_>0)
00355     {
00356       status_global_+=status_HB_; 
00357       it=subdetCells_.find("HB");
00358       totalcells+=it->second;
00359       status_HB_= 1-(status_HB_/it->second);
00360       for (unsigned int i=0;i<clients_.size();++i)
00361         {
00362           localHB[i]=1-(1.*localHB[i]/it->second);
00363           localHB[i]=std::max(0.,localHB[i]);
00364         }
00365       status_HB_=std::max(0.,status_HB_); // converts fraction of bad channels to good fraction
00366     }
00367   else status_HB_=-1; // enoughevents_ can be true even if HB not present; need to set status_HB_=-1 in both cases
00368  
00369   if (HEpresent_>0)
00370     {
00371       status_global_+=status_HE_;
00372       it=subdetCells_.find("HE");
00373       totalcells+=it->second;
00374       status_HE_= 1-(status_HE_/it->second);
00375       for (unsigned int i=0;i<clients_.size();++i)
00376         {
00377           localHE[i]=1-(1.*localHE[i]/it->second);
00378           localHE[i]=std::max(0.,localHE[i]);
00379         }
00380       status_HE_=std::max(0.,status_HE_); // converts fraction of bad channels to good fraction
00381     }
00382   else status_HE_=-1;
00383  
00384   if (HOpresent_>0)
00385     {
00386       status_global_+=status_HO_;
00387       it=subdetCells_.find("HO");
00388       totalcells+=it->second;
00389       status_HO_= 1-(status_HO_/it->second);
00390       status_HO_=std::max(0.,status_HO_); // converts fraction of bad channels to good fraction
00391       for (unsigned int i=0;i<clients_.size();++i)
00392         {
00393           localHO[i]=1-(1.*localHO[i]/it->second);
00394           localHO[i]=std::max(0.,localHO[i]);
00395         }
00396       it=subdetCells_.find("HO0");
00397       status_HO0_= 1-(status_HO0_/it->second);
00398       for (unsigned int i=0;i<clients_.size();++i)
00399         {
00400           localHO0[i]=1-(1.*localHO0[i]/it->second);
00401           localHO0[i]=std::max(0.,localHO0[i]);
00402         }
00403       status_HO0_=std::max(0.,status_HO0_); // converts fraction of bad channels to good fraction
00404       it=subdetCells_.find("HO12");
00405       status_HO12_= 1-(status_HO12_/it->second);
00406       status_HO12_=std::max(0.,status_HO12_); // converts fraction of bad channels to good fraction
00407       for (unsigned int i=0;i<clients_.size();++i)
00408         {
00409           localHO12[i]=1-(1.*localHO12[i]/it->second);
00410           localHO12[i]=std::max(0.,localHO12[i]);
00411         }
00412     }
00413   else
00414     {
00415       status_HO_=-1;
00416       status_HO0_=-1;
00417       status_HO12_=-1;
00418     }
00419   if (HFpresent_>0)
00420     {
00421       status_global_+=status_HF_;
00422       it=subdetCells_.find("HF");
00423       totalcells+=it->second;
00424       status_HF_= 1-(status_HF_/it->second);
00425       status_HF_=std::max(0.,status_HF_); // converts fraction of bad channels to good fraction
00426       for (unsigned int i=0;i<clients_.size();++i)
00427         {
00428           localHF[i]=1-(1.*localHF[i]/it->second);
00429           localHF[i]=std::max(0.,localHF[i]);
00430         }
00431       it=subdetCells_.find("HFlumi");
00432       status_HFlumi_= 1-(status_HFlumi_/it->second);
00433       status_HFlumi_=std::max(0.,status_HFlumi_); // converts fraction of bad channels to good fraction
00434       for (unsigned int i=0;i<clients_.size();++i)
00435         {
00436           localHFlumi[i]=1-(1.*localHFlumi[i]/it->second);
00437           localHFlumi[i]=std::max(0.,localHFlumi[i]);
00438         }
00439     }
00440   else
00441     {
00442       status_HF_=-1;
00443       status_HFlumi_=-1;
00444     }
00445  
00446   if (totalcells==0)
00447     status_global_=-1;
00448   else
00449     {
00450       status_global_=1-status_global_/totalcells;
00451       status_global_=std::max(0.,status_global_); // convert to good fraction
00452     }
00453  
00454 
00455   // Fill certification map here
00456 
00457   dqmStore_->setCurrentFolder(prefixME_+"HcalInfo");
00458   certificationMap_=dqmStore_->get(prefixME_+"HcalInfo/CertificationMap");
00459   if (certificationMap_) dqmStore_->removeElement(certificationMap_->getName());
00460   certificationMap_=dqmStore_->book2D("CertificationMap","Certification Map",7,0,7,
00461                                       clients_.size()+1,0,clients_.size()+1);
00462 
00463   certificationMap_->getTH2F()->GetYaxis()->SetBinLabel(1,"Summary");
00464   (certificationMap_->getTH2F())->SetOption("textcolz");
00465 
00466   for (int i=0;i<(int)clients_.size();++i)
00467     {
00468       certificationMap_->getTH2F()->GetYaxis()->SetBinLabel(i+2,(clients_[i]->name()).c_str());
00469     }
00470   certificationMap_->getTH2F()->GetYaxis()->SetLabelSize(0.02);
00471   certificationMap_->getTH2F()->GetXaxis()->SetBinLabel(1,"HB");
00472   certificationMap_->getTH2F()->GetXaxis()->SetBinLabel(2,"HE");
00473   certificationMap_->getTH2F()->GetXaxis()->SetBinLabel(3,"HO");
00474   certificationMap_->getTH2F()->GetXaxis()->SetBinLabel(4,"HF");
00475   certificationMap_->getTH2F()->GetXaxis()->SetBinLabel(5,"HO0");
00476   certificationMap_->getTH2F()->GetXaxis()->SetBinLabel(6,"HO12");
00477   certificationMap_->getTH2F()->GetXaxis()->SetBinLabel(7,"HFlumi");
00478   certificationMap_->getTH2F()->SetMinimum(-1);
00479   certificationMap_->getTH2F()->SetMaximum(1);
00480 
00481   for (unsigned int i=0;i<clients_.size();++i)
00482     {
00483       certificationMap_->setBinContent(1,i+2,localHB[i]);
00484       certificationMap_->setBinContent(2,i+2,localHE[i]);
00485       certificationMap_->setBinContent(3,i+2,localHO[i]);
00486       certificationMap_->setBinContent(4,i+2,localHF[i]);
00487       certificationMap_->setBinContent(5,i+2,localHO0[i]);
00488       certificationMap_->setBinContent(6,i+2,localHO12[i]);
00489       certificationMap_->setBinContent(7,i+2,localHF[i]);
00490     }
00491   certificationMap_->setBinContent(1,1,status_HB_);
00492   certificationMap_->setBinContent(2,1,status_HE_);
00493   certificationMap_->setBinContent(3,1,status_HO_);
00494   certificationMap_->setBinContent(4,1,status_HF_);
00495   certificationMap_->setBinContent(5,1,status_HO0_);
00496   certificationMap_->setBinContent(6,1,status_HO12_);
00497   certificationMap_->setBinContent(7,1,status_HF_);
00498   fillReportSummary(LS);
00499 } // analyze
00500 
00501 void HcalSummaryClient::fillReportSummary(int LS)
00502 {
00503 
00504   // We've now checked all tasks; now let's calculate summary values
00505  
00506   if (debug_>2)  std::cout <<"<HcalSummaryClient::fillReportSummary>"<<std::endl;
00507 
00508   if (debug_>3) 
00509     {
00510       std::cout <<"STATUS = "<<std::endl;
00511       std::cout <<"HB = "<<status_HB_<<std::endl;
00512       std::cout <<"HE = "<<status_HE_<<std::endl;
00513       std::cout <<"HO = "<<status_HO_<<std::endl;
00514       std::cout <<"HF = "<<status_HF_<<std::endl;
00515       std::cout <<"HO0 = "<<status_HO0_<<std::endl;
00516       std::cout <<"HO12 = "<<status_HO12_<<std::endl;
00517       std::cout <<"HFlumi = "<<status_HFlumi_<<std::endl;
00518     }
00519 
00520   // put the summary values into MonitorElements 
00521 
00522   if (LS>0)
00523     {
00524       if (StatusVsLS_)
00525         {
00526           StatusVsLS_->setBinContent(LS,1,status_HB_);
00527           StatusVsLS_->setBinContent(LS,2,status_HE_);
00528           StatusVsLS_->setBinContent(LS,3,status_HO_);
00529           StatusVsLS_->setBinContent(LS,4,status_HF_);
00530           StatusVsLS_->setBinContent(LS,5,status_HO0_);
00531           StatusVsLS_->setBinContent(LS,6,status_HO12_);
00532           StatusVsLS_->setBinContent(LS,7,status_HFlumi_);
00533         }
00534     }
00535 
00536   MonitorElement* me;
00537   dqmStore_->setCurrentFolder(subdir_);
00538  
00539   //me=dqmStore_->get(subdir_+"reportSummaryMap");
00540   if (reportMap_)
00541     {
00542       reportMap_->setBinContent(1,1,status_HB_);
00543       reportMap_->setBinContent(2,1,status_HE_);
00544       reportMap_->setBinContent(3,1,status_HO_);
00545       reportMap_->setBinContent(4,1,status_HF_);
00546       reportMap_->setBinContent(5,1,status_HO0_);
00547       reportMap_->setBinContent(6,1,status_HO12_);
00548       reportMap_->setBinContent(7,1,status_HFlumi_);
00549       // Set reportMap underflow bin based on whether enough total events have been processed
00550       if (enoughevents_==false)
00551         reportMap_->setBinContent(0,0,-1);
00552       else
00553         reportMap_->setBinContent(0,0,1);
00554     }
00555   else if (debug_>0) std::cout <<"<HcalSummaryClient::fillReportSummary> CANNOT GET REPORT SUMMARY MAP!!!!!"<<std::endl;
00556 
00557   me=dqmStore_->get(subdir_+"reportSummary");
00558   // Clear away old versions
00559   if (me) me->Fill(status_global_);
00560 
00561   // Create floats for each subdetector status
00562   std::string subdets[7] = {"HB","HE","HO","HF","HO0","HO12","HFlumi"};
00563   for (unsigned int i=0;i<7;++i)
00564     {
00565       // Create floats showing subtasks status
00566       dqmStore_->setCurrentFolder( subdir_+ "reportSummaryContents" );  
00567       me=dqmStore_->get(subdir_+"reportSummaryContents/Hcal_"+subdets[i]);
00568       if (me==0)
00569         {
00570           if (debug_>0) std::cout <<"<HcalSummaryClient::analyze()>  Could not get Monitor Element named 'Hcal_"<<subdets[i]<<"'"<<std::endl;
00571           continue;
00572         }
00573       if (subdets[i]=="HB") me->Fill(status_HB_);
00574       else if (subdets[i]=="HE") me->Fill(status_HE_);
00575       else if (subdets[i]=="HO") me->Fill(status_HO_);
00576       else if (subdets[i]=="HF") me->Fill(status_HF_);
00577       else if (subdets[i]=="HO0") me->Fill(status_HO0_);
00578       else if (subdets[i]=="HO12") me->Fill(status_HO12_);
00579       else if (subdets[i]=="HFlumi") me->Fill(status_HFlumi_);
00580     } // for (unsigned int i=0;...)
00581 
00582 } // fillReportSummary()
00583 
00584 
00585 void HcalSummaryClient::fillReportSummaryLSbyLS(int LS)
00586 {
00587 
00588   MonitorElement* me;
00589   dqmStore_->setCurrentFolder(prefixME_+"LSbyLS_Hcal/LSvalues");
00590   
00591   float status_HB=-1;
00592   float status_HE=-1;
00593   float status_HO=-1;
00594   float status_HF=-1;
00595   float status_HO0=-1;
00596   float status_HO12=-1;
00597   float status_HFlumi=-1;
00598   float status_global=-1;
00599 
00600   me=dqmStore_->get(prefixME_+"LSbyLS_Hcal/LSvalues/ProblemsThisLS");
00601   if (me!=0)
00602     {
00603       //check to see if enough events were processed to make tests
00604       int events=(int)me->getBinContent(-1);
00605       if (events>0)
00606         {
00607           std::map<std::string, int>::const_iterator it;
00608           int totalcells=0;
00609 
00610           status_HB=me->getBinContent(1,1);
00611           status_HE=me->getBinContent(2,1);
00612           status_HO=me->getBinContent(3,1);
00613           status_HF=me->getBinContent(4,1);
00614           status_HO0=me->getBinContent(5,1);
00615           status_HO12=me->getBinContent(6,1);
00616           status_HFlumi=me->getBinContent(7,1);
00617 
00618           status_global=status_HB+status_HE+status_HO+status_HF;
00619           if (debug_>1) std::cout <<"<HcalSummaryClient::fillReportsummaryLSbyLS>   BAD CHANNELS*EVENTS = HB: "<<status_HB<<" HE: "<<status_HE<<" HO: "<<status_HO<<" HO0: "<<status_HO0<<" HO12: "<<status_HO12<<" HF:"<<status_HF<<" HFlumi: "<<status_HFlumi<<"  TOTAL BAD CHANNELS*EVENTS = "<<status_global<<"  TOTAL EVENTS = "<<events<<std::endl;
00620 
00621           it=subdetCells_.find("HB");
00622           totalcells+=it->second;
00623           if (it->second>0)
00624             status_HB=1-(status_HB)/events/it->second;
00625 
00626           it=subdetCells_.find("HE");
00627           totalcells+=it->second;
00628           if (it->second>0)
00629             status_HE=1-(status_HE)/events/it->second;
00630 
00631           it=subdetCells_.find("HO");
00632           totalcells+=it->second;
00633           if (it->second>0)
00634             status_HO=1-(status_HO)/events/it->second;
00635 
00636           it=subdetCells_.find("HF");
00637           totalcells+=it->second;
00638           if (it->second>0)
00639             status_HF=1-(status_HF)/events/it->second;
00640 
00641           it=subdetCells_.find("HO0");
00642           if (it->second>0)
00643             status_HO0=1-(status_HO0)/events/it->second;
00644 
00645           it=subdetCells_.find("HO12");
00646           if (it->second>0)
00647             status_HO12=1-(status_HO12)/events/it->second;
00648 
00649           it=subdetCells_.find("HFlumi");
00650           if (it->second>0)
00651             status_HFlumi=1-(status_HFlumi)/events/it->second;
00652           if (totalcells>0)
00653             status_global=1-status_global/events/totalcells;
00654           if (debug_>1) std::cout <<"<HcalSummaryClient::fillReportsummaryLSbyLS>   STATUS= HB: "<<status_HB<<" HE: "<<status_HE<<" HO: "<<status_HO<<" HO0: "<<status_HO0<<" HO12: "<<status_HO12<<" HF:"<<status_HF<<" HFlumi: "<<status_HFlumi<<"  GLOBAL STATUS = "<<status_global<<"  TOTAL EVENTS = "<<events<<std::endl;
00655         } // if (events(>0)
00656     } // if (me!=0)
00657 
00658   dqmStore_->setCurrentFolder(subdir_);
00659   if (reportMap_)
00660     {
00661       reportMap_->setBinContent(1,1,status_HB);
00662       reportMap_->setBinContent(2,1,status_HE);
00663       reportMap_->setBinContent(3,1,status_HO);
00664       reportMap_->setBinContent(4,1,status_HF);
00665       reportMap_->setBinContent(5,1,status_HO0);
00666       reportMap_->setBinContent(6,1,status_HO12);
00667       reportMap_->setBinContent(7,1,status_HFlumi);
00668       // Set reportMap underflow bin based on whether enough total events have been processed
00669       if (enoughevents_==false)
00670         reportMap_->setBinContent(0,0,-1);
00671       else
00672         reportMap_->setBinContent(0,0,1);
00673 
00674     }
00675   else if (debug_>0) std::cout <<"<HcalSummaryClient::fillReportSummaryLSbyLS> CANNOT GET REPORT SUMMARY MAP!!!!!"<<std::endl;
00676 
00677   me=dqmStore_->get(subdir_+"reportSummary");
00678   // Clear away old versions
00679   if (me) me->Fill(status_global);
00680 
00681   // Create floats for each subdetector status
00682   std::string subdets[7] = {"HB","HE","HO","HF","HO0","HO12","HFlumi"};
00683   for (unsigned int i=0;i<7;++i)
00684     {
00685       // Create floats showing subtasks status
00686       dqmStore_->setCurrentFolder( subdir_+ "reportSummaryContents" );  
00687       me=dqmStore_->get(subdir_+"reportSummaryContents/Hcal_"+subdets[i]);
00688       if (me==0)
00689         {
00690           if (debug_>0) std::cout <<"<HcalSummaryClient::LSbyLS>  Could not get Monitor Element named 'Hcal_"<<subdets[i]<<"'"<<std::endl;
00691           continue;
00692         }
00693       if (subdets[i]=="HB") me->Fill(status_HB);
00694       else if (subdets[i]=="HE") me->Fill(status_HE);
00695       else if (subdets[i]=="HO") me->Fill(status_HO);
00696       else if (subdets[i]=="HF") me->Fill(status_HF);
00697       else if (subdets[i]=="HO0") me->Fill(status_HO0);
00698       else if (subdets[i]=="HO12") me->Fill(status_HO12);
00699       else if (subdets[i]=="HFlumi") me->Fill(status_HFlumi);
00700     } // for (unsigned int i=0;...)
00701 
00702   
00703   if (StatusVsLS_)
00704     {
00705       StatusVsLS_->setBinContent(LS,1,status_HB);
00706       StatusVsLS_->setBinContent(LS,2,status_HE);
00707       StatusVsLS_->setBinContent(LS,3,status_HO);
00708       StatusVsLS_->setBinContent(LS,4,status_HF);
00709       StatusVsLS_->setBinContent(LS,5,status_HO0);
00710       StatusVsLS_->setBinContent(LS,6,status_HO12);
00711       StatusVsLS_->setBinContent(LS,7,status_HFlumi);
00712     }
00713 
00714   return;
00715 
00716 
00717 } // void HcalSummaryClient::fillReportSummaryLSbyLS()
00718 
00719 
00720 
00721 void HcalSummaryClient::beginJob()
00722 {
00723   dqmStore_ = edm::Service<DQMStore>().operator->();
00724   // set total number of cells in each subdetector
00725   subdetCells_.insert(std::make_pair("HB",2592));
00726   subdetCells_.insert(std::make_pair("HE",2592));
00727   subdetCells_.insert(std::make_pair("HO",2160));
00728   subdetCells_.insert(std::make_pair("HF",1728));
00729   subdetCells_.insert(std::make_pair("HO0",576));
00730   subdetCells_.insert(std::make_pair("HO12",1584));
00731   subdetCells_.insert(std::make_pair("HFlumi",288));  // 8 rings, 36 cells/ring
00732   // Assume subdetectors are 'unknown'
00733   HBpresent_=-1;
00734   HEpresent_=-1;
00735   HOpresent_=-1;
00736   HFpresent_=-1;
00737   
00738   EnoughEvents_=0;
00739   MinEvents_=0;
00740   MinErrorRate_=0;
00741 }
00742 
00743 void HcalSummaryClient::endJob(){}
00744 
00745 void HcalSummaryClient::beginRun(void)
00746 {
00747   if (!dqmStore_) 
00748     {
00749       if (debug_>0) std::cout <<"<HcalSummaryClient::beginRun> dqmStore does not exist!"<<std::endl;
00750       return;
00751     }
00752   nevts_=0;
00753 
00754   dqmStore_->setCurrentFolder(subdir_);
00755 
00756   MonitorElement* me;
00757   // reportSummary holds overall detector status
00758   me=dqmStore_->get(subdir_+"reportSummary");
00759   // Clear away old versions
00760   if (me) dqmStore_->removeElement(me->getName());
00761   me = dqmStore_->bookFloat("reportSummary");
00762   me->Fill(-1); // set status to unknown at startup
00763 
00764   // Create floats for each subdetector status
00765   std::string subdets[7] = {"HB","HE","HO","HF","HO0","HO12","HFlumi"};
00766   for (unsigned int i=0;i<7;++i)
00767     {
00768       // Create floats showing subtasks status
00769       dqmStore_->setCurrentFolder( subdir_+ "reportSummaryContents" );  
00770       me=dqmStore_->get(subdir_+"reportSummaryContents/Hcal_"+subdets[i]);
00771       if (me) dqmStore_->removeElement(me->getName());
00772       me = dqmStore_->bookFloat("Hcal_"+subdets[i]);
00773       me->Fill(-1);
00774     } // for (unsigned int i=0;...)
00775 
00776   dqmStore_->setCurrentFolder(prefixME_+"HcalInfo/SummaryClientPlots");
00777   me=dqmStore_->get(prefixME_+"HcalInfo/SummaryClientPlots/HB HE HF Depth 1 Problem Summary Map");
00778   if (me) dqmStore_->removeElement(me->getName());
00779   me=dqmStore_->get(prefixME_+"HcalInfo/SummaryClientPlots/HB HE HF Depth 2 Problem Summary Map");
00780   if (me) dqmStore_->removeElement(me->getName());
00781   me=dqmStore_->get(prefixME_+"HcalInfo/SummaryClientPlots/HE Depth 3 Problem Summary Map");
00782   if (me) dqmStore_->removeElement(me->getName());
00783   me=dqmStore_->get(prefixME_+"HcalInfo/SummaryClientPlots/HO Depth 4 Problem Summary Map");
00784   if (me) dqmStore_->removeElement(me->getName());
00785 
00786   if (EnoughEvents_==0)
00787     EnoughEvents_=dqmStore_->book1D("EnoughEvents","Enough Events Passed From Each Task To Form Summary",1+(int)clients_.size(),0,1+(int)clients_.size());
00788   for (std::vector<HcalBaseDQClient*>::size_type i=0;i<clients_.size();++i)
00789     EnoughEvents_->setBinLabel(i+1,clients_[i]->name());
00790   EnoughEvents_->setBinLabel(1+(int)clients_.size(),"Summary");
00791 
00792   if (MinEvents_==0)
00793     MinEvents_=dqmStore_->book1D("MinEvents","Minimum Events Required From Each Task To Form Summary",
00794                                  1+(int)clients_.size(),0,1+(int)clients_.size());
00795   int summin=0;
00796   for (std::vector<HcalBaseDQClient*>::size_type i=0;i<clients_.size();++i)
00797     {
00798       MinEvents_->setBinLabel(i+1,clients_[i]->name());
00799       MinEvents_->setBinContent(i+1,clients_[i]->minevents_);
00800       summin=std::max(summin,clients_[i]->minevents_);
00801     }
00802   if (MinErrorRate_==0)
00803     MinErrorRate_=dqmStore_->book1D("MinErrorRate",
00804                                     "Minimum Error Rate Required For Channel To Be Counted As Problem",
00805                                     (int)clients_.size(),0,(int)clients_.size());
00806   for (std::vector<HcalBaseDQClient*>::size_type i=0;i<clients_.size();++i)
00807     {
00808       MinErrorRate_->setBinLabel(i+1,clients_[i]->name());
00809       MinErrorRate_->setBinContent(i+1,clients_[i]->minerrorrate_);
00810     }
00811 
00812   // Extra fix provided by Giuseppe
00813   
00814   if (SummaryMapByDepth!=0)
00815     {
00816       delete SummaryMapByDepth;
00817       SummaryMapByDepth=0;
00818     }
00819 
00820   if (SummaryMapByDepth==0) 
00821     {
00822       SummaryMapByDepth=new EtaPhiHists();
00823       SummaryMapByDepth->setup(dqmStore_,"Problem Summary Map");
00824     }
00825   // Set histogram values to -1
00826   // Set all bins to "unknown" to start
00827   int etabins=0;
00828   for (unsigned int depth=0;depth<4;++depth)
00829     {
00830       if (SummaryMapByDepth->depth[depth]==0) continue;
00831       SummaryMapByDepth->depth[depth]->Reset();
00832       etabins=(SummaryMapByDepth->depth[depth])->getNbinsX();
00833       for (int ieta=0;ieta<etabins;++ieta)
00834         {
00835           for (int iphi=0;iphi<72;++iphi)
00836             SummaryMapByDepth->depth[depth]->setBinContent(ieta+1,iphi+1,-1);
00837         }
00838     }
00839 
00840   // Make histogram of status vs LS
00841   StatusVsLS_ = dqmStore_->get(prefixME_+"HcalInfo/SummaryClientPlots/StatusVsLS");
00842   if (StatusVsLS_) dqmStore_->removeElement(StatusVsLS_->getName());
00843   StatusVsLS_ = dqmStore_->book2D("StatusVsLS","Status vs. Luminosity Section",
00844                                   NLumiBlocks_,0.5,NLumiBlocks_+0.5,
00845                                   7,0,7);
00846   // Set all status values to -1 to begin
00847   for (int i=1;i<=NLumiBlocks_;++i)
00848     for (int j=1;j<=7;++j)
00849       StatusVsLS_->setBinContent(i,j,-1);
00850   (StatusVsLS_->getTH2F())->GetYaxis()->SetBinLabel(1,"HB");
00851   (StatusVsLS_->getTH2F())->GetYaxis()->SetBinLabel(2,"HE");
00852   (StatusVsLS_->getTH2F())->GetYaxis()->SetBinLabel(3,"HO");
00853   (StatusVsLS_->getTH2F())->GetYaxis()->SetBinLabel(4,"HF");
00854   (StatusVsLS_->getTH2F())->GetYaxis()->SetBinLabel(5,"HO0");
00855   (StatusVsLS_->getTH2F())->GetYaxis()->SetBinLabel(6,"HO12");
00856   (StatusVsLS_->getTH2F())->GetYaxis()->SetBinLabel(7,"HFlumi");
00857   (StatusVsLS_->getTH2F())->GetXaxis()->SetTitle("Lumi Section");
00858   (StatusVsLS_->getTH2F())->SetMinimum(-1);
00859   (StatusVsLS_->getTH2F())->SetMaximum(1);
00860 
00861   // Finally, form report Summary Map
00862   dqmStore_->setCurrentFolder(subdir_);
00863 
00864   reportMap_=dqmStore_->get(subdir_+"reportSummaryMap");
00865   if (reportMap_)
00866     dqmStore_->removeElement(reportMap_->getName());
00867   reportMap_ = dqmStore_->book2D("reportSummaryMap","reportSummaryMap",
00868                                  7,0,7,1,0,1);
00869   (reportMap_->getTH2F())->GetXaxis()->SetBinLabel(1,"HB");
00870   (reportMap_->getTH2F())->GetXaxis()->SetBinLabel(2,"HE");
00871   (reportMap_->getTH2F())->GetXaxis()->SetBinLabel(3,"HO");
00872   (reportMap_->getTH2F())->GetXaxis()->SetBinLabel(4,"HF");
00873   (reportMap_->getTH2F())->GetXaxis()->SetBinLabel(5,"HO0");
00874   (reportMap_->getTH2F())->GetXaxis()->SetBinLabel(6,"HO12");
00875   (reportMap_->getTH2F())->GetXaxis()->SetBinLabel(7,"HFlumi");
00876   (reportMap_->getTH2F())->GetYaxis()->SetBinLabel(1,"Status");
00877   (reportMap_->getTH2F())->SetMarkerSize(3);
00878   (reportMap_->getTH2F())->SetOption("text90colz");
00879   //(reportMap_->getTH2F())->SetOption("textcolz");
00880   (reportMap_->getTH2F())->SetMinimum(-1);
00881   (reportMap_->getTH2F())->SetMaximum(1);
00882 
00883   // Set initial counters to -1 (unknown)
00884   status_global_=-1; 
00885   status_HB_=-1; 
00886   status_HE_=-1; 
00887   status_HO_=-1; 
00888   status_HF_=-1; 
00889 
00890   status_HO0_=-1;
00891   status_HO12_=-1;
00892   status_HFlumi_=-1;
00893   for (int i=1;i<=(reportMap_->getTH2F())->GetNbinsX();++i)
00894     reportMap_->setBinContent(i,1,-1);
00895 } // void HcalSummaryClient::beginRun(void)
00896 
00897 
00898 void HcalSummaryClient::endRun(void){}
00899 
00900 void HcalSummaryClient::setup(void){}
00901 void HcalSummaryClient::cleanup(void){}
00902 
00903 bool HcalSummaryClient::hasErrors_Temp(void){  return false;}
00904 
00905 bool HcalSummaryClient::hasWarnings_Temp(void){return false;}
00906 bool HcalSummaryClient::hasOther_Temp(void){return false;}
00907 bool HcalSummaryClient::test_enabled(void){return true;}
00908 
00909 void HcalSummaryClient::updateChannelStatus(std::map<HcalDetId, unsigned int>& myqual){return;}
00910 
00911