00001 #include "DQM/HcalMonitorTasks/interface/HcalDeadCellMonitor.h"
00002
00003 #define OUT if(fverbosity_)cout
00004 #define BITSHIFT 5
00005
00006 using namespace std;
00007
00008 HcalDeadCellMonitor::HcalDeadCellMonitor()
00009 {
00010 ievt_=0;
00011
00012 showTiming = false;
00013 fVerbosity = 0;
00014 deadmon_makeDiagnostics_ = false;
00015 }
00016
00017 HcalDeadCellMonitor::~HcalDeadCellMonitor()
00018 {
00019 }
00020
00021
00022
00023
00024 void HcalDeadCellMonitor::setup(const edm::ParameterSet& ps,
00025 DQMStore* dbe)
00026 {
00027 HcalBaseMonitor::setup(ps,dbe);
00028 if (showTiming)
00029 {
00030 cpu_timer.reset(); cpu_timer.start();
00031 }
00032 baseFolder_ = rootFolder_+"DeadCellMonitor_Hcal";
00033 if (fVerbosity>0)
00034 cout <<"<HcalDeadCellMonitor::setup> Setting up histograms"<<endl;
00035
00036
00037 HBpresent_=false;
00038 HEpresent_=false;
00039 HOpresent_=false;
00040 HFpresent_=false;
00041
00042
00043
00044 if (fVerbosity>1)
00045 cout <<"<HcalDeadCellMonitor::setup> Getting variable values from cfg files"<<endl;
00046
00047 doFCpeds_ = ps.getUntrackedParameter<bool>("DeadCellMonitor_pedestalsInFC", true);
00048
00049
00050 deadmon_makeDiagnostics_ = ps.getUntrackedParameter<bool>("DeadCellMonitor_makeDiagnosticPlots",makeDiagnostics);
00051
00052
00053 deadmon_checkNevents_ = ps.getUntrackedParameter<int>("DeadCellMonitor_checkNevents",checkNevents_);
00054 deadmon_checkNevents_occupancy_ = ps.getUntrackedParameter<int>("DeadCellMonitor_checkNevents_occupancy",deadmon_checkNevents_);
00055 deadmon_checkNevents_rechit_occupancy_ = ps.getUntrackedParameter<int>("DeadCellMonitor_checkNevents_rechit_occupancy",deadmon_checkNevents_);
00056 deadmon_checkNevents_pedestal_ = ps.getUntrackedParameter<int>("DeadCellMonitor_checkNevents_pedestal" ,deadmon_checkNevents_);
00057 deadmon_checkNevents_neighbor_ = ps.getUntrackedParameter<int>("DeadCellMonitor_checkNevents_neighbor" ,deadmon_checkNevents_);
00058 deadmon_checkNevents_energy_ = ps.getUntrackedParameter<int>("DeadCellMonitor_checkNevents_energy" ,deadmon_checkNevents_);
00059
00060
00061 deadmon_test_occupancy_ = ps.getUntrackedParameter<bool>("DeadCellMonitor_test_occupancy", true);
00062 deadmon_test_rechit_occupancy_ = ps.getUntrackedParameter<bool>("DeadCellMonitor_test_rechit_occupancy", true);
00063
00064 deadmon_test_pedestal_ = ps.getUntrackedParameter<bool>("DeadCellMonitor_test_pedestal", true);
00065 deadmon_test_neighbor_ = ps.getUntrackedParameter<bool>("DeadCellMonitor_test_neighbor", true);
00066 deadmon_test_energy_ = ps.getUntrackedParameter<bool>("DeadCellMonitor_test_energy", true);
00067
00068 deadmon_minErrorFlag_ = ps.getUntrackedParameter<double>("DeadCellMonitor_minErrorFlag",0.0);
00069
00070
00071 nsigma_ = ps.getUntrackedParameter<double>("DeadCellMonitor_pedestal_Nsigma", -10);
00072 HBnsigma_ = ps.getUntrackedParameter<double>("DeadCellMonitor_pedestal_HB_Nsigma", nsigma_);
00073 HEnsigma_ = ps.getUntrackedParameter<double>("DeadCellMonitor_pedestal_HE_Nsigma", nsigma_);
00074 HOnsigma_ = ps.getUntrackedParameter<double>("DeadCellMonitor_pedestal_HO_Nsigma", nsigma_);
00075 HFnsigma_ = ps.getUntrackedParameter<double>("DeadCellMonitor_pedestal_HF_Nsigma", nsigma_);
00076 ZDCnsigma_ = ps.getUntrackedParameter<double>("DeadCellMonitor_pedestal_ZDC_Nsigma", nsigma_);
00077
00078
00079 energyThreshold_ = ps.getUntrackedParameter<double>("DeadCellMonitor_energyThreshold", 1);
00080 HBenergyThreshold_ = ps.getUntrackedParameter<double>("DeadCellMonitor_HB_energyThreshold",energyThreshold_);
00081 HEenergyThreshold_ = ps.getUntrackedParameter<double>("DeadCellMonitor_HE_energyThreshold",energyThreshold_);
00082 HOenergyThreshold_ = ps.getUntrackedParameter<double>("DeadCellMonitor_HO_energyThreshold",energyThreshold_);
00083 HFenergyThreshold_ = ps.getUntrackedParameter<double>("DeadCellMonitor_HF_energyThreshold",energyThreshold_);
00084 HFenergyThreshold_ = ps.getUntrackedParameter<double>("DeadCellMonitor_HF_energyThreshold", -999);
00085 ZDCenergyThreshold_ = ps.getUntrackedParameter<double>("DeadCellMonitor_ZDC_energyThreshold", -999);
00086
00087
00088 defaultNeighborParams_.DeltaIphi = ps.getUntrackedParameter<int>("DeadCellMonitor_neighbor_deltaIphi", 1);
00089 defaultNeighborParams_.DeltaIeta = ps.getUntrackedParameter<int>("DeadCellMonitor_neighbor_deltaIeta", 1);
00090 defaultNeighborParams_.DeltaDepth = ps.getUntrackedParameter<int>("DeadCellMonitor_neighbor_deltaDepth", 0);
00091 defaultNeighborParams_.maxCellEnergy = ps.getUntrackedParameter<double>("DeadCellMonitor_neighbor_maxCellEnergy",3.);
00092 defaultNeighborParams_.minNeighborEnergy = ps.getUntrackedParameter<double>("DeadCellMonitor_neighbor_minNeighborEnergy",1.);
00093 defaultNeighborParams_.minGoodNeighborFrac = ps.getUntrackedParameter<double>("DeadCellMonitor_neighbor_minGoodNeighborFrac",0.7);
00094 defaultNeighborParams_.maxEnergyFrac = ps.getUntrackedParameter<double>("DeadCellMonitor_neighbor_maxEnergyFrac",0.2);
00095 setupNeighborParams(ps,HBNeighborParams_ ,"HB");
00096 setupNeighborParams(ps,HENeighborParams_ ,"HE");
00097 setupNeighborParams(ps,HONeighborParams_ ,"HO");
00098 setupNeighborParams(ps,HFNeighborParams_ ,"HF");
00099 setupNeighborParams(ps,ZDCNeighborParams_,"ZDC");
00100 HFNeighborParams_.DeltaIphi*=2;
00101
00102
00103 ievt_=0;
00104
00105
00106 for (int i=0;i<ETABINS;++i)
00107 {
00108 for (int j=0;j<PHIBINS;++j)
00109 {
00110 for (int k=0;k<4;++k)
00111 {
00112 occupancy[i][j][k]=0;
00113 rechit_occupancy[i][j][k]=0;
00114 abovepedestal[i][j][k]=0;
00115 belowneighbors[i][j][k]=0;
00116 aboveenergy[i][j][k]=0;
00117 }
00118 }
00119 }
00120
00121
00122 if (m_dbe)
00123 {
00124 if (fVerbosity>1)
00125 cout <<"<HcalDeadCellMonitor::setup> Setting up histograms"<<endl;
00126
00127 m_dbe->setCurrentFolder(baseFolder_);
00128 meEVT_ = m_dbe->bookInt("Dead Cell Task Event Number");
00129 meEVT_->Fill(ievt_);
00130
00131
00132
00133 ProblemDeadCells=m_dbe->book2D(" ProblemDeadCells",
00134 " Problem Dead Cell Rate for all HCAL",
00135 etaBins_,etaMin_,etaMax_,
00136 phiBins_,phiMin_,phiMax_);
00137 ProblemDeadCells->setAxisTitle("i#eta",1);
00138 ProblemDeadCells->setAxisTitle("i#phi",2);
00139
00140 (ProblemDeadCells->getTH2F())->SetMinimum(deadmon_minErrorFlag_);
00141 (ProblemDeadCells->getTH2F())->SetMaximum(1.);
00142
00143
00144 m_dbe->setCurrentFolder(baseFolder_+"/problem_deadcells");
00145 setupDepthHists2D(ProblemDeadCellsByDepth, " Problem Dead Cell Rate","");
00146 setMinMaxHists2D(ProblemDeadCellsByDepth,deadmon_minErrorFlag_,1.);
00147
00148
00149 stringstream units;
00150 m_dbe->setCurrentFolder(baseFolder_+"/dead_unoccupied_digi");
00151
00152 setupDepthHists2D(UnoccupiedDeadCellsByDepth,
00153 "Dead Cells with No Digis","");
00154 setMinMaxHists2D(UnoccupiedDeadCellsByDepth,0.,1.);
00155
00156 m_dbe->setCurrentFolder(baseFolder_+"/dead_unoccupied_rechit");
00157 setupDepthHists2D(UnoccupiedRecHitsByDepth,
00158 "Dead Cells with No Rec Hits","");
00159 setMinMaxHists2D(UnoccupiedRecHitsByDepth,0.,1.);
00160
00161 m_dbe->setCurrentFolder(baseFolder_+"/dead_pedestaltest");
00162 setupDepthHists2D(BelowPedestalDeadCellsByDepth,"Dead Cells Failing Pedestal Test","");
00163 setMinMaxHists2D(BelowPedestalDeadCellsByDepth,0.,1.);
00164
00165 units.str("");
00166 units<<"Dead Cells Failing Pedestal Test Depth 1 -- HB < ped + "<<HBnsigma_<<" #sigma, HF < ped + "<<HFnsigma_<<" #sigma";
00167 BelowPedestalDeadCellsByDepth[0]->setTitle(units.str().c_str());
00168 units.str("");
00169 units<<"Dead Cells Failing Pedestal Test Depth 2 -- HB < ped + "<<HBnsigma_<<" #sigma, HF < ped + "<<HFnsigma_<<" #sigma";
00170 BelowPedestalDeadCellsByDepth[1]->setTitle(units.str().c_str());
00171 units.str("");
00172 units<<"Dead Cells Failing Pedestal Test Depth 3 -- HE < ped + "<<HEnsigma_<<" #sigma";
00173 BelowPedestalDeadCellsByDepth[2]->setTitle(units.str().c_str());
00174 units.str("");
00175 units<<"Dead Cells Failing Pedestal Test Depth 4 -- HO < ped + "<<HOnsigma_<<" #sigma, ZDC TBD";
00176 BelowPedestalDeadCellsByDepth[3]->setTitle(units.str().c_str());
00177 units.str("");
00178 units<<"Dead Cells Failing Pedestal Test Depth 1 -- HE < ped + "<<HEnsigma_<<" #sigma";
00179 BelowPedestalDeadCellsByDepth[4]->setTitle(units.str().c_str());
00180 units.str("");
00181 units<<"Dead Cells Failing Pedestal Test Depth 2 -- HE < ped + "<<HEnsigma_<<" #sigma";
00182 BelowPedestalDeadCellsByDepth[5]->setTitle(units.str().c_str());
00183 units.str("");
00184
00185 m_dbe->setCurrentFolder(baseFolder_+"/dead_neighbortest");
00186 setupDepthHists2D(BelowNeighborsDeadCellsByDepth,"Dead Cells Failing Neighbor Test","");
00187 setMinMaxHists2D(BelowNeighborsDeadCellsByDepth,0.,1.);
00188
00189 m_dbe->setCurrentFolder(baseFolder_+"/dead_energytest");
00190 setupDepthHists2D(BelowEnergyThresholdCellsByDepth,"Dead Cells Failing Energy Threshold Test","");
00191 setMinMaxHists2D(BelowEnergyThresholdCellsByDepth,0.,1.);
00192
00193 units.str("");
00194 units<<"Dead Cells with Consistent Low Energy Depth 1 -- HB <"<<HBenergyThreshold_<<" GeV, HF <"<<HFenergyThreshold_<<" GeV";
00195 BelowEnergyThresholdCellsByDepth[0]->setTitle(units.str().c_str());
00196 units.str("");
00197 units<<"Dead Cells with Consistent Low Energy Depth 2 -- HB <"<<HBenergyThreshold_<<" GeV, HF <"<<HFenergyThreshold_<<" GeV";
00198 BelowEnergyThresholdCellsByDepth[1]->setTitle(units.str().c_str());
00199 units.str("");
00200 units<<"Dead Cells with Consistent Low Energy Depth 3 -- HE <"<<HEenergyThreshold_<<" GeV";
00201 BelowEnergyThresholdCellsByDepth[2]->setTitle(units.str().c_str());
00202 units.str("");
00203 units<<"Dead Cells with Consistent Low Energy Depth 4 -- HO <"<<HOenergyThreshold_<<" GeV, ZDC TBD";
00204 BelowEnergyThresholdCellsByDepth[3]->setTitle(units.str().c_str());
00205 units.str("");
00206 units<<"Dead Cells with Consistent Low Energy Depth 1 -- HE <"<<HEenergyThreshold_<<" GeV";
00207 BelowEnergyThresholdCellsByDepth[4]->setTitle(units.str().c_str());
00208 units.str("");
00209 units<<"Dead Cells with Consistent Low Energy Depth 2 -- HE <"<<HEenergyThreshold_<<" GeV";
00210 BelowEnergyThresholdCellsByDepth[5]->setTitle(units.str().c_str());
00211 units.str("");
00212
00213 if (deadmon_makeDiagnostics_)
00214 {
00215 m_dbe->setCurrentFolder(baseFolder_+"/diagnostics/pedestal");
00216 d_HBnormped=m_dbe->book1D("HB_normped","HB Dead Cell pedestal diagnostic ",300,-10,20);
00217 d_HEnormped=m_dbe->book1D("HE_normped","HE Dead Cell pedestal diagnostic",300,-10,20);
00218 d_HOnormped=m_dbe->book1D("HO_normped","HO Dead Cell pedestal diagnostic",300,-10,20);
00219 d_HFnormped=m_dbe->book1D("HF_normped","HF Dead Cell pedestal diagnostic",300,-10,20);
00220
00221 d_HBnormped->setAxisTitle("(avg ADC-pedestal)/#sigma",1);
00222 d_HEnormped->setAxisTitle("(avg ADC-pedestal)/#sigma",1);
00223 d_HOnormped->setAxisTitle("(avg ADC-pedestal)/#sigma",1);
00224 d_HFnormped->setAxisTitle("(avg ADC-pedestal)/#sigma",1);
00225
00226 m_dbe->setCurrentFolder(baseFolder_+"/diagnostics/energythreshold");
00227 d_HBrechitenergy=m_dbe->book1D("HB_rechitenergy","HB rechit energy",500,-10,40);
00228 d_HErechitenergy=m_dbe->book1D("HE_rechitenergy","HE rechit energy",500,-10,40);
00229 d_HOrechitenergy=m_dbe->book1D("HO_rechitenergy","HO rechit energy",500,-10,40);
00230 d_HFrechitenergy=m_dbe->book1D("HF_rechitenergy","HF rechit energy",500,-10,40);
00231
00232 m_dbe->setCurrentFolder(baseFolder_+"/diagnostics/neighborcells");
00233 d_HBenergyVsNeighbor=m_dbe->book2D("HB_energyVsNeighbor","HB rec hit energy vs. #Sigma Neighbors",100,0,25,100,-5,15);
00234 d_HEenergyVsNeighbor=m_dbe->book2D("HE_energyVsNeighbor","HE rec hit energy vs. #Sigma Neighbors",100,0,25,100,-5,15);
00235 d_HOenergyVsNeighbor=m_dbe->book2D("HO_energyVsNeighbor","HO rec hit energy vs. #Sigma Neighbors",100,0,25,100,-5,15);
00236 d_HFenergyVsNeighbor=m_dbe->book2D("HF_energyVsNeighbor","HF rec hit energy vs. #Sigma Neighbors",100,0,25,100,-5,15);
00237
00238 }
00239 }
00240
00241 return;
00242 }
00243
00244
00245 void HcalDeadCellMonitor::setupNeighborParams(const edm::ParameterSet& ps,
00246 neighborParams& N,
00247 char* type)
00248 {
00249
00250 ostringstream myname;
00251 myname<<"DeadCellMonitor_"<<type<<"_neighbor_deltaIphi";
00252 N.DeltaIphi = ps.getUntrackedParameter<int>(myname.str().c_str(),
00253 defaultNeighborParams_.DeltaIphi);
00254 myname.str("");
00255 myname<<"DeadCellMonitor_"<<type<<"_neighbor_deltaIeta";
00256 N.DeltaIeta = ps.getUntrackedParameter<int>(myname.str().c_str(),
00257 defaultNeighborParams_.DeltaIeta);
00258 myname.str("");
00259 myname<<"DeadCellMonitor_"<<type<<"_neighbor_deltaDepth";
00260 N.DeltaDepth = ps.getUntrackedParameter<int>(myname.str().c_str(),
00261 defaultNeighborParams_.DeltaDepth);
00262 myname.str("");
00263 myname<<"DeadCellMonitor_"<<type<<"_neighbor_maxCellEnergy";
00264 N.maxCellEnergy = ps.getUntrackedParameter<double>(myname.str().c_str(),
00265 defaultNeighborParams_.maxCellEnergy);
00266 myname.str("");
00267 myname<<"DeadCellMonitor_"<<type<<"_neighbor_minNeighborEnergy";
00268 N.minNeighborEnergy = ps.getUntrackedParameter<double>(myname.str().c_str(),
00269 defaultNeighborParams_.minNeighborEnergy);
00270 myname.str("");
00271 myname<<"DeadCellMonitor_"<<type<<"_neighbor_minGoodNeighborFrac";
00272 N.minGoodNeighborFrac = ps.getUntrackedParameter<double>(myname.str().c_str(),
00273 defaultNeighborParams_.minGoodNeighborFrac);
00274 myname.str("");
00275 myname<<"DeadCellMonitor_"<<type<<"_neighbor_maxEnergyFrac";
00276 N.maxEnergyFrac = ps.getUntrackedParameter<double>(myname.str().c_str(),
00277 defaultNeighborParams_.maxEnergyFrac);
00278 return;
00279 }
00280
00281
00282
00283 void HcalDeadCellMonitor::reset(){}
00284
00285
00286
00287 void HcalDeadCellMonitor::createMaps(const HcalDbService& cond)
00288 {
00289
00290
00291
00292 if (!deadmon_test_pedestal_) return;
00293
00294 if (showTiming)
00295 {
00296 cpu_timer.reset(); cpu_timer.start();
00297 }
00298
00299 if (fVerbosity>0)
00300 cout <<"<HcalDeadCellMonitor::createMaps>: Making pedestal maps"<<endl;
00301 double ped=0;
00302 double width=0;
00303 HcalCalibrations calibs;
00304 const HcalQIEShape* shape = cond.getHcalShape();
00305
00306 double myNsigma=0;
00307 double myADC=0;
00308
00309 for (int ieta=static_cast<int>(etaMin_);ieta<=static_cast<int>(etaMax_);++ieta)
00310 {
00311 for (int iphi=static_cast<int>(phiMin_);iphi<=static_cast<int>(phiMax_);++iphi)
00312 {
00313 for (int depth=1;depth<=4;++depth)
00314 {
00315 for (int subdet=1;subdet<=4;++subdet)
00316 {
00317 if (!validDetId((HcalSubdetector)subdet, ieta, iphi, depth))
00318 continue;
00319 HcalDetId hcal((HcalSubdetector)(subdet), ieta, iphi, depth);
00320
00321 if (hcal.subdet()==HcalBarrel)
00322 myNsigma=HBnsigma_;
00323 else if (hcal.subdet()==HcalEndcap)
00324 myNsigma=HEnsigma_;
00325 else if (hcal.subdet()==HcalOuter)
00326 myNsigma=HOnsigma_;
00327 else if (hcal.subdet()==HcalForward)
00328 myNsigma=HFnsigma_;
00329
00330 calibs=cond.getHcalCalibrations(hcal);
00331 const HcalPedestalWidth* pedw = cond.getPedestalWidth(hcal);
00332
00333 ped=0.;
00334 width=0.;
00335 myADC=0.;
00336
00337 for (int capid=0;capid<4;++capid)
00338 {
00339
00340 const HcalQIECoder* channelCoder=cond.getHcalCoder(hcal);
00341
00342
00343 myADC=channelCoder->adc(*shape,
00344 (float)calibs.pedestal(capid),
00345 capid);
00346 ped+=myADC;
00347
00348
00349 if (doFCpeds_)
00350 {
00351
00352
00353 width+=(pedw->getSigma(capid,capid)*pow(myADC/calibs.pedestal(capid),2));
00354 }
00355 else
00356 width+=pedw->getSigma(capid,capid);
00357 }
00358
00359 ped/=4.;
00360 width=pow(width,0.5)/4.;
00361
00362 pedestals_[hcal]=ped;
00363 widths_[hcal]=width;
00364 if (fVerbosity>1) cout <<"<HcalDeadCellMonitor::createMaps> Pedestal Value -- ID = "<<(HcalSubdetector)subdet<<" ("<<ieta<<", "<<iphi<<", "<<depth<<"): "<<ped<<"; width = "<<width<<endl;
00365 pedestal_thresholds_[hcal]=ped+myNsigma*width;
00366 }
00367 }
00368 }
00369 }
00370
00371 return;
00372 }
00373
00374
00375
00376
00377
00378
00379 void HcalDeadCellMonitor::done(std::map<HcalDetId, unsigned int>& myqual)
00380 {
00381 if (dump2database==0)
00382 return;
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393 int eta,phi;
00394 float binval;
00395 int mydepth;
00396
00397 int subdet;
00398 char* subdetname;
00399 if (fVerbosity>1)
00400 {
00401 cout <<"<HcalDeadCellMonitor> Summary of Dead Cells in Run: "<<endl;
00402 cout <<"(Error rate must be >= "<<deadmon_minErrorFlag_*100.<<"% )"<<endl;
00403 }
00404 for (int ieta=1;ieta<=etaBins_;++ieta)
00405 {
00406 for (int iphi=1;iphi<=phiBins_;++iphi)
00407 {
00408 eta=ieta+int(etaMin_)-1;
00409 phi=iphi+int(phiMin_)-1;
00410
00411 for (int d=0;d<6;++d)
00412 {
00413 binval=ProblemDeadCellsByDepth[d]->getBinContent(ieta,iphi);
00414
00415
00416 if (d<2)
00417 {
00418 if (abs(eta)<29)
00419 {
00420 subdetname="HB";
00421 subdet=1;
00422 }
00423 else
00424 {
00425 subdetname="HF";
00426 subdet=4;
00427 }
00428 }
00429 else if (d==3)
00430 {
00431 if (abs(eta)==43)
00432 {
00433 subdetname="ZDC";
00434 subdet=7;
00435 }
00436 else
00437 {
00438 subdetname="HO";
00439 subdet=3;
00440 }
00441 }
00442 else
00443 {
00444 subdetname="HE";
00445 subdet=2;
00446 }
00447
00448 if (d>3)
00449 mydepth=d-3;
00450 else
00451 mydepth=d+1;
00452 HcalDetId myid((HcalSubdetector)(subdet), eta, phi, mydepth);
00453 if (!validDetId((HcalSubdetector)(subdet), eta, phi, mydepth))
00454 continue;
00455
00456 if (fVerbosity>0 && binval>deadmon_minErrorFlag_)
00457 cout <<"Dead Cell "<<subdet<<"("<<eta<<", "<<phi<<", "<<mydepth<<"): "<<binval*100.<<"%"<<endl;
00458 int value = 0;
00459 if (binval>deadmon_minErrorFlag_)
00460 value=1;
00461
00462 if (value==1)
00463 if (myqual.find(myid)==myqual.end())
00464 {
00465 myqual[myid]=(value<<BITSHIFT);
00466 }
00467 else
00468 {
00469 int mask=(1<<BITSHIFT);
00470 if (value==1)
00471 myqual[myid] |=mask;
00472
00473 else
00474 myqual[myid] &=~mask;
00475 if (value==1 && fVerbosity>1) cout <<"myqual = "<<std::hex<<myqual[myid]<<std::dec<<" MASK = "<<std::hex<<mask<<std::dec<<endl;
00476 }
00477
00478
00479
00480
00481 }
00482 }
00483 }
00484
00485
00486 return;
00487
00488 }
00489
00490
00491
00492
00493
00494 void HcalDeadCellMonitor::clearME()
00495 {
00496
00497
00498 if (m_dbe)
00499 {
00500 m_dbe->setCurrentFolder(baseFolder_);
00501 m_dbe->removeContents();
00502 }
00503 return;
00504 }
00505
00506
00507
00508
00509 void HcalDeadCellMonitor::processEvent(const HBHERecHitCollection& hbHits,
00510 const HORecHitCollection& hoHits,
00511 const HFRecHitCollection& hfHits,
00512
00513 const HBHEDigiCollection& hbhedigi,
00514 const HODigiCollection& hodigi,
00515 const HFDigiCollection& hfdigi,
00516
00517 const HcalDbService& cond
00518 )
00519 {
00520
00521 if (showTiming)
00522 {
00523 cpu_timer.reset(); cpu_timer.start();
00524 }
00525
00526 ++ievt_;
00527 if (m_dbe) meEVT_->Fill(ievt_);
00528
00529 HOpresent_ = (hodigi.size()>0||hoHits.size()>0);
00530 HFpresent_ = (hfdigi.size()>0||hfHits.size()>0);
00531 if (fVerbosity>1) cout <<"<HcalDeadCellMonitor::processEvent> Processing event..."<<endl;
00532
00533
00534
00535 if (deadmon_test_occupancy_ || deadmon_test_pedestal_)
00536 processEvent_digi(hbhedigi,hodigi,hfdigi,cond);
00537
00538
00539 if (deadmon_test_energy_ || deadmon_test_rechit_occupancy_)
00540 {
00541 processEvent_rechitenergy(hbHits, hoHits,hfHits);
00542 }
00543
00544
00545 if (deadmon_test_neighbor_)
00546 {
00547 processEvent_rechitneighbors(hbHits, hoHits, hfHits);
00548 }
00549
00550
00551 if (((ievt_%deadmon_checkNevents_occupancy_ ==0) && deadmon_test_occupancy_ )||
00552 ((ievt_%deadmon_checkNevents_pedestal_ ==0) && deadmon_test_pedestal_ )||
00553 ((ievt_%deadmon_checkNevents_neighbor_ ==0) && deadmon_test_neighbor_ )||
00554 ((ievt_%deadmon_checkNevents_energy_ ==0) && deadmon_test_energy_ ))
00555 {
00556 fillNevents_problemCells();
00557 }
00558
00559 return;
00560 }
00561
00562
00563
00564 void HcalDeadCellMonitor::fillDeadHistosAtEndRun()
00565 {
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575 return;
00576
00577 if (deadmon_test_occupancy_ && ievt_%deadmon_checkNevents_occupancy_>0) fillNevents_occupancy();
00578 if (deadmon_test_pedestal_ && ievt_%deadmon_checkNevents_pedestal_ >0) fillNevents_pedestal();
00579 if (deadmon_test_neighbor_ && ievt_%deadmon_checkNevents_neighbor_ >0) fillNevents_neighbor();
00580 if (deadmon_test_energy_ && ievt_%deadmon_checkNevents_energy_ >0) fillNevents_energy();
00581 if (deadmon_test_occupancy_ || deadmon_test_pedestal_ ||
00582 deadmon_test_neighbor_ || deadmon_test_energy_)
00583 {
00584 fillNevents_problemCells();
00585 FillUnphysicalHEHFBins(ProblemDeadCellsByDepth);
00586 }
00587 }
00588
00589
00590
00591
00592 void HcalDeadCellMonitor::processEvent_rechitenergy( const HBHERecHitCollection& hbheHits,
00593 const HORecHitCollection& hoHits,
00594 const HFRecHitCollection& hfHits)
00595
00596 {
00597
00598
00599
00600 if (showTiming)
00601 {
00602 cpu_timer.reset(); cpu_timer.start();
00603 }
00604
00605 if (fVerbosity>1) cout <<"<HcalDeadCellMonitor::processEvent_rechitenergy> Processing rechits..."<<endl;
00606 if (deadmon_test_neighbor_) rechitEnergies_.clear();
00607
00608
00609 for (HBHERecHitCollection::const_iterator HBHEiter=hbheHits.begin(); HBHEiter!=hbheHits.end(); ++HBHEiter)
00610 {
00611 float en = HBHEiter->energy();
00612
00613
00614 HcalDetId id(HBHEiter->detid().rawId());
00615 int ieta = id.ieta();
00616 int iphi = id.iphi();
00617 int depth = id.depth();
00618 if (id.subdet()==HcalBarrel)
00619 {
00620 HBpresent_=true;
00621 if (!checkHB_) continue;
00622 if (deadmon_makeDiagnostics_) d_HBrechitenergy->Fill(en);
00623 ++rechit_occupancy[static_cast<int>(ieta+(etaBins_-2)/2)][iphi-1][depth-1];
00624 if (en>=HBenergyThreshold_)
00625 ++aboveenergy[static_cast<int>(ieta+(etaBins_-2)/2)][iphi-1][depth-1];
00626 }
00627 else
00628 {
00629 HEpresent_=true;
00630 if (!checkHE_) continue;
00631 if (deadmon_makeDiagnostics_) d_HErechitenergy->Fill(en);
00632 ++rechit_occupancy[static_cast<int>(ieta+(etaBins_-2)/2)][iphi-1][depth-1];
00633 if (en>=HEenergyThreshold_)
00634 ++aboveenergy[static_cast<int>(ieta+(etaBins_-2)/2)][iphi-1][depth-1];
00635 }
00636 if (deadmon_test_neighbor_) rechitEnergies_[id]=en;
00637 }
00638
00639
00640 if (checkHO_)
00641 {
00642 for (HORecHitCollection::const_iterator HOiter=hoHits.begin(); HOiter!=hoHits.end(); ++HOiter)
00643 {
00644 float en = HOiter->energy();
00645
00646 HcalDetId id(HOiter->detid().rawId());
00647 int ieta = id.ieta();
00648 int iphi = id.iphi();
00649 int depth = id.depth();
00650 ++rechit_occupancy[static_cast<int>(ieta+(etaBins_-2)/2)][iphi-1][depth-1];
00651 if (deadmon_makeDiagnostics_) d_HOrechitenergy->Fill(en);
00652 if (en>=HOenergyThreshold_)
00653 ++aboveenergy[static_cast<int>(ieta+(etaBins_-2)/2)][iphi-1][depth-1];
00654 if (deadmon_test_neighbor_) rechitEnergies_[id]=en;
00655 }
00656 }
00657
00658
00659 if (checkHF_)
00660 {
00661 for (HFRecHitCollection::const_iterator HFiter=hfHits.begin(); HFiter!=hfHits.end(); ++HFiter)
00662 {
00663 float en = HFiter->energy();
00664
00665 HcalDetId id(HFiter->detid().rawId());
00666 int ieta = id.ieta();
00667 int iphi = id.iphi();
00668 int depth = id.depth();
00669 if (deadmon_makeDiagnostics_) d_HFrechitenergy->Fill(en);
00670 ++rechit_occupancy[static_cast<int>(ieta+(etaBins_-2)/2)][iphi-1][depth+1];
00671 if (en>=HFenergyThreshold_)
00672 ++aboveenergy[static_cast<int>(ieta+(etaBins_-2)/2)][iphi-1][depth+1];
00673 if (deadmon_test_neighbor_) rechitEnergies_[id]=en;
00674 }
00675 }
00676
00677
00678
00679 if (ievt_%deadmon_checkNevents_energy_==0)
00680 {
00681 if (fVerbosity>0) cout <<"<HcalDeadCellMonitor::processEvent_rechitenergy> Filling DeadCell Energy plots"<<endl;
00682 fillNevents_energy();
00683 }
00684
00685 if (showTiming)
00686 {
00687 cpu_timer.stop(); cout <<"TIMER:: HcalDeadCellMonitor PROCESSEVENT_RECHITENERGY -> "<<cpu_timer.cpuTime()<<endl;
00688 }
00689 return;
00690 }
00691
00692
00693
00694
00695 void HcalDeadCellMonitor::processEvent_rechitneighbors( const HBHERecHitCollection& hbheHits,
00696 const HORecHitCollection& hoHits,
00697 const HFRecHitCollection& hfHits
00698 )
00699 {
00700
00701
00702
00703
00704 if (showTiming)
00705 {
00706 cpu_timer.reset(); cpu_timer.start();
00707 }
00708
00709 if (fVerbosity>1) cout <<"<HcalDeadCellMonitor::processEvent_rechitneighbors> Processing rechits..."<<endl;
00710
00711
00712 if (!deadmon_test_energy_)
00713 {
00714 rechitEnergies_.clear();
00715 for (HBHERecHitCollection::const_iterator HBHEiter=hbheHits.begin(); HBHEiter!=hbheHits.end(); ++HBHEiter)
00716 {
00717 float en = HBHEiter->energy();
00718 HcalDetId id(HBHEiter->detid().rawId());
00719 if (id.subdet()==HcalBarrel)
00720 {
00721 HBpresent_=true;
00722 if (!checkHB_)
00723 continue;
00724 }
00725 else
00726 {
00727 HEpresent_=true;
00728 if (!checkHE_)
00729 continue;
00730 }
00731 rechitEnergies_[id]=en;
00732 }
00733
00734 if (checkHO_)
00735 {
00736 for (HORecHitCollection::const_iterator HOiter=hoHits.begin(); HOiter!=hoHits.end(); ++HOiter)
00737 {
00738 float en = HOiter->energy();
00739 HcalDetId id(HOiter->detid().rawId());
00740 rechitEnergies_[id]=en;
00741 }
00742 }
00743
00744 if (checkHF_)
00745 {
00746 for (HFRecHitCollection::const_iterator HFiter=hfHits.begin(); HFiter!=hfHits.end(); ++HFiter)
00747 {
00748 float en = HFiter->energy();
00749 HcalDetId id(HFiter->detid().rawId());
00750 rechitEnergies_[id]=en;
00751 }
00752 }
00753
00754 }
00755
00756
00757
00758
00759
00760
00761
00762
00763 int ieta, iphi, depth;
00764 float en;
00765
00766 int cellsfound=0;
00767 int allneighbors=0;
00768 float enNeighbor=0;
00769
00770
00771 for (HBHERecHitCollection::const_iterator HBHEiter=hbheHits.begin();
00772 HBHEiter!=hbheHits.end();
00773 ++HBHEiter)
00774 {
00775
00776 en = HBHEiter->energy();
00777 HcalDetId id(HBHEiter->detid().rawId());
00778 ieta = id.ieta();
00779 iphi = id.iphi();
00780 depth = id.depth();
00781
00782 if (id.subdet()==HcalBarrel)
00783 {
00784 HBpresent_=true;
00785 if (!checkHB_) continue;
00786
00787 if (en>HBNeighborParams_.maxCellEnergy)
00788 continue;
00789 allneighbors=0;
00790 cellsfound=0;
00791 enNeighbor=0;
00792 for (int nD=-1*HBNeighborParams_.DeltaDepth;nD<=HBNeighborParams_.DeltaDepth;++nD)
00793 {
00794 for (int nP =-1*HBNeighborParams_.DeltaIphi;nP<=HBNeighborParams_.DeltaIphi;++nP)
00795 {
00796 for (int nE =-1*HBNeighborParams_.DeltaIeta;nE<=HBNeighborParams_.DeltaIeta;++nE)
00797 {
00798 if (nD==0 && nE==0 && nP==0)
00799 continue;
00800 int myphi=nP+iphi;
00801 if (myphi>72) myphi-=72;
00802 if (myphi<=0) myphi+=72;
00803 if (!validDetId((HcalSubdetector)(1),nE+ieta, myphi, nD+depth)) continue;
00804 HcalDetId myid((HcalSubdetector)(1), nE+ieta, myphi, nD+depth);
00805 ++allneighbors;
00806 if (rechitEnergies_.find(myid)==rechitEnergies_.end())
00807 continue;
00808 if (rechitEnergies_[myid]<HBNeighborParams_.minNeighborEnergy)
00809 continue;
00810 ++cellsfound;
00811 enNeighbor+=rechitEnergies_[myid];
00812 }
00813 }
00814 }
00815
00816 if (deadmon_makeDiagnostics_)
00817 d_HBenergyVsNeighbor->Fill(enNeighbor,en);
00818
00819
00820 if (1.*cellsfound/allneighbors<HBNeighborParams_.minGoodNeighborFrac)
00821 continue;
00822
00823 if (1.*en/(enNeighbor/allneighbors)>HENeighborParams_.maxEnergyFrac)
00824 continue;
00825
00826 ++belowneighbors[static_cast<int>(ieta+(etaBins_-2)/2)][iphi-1][depth-1];
00827 }
00828 else
00829 {
00830 HEpresent_=true;
00831 if (!checkHE_) continue;
00832
00833 if (en>HENeighborParams_.maxCellEnergy)
00834 continue;
00835 allneighbors=0;
00836 cellsfound=0;
00837 enNeighbor=0;
00838 int HEDeltaIphi = HENeighborParams_.DeltaIphi;
00839
00840 if (abs(ieta)>20) HEDeltaIphi*=2;
00841
00842 for (int nD=-1*HENeighborParams_.DeltaDepth;nD<=HENeighborParams_.DeltaDepth;++nD)
00843 {
00844 for (int nP =-1*HEDeltaIphi;nP<=HEDeltaIphi;++nP)
00845 {
00846 for (int nE =-1*HENeighborParams_.DeltaIeta;nE<=HENeighborParams_.DeltaIeta;++nE)
00847 {
00848 if (nD==0 && nE==0 && nP==0)
00849 continue;
00850
00851 int myphi=nP+iphi;
00852 if (myphi>72) myphi-=72;
00853 if (myphi<=0) myphi+=72;
00854 if (!validDetId((HcalSubdetector)(2),nE+ieta, myphi, nD+depth)) continue;
00855 HcalDetId myid((HcalSubdetector)(2), nE+ieta, myphi, nD+depth);
00856 ++allneighbors;
00857 if (rechitEnergies_.find(myid)==rechitEnergies_.end())
00858 continue;
00859 if (rechitEnergies_[myid]<HENeighborParams_.minNeighborEnergy)
00860 continue;
00861 ++cellsfound;
00862 enNeighbor+=rechitEnergies_[myid];
00863 }
00864 }
00865 }
00866
00867 if (deadmon_makeDiagnostics_)
00868 d_HEenergyVsNeighbor->Fill(enNeighbor,en);
00869
00870
00871 if (1.*cellsfound/allneighbors<HENeighborParams_.minGoodNeighborFrac)
00872 continue;
00873
00874 if (1.*en/(enNeighbor/allneighbors)>HENeighborParams_.maxEnergyFrac)
00875 continue;
00876
00877 ++belowneighbors[static_cast<int>(ieta+(etaBins_-2)/2)][iphi-1][depth-1];
00878 }
00879 }
00880
00881
00882 if (checkHO_)
00883 {
00884 for (HORecHitCollection::const_iterator HOiter=hoHits.begin(); HOiter!=hoHits.end(); ++HOiter)
00885 {
00886 float en = HOiter->energy();
00887 HcalDetId id(HOiter->detid().rawId());
00888 int ieta = id.ieta();
00889 int iphi = id.iphi();
00890 int depth = id.depth();
00891
00892
00893 if (en>HONeighborParams_.maxCellEnergy)
00894 continue;
00895 allneighbors=0;
00896 cellsfound=0;
00897 enNeighbor=0;
00898 for (int nD=-1*HONeighborParams_.DeltaDepth;nD<=HONeighborParams_.DeltaDepth;++nD)
00899 {
00900 for (int nP =-1*HONeighborParams_.DeltaIphi;nP<=HONeighborParams_.DeltaIphi;++nP)
00901 {
00902 for (int nE =-1*HONeighborParams_.DeltaIeta;nE<=HONeighborParams_.DeltaIeta;++nE)
00903 {
00904 if (nD==0 && nE==0 && nP==0)
00905 continue;
00906 int myphi=nP+iphi;
00907 if (myphi>72) myphi-=72;
00908 if (myphi<=0) myphi+=72;
00909 if (!validDetId((HcalSubdetector)(3),nE+ieta, myphi, nD+depth)) continue;
00910 HcalDetId myid((HcalSubdetector)(3), nE+ieta, myphi, nD+depth);
00911 ++allneighbors;
00912 if (rechitEnergies_.find(myid)==rechitEnergies_.end())
00913 continue;
00914 if (rechitEnergies_[myid]<HONeighborParams_.minNeighborEnergy)
00915 continue;
00916 ++cellsfound;
00917 enNeighbor+=rechitEnergies_[myid];
00918 }
00919 }
00920 }
00921
00922 if (deadmon_makeDiagnostics_)
00923 d_HOenergyVsNeighbor->Fill(enNeighbor,en);
00924
00925
00926 if (1.*cellsfound/allneighbors<HONeighborParams_.minGoodNeighborFrac)
00927 continue;
00928
00929 if (1.*en/(enNeighbor/allneighbors)>HONeighborParams_.maxEnergyFrac)
00930 continue;
00931
00932 ++belowneighbors[static_cast<int>(ieta+(etaBins_-2)/2)][iphi-1][depth-1];
00933 }
00934 }
00935
00936
00937 if (checkHF_)
00938 {
00939 for (HFRecHitCollection::const_iterator HFiter=hfHits.begin(); HFiter!=hfHits.end(); ++HFiter)
00940 {
00941 float en = HFiter->energy();
00942 HcalDetId id(HFiter->detid().rawId());
00943 int ieta = id.ieta();
00944 int iphi = id.iphi();
00945 int depth = id.depth();
00946
00947
00948 if (en>HFNeighborParams_.maxCellEnergy)
00949 continue;
00950 allneighbors=0;
00951 cellsfound=0;
00952 enNeighbor=0;
00953 int HFDeltaIphi = HFNeighborParams_.DeltaIphi;
00954 if (abs(ieta)>39) HFDeltaIphi*=2;
00955
00956 for (int nD=-1*HFNeighborParams_.DeltaDepth;nD<=HFNeighborParams_.DeltaDepth;++nD)
00957 {
00958 for (int nP =-1*HFDeltaIphi;nP<=HFDeltaIphi;++nP)
00959 {
00960 for (int nE =-1*HFNeighborParams_.DeltaIeta;nE<=HFNeighborParams_.DeltaIeta;++nE)
00961 {
00962 if (nD==0 && nE==0 && nP==0)
00963 continue;
00964 int myphi=nP+iphi;
00965 if (myphi>72) myphi-=72;
00966 if (myphi<=0) myphi+=72;
00967 if (!validDetId((HcalSubdetector)(4),nE+ieta, myphi, nD+depth)) continue;
00968 HcalDetId myid((HcalSubdetector)(4), nE+ieta, myphi, nD+depth);
00969
00970 ++allneighbors;
00971 if (rechitEnergies_.find(myid)==rechitEnergies_.end())
00972 continue;
00973 if (rechitEnergies_[myid]<HFNeighborParams_.minNeighborEnergy)
00974 continue;
00975 ++cellsfound;
00976 enNeighbor+=rechitEnergies_[myid];
00977 }
00978 }
00979 }
00980
00981 if (deadmon_makeDiagnostics_)
00982 d_HFenergyVsNeighbor->Fill(enNeighbor,en);
00983
00984
00985 if (1.*cellsfound/allneighbors<HFNeighborParams_.minGoodNeighborFrac)
00986 continue;
00987
00988 if (1.*en/(enNeighbor/allneighbors)>HFNeighborParams_.maxEnergyFrac)
00989 continue;
00990
00991
00992 ++belowneighbors[static_cast<int>(ieta+(etaBins_-2)/2)][iphi-1][depth+1];
00993 }
00994 }
00995
00996
00997
00998 if (ievt_%deadmon_checkNevents_neighbor_==0)
00999 {
01000 if (fVerbosity>1) cout <<"<HcalDeadCellMonitor::processEvent_rechitneighbor> Filling DeadCell Neighbor plots"<<endl;
01001 fillNevents_neighbor();
01002 }
01003
01004 if (showTiming)
01005 {
01006 cpu_timer.stop(); cout <<"TIMER:: HcalDeadCellMonitor PROCESSEVENT_RECHITNEIGHBOR -> "<<cpu_timer.cpuTime()<<endl;
01007 }
01008 return;
01009 }
01010
01011
01012
01013
01014
01015 void HcalDeadCellMonitor::processEvent_digi( const HBHEDigiCollection& hbhedigi,
01016 const HODigiCollection& hodigi,
01017 const HFDigiCollection& hfdigi,
01018
01019 const HcalDbService& cond
01020 )
01021 {
01022
01023 if (showTiming)
01024 {
01025 cpu_timer.reset(); cpu_timer.start();
01026 }
01027
01028 if (fVerbosity>1) cout <<"<HcalDeadCellMonitor::processEvent_digi> Processing digis..."<<endl;
01029
01030
01031 float digival=0;
01032 float maxval=0;
01033 int maxbin=0;
01034 float ADCsum=0;
01035
01036
01037 int ieta=0;
01038 int iphi=0;
01039 int depth=0;
01040
01041 HcalCalibrationWidths widths;
01042 HcalCalibrations calibs;
01043 const HcalQIEShape* shape=cond.getHcalShape();
01044
01045
01046
01047 if (fVerbosity>1) cout <<"<HcalDeadCellMonitor::processEvent_digi> Processing HBHE..."<<endl;
01048
01049 for (HBHEDigiCollection::const_iterator j=hbhedigi.begin();
01050 j!=hbhedigi.end(); ++j)
01051 {
01052 digival=0;
01053 maxval=0;
01054 maxbin=0;
01055 ADCsum=0;
01056 const HBHEDataFrame digi = (const HBHEDataFrame)(*j);
01057 if ((HcalSubdetector)(digi.id().subdet())==HcalBarrel)
01058 {
01059 HBpresent_=true;
01060 if (!checkHB_)
01061 continue;
01062 }
01063 else
01064 {
01065 HEpresent_=true;
01066 if (!checkHE_)
01067 continue;
01068 }
01069 ieta=digi.id().ieta();
01070 iphi=digi.id().iphi();
01071 depth=digi.id().depth();
01072
01073 ++occupancy[static_cast<int>(ieta+(etaBins_-2)/2)][iphi-1][depth-1];
01074
01075 if (!deadmon_test_pedestal_)
01076 continue;
01077
01078 HcalDetId myid = digi.id();
01079 cond.makeHcalCalibrationWidth(digi.id(),&widths);
01080
01081
01082 calibs = cond.getHcalCalibrations(digi.id());
01083
01084
01085 for (int i=0;i<digi.size();++i)
01086 {
01087 int thisCapid = digi.sample(i).capid();
01088 if (doFCpeds_)
01089 {
01090 const HcalQIECoder* coder = cond.getHcalCoder(digi.id());
01091 digival = coder->charge(*shape,digi.sample(i).adc(),digi.sample(i).capid())-calibs.pedestal(thisCapid);
01092 }
01093 else
01094 digival=digi.sample(i).adc()-calibs.pedestal(thisCapid);
01095
01096
01097 if (digival>maxval)
01098 {
01099 maxval=digival;
01100 maxbin=i;
01101 }
01102 }
01103
01104
01105
01106
01107 int bins=0;
01108 for (int i=max(0,maxbin-1);i<=min(digi.size()-1,maxbin+2);++i)
01109 {
01110 ADCsum+=digi.sample(i).adc();
01111 ++bins;
01112 }
01113
01114
01115
01116 ADCsum*=1./bins;
01117
01118
01119 if (pedestal_thresholds_.find(myid)!=pedestal_thresholds_.end())
01120 {
01121 if (ADCsum >= pedestal_thresholds_[myid])
01122 ++abovepedestal[static_cast<int>(ieta+(etaBins_-2)/2)][iphi-1][depth-1];
01123 if (deadmon_makeDiagnostics_)
01124 {
01125 if (widths_[myid]==0) continue;
01126
01127 if (myid.subdet()==HcalBarrel)
01128 d_HBnormped->Fill(1.*(ADCsum-pedestals_[myid])/widths_[myid]);
01129 else
01130 d_HEnormped->Fill(1.*(ADCsum-pedestals_[myid])/widths_[myid]);
01131 }
01132 }
01133 else if (ADCsum>0)
01134 ++abovepedestal[static_cast<int>(ieta+(etaBins_-2)/2)][iphi-1][depth-1];
01135 }
01136
01137
01138 if (checkHO_)
01139 {
01140 if (fVerbosity>1) cout <<"<HcalDeadCellMonitor::processEvent_digi> Processing HO..."<<endl;
01141
01142 for (HODigiCollection::const_iterator j=hodigi.begin();
01143 j!=hodigi.end(); ++j)
01144 {
01145 digival=0;
01146 maxval=0;
01147 maxbin=0;
01148 ADCsum=0;
01149 const HODataFrame digi = (const HODataFrame)(*j);
01150
01151 ieta=digi.id().ieta();
01152 iphi=digi.id().iphi();
01153 depth=digi.id().depth();
01154
01155
01156 ++occupancy[static_cast<int>(ieta+(etaBins_-2)/2)][iphi-1][depth-1];
01157
01158 if (!deadmon_test_pedestal_)
01159 continue;
01160
01161 HcalDetId myid = digi.id();
01162
01163 cond.makeHcalCalibrationWidth(digi.id(),&widths);
01164
01165 calibs = cond.getHcalCalibrations(digi.id());
01166
01167 for (int i=0;i<digi.size();++i)
01168 {
01169 int thisCapid = digi.sample(i).capid();
01170 if (doFCpeds_)
01171 {
01172 const HcalQIECoder* coder = cond.getHcalCoder(digi.id());
01173 digival = coder->charge(*shape,digi.sample(i).adc(),digi.sample(i).capid())-calibs.pedestal(thisCapid);
01174 }
01175 else
01176 digival=digi.sample(i).adc()-calibs.pedestal(thisCapid);
01177
01178
01179 if (digival>maxval)
01180 {
01181 maxval=digival;
01182 maxbin=i;
01183 }
01184 }
01185
01186
01187
01188
01189 int bins=0;
01190 for (int i=max(0,maxbin-1);i<=min(digi.size()-1,maxbin+2);++i)
01191 {
01192 ADCsum+=digi.sample(i).adc();
01193 ++bins;
01194 }
01195
01196 ADCsum*=1./bins;
01197
01198 if (pedestal_thresholds_.find(myid)!=pedestal_thresholds_.end())
01199 {
01200 if (ADCsum >= pedestal_thresholds_[myid])
01201 ++abovepedestal[static_cast<int>(ieta+(etaBins_-2)/2)][iphi-1][depth-1];
01202 if (deadmon_makeDiagnostics_)
01203 {
01204 if (widths_[myid]==0) continue;
01205 d_HOnormped->Fill(1.*(ADCsum-pedestals_[myid])/widths_[myid]);
01206 }
01207 }
01208 else if (ADCsum>0)
01209 ++abovepedestal[static_cast<int>(ieta+(etaBins_-2)/2)][iphi-1][depth-1];
01210
01211 }
01212 }
01213
01214 if (checkHF_)
01215 {
01216
01217 if (fVerbosity>1) cout <<"<HcalDeadCellMonitor::processEvent_digi> Processing HF..."<<endl;
01218
01219 for (HFDigiCollection::const_iterator j=hfdigi.begin();
01220 j!=hfdigi.end(); ++j)
01221 {
01222 digival=0;
01223 maxval=0;
01224 maxbin=0;
01225 ADCsum=0;
01226 const HFDataFrame digi = (const HFDataFrame)(*j);
01227
01228 ieta=digi.id().ieta();
01229 iphi=digi.id().iphi();
01230 depth=digi.id().depth()+2;
01231
01232
01233 ++occupancy[static_cast<int>(ieta+(etaBins_-2)/2)][iphi-1][depth-1];
01234
01235 if (!deadmon_test_pedestal_)
01236 continue;
01237
01238 HcalDetId myid = digi.id();
01239
01240 cond.makeHcalCalibrationWidth(digi.id(),&widths);
01241 calibs = cond.getHcalCalibrations(digi.id());
01242
01243 for (int i=0;i<digi.size();++i)
01244 {
01245 int thisCapid = digi.sample(i).capid();
01246 if (doFCpeds_)
01247 {
01248 const HcalQIECoder* coder = cond.getHcalCoder(digi.id());
01249 digival = coder->charge(*shape,digi.sample(i).adc(),digi.sample(i).capid())-calibs.pedestal(thisCapid);
01250 }
01251 else
01252 digival=digi.sample(i).adc()-calibs.pedestal(thisCapid);
01253
01254
01255 if (digival>maxval)
01256 {
01257 maxval=digival;
01258 maxbin=i;
01259 }
01260 }
01261
01262
01263
01264
01265 int bins=0;
01266 for (int i=max(0,maxbin-1);i<=min(digi.size()-1,maxbin+2);++i)
01267 {
01268 ADCsum+=digi.sample(i).adc();
01269 ++bins;
01270 }
01271
01272 ADCsum*=1./bins;
01273
01274 if (pedestal_thresholds_.find(myid)!=pedestal_thresholds_.end())
01275 {
01276 if (ADCsum >= pedestal_thresholds_[myid])
01277 ++abovepedestal[static_cast<int>(ieta+(etaBins_-2)/2)][iphi-1][depth-1];
01278 if (deadmon_makeDiagnostics_)
01279 {
01280 if (widths_[myid]==0) continue;
01281 d_HFnormped->Fill(1.*(ADCsum-pedestals_[myid])/widths_[myid]);
01282 }
01283 }
01284 else if (ADCsum>0)
01285 ++abovepedestal[static_cast<int>(ieta+(etaBins_-2)/2)][iphi-1][depth-1];
01286
01287 }
01288 }
01289
01290
01291 if (ievt_%deadmon_checkNevents_occupancy_==0)
01292 {
01293 if (deadmon_test_occupancy_)
01294 {
01295 if (fVerbosity>1) cout <<"<HcalDeadCellMonitor::processEvent_digi> Filling DeadCell Occupancy plots"<<endl;
01296 fillNevents_occupancy();
01297 }
01298 }
01299
01300 if (ievt_%deadmon_checkNevents_pedestal_==0)
01301 {
01302 if( deadmon_test_pedestal_)
01303 {
01304 if (fVerbosity>1) cout <<"<HcalDeadCellMonitor::processEvent_digi> Filling DeadCell Pedestal plots"<<endl;
01305 fillNevents_pedestal();
01306 }
01307 }
01308
01309 if (showTiming)
01310 {
01311 cpu_timer.stop(); cout <<"TIMER:: HcalDeadCellMonitor PROCESSEVENT_DIGI -> "<<cpu_timer.cpuTime()<<endl;
01312 }
01313
01314 return;
01315 }
01316
01317
01318
01319
01320 void HcalDeadCellMonitor::fillNevents_occupancy(void)
01321 {
01322
01323
01324 if (showTiming)
01325 {
01326 cpu_timer.reset(); cpu_timer.start();
01327 }
01328
01329 if (fVerbosity>0)
01330 cout <<"<HcalDeadCellMonitor::fillNevents_occupancy> FILLING OCCUPANCY PLOTS"<<endl;
01331
01332 int mydepth=0;
01333 int ieta=0;
01334 int iphi=0;
01335 for (int eta=0;eta<(etaBins_-2);++eta)
01336 {
01337 ieta=eta-int((etaBins_-2)/2);
01338 for (int phi=0;phi<72;++phi)
01339 {
01340 iphi=phi+1;
01341 for (int depth=0;depth<4;++depth)
01342 {
01343 for (int subdet=1;subdet<=4;++subdet)
01344 {
01345 if (!validDetId((HcalSubdetector)subdet, ieta, iphi, depth+1))
01346 continue;
01347
01348 if ((subdet==1 && !HBpresent_) || (subdet==2 &&!HEpresent_)||(subdet==3 &&!HOpresent_) || (subdet==4 &&!HFpresent_)) continue;
01349
01350 if ((!checkHB_ && subdet==1) ||
01351 (!checkHE_ && subdet==2) ||
01352 (!checkHO_ && subdet==3) ||
01353 (!checkHF_ && subdet==4)) continue;
01354 mydepth=depth;
01355 if (subdet==4)
01356 mydepth=depth+2;
01357 if (occupancy[eta][phi][mydepth]==0)
01358 {
01359 if (fVerbosity>0) cout <<"DEAD CELL; NO OCCUPANCY = "<<subdet<<" eta = "<<ieta<<", phi = "<<iphi<<" depth = "<<depth+1<<endl;
01360 if (subdet==2 && depth<2)
01361 mydepth=depth+4;
01362 else
01363 mydepth=depth;
01364
01365 int oldevts=(ievt_/deadmon_checkNevents_occupancy_);
01366 if (ievt_%deadmon_checkNevents_occupancy_==0)
01367 oldevts-=1;
01368 oldevts*=deadmon_checkNevents_occupancy_;
01369 int newevts=ievt_-oldevts;
01370 if (newevts<0) newevts=0;
01371 if (fVerbosity>2)
01372 {
01373 cout <<"\t MYDEPTH = "<<mydepth<<endl;
01374 cout <<"\t oldevents = "<<oldevts<<" new = "<<newevts<<endl;
01375 cout <<"\t\t"<<(oldevts*UnoccupiedDeadCellsByDepth[mydepth]->getBinContent(eta+2,phi+2)+newevts)*1./ievt_<<endl;
01376 }
01377
01378
01379 UnoccupiedDeadCellsByDepth[mydepth]->setBinContent( eta+2,phi+2,
01380 (oldevts*UnoccupiedDeadCellsByDepth[mydepth]->getBinContent(eta+2,phi+2)+newevts)*1./ievt_);
01381 }
01382 else
01383 occupancy[eta][phi][depth]=0;
01384 }
01385
01386 }
01387 }
01388 }
01389 FillUnphysicalHEHFBins(UnoccupiedDeadCellsByDepth);
01390 if (showTiming)
01391 {
01392 cpu_timer.stop(); cout <<"TIMER:: HcalDeadCellMonitor FILLNEVENTS_OCCUPANCY -> "<<cpu_timer.cpuTime()<<endl;
01393 }
01394
01395 return;
01396
01397
01398 }
01399
01400
01401
01402
01403
01404
01405 void HcalDeadCellMonitor::fillNevents_pedestal(void)
01406 {
01407
01408
01409 if (showTiming)
01410 {
01411 cpu_timer.reset(); cpu_timer.start();
01412 }
01413
01414 if (fVerbosity>0)
01415 cout <<"<HcalDeadCellMonitor::fillNevents_pedestal> FILLING OCCUPANCY PLOTS"<<endl;
01416
01417 int mydepth=0;
01418 int ieta=0;
01419 int iphi=0;
01420 for (int eta=0;eta<(etaBins_-2);++eta)
01421 {
01422 ieta=eta-int((etaBins_-2)/2);
01423 for (int phi=0;phi<72;++phi)
01424 {
01425 iphi=phi+1;
01426 for (int depth=0;depth<4;++depth)
01427 {
01428 for (int subdet=1;subdet<=4;++subdet)
01429 {
01430 if (!validDetId((HcalSubdetector)subdet, ieta, iphi, depth+1))
01431 continue;
01432
01433 if ((subdet==1 && !HBpresent_) || (subdet==2 &&!HEpresent_)||(subdet==3 &&!HOpresent_) || (subdet==4 &&!HFpresent_)) continue;
01434
01435 if ((!checkHB_ && subdet==1) ||
01436 (!checkHE_ && subdet==2) ||
01437 (!checkHO_ && subdet==3) ||
01438 (!checkHF_ && subdet==4)) continue;
01439
01440 if (occupancy[eta][phi][mydepth]==0)
01441 {
01442 abovepedestal[eta][phi][mydepth]=0;
01443 continue;
01444 }
01445 int oldevts=(ievt_/deadmon_checkNevents_pedestal_);
01446 if (ievt_%deadmon_checkNevents_pedestal_==0)
01447 oldevts-=1;
01448 oldevts*=deadmon_checkNevents_pedestal_;
01449 int newevts=ievt_-oldevts;
01450 if (newevts<0) newevts=0;
01451
01452 mydepth=depth;
01453 if (subdet==4)
01454 mydepth=depth+2;
01455
01456
01457 if (abovepedestal[eta][phi][mydepth]>0)
01458 {
01459 abovepedestal[eta][phi][mydepth]=0;
01460 continue;
01461 }
01462
01463
01464 if (fVerbosity>0) cout <<"DEAD CELL; BELOW PEDESTAL THRESHOLD = "<<subdet<<" eta = "<<ieta<<", phi = "<<iphi<<" depth = "<<depth+1<<endl;
01465 if (subdet==2 && depth<2)
01466 mydepth=depth+4;
01467 else
01468 mydepth=depth;
01469
01470
01471 if (fVerbosity>0)
01472 {
01473 cout <<"\t MYDEPTH = "<<mydepth<<endl;
01474 cout <<"\t oldevents = "<<oldevts<<" new = "<<newevts<<endl;
01475 cout <<"\t\t"<<(oldevts*BelowPedestalDeadCellsByDepth[mydepth]->getBinContent(eta+2,phi+2)+newevts)*1./ievt_<<endl;
01476 }
01477
01478
01479 BelowPedestalDeadCellsByDepth[mydepth]->setBinContent( eta+2,phi+2,
01480 (oldevts*BelowPedestalDeadCellsByDepth[mydepth]->getBinContent(eta+2,phi+2)+newevts)*1./ievt_);
01481
01482 abovepedestal[eta][phi][depth]=0;
01483 }
01484
01485 }
01486 }
01487 }
01488 FillUnphysicalHEHFBins(BelowPedestalDeadCellsByDepth);
01489 if (showTiming)
01490 {
01491 cpu_timer.stop(); cout <<"TIMER:: HcalDeadCellMonitor FILLNEVENTS_BELOWPEDESTAL -> "<<cpu_timer.cpuTime()<<endl;
01492 }
01493
01494 return;
01495
01496
01497 }
01498
01499
01500
01501
01502 void HcalDeadCellMonitor::fillNevents_energy(void)
01503 {
01504
01505
01506 if (showTiming)
01507 {
01508 cpu_timer.reset(); cpu_timer.start();
01509 }
01510
01511 if (fVerbosity>0)
01512 cout <<"<HcalDeadCellMonitor::fillNevents_energy> BELOW-ENERGY-THRESHOLD PLOTS"<<endl;
01513
01514 int mydepth=0;
01515 int ieta=0;
01516 int iphi=0;
01517 for (int eta=0;eta<(etaBins_-2);++eta)
01518 {
01519 ieta=eta-int((etaBins_-2)/2);
01520 for (int phi=0;phi<72;++phi)
01521 {
01522 iphi=phi+1;
01523 for (int depth=0;depth<4;++depth)
01524 {
01525 for (int subdet=1;subdet<=4;++subdet)
01526 {
01527 if (!validDetId((HcalSubdetector)subdet, ieta, iphi, depth+1))
01528 continue;
01529
01530 if ((subdet==1 && !HBpresent_) || (subdet==2 &&!HEpresent_)||(subdet==3 &&!HOpresent_) || (subdet==4 &&!HFpresent_)) continue;
01531
01532 if ((!checkHB_ && subdet==1) ||
01533 (!checkHE_ && subdet==2) ||
01534 (!checkHO_ && subdet==3) ||
01535 (!checkHF_ && subdet==4)) continue;
01536 mydepth=depth;
01537 if (subdet==4)
01538 mydepth=depth+2;
01539
01540
01541
01542
01543 int oldevts=(ievt_/deadmon_checkNevents_pedestal_);
01544 if (ievt_%deadmon_checkNevents_pedestal_==0)
01545 oldevts-=1;
01546 oldevts*=deadmon_checkNevents_pedestal_;
01547 int newevts=ievt_-oldevts;
01548 if (newevts<0) newevts=0;
01549 if (rechit_occupancy[eta][phi][mydepth]==0 && deadmon_test_rechit_occupancy_)
01550 {
01551 int filldepth=depth;
01552 if (subdet==2 && depth<2) filldepth+=4;
01553 UnoccupiedRecHitsByDepth[filldepth]->setBinContent( eta+2,phi+2,
01554 (oldevts*UnoccupiedRecHitsByDepth[filldepth]->getBinContent(eta+2,phi+2)+newevts)*1./ievt_);
01555 aboveenergy[eta][phi][mydepth]=0;
01556 continue;
01557 }
01558
01559 if (!deadmon_test_energy_) continue;
01560 if (aboveenergy[eta][phi][mydepth]>0)
01561 {
01562
01563 aboveenergy[eta][phi][mydepth]=0;
01564 continue;
01565 }
01566
01567 if (fVerbosity>2)
01568 cout <<"DEAD CELL; BELOW ENERGY THRESHOLD = "<<subdet<<" eta = "<<ieta<<", phi = "<<iphi<<" depth = "<<depth+1<<endl;
01569 if (subdet==2 && depth<2)
01570 mydepth=depth+4;
01571 else
01572 mydepth=depth;
01573
01574
01575
01576
01577
01578 BelowEnergyThresholdCellsByDepth[mydepth]->setBinContent( eta+2,phi+2,
01579 (oldevts*BelowEnergyThresholdCellsByDepth[mydepth]->getBinContent(eta+2,phi+2)+newevts)*1./ievt_);
01580 }
01581
01582 aboveenergy[eta][phi][depth]=0;
01583 rechit_occupancy[eta][phi][depth]=0;
01584 }
01585 }
01586 }
01587 FillUnphysicalHEHFBins(UnoccupiedRecHitsByDepth);
01588 FillUnphysicalHEHFBins(BelowEnergyThresholdCellsByDepth);
01589 if (showTiming)
01590 {
01591 cpu_timer.stop(); cout <<"TIMER:: HcalDeadCellMonitor FILLNEVENTS_ENERGY -> "<<cpu_timer.cpuTime()<<endl;
01592 }
01593
01594 return;
01595
01596
01597 }
01598
01599
01600
01601
01602
01603 void HcalDeadCellMonitor::fillNevents_neighbor(void)
01604 {
01605
01606
01607 if (showTiming)
01608 {
01609 cpu_timer.reset(); cpu_timer.start();
01610 }
01611
01612 if (fVerbosity>0)
01613 cout <<"<HcalDeadCellMonitor::fillNevents_neighbor> FILLING BELOW-NEIGHBOR-ENERGY PLOTS"<<endl;
01614
01615 int mydepth=0;
01616 int ieta=0;
01617 int iphi=0;
01618 for (int eta=0;eta<(etaBins_-2);++eta)
01619 {
01620 ieta=eta-int((etaBins_-2)/2);
01621 for (int phi=0;phi<72;++phi)
01622 {
01623 iphi=phi+1;
01624 for (int depth=0;depth<4;++depth)
01625 {
01626 for (int subdet=1;subdet<=4;++subdet)
01627 {
01628 if (!validDetId((HcalSubdetector)subdet, ieta, iphi, depth+1))
01629 continue;
01630
01631 if ((subdet==1 && !HBpresent_) || (subdet==2 &&!HEpresent_)||(subdet==3 &&!HOpresent_) || (subdet==4 &&!HFpresent_)) continue;
01632 if ((!checkHB_ && subdet==1) ||
01633 (!checkHE_ && subdet==2) ||
01634 (!checkHO_ && subdet==3) ||
01635 (!checkHF_ && subdet==4)) continue;
01636 mydepth=depth;
01637 if (subdet==4)
01638 mydepth=depth+2;
01639 if (rechit_occupancy[eta][phi][mydepth]==0)
01640 {
01641 belowneighbors[eta][phi][mydepth]=0;
01642 continue;
01643 }
01644 if (belowneighbors[eta][phi][mydepth]>0)
01645 {
01646 if (fVerbosity>2) cout <<"DEAD CELL; BELOW NEIGHBORS = "<<subdet<<" eta = "<<ieta<<", phi = "<<iphi<<" depth = "<<depth+1<<endl;
01647 if (subdet==2 && depth<2)
01648 mydepth=depth+4;
01649 else
01650 mydepth=depth;
01651
01652 int oldevts=(ievt_/deadmon_checkNevents_neighbor_);
01653 if (ievt_%deadmon_checkNevents_neighbor_==0)
01654 oldevts-=1;
01655 oldevts*=deadmon_checkNevents_neighbor_;
01656
01657
01658 BelowNeighborsDeadCellsByDepth[mydepth]->setBinContent( eta+2,phi+2,
01659 (oldevts*BelowNeighborsDeadCellsByDepth[mydepth]->getBinContent(eta+2,phi+2)+belowneighbors[eta][phi][mydepth])*1./ievt_);
01660
01661 belowneighbors[eta][phi][depth]=0;
01662 }
01663 }
01664
01665 }
01666 }
01667 }
01668 FillUnphysicalHEHFBins(BelowNeighborsDeadCellsByDepth);
01669 if (showTiming)
01670 {
01671 cpu_timer.stop(); cout <<"TIMER:: HcalDeadCellMonitor FILLNEVENTS_NEIGHBOR -> "<<cpu_timer.cpuTime()<<endl;
01672 }
01673
01674 return;
01675
01676
01677 }
01678
01679
01680
01681
01682
01683
01684 void HcalDeadCellMonitor::fillNevents_problemCells(void)
01685 {
01686 if (showTiming)
01687 {
01688 cpu_timer.reset(); cpu_timer.start();
01689 }
01690
01691 if (fVerbosity>0)
01692 cout <<"<HcalDeadCellMonitor::fillNevents_problemCells> FILLING PROBLEM CELL PLOTS"<<endl;
01693
01694 int ieta=0;
01695 int iphi=0;
01696
01697 double problemvalue=0;
01698 double sumproblemvalue=0;
01699 for (int eta=0;eta<(etaBins_-2);++eta)
01700 {
01701 ieta=eta-int((etaBins_-2)/2);
01702 for (int phi=0;phi<72;++phi)
01703 {
01704 iphi=phi+1;
01705 sumproblemvalue=0;
01706 for (int mydepth=0;mydepth<6;++mydepth)
01707 {
01708
01709
01710
01711 problemvalue=0;
01712 if (deadmon_test_occupancy_)
01713 {
01714 problemvalue+=UnoccupiedDeadCellsByDepth[mydepth]->getBinContent(eta+2,phi+2);
01715 sumproblemvalue+=UnoccupiedDeadCellsByDepth[mydepth]->getBinContent(eta+2,phi+2);
01716 }
01717 if (deadmon_test_rechit_occupancy_)
01718 {
01719 problemvalue+=UnoccupiedRecHitsByDepth[mydepth]->getBinContent(eta+2,phi+2);
01720 sumproblemvalue+=UnoccupiedRecHitsByDepth[mydepth]->getBinContent(eta+2,phi+2);
01721 }
01722 if (deadmon_test_pedestal_)
01723 {
01724 problemvalue+=BelowPedestalDeadCellsByDepth[mydepth]->getBinContent(eta+2,phi+2);
01725 sumproblemvalue+=BelowPedestalDeadCellsByDepth[mydepth]->getBinContent(eta+2,phi+2);
01726 }
01727 if (deadmon_test_neighbor_)
01728 {
01729 problemvalue+=BelowNeighborsDeadCellsByDepth[mydepth]->getBinContent(eta+2,phi+2);
01730 sumproblemvalue+=BelowNeighborsDeadCellsByDepth[mydepth]->getBinContent(eta+2,phi+2);
01731 }
01732 if (deadmon_test_energy_)
01733 {
01734 problemvalue+=BelowEnergyThresholdCellsByDepth[mydepth]->getBinContent(eta+2,phi+2);
01735 sumproblemvalue+=BelowEnergyThresholdCellsByDepth[mydepth]->getBinContent(eta+2,phi+2);
01736 }
01737
01738 problemvalue=min(1.,problemvalue);
01739 ProblemDeadCellsByDepth[mydepth]->setBinContent(eta+2,phi+2,problemvalue);
01740 }
01741 sumproblemvalue=min(1.,sumproblemvalue);
01742 ProblemDeadCells->setBinContent(eta+2,phi+2,sumproblemvalue);
01743 }
01744 }
01745
01746 if (showTiming)
01747 {
01748 cpu_timer.stop(); cout <<"TIMER:: HcalDeadCellMonitor FILLNEVENTS_PROBLEMCELLS -> "<<cpu_timer.cpuTime()<<endl;
01749 }
01750
01751 }