301 int nBinsX =
histo->GetNbinsX();
305 bool failLayer =
false;
306 bool failCells =
false;
309 if(
histo->Integral() == 0) {
310 chamberPercentage = 0;
314 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"--- Occupancy test for chamber: " << chId << endl;
317 if(chId.
station() == 4) nSL = 2;
323 values[1] = chId.
wheel();
325 values[3] = chId.
sector();
331 double totalChamberOccupp = 0;
332 double squaredLayerOccupSum = 0;
334 map<DTLayerId, pair<double, double> > averageCellOccupAndRMS;
335 map<DTLayerId, double> layerOccupancyMap;
338 for(
int slay = 1; slay <= 3; ++slay) {
340 if(chId.
station() == 4 && slay == 2) {
355 int binYlow = ((slay-1)*4)+1;
356 int binYhigh = binYlow+3;
357 double slInteg =
histo->Integral(1,nBinsX,binYlow,binYhigh);
359 chamberPercentage = 1.-1./(float)nSL;
363 for(
int lay = 1; lay <= 4; ++lay) {
366 int binY = binYlow+(lay-1);
368 double layerInteg =
histo->Integral(1,nBinsX,binY,binY);
369 squaredLayerOccupSum += layerInteg*layerInteg;
370 totalChamberOccupp+= layerInteg;
372 layerOccupancyMap[layID] = layerInteg;
375 int nWires =
muonGeom->layer(layID)->specificTopology().channels();
376 int firstWire =
muonGeom->layer(layID)->specificTopology().firstChannel();
377 double layerSquaredSum = 0;
379 histo->SetBinContent(nBinsX+1,binY,0.);
381 for(
int cell = firstWire; cell != (nWires+firstWire); ++cell) {
382 double cellOccup =
histo->GetBinContent(cell,binY);
383 layerSquaredSum+=cellOccup*cellOccup;
389 double averageCellOccup = layerInteg/nWires;
390 double averageSquaredCellOccup = layerSquaredSum/nWires;
391 double rmsCellOccup =
sqrt(averageSquaredCellOccup - averageCellOccup*averageCellOccup);
392 averageCellOccupAndRMS[layID] = make_pair(averageCellOccup, rmsCellOccup);
393 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" " << layID
394 <<
" average cell occ.: " << averageCellOccup
395 <<
" RMS: " << rmsCellOccup << endl;
398 values[
index] = averageCellOccup;
400 values[
index] = rmsCellOccup;
412 double minCellRMS = 99999999;
413 double referenceCellOccup = -1;
418 for(
map<
DTLayerId, pair<double, double> >::const_iterator layAndValues = averageCellOccupAndRMS.begin();
419 layAndValues != averageCellOccupAndRMS.end(); layAndValues++) {
422 double rms = (*layAndValues).second.second;
423 double lOcc = layerOccupancyMap[lid];
424 double avCellOcc = (*layAndValues).second.first;
425 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" " << lid <<
" tot. occ: " << lOcc
426 <<
" average cell occ: " << avCellOcc
427 <<
" RMS: " << rms << endl;
443 double safeFactor = 3.;
446 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" Reference cell occup.: " << referenceCellOccup
447 <<
" RMS: " << minCellRMS << endl;
459 for(
int slay = 1; slay <= 3; ++slay) {
461 if(chId.
station() == 4 && slay == 2)
continue;
463 int binYlow = ((slay-1)*4)+1;
467 int nFailingLayers = 0;
469 for(
int lay = 1; lay <= 4; ++lay) {
471 int nWires =
muonGeom->layer(layID)->specificTopology().channels();
472 int firstWire =
muonGeom->layer(layID)->specificTopology().firstChannel();
473 int binY = binYlow+(lay-1);
476 double layerInteg =
histo->Integral(1,nBinsX,binY,binY);
478 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" layer: " << layID <<
" integral: " << layerInteg << endl;
481 bool alreadyMonitored =
false;
485 if(layerInteg == 0) {
486 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" fail layer: no entries" << endl;
491 histo->SetBinContent(nBinsX+1,binY,-1.);
512 int totalDeadCells = 0;
513 int nDeadCellsInARow = 1;
514 int nDeadCellsInARowMax = 0;
515 int nCellsZeroCount = 0;
516 bool previousIsDead =
false;
518 int interDeadCells = 0;
519 for(
int cell = firstWire; cell != (nWires+firstWire); ++cell) {
520 double cellOccup =
histo->GetBinContent(cell,binY);
521 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" cell occup: " << cellOccup;
522 if(cellOccup == 0 || cellOccup < (referenceCellOccup-safeFactor*
sqrt(referenceCellOccup))) {
523 if(cellOccup == 0) nCellsZeroCount++;
525 if(previousIsDead) nDeadCellsInARow++;
526 previousIsDead =
true;
528 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" below reference" << endl;
530 previousIsDead =
false;
534 if(interDeadCells > 3) {
535 if(nDeadCellsInARow > nDeadCellsInARowMax) nDeadCellsInARowMax = nDeadCellsInARow;
536 nDeadCellsInARow = 1;
540 if(nDeadCellsInARow > nDeadCellsInARowMax) nDeadCellsInARowMax = nDeadCellsInARow;
541 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" # wires: " << nWires
542 <<
" # cells 0 count: " << nCellsZeroCount
543 <<
" # dead cells in a row: " << nDeadCellsInARowMax
544 <<
" total # of dead cells: " << totalDeadCells;
556 if((TMath::Erfc(referenceCellOccup/
sqrt(referenceCellOccup)) < 10./(
double)nWires &&
557 nDeadCellsInARowMax>= 10.) ||
558 (TMath::Erfc(referenceCellOccup/
sqrt(referenceCellOccup)) < 0.5 &&
559 totalDeadCells > nWires/2.)) {
560 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" -> fail layer!" << endl;
563 histo->SetBinContent(nBinsX+1,binY,-1.);
564 }
else if(referenceCellOccup > 10 &&
565 nCellsZeroCount > nWires/3. &&
566 (
double)nCellsZeroCount/(
double)nWires >
567 2.*TMath::Erfc(referenceCellOccup/
sqrt(referenceCellOccup))) {
568 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" -> would fail cells!" << endl;
569 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" # of cells with 0 count: " << nCellsZeroCount
570 <<
" # wires: " << nWires
572 << TMath::Erfc(referenceCellOccup/
sqrt(referenceCellOccup))
587 if( nFailingLayers == 4) {
594 if(nFailingSLs == nSL) {
595 chamberPercentage = 0;
598 chamberPercentage = 1.-(float)nFailingSLs/(
float)nSL;
603 if(failLayer)
return 2;
604 if(failCells)
return 1;
DTOccupancyCluster getBestCluster() const
get the cluster correspondig to "normal" cell occupancy.
double averageRMS() const
average RMS of the cell occpuancy distributions of the layers in the cluster
edm::ESHandle< DTGeometry > muonGeom
double averageMean() const
average cell occupancy of the layers in the cluster
void addPoint(const DTOccupancyPoint &point)
Add an occupancy point for a given layer.
void buildClusters()
build the clusters
std::set< DTLayerId > monitoredLayers
bool isProblematic(DTLayerId layerId) const
int station() const
Return the station number.
int wheel() const
Return the wheel number.
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point