299 int nBinsX =
histo->GetNbinsX();
303 bool failLayer =
false;
304 bool failCells =
false;
307 if(
histo->Integral() == 0) {
308 chamberPercentage = 0;
312 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"--- Occupancy test for chamber: " << chId << endl;
315 if(chId.
station() == 4) nSL = 2;
321 values[1] = chId.
wheel();
323 values[3] = chId.
sector();
329 double totalChamberOccupp = 0;
330 double squaredLayerOccupSum = 0;
332 map<DTLayerId, pair<double, double> > averageCellOccupAndRMS;
333 map<DTLayerId, double> layerOccupancyMap;
336 for(
int slay = 1; slay <= 3; ++slay) {
338 if(chId.
station() == 4 && slay == 2) {
353 int binYlow = ((slay-1)*4)+1;
354 int binYhigh = binYlow+3;
355 double slInteg =
histo->Integral(1,nBinsX,binYlow,binYhigh);
357 chamberPercentage = 1.-1./(float)nSL;
361 for(
int lay = 1; lay <= 4; ++lay) {
364 int binY = binYlow+(lay-1);
366 double layerInteg =
histo->Integral(1,nBinsX,binY,binY);
367 squaredLayerOccupSum += layerInteg*layerInteg;
368 totalChamberOccupp+= layerInteg;
370 layerOccupancyMap[layID] = layerInteg;
373 int nWires =
muonGeom->layer(layID)->specificTopology().channels();
374 int firstWire =
muonGeom->layer(layID)->specificTopology().firstChannel();
375 double layerSquaredSum = 0;
377 histo->SetBinContent(nBinsX+1,binY,0.);
379 for(
int cell = firstWire; cell != (nWires+firstWire); ++cell) {
380 double cellOccup =
histo->GetBinContent(cell,binY);
381 layerSquaredSum+=cellOccup*cellOccup;
387 double averageCellOccup = layerInteg/nWires;
388 double averageSquaredCellOccup = layerSquaredSum/nWires;
389 double rmsCellOccup =
sqrt(averageSquaredCellOccup - averageCellOccup*averageCellOccup);
390 averageCellOccupAndRMS[layID] = make_pair(averageCellOccup, rmsCellOccup);
391 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" " << layID
392 <<
" average cell occ.: " << averageCellOccup
393 <<
" RMS: " << rmsCellOccup << endl;
396 values[
index] = averageCellOccup;
398 values[
index] = rmsCellOccup;
410 double minCellRMS = 99999999;
411 double referenceCellOccup = -1;
416 for(
map<
DTLayerId, pair<double, double> >::const_iterator layAndValues = averageCellOccupAndRMS.begin();
417 layAndValues != averageCellOccupAndRMS.end(); layAndValues++) {
420 double rms = (*layAndValues).second.second;
421 double lOcc = layerOccupancyMap[lid];
422 double avCellOcc = (*layAndValues).second.first;
423 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" " << lid <<
" tot. occ: " << lOcc
424 <<
" average cell occ: " << avCellOcc
425 <<
" RMS: " << rms << endl;
441 double safeFactor = 3.;
444 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" Reference cell occup.: " << referenceCellOccup
445 <<
" RMS: " << minCellRMS << endl;
457 for(
int slay = 1; slay <= 3; ++slay) {
459 if(chId.
station() == 4 && slay == 2)
continue;
461 int binYlow = ((slay-1)*4)+1;
465 int nFailingLayers = 0;
467 for(
int lay = 1; lay <= 4; ++lay) {
469 int nWires =
muonGeom->layer(layID)->specificTopology().channels();
470 int firstWire =
muonGeom->layer(layID)->specificTopology().firstChannel();
471 int binY = binYlow+(lay-1);
474 double layerInteg =
histo->Integral(1,nBinsX,binY,binY);
476 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" layer: " << layID <<
" integral: " << layerInteg << endl;
479 bool alreadyMonitored =
false;
483 if(layerInteg == 0) {
484 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" fail layer: no entries" << endl;
489 histo->SetBinContent(nBinsX+1,binY,-1.);
510 int totalDeadCells = 0;
511 int nDeadCellsInARow = 1;
512 int nDeadCellsInARowMax = 0;
513 int nCellsZeroCount = 0;
514 bool previousIsDead =
false;
516 int interDeadCells = 0;
517 for(
int cell = firstWire; cell != (nWires+firstWire); ++cell) {
518 double cellOccup =
histo->GetBinContent(cell,binY);
519 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" cell occup: " << cellOccup;
520 if(cellOccup == 0 || cellOccup < (referenceCellOccup-safeFactor*
sqrt(referenceCellOccup))) {
521 if(cellOccup == 0) nCellsZeroCount++;
523 if(previousIsDead) nDeadCellsInARow++;
524 previousIsDead =
true;
526 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" below reference" << endl;
528 previousIsDead =
false;
532 if(interDeadCells > 3) {
533 if(nDeadCellsInARow > nDeadCellsInARowMax) nDeadCellsInARowMax = nDeadCellsInARow;
534 nDeadCellsInARow = 1;
538 if(nDeadCellsInARow > nDeadCellsInARowMax) nDeadCellsInARowMax = nDeadCellsInARow;
539 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" # wires: " << nWires
540 <<
" # cells 0 count: " << nCellsZeroCount
541 <<
" # dead cells in a row: " << nDeadCellsInARowMax
542 <<
" total # of dead cells: " << totalDeadCells;
554 if((TMath::Erfc(referenceCellOccup/
sqrt(referenceCellOccup)) < 10./(
double)nWires &&
555 nDeadCellsInARowMax>= 10.) ||
556 (TMath::Erfc(referenceCellOccup/
sqrt(referenceCellOccup)) < 0.5 &&
557 totalDeadCells > nWires/2.)) {
558 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" -> fail layer!" << endl;
561 histo->SetBinContent(nBinsX+1,binY,-1.);
562 }
else if(referenceCellOccup > 10 &&
563 nCellsZeroCount > nWires/3. &&
564 (
double)nCellsZeroCount/(
double)nWires >
565 2.*TMath::Erfc(referenceCellOccup/
sqrt(referenceCellOccup))) {
566 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" -> would fail cells!" << endl;
567 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" # of cells with 0 count: " << nCellsZeroCount
568 <<
" # wires: " << nWires
570 << TMath::Erfc(referenceCellOccup/
sqrt(referenceCellOccup))
585 if( nFailingLayers == 4) {
592 if(nFailingSLs == nSL) {
593 chamberPercentage = 0;
596 chamberPercentage = 1.-(float)nFailingSLs/(
float)nSL;
601 if(failLayer)
return 2;
602 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