CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 #include "Geometry/HcalTowerAlgo/src/HcalHardcodeGeometryData.h" // for eta bounds
00002 #include "DQM/HcalMonitorTasks/interface/HcalHotCellMonitor.h"
00003 #include "FWCore/Framework/interface/LuminosityBlock.h"
00004 
00005 HcalHotCellMonitor::HcalHotCellMonitor(const edm::ParameterSet& ps)
00006 {
00007   // Standard information, inherited from base class
00008   Online_                = ps.getUntrackedParameter<bool>("online",false);
00009   mergeRuns_             = ps.getUntrackedParameter<bool>("mergeRuns",false);
00010   enableCleanup_         = ps.getUntrackedParameter<bool>("enableCleanup",false);
00011   debug_                 = ps.getUntrackedParameter<int>("debug",0);
00012   makeDiagnostics_       = ps.getUntrackedParameter<bool>("makeDiagnostics",false);
00013   prefixME_              = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
00014   if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
00015     prefixME_.append("/");
00016   subdir_                = ps.getUntrackedParameter<std::string>("TaskFolder","HotCellMonitor_Hcal/"); // HotCellMonitor_Hcal
00017   if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
00018     subdir_.append("/");
00019   subdir_=prefixME_+subdir_;
00020   AllowedCalibTypes_     = ps.getUntrackedParameter<std::vector<int> > ("AllowedCalibTypes");
00021   skipOutOfOrderLS_      = ps.getUntrackedParameter<bool>("skipOutOfOrderLS",true);
00022   NLumiBlocks_           = ps.getUntrackedParameter<int>("NLumiBlocks",4000);
00023 
00024   // Collection type info
00025   hbheRechitLabel_       = ps.getUntrackedParameter<edm::InputTag>("hbheRechitLabel");
00026   hoRechitLabel_         = ps.getUntrackedParameter<edm::InputTag>("hoRechitLabel");
00027   hfRechitLabel_         = ps.getUntrackedParameter<edm::InputTag>("hfRechitLabel");
00028 
00029   // Hot Cell-specific tests
00030   minEvents_      = ps.getUntrackedParameter<int>("minEvents");
00031   minErrorFlag_   = ps.getUntrackedParameter<double>("minErrorFlag",1);
00032 
00033   // exclude HO ring 2
00034   excludeHORing2_       = ps.getUntrackedParameter<bool>("excludeHORing2",false);
00035 
00036 
00037   // Set which hot cell checks will be performed
00038   test_persistent_         = ps.getUntrackedParameter<bool>("test_persistent"); // true by default
00039   test_neighbor_           = ps.getUntrackedParameter<bool>("test_neighbor"); // false by default; test disabled
00040   test_energy_             = ps.getUntrackedParameter<bool>("test_energy"); // true by default
00041   test_et_                 = ps.getUntrackedParameter<bool>("test_et"); // true by default
00042 
00043 
00044   // rechit energy test -- cell must be above threshold value for a number of consecutive events to be considered hot
00045   energyThreshold_                = ps.getUntrackedParameter<double>("energyThreshold");
00046   ETThreshold_                    = ps.getUntrackedParameter<double>("ETThreshold");
00047 
00048   HBenergyThreshold_              = ps.getUntrackedParameter<double>("energyThreshold_HB",energyThreshold_);
00049   HEenergyThreshold_              = ps.getUntrackedParameter<double>("energyThreshold_HE",energyThreshold_);
00050   HOenergyThreshold_              = ps.getUntrackedParameter<double>("energyThreshold_HO",energyThreshold_);
00051   HFenergyThreshold_              = ps.getUntrackedParameter<double>("energyThreshold_HF",energyThreshold_);
00052 
00053   HBETThreshold_                  = ps.getUntrackedParameter<double>("ETThreshold_HB",ETThreshold_);
00054   HEETThreshold_                  = ps.getUntrackedParameter<double>("ETThreshold_HE",ETThreshold_);
00055   HOETThreshold_                  = ps.getUntrackedParameter<double>("ETThreshold_HO",ETThreshold_);
00056   HFETThreshold_                  = ps.getUntrackedParameter<double>("ETThreshold_HF",ETThreshold_);
00057 
00058   // rechit event-by-event energy test -- cell must be above threshold to be considered hot
00059   persistentThreshold_           = ps.getUntrackedParameter<double>("persistentThreshold");
00060 
00061   HBpersistentThreshold_         = ps.getUntrackedParameter<double>("persistentThreshold_HB",persistentThreshold_);
00062   HEpersistentThreshold_         = ps.getUntrackedParameter<double>("persistentThreshold_HE",persistentThreshold_);
00063   HOpersistentThreshold_         = ps.getUntrackedParameter<double>("persistentThreshold_HO",persistentThreshold_);
00064   HFpersistentThreshold_         = ps.getUntrackedParameter<double>("persistentThreshold_HF",persistentThreshold_);
00065 
00066   persistentETThreshold_           = ps.getUntrackedParameter<double>("persistentETThreshold");
00067 
00068   HBpersistentETThreshold_         = ps.getUntrackedParameter<double>("persistentETThreshold_HB",persistentETThreshold_);
00069   HEpersistentETThreshold_         = ps.getUntrackedParameter<double>("persistentETThreshold_HE",persistentETThreshold_);
00070   HOpersistentETThreshold_         = ps.getUntrackedParameter<double>("persistentETThreshold_HO",persistentETThreshold_);
00071   HFpersistentETThreshold_         = ps.getUntrackedParameter<double>("persistentETThreshold_HF",persistentETThreshold_);
00072 
00073   HFfarfwdScale_                 = ps.getUntrackedParameter<double>("HFfwdScale",2.);
00074   SiPMscale_                     = ps.getUntrackedParameter<double>("HO_SiPMscalefactor",1.); // default scale factor of 4?
00075   
00076   // neighboring-cell tests
00077   HBHENeighborParams_.DeltaIphi            = ps.getUntrackedParameter<int>("HBHE_neighbor_deltaIphi", 1);
00078   HBHENeighborParams_.DeltaIeta            = ps.getUntrackedParameter<int>("HBHE_neighbor_deltaIeta", 1);
00079   HBHENeighborParams_.DeltaDepth           = ps.getUntrackedParameter<int>("HBHE_neighbor_deltaDepth", 2);
00080   HBHENeighborParams_.minCellEnergy        = ps.getUntrackedParameter<double>("HBHE_neighbor_minCellEnergy",3.);
00081   HBHENeighborParams_.minNeighborEnergy    = ps.getUntrackedParameter<double>("HBHE_neighbor_minNeighborEnergy",0.);
00082   HBHENeighborParams_.maxEnergy            = ps.getUntrackedParameter<double>("HBHE_neighbor_maxEnergy",100);
00083   HBHENeighborParams_.HotEnergyFrac        = ps.getUntrackedParameter<double>("HBHE_neighbor_HotEnergyFrac",0.05);
00084 
00085   HONeighborParams_.DeltaIphi            = ps.getUntrackedParameter<int>("HO_neighbor_deltaIphi", 1);
00086   HONeighborParams_.DeltaIeta            = ps.getUntrackedParameter<int>("HO_neighbor_deltaIeta", 1);
00087   HONeighborParams_.DeltaDepth           = ps.getUntrackedParameter<int>("HO_neighbor_deltaDepth", 0);
00088   HONeighborParams_.minCellEnergy        = ps.getUntrackedParameter<double>("HO_neighbor_minCellEnergy",10.);
00089   HONeighborParams_.minNeighborEnergy    = ps.getUntrackedParameter<double>("HO_neighbor_minNeighborEnergy",0.);
00090   HONeighborParams_.maxEnergy            = ps.getUntrackedParameter<double>("HO_neighbor_maxEnergy",100);
00091   HONeighborParams_.HotEnergyFrac        = ps.getUntrackedParameter<double>("HO_neighbor_HotEnergyFrac",0.01);
00092 
00093   HFNeighborParams_.DeltaIphi            = ps.getUntrackedParameter<int>("HF_neighbor_deltaIphi", 1);
00094   HFNeighborParams_.DeltaIeta            = ps.getUntrackedParameter<int>("HF_neighbor_deltaIeta", 1);
00095   HFNeighborParams_.DeltaDepth           = ps.getUntrackedParameter<int>("HF_neighbor_deltaDepth", 1);
00096   HFNeighborParams_.minCellEnergy        = ps.getUntrackedParameter<double>("HF_neighbor_minCellEnergy",10.);
00097   HFNeighborParams_.minNeighborEnergy    = ps.getUntrackedParameter<double>("HF_neighbor_minNeighborEnergy",0.);
00098   HFNeighborParams_.maxEnergy            = ps.getUntrackedParameter<double>("HF_neighbor_maxEnergy",100);
00099   HFNeighborParams_.HotEnergyFrac        = ps.getUntrackedParameter<double>("HF_neighbor_HotEnergyFrac",0.01);
00100 
00101 } //constructor
00102 
00103 HcalHotCellMonitor::~HcalHotCellMonitor()
00104 {
00105 } //destructor
00106 
00107 
00108 /* ------------------------------------ */ 
00109 
00110 void HcalHotCellMonitor::setup()
00111 {
00112   // Call base class setup
00113   HcalBaseDQMonitor::setup();
00114 
00115   if (debug_>1)
00116     std::cout <<"<HcalHotCellMonitor::setup>  Setting up histograms"<<std::endl;
00117 
00118   dbe_->setCurrentFolder(subdir_);
00119 
00120   MonitorElement* me;
00121   me=dbe_->bookFloat("minErrorFractionPerLumiSection");
00122   me->Fill(minErrorFlag_);
00123   // Create plots of problems vs LB
00124 
00125   // 1D plots count number of bad cells vs. luminosity block
00126   ProblemsVsLB=dbe_->bookProfile("TotalHotCells_HCAL_vs_LS",
00127                                  "Total Number of Hot Hcal Cells vs lumi section", 
00128                                  NLumiBlocks_,0.5,NLumiBlocks_+0.5,100,0,10000);
00129 
00130   ProblemsVsLB_HB=dbe_->bookProfile("TotalHotCells_HB_vs_LS",
00131                                     "Total Number of Hot HB Cells vs lumi section",
00132                                     NLumiBlocks_,0.5,NLumiBlocks_+0.5,100,0,3000);
00133   ProblemsVsLB_HE=dbe_->bookProfile("TotalHotCells_HE_vs_LS",
00134                                     "Total Number of Hot HE Cells vs lumi section",
00135                                     NLumiBlocks_,0.5,NLumiBlocks_+0.5,100,0,3000);
00136   ProblemsVsLB_HO=dbe_->bookProfile("TotalHotCells_HO_vs_LS",
00137                                     "Total Number of Hot HO Cells vs lumi section",
00138                                     NLumiBlocks_,0.5,NLumiBlocks_+0.5,100,0,3000);
00139   ProblemsVsLB_HF=dbe_->bookProfile("TotalHotCells_HF_vs_LS",
00140                                     "Total Number of Hot HF Cells vs lumi section",
00141                                     NLumiBlocks_,0.5,NLumiBlocks_+0.5,100,0,2000);
00142   ProblemsVsLB_HBHEHF=dbe_->bookProfile("TotalHotCells_HBHEHF_vs_LS",
00143                                     "Total Number of Hot HBHEHF Cells vs lumi section",
00144                                     NLumiBlocks_,0.5,NLumiBlocks_+0.5,100,0,2000);
00145  
00146   ProblemsVsLB->getTProfile()->SetMarkerStyle(20);
00147   ProblemsVsLB_HB->getTProfile()->SetMarkerStyle(20);
00148   ProblemsVsLB_HE->getTProfile()->SetMarkerStyle(20);
00149   ProblemsVsLB_HO->getTProfile()->SetMarkerStyle(20);
00150   ProblemsVsLB_HF->getTProfile()->SetMarkerStyle(20);
00151   ProblemsVsLB_HBHEHF->getTProfile()->SetMarkerStyle(20);
00152 
00153   // Set up plots for each failure mode of hot cells
00154   std::stringstream units; // We'll need to set the titles individually, rather than passing units to SetupEtaPhiHists (since this also would affect the name of the histograms)
00155 
00156   dbe_->setCurrentFolder(subdir_+"hot_rechit_above_threshold");
00157   me=dbe_->bookInt("HotCellAboveThresholdTestEnabled");
00158   me->Fill(0);
00159   
00160   if (test_energy_)
00161     {
00162       me->Fill(1);
00163       SetupEtaPhiHists(AboveEnergyThresholdCellsByDepth,
00164                        "Hot Cells Above Energy Threshold","");
00165       //setMinMaxHists2D(AboveEnergyThresholdCellsByDepth,0.,1.);
00166       
00167       // set more descriptive titles for plots
00168       units.str("");
00169       units<<"Hot Cells: Depth 1 -- HB > "<<HBenergyThreshold_<<" GeV, HE > "<<HEenergyThreshold_<<" GeV, HF > "<<HFenergyThreshold_<<" GeV";
00170       AboveEnergyThresholdCellsByDepth.depth[0]->setTitle(units.str().c_str());
00171       units.str("");
00172       units<<"Hot Cells: Depth 2 -- HB > "<<HBenergyThreshold_<<" GeV, HE > "<<HEenergyThreshold_<<" GeV, HF > "<<HFenergyThreshold_<<" GeV";
00173       AboveEnergyThresholdCellsByDepth.depth[1]->setTitle(units.str().c_str());
00174       units.str("");
00175       units<<"Hot Cells: Depth 3 -- HE > "<<HEenergyThreshold_<<" GeV";
00176       AboveEnergyThresholdCellsByDepth.depth[2]->setTitle(units.str().c_str());
00177       units.str("");
00178       units<<"Hot Cells: HO > "<<HOenergyThreshold_<<" GeV";
00179       AboveEnergyThresholdCellsByDepth.depth[3]->setTitle(units.str().c_str());
00180       units.str("");
00181     }
00182   if (test_et_)
00183     {
00184       me->Fill(1);
00185       SetupEtaPhiHists(AboveETThresholdCellsByDepth,
00186                        "Hot Cells Above ET Threshold","");
00187       //setMinMaxHists2D(AboveETThresholdCellsByDepth,0.,1.);
00188       
00189       // set more descriptive titles for plots
00190       units.str("");
00191       units<<"Hot Cells: Depth 1 -- HB > "<<HBETThreshold_<<" GeV (ET), HE > "<<HEETThreshold_<<" GeV (ET), HF > "<<HFETThreshold_<<" GeV (ET)";
00192       AboveETThresholdCellsByDepth.depth[0]->setTitle(units.str().c_str());
00193       units.str("");
00194       units<<"Hot Cells: Depth 2 -- HB > "<<HBETThreshold_<<" GeV (ET), HE > "<<HEETThreshold_<<" GeV (ET), HF > "<<HFETThreshold_<<" GeV (ET)";
00195       AboveETThresholdCellsByDepth.depth[1]->setTitle(units.str().c_str());
00196       units.str("");
00197       units<<"Hot Cells: Depth 3 -- HE > "<<HEETThreshold_<<" GeV (ET)";
00198       AboveETThresholdCellsByDepth.depth[2]->setTitle(units.str().c_str());
00199       units.str("");
00200       units<<"Hot Cells: HO > "<<HOETThreshold_<<" GeV (ET)";
00201       AboveETThresholdCellsByDepth.depth[3]->setTitle(units.str().c_str());
00202       units.str("");
00203     }
00204   
00205   dbe_->setCurrentFolder(subdir_+"hot_rechit_always_above_threshold");
00206   me=dbe_->bookInt("PersistentHotCellTestEnabled");
00207   me->Fill(0);
00208   if (test_persistent_)
00209     {
00210       me->Fill(1);
00211       me=dbe_->bookInt("minEventsPerLS");
00212       me->Fill(minEvents_);
00213 
00214       if (test_energy_) {
00215         SetupEtaPhiHists(AbovePersistentThresholdCellsByDepth,
00216                          "Hot Cells Persistently Above Energy Threshold","");
00217         //setMinMaxHists2D(AbovePersistentThresholdCellsByDepth,0.,1.);
00218         
00219         // set more descriptive titles for plots
00220         units.str("");
00221         units<<"Hot Cells: Depth 1 -- HB > "<<HBpersistentThreshold_<<" GeV, HE > "<<HEpersistentThreshold_<<", HF > "<<HFpersistentThreshold_<<" GeV for 1 full Lumi Block";
00222         AbovePersistentThresholdCellsByDepth.depth[0]->setTitle(units.str().c_str());
00223         units.str("");
00224         units<<"Hot Cells: Depth 2 -- HB > "<<HBpersistentThreshold_<<" GeV, HE > "<<HEpersistentThreshold_<<", HF > "<<HFpersistentThreshold_<<" GeV for 1 full Lumi Block";
00225         AbovePersistentThresholdCellsByDepth.depth[1]->setTitle(units.str().c_str());
00226         units.str("");
00227         units<<"Hot Cells: Depth 3 -- HE > "<<HEpersistentThreshold_<<" GeV for 1 full Lumi Block";
00228         AbovePersistentThresholdCellsByDepth.depth[2]->setTitle(units.str().c_str());
00229         units.str("");
00230         units<<"Hot Cells:  HO > "<<HOpersistentThreshold_<<" GeV for 1 full Lumi Block";
00231         AbovePersistentThresholdCellsByDepth.depth[3]->setTitle(units.str().c_str());
00232         units.str("");
00233       }
00234   
00235       if (test_et_) {
00236         SetupEtaPhiHists(AbovePersistentETThresholdCellsByDepth,
00237                          "Hot Cells Persistently Above ET Threshold","");
00238         //setMinMaxHists2D(AbovePersistentThresholdCellsByDepth,0.,1.);
00239         
00240         // set more descriptive titles for plots
00241         units.str("");
00242         units<<"Hot Cells: Depth 1 -- HB > "<<HBpersistentETThreshold_<<" GeV (ET), HE > "<<HEpersistentETThreshold_<<" GeV (ET), HF > "<<HFpersistentETThreshold_<<" GeV (ET) for 1 full Lumi Block";
00243         AbovePersistentETThresholdCellsByDepth.depth[0]->setTitle(units.str().c_str());
00244         units.str("");
00245         units<<"Hot Cells: Depth 2 -- HB > "<<HBpersistentETThreshold_<<" GeV (ET), HE > "<<HEpersistentETThreshold_<<" GeV (ET), HF > "<<HFpersistentETThreshold_<<" GeV (ET) for 1 full Lumi Block";
00246         AbovePersistentETThresholdCellsByDepth.depth[1]->setTitle(units.str().c_str());
00247         units.str("");
00248         units<<"Hot Cells: Depth 3 -- HE > "<<HEpersistentETThreshold_<<" GeV (ET) for 1 full Lumi Block";
00249         AbovePersistentETThresholdCellsByDepth.depth[2]->setTitle(units.str().c_str());
00250         units.str("");
00251         units<<"Hot Cells:  HO > "<<HOpersistentETThreshold_<<" GeV (ET) for 1 full Lumi Block";
00252         AbovePersistentETThresholdCellsByDepth.depth[3]->setTitle(units.str().c_str());
00253         units.str("");
00254       }
00255     }
00256   
00257   dbe_->setCurrentFolder(subdir_+"hot_neighbortest");
00258   me=dbe_->bookInt("NeighborTestEnabled");
00259   me->Fill(0);
00260   if (test_neighbor_)
00261     me->Fill(1);
00262   if (test_neighbor_ || makeDiagnostics_)
00263     {
00264       SetupEtaPhiHists(AboveNeighborsHotCellsByDepth,"Hot Cells Failing Neighbor Test","");
00265       if (makeDiagnostics_)
00266         {
00267           d_HBenergyVsNeighbor=dbe_->book1D("NeighborSumOverEnergyHB","HB Neighbor Sum Energy/Cell Energy;sum(neighbors)/E_cell",500,0,10);
00268           d_HEenergyVsNeighbor=dbe_->book1D("NeighborSumOverEnergyHE","HE Neighbor Sum Energy/Cell Energy;sum(neighbors)/E_cell",500,0,10);
00269           d_HOenergyVsNeighbor=dbe_->book1D("NeighborSumOverEnergyHO","HO Neighbor Sum Energy/Cell Energy;sum(neighbors)/E_cell",500,0,10);
00270           d_HFenergyVsNeighbor=dbe_->book1D("NeighborSumOverEnergyHF","HF Neighbor Sum Energy/Cell Energy;sum(neighbors)/E_cell",500,0,10);
00271         }
00272     } // if (test_neighbor_ || makeDiagnostics_)
00273   
00274   this->reset();
00275 } // void HcalHotCellMonitor::setup(...)
00276 
00277 void HcalHotCellMonitor::beginRun(const edm::Run& run, const edm::EventSetup& c)
00278 {
00279   if (debug_>1) std::cout <<"HcalHotCellMonitor::beginRun"<<std::endl;
00280   HcalBaseDQMonitor::beginRun(run,c);
00281 
00282   if (tevt_==0) this->setup(); // set up histograms if they have not been created before
00283   if (mergeRuns_==false)
00284     this->reset();
00285 
00286   return;
00287 } //void HcalHotCellMonitor::beginRun(...)
00288 
00289 
00290 /* --------------------------- */
00291 
00292 void HcalHotCellMonitor::reset()
00293 {
00294   HcalBaseDQMonitor::reset();
00295   zeroCounters();
00296 
00297   // now reset all the MonitorElements
00298 
00299   // resetting eta-phi histograms
00300   if (test_neighbor_ || makeDiagnostics_)
00301     AboveNeighborsHotCellsByDepth.Reset();
00302 
00303   if (test_energy_ ) 
00304     AboveEnergyThresholdCellsByDepth.Reset();
00305 
00306   if ( test_et_ ) 
00307     AboveETThresholdCellsByDepth.Reset();
00308 
00309   if (test_persistent_)
00310     {
00311       if (test_energy_) AbovePersistentThresholdCellsByDepth.Reset();
00312       if (test_et_)     AbovePersistentETThresholdCellsByDepth.Reset();
00313     }
00314   if (makeDiagnostics_)
00315     {
00316       d_HBenergyVsNeighbor->Reset();
00317       d_HEenergyVsNeighbor->Reset();
00318       d_HOenergyVsNeighbor->Reset();
00319       d_HFenergyVsNeighbor->Reset();
00320     }
00321 }  
00322 
00323 
00324 
00325 void HcalHotCellMonitor::beginLuminosityBlock(const edm::LuminosityBlock& lumiSeg,
00326                                               const edm::EventSetup& c)
00327 {
00328   if (LumiInOrder(lumiSeg.luminosityBlock())==false) return;
00329   HcalBaseDQMonitor::beginLuminosityBlock(lumiSeg,c);
00330   zeroCounters(); // zero hot cell counters at the start of each luminosity block
00331   ProblemsCurrentLB->Reset();
00332   return;
00333 } // beginLuminosityBlock(...)
00334 
00335 
00336 void HcalHotCellMonitor::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg,
00337                                             const edm::EventSetup& c)
00338 {
00339   //FIX with check on whether LB already processed
00340   
00341   if (LumiInOrder(lumiSeg.luminosityBlock())==false) return;
00342 
00343   if (test_neighbor_ || makeDiagnostics_)
00344     fillNevents_neighbor();
00345 
00346   if (test_energy_ || test_et_)
00347     fillNevents_energy();
00348 
00349   if (test_persistent_)
00350     fillNevents_persistentenergy();
00351 
00352   fillNevents_problemCells();
00353   return;
00354 } //endLuminosityBlock(...)
00355 
00356 
00357 
00358 /* ------------------------- */
00359 
00360 void HcalHotCellMonitor::done()
00361 {
00362   // moved database dumps to client; we want to be able to sum over results in offline
00363   return;
00364 
00365 } // void HcalHotCellMonitor::done()
00366 
00367 
00368 void HcalHotCellMonitor::analyze(edm::Event const&e, edm::EventSetup const&s)
00369 {
00370 
00371   if (!IsAllowedCalibType()) return;
00372   if (LumiInOrder(e.luminosityBlock())==false) return;
00373 
00374   // try to get rechits
00375   edm::Handle<HBHERecHitCollection> hbhe_rechit;
00376   edm::Handle<HORecHitCollection> ho_rechit;
00377   edm::Handle<HFRecHitCollection> hf_rechit;
00378 
00379   if (!(e.getByLabel(hbheRechitLabel_,hbhe_rechit)))
00380     {
00381       edm::LogWarning("HcalHotCellMonitor")<< hbheRechitLabel_<<" hbhe_rechit not available";
00382       return;
00383     }
00384 
00385   if (!(e.getByLabel(hfRechitLabel_,hf_rechit)))
00386     {
00387       edm::LogWarning("HcalHotCellMonitor")<< hfRechitLabel_<<" hf_rechit not available";
00388       return;
00389     }
00390   if (!(e.getByLabel(hoRechitLabel_,ho_rechit)))
00391     {
00392       edm::LogWarning("HcalHotCellMonitor")<< hoRechitLabel_<<" ho_rechit not available";
00393       return;
00394     }
00395 
00396   // Good event found; increment counter (via base class analyze method)
00397 
00398   HcalBaseDQMonitor::analyze(e,s);
00399   if (debug_>1) std::cout <<"\t<HcalHotCellMonitor::analyze>  Processing good event! event # = "<<ievt_<<std::endl;
00400 
00401   processEvent(*hbhe_rechit, *ho_rechit, *hf_rechit);
00402 
00403 } // void HcalHotCellMonitor::analyze(...)
00404 
00405 
00406 
00407 
00408 /* -------------------------------- */
00409 
00410 
00411 void HcalHotCellMonitor::processEvent(const HBHERecHitCollection& hbHits,
00412                                       const HORecHitCollection& hoHits,
00413                                       const HFRecHitCollection& hfHits
00414                                       )
00415 {
00416   
00417   if (debug_>1) std::cout <<"<HcalHotCellMonitor::processEvent> Processing event..."<<std::endl;
00418 
00419   // Search for hot cells above a certain energy
00420   if (test_energy_ || test_et_ || test_persistent_)
00421     {
00422       processEvent_rechitenergy(hbHits, hoHits,hfHits);
00423     }
00424 
00425   return;
00426 } // void HcalHotCellMonitor::processEvent(...)
00427 
00428 
00429 /* --------------------------------------- */
00430 
00431 
00432 void HcalHotCellMonitor::processEvent_rechitenergy( const HBHERecHitCollection& hbheHits,
00433                                                     const HORecHitCollection& hoHits,
00434                                                     const HFRecHitCollection& hfHits)
00435   
00436 {
00437   // Looks at rechits of cells and compares to threshold energies.
00438   // Cells above thresholds get marked as hot candidates
00439 
00440   if (debug_>1) std::cout <<"<HcalHotCellMonitor::processEvent_rechitenergy> Processing rechits..."<<std::endl;
00441 
00442   // loop over HBHE
00443   for (HBHERecHitCollection::const_iterator HBHEiter=hbheHits.begin(); HBHEiter!=hbheHits.end(); ++HBHEiter) 
00444     { // loop over all hits
00445       float en = HBHEiter->energy();
00446       //float ti = HBHEiter->time();
00447 
00448       HcalDetId id(HBHEiter->detid().rawId());
00449       int ieta = id.ieta();
00450       int iphi = id.iphi();
00451       int depth = id.depth();
00452       double fEta=fabs(0.5*(theHBHEEtaBounds[abs(ieta)-1]+theHBHEEtaBounds[abs(ieta)]));
00453       float et = en/cosh(fEta);
00454 
00455       if (test_neighbor_ || makeDiagnostics_)
00456         {
00457           processHit_rechitNeighbors(HBHEiter, hbheHits, HBHENeighborParams_);
00458         }
00459       if (id.subdet()==HcalBarrel)
00460         {
00461           if (en>=HBenergyThreshold_)
00462               ++aboveenergy[CalcEtaBin(id.subdet(),ieta,depth)][iphi-1][depth-1];
00463           if (et>=HBETThreshold_)
00464               ++aboveet[CalcEtaBin(id.subdet(),ieta,depth)][iphi-1][depth-1];
00465           if (test_energy_ && en>=HBpersistentThreshold_)
00466                 ++abovepersistent[CalcEtaBin(id.subdet(),ieta,depth)][iphi-1][depth-1];
00467           if (test_et_ && et>=HBpersistentETThreshold_)
00468                 ++abovepersistentET[CalcEtaBin(id.subdet(),ieta,depth)][iphi-1][depth-1];
00469         }
00470       else if (id.subdet()==HcalEndcap)
00471         {
00472           if (en>=HEenergyThreshold_)
00473             ++aboveenergy[CalcEtaBin(id.subdet(),ieta,depth)][iphi-1][depth-1];
00474           if (et>=HEETThreshold_)
00475             ++aboveet[CalcEtaBin(id.subdet(),ieta,depth)][iphi-1][depth-1];
00476           if (test_energy_) 
00477             if (en>=HEpersistentThreshold_)
00478               ++abovepersistent[CalcEtaBin(id.subdet(),ieta,depth)][iphi-1][depth-1];
00479           if (test_et_) 
00480             if (et>=HEpersistentETThreshold_)
00481               ++abovepersistentET[CalcEtaBin(id.subdet(),ieta,depth)][iphi-1][depth-1];
00482         }
00483     } //for (HBHERecHitCollection::const_iterator HBHEiter=...)
00484 
00485   // loop over HO
00486   for (HORecHitCollection::const_iterator HOiter=hoHits.begin(); HOiter!=hoHits.end(); ++HOiter) 
00487     { // loop over all hits
00488       float en = HOiter->energy();
00489      
00490       HcalDetId id(HOiter->detid().rawId());
00491       int ieta = id.ieta();
00492       int iphi = id.iphi();
00493       int depth = id.depth();
00494       double fEta=fabs(0.5*(theHBHEEtaBounds[abs(ieta)-1]+theHBHEEtaBounds[abs(ieta)]));
00495       float et = en/cosh(fEta);
00496 
00497       if (test_neighbor_ || makeDiagnostics_)
00498         processHit_rechitNeighbors(HOiter, hoHits, HONeighborParams_);
00499 
00500       if (isSiPM(ieta,iphi,depth))
00501         {
00502           if (en>=HOenergyThreshold_*SiPMscale_)
00503             ++aboveenergy[CalcEtaBin(id.subdet(),ieta,depth)][iphi-1][depth-1]; 
00504           if (et>=HOETThreshold_*SiPMscale_)
00505             ++aboveet[CalcEtaBin(id.subdet(),ieta,depth)][iphi-1][depth-1]; 
00506           if (test_energy_) 
00507             if (en>=HOpersistentThreshold_*SiPMscale_)
00508               ++abovepersistent[CalcEtaBin(id.subdet(),ieta,depth)][iphi-1][depth-1];
00509           if (test_et_) 
00510             if (et>=HOpersistentETThreshold_*SiPMscale_)
00511               ++abovepersistentET[CalcEtaBin(id.subdet(),ieta,depth)][iphi-1][depth-1];
00512         }
00513       else
00514         {
00515           // Skip HO ring 2 when required
00516           if (abs(ieta)>10 && excludeHORing2_==true)
00517             continue;
00518 
00519           if (en>=HOenergyThreshold_)
00520             ++aboveenergy[CalcEtaBin(id.subdet(),ieta,depth)][iphi-1][depth-1]; 
00521           if (et>=HOETThreshold_)
00522             ++aboveet[CalcEtaBin(id.subdet(),ieta,depth)][iphi-1][depth-1]; 
00523           if (test_energy_) 
00524             if (en>=HOpersistentThreshold_)
00525               ++abovepersistent[CalcEtaBin(id.subdet(),ieta,depth)][iphi-1][depth-1];
00526           if (test_et_) 
00527             if (en>=HOpersistentETThreshold_)
00528               ++abovepersistentET[CalcEtaBin(id.subdet(),ieta,depth)][iphi-1][depth-1];
00529         }
00530     }
00531     
00532   // loop over HF
00533   for (HFRecHitCollection::const_iterator HFiter=hfHits.begin(); HFiter!=hfHits.end(); ++HFiter) 
00534     { // loop over all hits
00535       float en = HFiter->energy();
00536       float threshold=HFenergyThreshold_;
00537       float threshold_pers = HFpersistentThreshold_; 
00538       float etthreshold=HFETThreshold_;
00539       HcalDetId id(HFiter->detid().rawId());
00540       int ieta = id.ieta();
00541       int iphi = id.iphi();
00542       int depth = id.depth();
00543       double fEta=fabs(0.5*(theHFEtaBounds[abs(ieta)-29]+theHFEtaBounds[abs(ieta)-28]));
00544       float et = en/cosh(fEta);
00545 
00546       if (test_neighbor_ || makeDiagnostics_)
00547         processHit_rechitNeighbors(HFiter, hfHits, HFNeighborParams_);
00548 
00549       if (abs(ieta)>39) // increase the thresholds in far-forward part of HF
00550         {
00551           threshold*=HFfarfwdScale_;
00552           threshold_pers*=HFfarfwdScale_;
00553         }
00554       
00555       if (en>=threshold)
00556         ++aboveenergy[CalcEtaBin(id.subdet(),ieta,depth)][iphi-1][depth-1];
00557       if (et>=etthreshold)
00558         ++aboveet[CalcEtaBin(id.subdet(),ieta,depth)][iphi-1][depth-1];
00559       if (test_energy_) {
00560         if (en>=threshold_pers)
00561           ++abovepersistent[CalcEtaBin(id.subdet(),ieta,depth)][iphi-1][depth-1];
00562       }
00563       if (test_et_) {
00564         if (et>=HFpersistentETThreshold_)
00565           ++abovepersistentET[CalcEtaBin(id.subdet(),ieta,depth)][iphi-1][depth-1];
00566       }
00567     }
00568 
00569   // call update every event -- still necessary?
00570  
00571   for (unsigned int i=0;i<AbovePersistentThresholdCellsByDepth.depth.size();++i)
00572     AbovePersistentThresholdCellsByDepth.depth[i]->update();
00573   for (unsigned int i=0;i<AboveEnergyThresholdCellsByDepth.depth.size();++i)
00574     AboveEnergyThresholdCellsByDepth.depth[i]->update();
00575   for (unsigned int i=0;i<AboveETThresholdCellsByDepth.depth.size();++i)
00576     AboveETThresholdCellsByDepth.depth[i]->update();
00577   for (unsigned int i=0;i<AboveNeighborsHotCellsByDepth.depth.size();++i)
00578     AboveNeighborsHotCellsByDepth.depth[i]->update();
00579 
00580   return;
00581 } // void HcalHotCellMonitor::processEvent_rechitenergy
00582 
00583 /* --------------------------------------- */
00584 
00585  
00586 template <class RECHIT, class RECHITCOLLECTION>
00587 void HcalHotCellMonitor::processHit_rechitNeighbors( RECHIT& rechit,
00588                                                      RECHITCOLLECTION& coll,
00589                                                      hotNeighborParams& params
00590                                                      )
00591 {
00592   // Compares energy to energy of neighboring cells.
00593   // This is a slightly simplified version of D0's NADA algorithm
00594   // 17 June 2009 -- this needs major work.  I'm not sure I have the [eta][phi][depth] array mapping correct everywhere. 
00595   // Maybe even tear it apart and start again?
00596  
00597   int ieta, iphi, depth;
00598   float en;
00599   
00600   int neighborsfound=0;
00601   float enNeighbor=0;
00602 
00603   en = rechit->energy();
00604   HcalDetId id(rechit->detid().rawId());
00605   ieta = id.ieta();
00606   iphi = id.iphi();
00607   depth = id.depth();
00608  
00609   double fEta=0;
00610   if (id.subdet()!=HcalForward)
00611     fEta=fabs(0.5*(theHBHEEtaBounds[abs(ieta)-1]+theHBHEEtaBounds[abs(ieta)]));
00612   else
00613     fEta=fabs(0.5*(theHFEtaBounds[abs(ieta)-29]+theHFEtaBounds[abs(ieta)-28]));
00614 
00615   float et = en/cosh(fEta);
00616 
00617   // Case 0:  ET too low to trigger hot cell check
00618   if (et<=params.minCellEnergy) return;
00619   
00620   // Case 1:  above threshold energy; always count as hot
00621   if (et>params.maxEnergy)
00622     {
00623       aboveneighbors[CalcEtaBin(id.subdet(),ieta,depth)][iphi-1][depth-1];
00624       if (makeDiagnostics_)
00625         {
00626           // fill overflow bin when energy > max threshold
00627           if       (id.subdet()==HcalBarrel)  d_HBenergyVsNeighbor->Fill(1000);
00628           else if  (id.subdet()==HcalEndcap)  d_HEenergyVsNeighbor->Fill(1000);
00629           else if  (id.subdet()==HcalOuter)   d_HOenergyVsNeighbor->Fill(1000);
00630           else if  (id.subdet()==HcalForward) d_HFenergyVsNeighbor->Fill(1000);
00631         }
00632       return;
00633     }
00634      
00635   // Case 2:  Search keys for neighboring cells
00636 
00637   neighborsfound=0;
00638   enNeighbor=0;
00639 
00640   int mydeltaphi=params.DeltaIphi;
00641   // scale appropriately for larger cells at higher eta values
00642   if (abs(ieta)>39) mydeltaphi*=4;
00643   else if (abs(ieta)>20) mydeltaphi*=2;
00644 
00645   for (int nD=-1*params.DeltaDepth;nD<=params.DeltaDepth;++nD)
00646     {
00647       for (int nP =-1*mydeltaphi;nP<=mydeltaphi;++nP)
00648         {
00649           for (int nE =-1*params.DeltaIeta;nE<=params.DeltaIeta;++nE)
00650             {
00651               if (nD==0 && nE==0 && nP==0) 
00652                 continue; // don't count the cell itself
00653               int myphi=(nP+iphi)%72;
00654               HcalDetId myid((HcalSubdetector)(1), nE+ieta, myphi, nD+depth); // HB
00655               RECHIT part=coll.find(myid);
00656               if (part==coll.end())
00657                 continue;
00658               if (part->energy()<params.minNeighborEnergy)
00659                 continue;
00660               ++neighborsfound;
00661               enNeighbor+=part->energy();
00662             } // loop over nE (neighbor eta)
00663         } // loop over nP (neighbor phi)
00664     } // loop over nD depths
00665  
00666   // Case 2a:  Not enough good neighbors found -- do we want to implement this?
00667   //if (neighborsfound==0)
00668   //  return;
00669 
00670   // Case 2b: (avg. neighbor energy)/energy too large for cell to be considered hot
00671   if (makeDiagnostics_)
00672     {
00673       int myval=(int)(enNeighbor/en*50);
00674       if (myval<0) myval=0;
00675       if (myval>499) myval=499;
00676       if (enNeighbor/en<0 || enNeighbor/en>=10) return;
00677       if       (id.subdet()==HcalBarrel)  ++hbVsNeighbor[myval];
00678       else if  (id.subdet()==HcalEndcap)  ++heVsNeighbor[myval];
00679       else if  (id.subdet()==HcalOuter)   ++hoVsNeighbor[myval];
00680       else if  (id.subdet()==HcalForward) ++hfVsNeighbor[myval];
00681     }
00682   if ((1.*enNeighbor/en)>params.HotEnergyFrac && en>0 && enNeighbor>0)
00683     return;
00684   
00685   // Case 2c:  Tests passed; cell marked as hot
00686   aboveneighbors[CalcEtaBin(id.subdet(),ieta,depth)][iphi-1][depth-1]++;
00687 
00688   return;
00689 } // void HcalHotCellMonitor::processEvent_rechitneighbor
00690 
00691 
00692 /* --------------------------------------- */
00693 
00694 
00695 void HcalHotCellMonitor::fillNevents_persistentenergy(void)
00696 {
00697   // Fill Histograms showing rechits with energies > some threshold for N consecutive events
00698 
00699   if (levt_<minEvents_) return;
00700 
00701   if (debug_>0)
00702     std::cout <<"<HcalHotCellMonitor::fillNevents_persistentenergy> FILLING PERSISTENT ENERGY PLOTS"<<std::endl;
00703   
00704   if (test_energy_)
00705     {
00706   for (unsigned int h=0;h<AbovePersistentThresholdCellsByDepth.depth.size();++h)
00707     AbovePersistentThresholdCellsByDepth.depth[h]->setBinContent(0,0,ievt_);
00708 
00709   int ieta=0;
00710   int iphi=0;
00711   int etabins=0;
00712   int phibins=0;
00713 
00714   for (unsigned int depth=0;depth<AbovePersistentThresholdCellsByDepth.depth.size();++depth)
00715     { 
00716       etabins=AbovePersistentThresholdCellsByDepth.depth[depth]->getNbinsX();
00717       phibins=AbovePersistentThresholdCellsByDepth.depth[depth]->getNbinsY();
00718 
00719       for (int eta=0;eta<etabins;++eta)
00720         {
00721           for (int phi=0;phi<phibins;++phi)
00722             {
00723               iphi=phi+1;
00724               for (int subdet=1;subdet<=4;++subdet)
00725                 {
00726                   ieta=CalcIeta((HcalSubdetector)subdet,eta,depth+1); //converts bin to ieta
00727                   if (ieta==-9999) continue;
00728                   if (!validDetId((HcalSubdetector)subdet, ieta, iphi, depth+1))
00729                     continue;
00730                   if (subdet==HcalForward) // shift HcalForward ieta by 1 for filling purposes
00731                     ieta<0 ? ieta-- : ieta++;
00732                    
00733                   // MUST BE ABOVE ENERGY THRESHOLD FOR ALL N EVENTS in a luminosity block
00734                   if (abovepersistent[eta][phi][depth]<levt_)
00735                     {
00736                       abovepersistent[eta][phi][depth]=0;
00737                       continue;                 
00738                     }
00739                   if (debug_>0) std::cout <<"HOT CELL; PERSISTENT ENERGY at subdet = "<<subdet<<", eta = "<<ieta<<", phi = "<<iphi<<" depth = "<<depth<<std::endl;
00740                   AbovePersistentThresholdCellsByDepth.depth[depth]->Fill(ieta,iphi,abovepersistent[eta][phi][depth]);
00741                   AbovePersistentThresholdCellsByDepth.depth[depth]->setBinContent(0,0,ievt_);
00742                   abovepersistent[eta][phi][depth]=0; // reset counter
00743                 } // for (int subdet=1; subdet<=4;++subdet)
00744             } // for (int phi=0;...)
00745         } // for (int eta=0;...)
00746     } // for (unsigned int depth=0;...)
00747   FillUnphysicalHEHFBins(AbovePersistentThresholdCellsByDepth);
00748     } // if (test_energy_)
00749 
00750   if (test_et_)
00751     {
00752       for (unsigned int h=0;h<AbovePersistentETThresholdCellsByDepth.depth.size();++h)
00753         AbovePersistentETThresholdCellsByDepth.depth[h]->setBinContent(0,0,ievt_);
00754       
00755       int ieta=0;
00756       int iphi=0;
00757       int etabins=0;
00758       int phibins=0;
00759       
00760       for (unsigned int depth=0;depth<AbovePersistentETThresholdCellsByDepth.depth.size();++depth)
00761         { 
00762           etabins=AbovePersistentETThresholdCellsByDepth.depth[depth]->getNbinsX();
00763           phibins=AbovePersistentETThresholdCellsByDepth.depth[depth]->getNbinsY();
00764           
00765           for (int eta=0;eta<etabins;++eta)
00766             {
00767               for (int phi=0;phi<phibins;++phi)
00768                 {
00769                   iphi=phi+1;
00770                   for (int subdet=1;subdet<=4;++subdet)
00771                     {
00772                       ieta=CalcIeta((HcalSubdetector)subdet,eta,depth+1); //converts bin to ieta
00773                       if (ieta==-9999) continue;
00774                       if (!validDetId((HcalSubdetector)subdet, ieta, iphi, depth+1))
00775                         continue;
00776                       if (subdet==HcalForward) // shift HcalForward ieta by 1 for filling purposes
00777                         ieta<0 ? ieta-- : ieta++;
00778                       
00779                       // MUST BE ABOVE ET THRESHOLD FOR ALL N EVENTS in a luminosity block
00780                       if (abovepersistentET[eta][phi][depth]<levt_)
00781                         {
00782                           abovepersistentET[eta][phi][depth]=0;
00783                           continue;             
00784                         }
00785                       if (debug_>0) std::cout <<"HOT CELL; PERSISTENT ENERGY at subdet = "<<subdet<<", eta = "<<ieta<<", phi = "<<iphi<<" depth = "<<depth<<std::endl;
00786                       AbovePersistentETThresholdCellsByDepth.depth[depth]->Fill(ieta,iphi,abovepersistentET[eta][phi][depth]);
00787                       AbovePersistentETThresholdCellsByDepth.depth[depth]->setBinContent(0,0,ievt_);
00788                       abovepersistentET[eta][phi][depth]=0; // reset counter
00789                     } // for (int subdet=1; subdet<=4;++subdet)
00790                 } // for (int phi=0;...)
00791             } // for (int eta=0;...)
00792         } // for (unsigned int depth=0;...)
00793       FillUnphysicalHEHFBins(AbovePersistentETThresholdCellsByDepth);
00794     
00795     } // if (test_et_)
00796   // Add test_ET
00797   return;
00798 } // void HcalHotCellMonitor::fillNevents_persistentenergy(void)
00799 
00800 
00801 
00802 /* ----------------------------------- */
00803 
00804 void HcalHotCellMonitor::fillNevents_energy(void)
00805 {
00806   // Fill Histograms showing rec hits that are above some energy value 
00807   // (Fill for each instance when cell is above energy; don't require it to be hot for a number of consecutive events)
00808 
00809   if (debug_>0)
00810     std::cout <<"<HcalHotCellMonitor::fillNevents_energy> ABOVE-ENERGY-THRESHOLD PLOTS"<<std::endl;
00811 
00812   if (test_energy_)
00813     {
00814       for (unsigned int h=0;h<AboveEnergyThresholdCellsByDepth.depth.size();++h)
00815         AboveEnergyThresholdCellsByDepth.depth[h]->setBinContent(0,0,ievt_);
00816     }
00817   if (test_et_)
00818     {
00819       for (unsigned int h=0;h<AboveETThresholdCellsByDepth.depth.size();++h)
00820         AboveETThresholdCellsByDepth.depth[h]->setBinContent(0,0,ievt_);
00821     }
00822 
00823   int ieta=0;
00824   int iphi=0;
00825   int etabins=0;
00826   int phibins=0;
00827   unsigned int maxdepth=0;
00828   
00829   if (test_energy_)
00830     maxdepth = AboveEnergyThresholdCellsByDepth.depth.size();
00831   if (maxdepth==0 && test_et_)
00832     maxdepth = AboveETThresholdCellsByDepth.depth.size();
00833   for (unsigned int depth=0;depth<maxdepth;++depth)
00834     { 
00835       if (test_energy_)
00836         {
00837           etabins=AboveEnergyThresholdCellsByDepth.depth[depth]->getNbinsX();
00838           phibins=AboveEnergyThresholdCellsByDepth.depth[depth]->getNbinsY();
00839         }
00840       if (test_et_)
00841         {
00842           etabins=AboveETThresholdCellsByDepth.depth[depth]->getNbinsX();
00843           phibins=AboveETThresholdCellsByDepth.depth[depth]->getNbinsY();
00844         }
00845       for (int eta=0;eta<etabins;++eta)
00846         {
00847           for (int phi=0;phi<phibins;++phi)
00848             {
00849               iphi=phi+1;
00850               for (int subdet=1;subdet<=4;++subdet)
00851                 {
00852                   ieta=CalcIeta((HcalSubdetector)subdet,eta,depth+1); //converts bin to ieta
00853                   if (ieta==-9999) continue;
00854                   if (!validDetId((HcalSubdetector)subdet, ieta, iphi, depth+1))
00855                     continue;
00856                   if (subdet==HcalForward) // shift HcalForward ieta by 1 for filling purposes
00857                     ieta<0 ? ieta-- : ieta++;
00858                   
00859                   if (test_energy_) 
00860                     {
00861                       if (aboveenergy[eta][phi][depth]>0)
00862                         {
00863                           if (debug_>2) 
00864                             std::cout <<"HOT CELL; ABOVE ENERGY THRESHOLD at subdet = "<<subdet<<", eta = "<<ieta<<", phi = "<<iphi<<" depth = "<<depth+1<<"  ABOVE THRESHOLD IN "<<aboveenergy[eta][phi][depth]<<"  EVENTS"<<std::endl;
00865                           AboveEnergyThresholdCellsByDepth.depth[depth]->Fill(ieta,iphi, aboveenergy[eta][phi][depth]);
00866                           aboveenergy[eta][phi][depth]=0;
00867                         } // if (aboveenergy[eta][phi][depth])
00868                     } // if (test_energy_)
00869                   if (test_et_)
00870                     {
00871                       if (aboveet[eta][phi][depth]>0)
00872                         {
00873                           if (debug_>2) 
00874                             std::cout <<"HOT CELL; ABOVE ET THRESHOLD at subdet = "<<subdet<<", eta = "<<ieta<<", phi = "<<iphi<<" depth = "<<depth+1<<"  ABOVE THRESHOLD IN "<<aboveet[eta][phi][depth]<<"  EVENTS"<<std::endl;
00875                           AboveETThresholdCellsByDepth.depth[depth]->Fill(ieta,iphi, aboveet[eta][phi][depth]);
00876                           aboveet[eta][phi][depth]=0;
00877                         } // if (aboveet[eta][phi][depth])
00878                     } // if (test_et_)
00879                 } // for (int subdet=0)
00880             } // for (int phi=0;...)
00881         } // for (int eta=0;...)
00882     } // for (int depth=0;...)
00883 
00884   if (test_energy_) 
00885       FillUnphysicalHEHFBins(AboveEnergyThresholdCellsByDepth);
00886 
00887   if (test_et_)
00888       FillUnphysicalHEHFBins(AboveETThresholdCellsByDepth);
00889 
00890   return;
00891 
00892 
00893 } // void HcalHotCellMonitor::fillNevents_energy(void)
00894 
00895 
00896 
00897 /* ----------------------------------- */
00898 
00899 void HcalHotCellMonitor::fillNevents_neighbor(void)
00900 {
00901   // Fill Histograms showing rec hits with energy much less than neighbors' average
00902 
00903   if (debug_>0)
00904     std::cout <<"<HcalHotCellMonitor::fillNevents_neighbor> FILLING ABOVE-NEIGHBOR-ENERGY PLOTS"<<std::endl;
00905 
00906   for (unsigned int h=0;h<AboveNeighborsHotCellsByDepth.depth.size();++h)
00907     AboveNeighborsHotCellsByDepth.depth[h]->setBinContent(0,0,ievt_);
00908 
00909   int ieta=0;
00910   int iphi=0;
00911   int etabins=0;
00912   int phibins=0;
00913   
00914   for (unsigned int depth=0;depth<AboveNeighborsHotCellsByDepth.depth.size();++depth)
00915     { 
00916       etabins=AboveNeighborsHotCellsByDepth.depth[depth]->getNbinsX();
00917       phibins=AboveNeighborsHotCellsByDepth.depth[depth]->getNbinsY();
00918       
00919       for (int eta=0;eta<etabins;++eta)
00920         {
00921           for (int phi=0;phi<phibins;++phi)
00922             {
00923               iphi=phi+1;
00924               for (int subdet=1;subdet<=4;++subdet)
00925                 {
00926                   ieta=CalcIeta((HcalSubdetector)subdet,eta,depth+1); //converts bin to ieta
00927                   if (ieta==-9999) continue;
00928                   if (!validDetId((HcalSubdetector)subdet, ieta, iphi, depth+1))
00929                     continue;
00930                   if (subdet==HcalForward) // shift HcalForward ieta by 1 for filling purposes
00931                     ieta<0 ? ieta-- : ieta++;
00932                   
00933                   if (aboveneighbors[eta][phi][depth]>0)
00934                     {
00935                       if (debug_>2) std::cout <<"HOT CELL; ABOVE NEIGHBORS at eta = "<<ieta<<", phi = "<<iphi<<" depth = "<<(depth>4 ? depth+1 : depth-3)<<std::endl;
00936                       AboveNeighborsHotCellsByDepth.depth[depth]->Fill(ieta,iphi,aboveneighbors[eta][phi][depth]);
00937                       //reset counter
00938                       aboveneighbors[eta][phi][depth]=0;
00939                     } // if (aboveneighbors[eta][phi][mydepth]>0)
00940                 } // for (int subdet=1;...)
00941             } // for (int phi=0;...)
00942         } // for (int eta=0;...)
00943     } // for (unsigned int depth=0;...)
00944   FillUnphysicalHEHFBins(AboveNeighborsHotCellsByDepth);
00945 
00946   if (!makeDiagnostics_) return;
00947   for (int i=0;i<500;++i)
00948     {
00949       d_HBenergyVsNeighbor->Fill(i/50.,hbVsNeighbor[i]);
00950       hbVsNeighbor[i]=0;
00951       d_HEenergyVsNeighbor->Fill(i/50.,heVsNeighbor[i]);
00952       heVsNeighbor[i]=0;
00953       d_HOenergyVsNeighbor->Fill(i/50.,hoVsNeighbor[i]);
00954       hoVsNeighbor[i]=0;
00955       d_HFenergyVsNeighbor->Fill(i/50.,hfVsNeighbor[i]);
00956       hfVsNeighbor[i]=0;
00957     }
00958 
00959   return;
00960 
00961 } // void HcalHotCellMonitor::fillNevents_neighbor(void)
00962 
00963 
00964 
00965 
00966 
00967 
00968 void HcalHotCellMonitor::fillNevents_problemCells(void)
00969 {
00970   if (debug_>0)
00971     std::cout <<"<HcalHotCellMonitor::fillNevents_problemCells> FILLING PROBLEM CELL PLOTS"<<std::endl;
00972 
00973   if (ievt_==0) return;  // no events; no need to bother with this 
00974 
00975   int ieta=0;
00976   int etabins=0;
00977   int phibins=0;
00978   bool problemvalue=false;
00979 
00980   // Count problem cells in each subdetector
00981   int NumBadHB=0;
00982   int NumBadHE=0;
00983   int NumBadHO=0;
00984   int NumBadHF=0;
00985   int NumBadHO0=0;
00986   int NumBadHO12=0;
00987   int NumBadHFLUMI=0;
00988 
00989   unsigned int DEPTH = 0;
00990 
00991   if (test_persistent_)  
00992     {
00993       if (test_energy_)
00994         DEPTH = AbovePersistentThresholdCellsByDepth.depth.size();
00995       else if (test_et_)
00996         DEPTH = AbovePersistentETThresholdCellsByDepth.depth.size();
00997     }
00998   else if (test_energy_ && DEPTH==0)    DEPTH = AboveEnergyThresholdCellsByDepth.depth.size();
00999   else if (test_et_ && DEPTH==0)        DEPTH = AboveETThresholdCellsByDepth.depth.size();
01000   else if (test_neighbor_ && DEPTH==0)  DEPTH = AboveNeighborsHotCellsByDepth.depth.size();
01001   
01002   if (DEPTH==0) return;
01003 
01004   for (unsigned int depth=0;depth<DEPTH;++depth)
01005     {
01006       if (test_persistent_) 
01007         {
01008           if (test_energy_)
01009             {
01010               etabins=AbovePersistentThresholdCellsByDepth.depth[depth]->getNbinsX();
01011               phibins=AbovePersistentThresholdCellsByDepth.depth[depth]->getNbinsY();
01012             }
01013           else if (test_et_)
01014             {
01015               etabins=AbovePersistentETThresholdCellsByDepth.depth[depth]->getNbinsX();
01016               phibins=AbovePersistentETThresholdCellsByDepth.depth[depth]->getNbinsY();
01017             }
01018         }
01019 
01020       if (test_neighbor_ && (etabins==0 || phibins==0))
01021         {
01022           etabins=AboveNeighborsHotCellsByDepth.depth[depth]->getNbinsX();
01023           phibins=AboveNeighborsHotCellsByDepth.depth[depth]->getNbinsY();
01024         }
01025 
01026       if (test_energy_ && (etabins==0 || phibins==0))
01027         {
01028           etabins=AboveEnergyThresholdCellsByDepth.depth[depth]->getNbinsX();
01029           phibins=AboveEnergyThresholdCellsByDepth.depth[depth]->getNbinsY();
01030         }
01031 
01032       if (test_et_ && (etabins==0 || phibins==0))
01033         {
01034           etabins=AboveETThresholdCellsByDepth.depth[depth]->getNbinsX();
01035           phibins=AboveETThresholdCellsByDepth.depth[depth]->getNbinsY();
01036         }
01037 
01038       for (int eta=0;eta<etabins;++eta)
01039         {
01040           ieta=CalcIeta(eta,depth+1);
01041           if (ieta==-9999) continue;
01042           for (int phi=0;phi<phibins;++phi)
01043             {
01044               if (abs(ieta)>20 && phi%2==1) continue; //skip non-physical cells
01045               else if (abs(ieta)>39 && (phi+1)%4!=3) continue;
01046               // find problem rate for particular cell
01047               problemvalue=false;
01048               if (test_energy_ && test_persistent_ && AbovePersistentThresholdCellsByDepth.depth[depth]->getBinContent(eta+1,phi+1)>minErrorFlag_*ievt_)
01049                 problemvalue=true;
01050               if (test_neighbor_ && AboveNeighborsHotCellsByDepth.depth[depth]->getBinContent(eta+1,phi+1)>minErrorFlag_*ievt_)
01051                 problemvalue=true;
01052               if (test_energy_  && AboveEnergyThresholdCellsByDepth.depth[depth]->getBinContent(eta+1,phi+1)>minErrorFlag_*ievt_)
01053                 problemvalue=true;
01054               if (test_et_      && AboveETThresholdCellsByDepth.depth[depth]->getBinContent(eta+1,phi+1)>minErrorFlag_*ievt_)
01055                 problemvalue=true;
01056               if (test_et_ && test_persistent_ && AbovePersistentETThresholdCellsByDepth.depth[depth]->getBinContent(eta+1,phi+1)>minErrorFlag_*ievt_)
01057                 problemvalue=true;
01058               if (problemvalue==false) continue;
01059               if (isHB(eta,depth+1)) ++NumBadHB;
01060               else if (isHE(eta,depth+1)) 
01061                 ++NumBadHE;
01062               else if (isHO(eta,depth+1))
01063                 {
01064                   ++NumBadHO;
01065                   if (abs(ieta)<5) ++NumBadHO0;
01066                   else ++NumBadHO12;
01067                 }
01068               else if (isHF(eta,depth+1)) 
01069                 {
01070                   ++NumBadHF;
01071                   if (depth+1==1 && (abs(ieta)==33 || abs(ieta)==34)) ++NumBadHFLUMI;
01072                   else if (depth+1==2 && (abs(ieta)==35 || abs(ieta)==36)) ++NumBadHFLUMI;
01073                 }
01074             } // for (int phi=0;...)
01075         } //for (int eta=0;...)
01076     } // for (int depth=0;...)
01077   
01078   if (debug_>2) std::cout <<"<HcalHotCellMonitor::fillNevents_problemCells>  Num Bad HB = "<<NumBadHB<<"  Num Bad HE = "<<NumBadHE<<"  Num Bad HO = "<<NumBadHO<<"  Num Bad HF = "<<NumBadHF<<"  CURRENT LS = "<<currentLS<<std::endl;
01079   // Fill number of problem cells
01080   ProblemsVsLB_HB->Fill(currentLS,NumBadHB);
01081   ProblemsVsLB_HE->Fill(currentLS,NumBadHE);
01082   ProblemsVsLB_HO->Fill(currentLS,NumBadHO);
01083   ProblemsVsLB_HF->Fill(currentLS,NumBadHF);
01084   ProblemsVsLB_HBHEHF->Fill(currentLS,NumBadHB+NumBadHE+NumBadHF);
01085   ProblemsVsLB->Fill(currentLS,NumBadHB+NumBadHE+NumBadHO+NumBadHF);
01086 
01087   ProblemsCurrentLB->Fill(-1,-1,levt_);
01088   ProblemsCurrentLB->Fill(0,0,NumBadHB);
01089   ProblemsCurrentLB->Fill(1,0,NumBadHE);
01090   ProblemsCurrentLB->Fill(2,0,NumBadHO);
01091   ProblemsCurrentLB->Fill(3,0,NumBadHF);
01092   ProblemsCurrentLB->Fill(4,0,NumBadHO0);
01093   ProblemsCurrentLB->Fill(5,0,NumBadHO12);
01094   ProblemsCurrentLB->Fill(6,0,NumBadHFLUMI);
01095 
01096 } // void HcalHotCellMonitor::fillNevents_problemCells(void)
01097 
01098 
01099 void HcalHotCellMonitor::zeroCounters(void)
01100 {
01101 
01102   // zero all counters
01103   for (int i=0;i<85;++i)
01104     {
01105       for (int j=0;j<72;++j)
01106         {
01107           for (int k=0;k<4;++k)
01108             {
01109               abovepersistent[i][j][k]=0;
01110               abovepersistentET[i][j][k]=0;
01111               aboveneighbors[i][j][k]=0;
01112               aboveenergy[i][j][k]=0;
01113               aboveet[i][j][k]=0;
01114               rechit_occupancy_sum[i][j][k]=0;
01115             }
01116         }
01117     }
01118 
01119   for (int i=0;i<500;++i)
01120     {
01121       hbVsNeighbor[i]=0;
01122       heVsNeighbor[i]=0;
01123       hoVsNeighbor[i]=0;
01124       hfVsNeighbor[i]=0;
01125     }
01126   return;
01127 
01128 } // void HcalHotCellMonitor::zeroCounters()
01129 
01130 void HcalHotCellMonitor::endRun(const edm::Run& run, const edm::EventSetup& c)
01131 {
01132   // Anything to do here?
01133 }
01134 
01135 void HcalHotCellMonitor::endJob()
01136 {
01137   if (debug_>0) std::cout <<"HcalHotCellMonitor::endJob()"<<std::endl;
01138   if (enableCleanup_) cleanup(); // when do we force cleanup?
01139 }
01140 
01141 void HcalHotCellMonitor::cleanup()
01142 {
01143   if (debug_>0) std::cout <<"HcalHotCellMonitor::cleanup()"<<std::endl;
01144   if (!enableCleanup_) return;
01145   if (dbe_)
01146     {
01147       // removeContents doesn't remove subdirectories
01148       dbe_->setCurrentFolder(subdir_);
01149       dbe_->removeContents();
01150       dbe_->setCurrentFolder(subdir_+"hot_rechit_above_threshold");
01151       dbe_->removeContents();
01152       dbe_->setCurrentFolder(subdir_+"hot_rechit_always_above_threshold");
01153       dbe_->removeContents();
01154       dbe_->setCurrentFolder(subdir_+"hot_neighbortest");
01155       dbe_->removeContents();
01156       dbe_->setCurrentFolder(subdir_+"LSvalues");
01157       dbe_->removeContents();
01158     }
01159 } // cleanup
01160 
01161 void HcalHotCellMonitor::periodicReset()
01162 {
01163 
01164   // first reset base class objects
01165   //FIX HcalBaseMonitor::periodicReset();
01166 
01167   // then reset the temporary histograms
01168   zeroCounters();
01169 
01170   // now reset all the MonitorElements
01171 
01172   // resetting eta-phi histograms
01173   if (test_neighbor_)
01174     AboveNeighborsHotCellsByDepth.Reset();
01175   if (test_energy_ || makeDiagnostics_)
01176     AboveEnergyThresholdCellsByDepth.Reset();
01177   if (test_et_ || makeDiagnostics_)
01178     AboveETThresholdCellsByDepth.Reset();
01179   if (test_persistent_)
01180     {
01181       AbovePersistentThresholdCellsByDepth.Reset();
01182       if (test_et_)
01183         AbovePersistentETThresholdCellsByDepth.Reset();
01184     }
01185   return;
01186 }
01187 DEFINE_FWK_MODULE(HcalHotCellMonitor);