CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/DQM/HcalMonitorTasks/src/HcalLSbyLSMonitor.cc

Go to the documentation of this file.
00001 #include "DQM/HcalMonitorTasks/interface/HcalLSbyLSMonitor.h"
00002 #include "FWCore/Framework/interface/LuminosityBlock.h"
00003 
00004 /*
00005   This task looks at the output from all other tasks (as stored in their 
00006   ProblemsCurrentLB histograms), and combines the output into its own ProblemsCurrentLB histogram.  Its own ProblemsCurrentLB histogram, though, is marked with the setLumiFlag, so that its contents will be stored for every lumi section.
00007 */
00008 
00009 // constructor
00010 HcalLSbyLSMonitor::HcalLSbyLSMonitor(const edm::ParameterSet& ps) 
00011 {
00012   Online_                = ps.getUntrackedParameter<bool>("online",false);
00013   mergeRuns_             = ps.getUntrackedParameter<bool>("mergeRuns",false);
00014   enableCleanup_         = ps.getUntrackedParameter<bool>("enableCleanup",false);
00015   debug_                 = ps.getUntrackedParameter<int>("debug",0);
00016   prefixME_              = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
00017   if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
00018     prefixME_.append("/");
00019   subdir_                = ps.getUntrackedParameter<std::string>("TaskFolder","LSbyLSMonitor_Hcal"); 
00020   if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
00021     subdir_.append("/");
00022   subdir_=prefixME_+subdir_;
00023   AllowedCalibTypes_     = ps.getUntrackedParameter<std::vector<int> > ("AllowedCalibTypes");
00024   skipOutOfOrderLS_      = ps.getUntrackedParameter<bool>("skipOutOfOrderLS",true);
00025   NLumiBlocks_           = ps.getUntrackedParameter<int>("NLumiBlocks",4000);
00026   makeDiagnostics_       = ps.getUntrackedParameter<bool>("makeDiagnostics",false);
00027 
00028   // Specify the directories where the tasks to be check reside
00029   TaskList_              = ps.getUntrackedParameter<std::vector<std::string> >("TaskDirectories");
00030   // Minimum number of events per lumi section that must be present for checks to be made.  *ALL* tasks must contain at least this many events
00031   minEvents_             = ps.getUntrackedParameter<int>("minEvents",500);
00032 }
00033 
00034 HcalLSbyLSMonitor::~HcalLSbyLSMonitor()
00035 {
00036 } //destructor
00037 
00038 void HcalLSbyLSMonitor::setup()
00039 {
00040   // Call base class setup
00041   HcalBaseDQMonitor::setup();
00042 
00043   if (debug_>1)
00044     std::cout <<"<HcalLSbyLSMonitor::setup>  Setting up histograms"<<std::endl;
00045 
00046   dbe_->setCurrentFolder(subdir_);
00047   // This will cause this information to be kept for every lumi block
00048   if (ProblemsCurrentLB)
00049     ProblemsCurrentLB->setLumiFlag();
00050   this->reset();
00051 }
00052 void HcalLSbyLSMonitor::beginRun(const edm::Run& run, const edm::EventSetup& c)
00053 {
00054   if (debug_>1) std::cout <<"HcalLSbyLSMonitor::beginRun"<<std::endl;
00055   HcalBaseDQMonitor::beginRun(run,c);
00056 
00057   if (tevt_==0) this->setup(); // set up histograms if they have not been created before
00058   if (mergeRuns_==false)
00059     this->reset();
00060 
00061   return;
00062 } //void HcalLSbyLSMonitor::beginRun(...)
00063 
00064 
00065 void HcalLSbyLSMonitor::reset()
00066 {
00067   HcalBaseDQMonitor::reset();
00068   ProblemsCurrentLB->Reset();
00069 }  // reset function is empty for now
00070 
00071 void HcalLSbyLSMonitor::beginLuminosityBlock(const edm::LuminosityBlock& lumiSeg,
00072                                               const edm::EventSetup& c)
00073 {
00074   if (LumiInOrder(lumiSeg.luminosityBlock())==false) return;
00075   HcalBaseDQMonitor::beginLuminosityBlock(lumiSeg,c);
00076   ProblemsCurrentLB->Reset();
00077   return;
00078 } // beginLuminosityBlock(...)
00079 
00080 void HcalLSbyLSMonitor::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg,
00081                                             const edm::EventSetup& c)
00082 {
00083   // Processing should go here
00084   if (!dbe_) return;
00085   bool enoughEvents=true;
00086   int Nevents=0;
00087   int TotalEvents=0;
00088   int badHB=0;
00089   int badHE=0;
00090   int badHO=0;
00091   int badHF=0;
00092   int badHO0=0;
00093   int badHO12=0;
00094   int badHFLUMI=0;
00095   
00096   for (unsigned int i=0;i<TaskList_.size();++i)
00097     {
00098       std::string name=prefixME_+TaskList_[i]+"LSvalues/";
00099       dbe_->setCurrentFolder(name.c_str());
00100       // Do we need the 'name' prefix here?
00101       MonitorElement *me=dbe_->get(name+"ProblemsThisLS");
00102       if (me==0)
00103         {
00104           if (debug_>0) std::cout <<"<HcalLSbyLSMonitor>  Error!  Could not get histogram "<<name.c_str()<<std::endl;
00105           enoughEvents=false;
00106           break;
00107         }
00108 
00109       Nevents=(int)me->getBinContent(-1);
00110       if (Nevents<minEvents_)
00111         {
00112           if (debug_>0) 
00113             std::cout <<"<HcalLSbyLSMonitor>  Error!  Number of events "<<Nevents<<" for histogram "<<name.c_str()<<" is less than the required minimum of "<<minEvents_<<std::endl;
00114           enoughEvents=false;
00115           break;
00116         }
00117       // Total events is the number of events processed in this LS
00118       TotalEvents=std::max(TotalEvents,Nevents);
00119       // errors are sum over all tests.  This WILL lead to double counting in some subdetectors!
00120       badHB+=(int)me->getBinContent(1,1);
00121       badHE+=(int)me->getBinContent(2,1);
00122       badHO+=(int)me->getBinContent(3,1);
00123       badHF+=(int)me->getBinContent(4,1);
00124       badHO0+=(int)me->getBinContent(5,1);
00125       badHO12+=(int)me->getBinContent(6,1);
00126       badHFLUMI+=(int)me->getBinContent(7,1);
00127     }
00128   if (enoughEvents==false)  // not enough events to make a decision
00129     {
00130       return;
00131     }
00132   ProblemsCurrentLB->setBinContent(-1,-1,TotalEvents);
00133   ProblemsCurrentLB->setBinContent(1,1,badHB);
00134   ProblemsCurrentLB->setBinContent(2,1,badHE);
00135   ProblemsCurrentLB->setBinContent(3,1,badHO);
00136   ProblemsCurrentLB->setBinContent(4,1,badHF);
00137   ProblemsCurrentLB->setBinContent(5,1,badHO0);
00138   ProblemsCurrentLB->setBinContent(6,1,badHO12);
00139   ProblemsCurrentLB->setBinContent(7,1,badHFLUMI);
00140   return;
00141 }
00142 
00143 
00144 void HcalLSbyLSMonitor::done()
00145 {
00146   // moved database dumps to client; we want to be able to sum over results in offline
00147   return;
00148 
00149 } // void HcalLSbyLSMonitor::done()
00150 
00151 
00152 void HcalLSbyLSMonitor::endJob()
00153 {
00154   if (debug_>0) std::cout <<"HcalLSbyLSMonitor::endJob()"<<std::endl;
00155   if (enableCleanup_) cleanup(); // when do we force cleanup?
00156 }
00157 
00158 
00159 void HcalLSbyLSMonitor::cleanup()
00160 {
00161   if (!enableCleanup_) return;
00162   if (dbe_)
00163     {
00164       dbe_->setCurrentFolder(subdir_);
00165       dbe_->removeContents();
00166       dbe_->setCurrentFolder(subdir_+"LSvalues");
00167       dbe_->removeContents();
00168     }
00169 }
00170 
00171 DEFINE_FWK_MODULE(HcalLSbyLSMonitor);