278 int nBinsX =
histo->GetNbinsX();
282 bool failLayer =
false;
283 bool failCells =
false;
286 if(
histo->Integral() == 0) {
287 chamberPercentage = 0;
291 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"--- Occupancy test for chamber: " << chId << endl;
294 if(chId.
station() == 4) nSL = 2;
300 values[1] = chId.
wheel();
302 values[3] = chId.
sector();
308 double totalChamberOccupp = 0;
309 double squaredLayerOccupSum = 0;
311 map<DTLayerId, pair<double, double> > averageCellOccupAndRMS;
312 map<DTLayerId, double> layerOccupancyMap;
315 for(
int slay = 1; slay <= 3; ++slay) {
317 if(chId.
station() == 4 && slay == 2) {
332 int binYlow = ((slay-1)*4)+1;
333 int binYhigh = binYlow+3;
334 double slInteg =
histo->Integral(1,nBinsX,binYlow,binYhigh);
336 chamberPercentage = 1.-1./(float)nSL;
340 for(
int lay = 1; lay <= 4; ++lay) {
343 int binY = binYlow+(lay-1);
345 double layerInteg =
histo->Integral(1,nBinsX,binY,binY);
346 squaredLayerOccupSum += layerInteg*layerInteg;
347 totalChamberOccupp+= layerInteg;
349 layerOccupancyMap[layID] = layerInteg;
352 int nWires =
muonGeom->layer(layID)->specificTopology().channels();
353 int firstWire =
muonGeom->layer(layID)->specificTopology().firstChannel();
354 double layerSquaredSum = 0;
356 histo->SetBinContent(nBinsX+1,binY,0.);
358 for(
int cell = firstWire; cell != (nWires+firstWire); ++cell) {
359 double cellOccup =
histo->GetBinContent(cell,binY);
360 layerSquaredSum+=cellOccup*cellOccup;
366 double averageCellOccup = layerInteg/nWires;
367 double averageSquaredCellOccup = layerSquaredSum/nWires;
368 double rmsCellOccup =
sqrt(averageSquaredCellOccup - averageCellOccup*averageCellOccup);
369 averageCellOccupAndRMS[layID] = make_pair(averageCellOccup, rmsCellOccup);
370 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" " << layID
371 <<
" average cell occ.: " << averageCellOccup
372 <<
" RMS: " << rmsCellOccup << endl;
375 values[
index] = averageCellOccup;
377 values[
index] = rmsCellOccup;
385 double minCellRMS = 99999999;
386 double referenceCellOccup = -1;
391 for(
map<
DTLayerId, pair<double, double> >::const_iterator layAndValues = averageCellOccupAndRMS.begin();
392 layAndValues != averageCellOccupAndRMS.end(); layAndValues++) {
395 double rms = (*layAndValues).second.second;
396 double lOcc = layerOccupancyMap[lid];
397 double avCellOcc = (*layAndValues).second.first;
398 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" " << lid <<
" tot. occ: " << lOcc
399 <<
" average cell occ: " << avCellOcc
400 <<
" RMS: " << rms << endl;
414 double safeFactor = 3.;
416 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" Reference cell occup.: " << referenceCellOccup
417 <<
" RMS: " << minCellRMS << endl;
422 for(
int slay = 1; slay <= 3; ++slay) {
424 if(chId.
station() == 4 && slay == 2)
continue;
426 int binYlow = ((slay-1)*4)+1;
427 int nFailingLayers = 0;
429 for(
int lay = 1; lay <= 4; ++lay) {
431 int nWires =
muonGeom->layer(layID)->specificTopology().channels();
432 int firstWire =
muonGeom->layer(layID)->specificTopology().firstChannel();
433 int binY = binYlow+(lay-1);
436 double layerInteg =
histo->Integral(1,nBinsX,binY,binY);
438 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" layer: " << layID <<
" integral: " << layerInteg << endl;
441 bool alreadyMonitored =
false;
445 if(layerInteg == 0) {
446 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" fail layer: no entries" << endl;
451 histo->SetBinContent(nBinsX+1,binY,-1.);
461 int totalDeadCells = 0;
462 int nDeadCellsInARow = 1;
463 int nDeadCellsInARowMax = 0;
464 int nCellsZeroCount = 0;
465 bool previousIsDead =
false;
467 int interDeadCells = 0;
468 for(
int cell = firstWire; cell != (nWires+firstWire); ++cell) {
469 double cellOccup =
histo->GetBinContent(cell,binY);
470 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" cell occup: " << cellOccup;
471 if(cellOccup == 0 || cellOccup < (referenceCellOccup-safeFactor*
sqrt(referenceCellOccup))) {
472 if(cellOccup == 0) nCellsZeroCount++;
474 if(previousIsDead) nDeadCellsInARow++;
475 previousIsDead =
true;
477 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" below reference" << endl;
479 previousIsDead =
false;
483 if(interDeadCells > 3) {
484 if(nDeadCellsInARow > nDeadCellsInARowMax) nDeadCellsInARowMax = nDeadCellsInARow;
485 nDeadCellsInARow = 1;
489 if(nDeadCellsInARow > nDeadCellsInARowMax) nDeadCellsInARowMax = nDeadCellsInARow;
490 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" # wires: " << nWires
491 <<
" # cells 0 count: " << nCellsZeroCount
492 <<
" # dead cells in a row: " << nDeadCellsInARowMax
493 <<
" total # of dead cells: " << totalDeadCells;
495 if((TMath::Erfc(referenceCellOccup/
sqrt(referenceCellOccup)) < 10./(
double)nWires &&
496 nDeadCellsInARowMax>= 10.) ||
497 (TMath::Erfc(referenceCellOccup/
sqrt(referenceCellOccup)) < 0.5 &&
498 totalDeadCells > nWires/2.)) {
499 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" -> fail layer!" << endl;
502 histo->SetBinContent(nBinsX+1,binY,-1.);
503 }
else if(referenceCellOccup > 10 &&
504 nCellsZeroCount > nWires/3. &&
505 (
double)nCellsZeroCount/(
double)nWires >
506 2.*TMath::Erfc(referenceCellOccup/
sqrt(referenceCellOccup))) {
507 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" -> would fail cells!" << endl;
508 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" # of cells with 0 count: " << nCellsZeroCount
509 <<
" # wires: " << nWires
511 << TMath::Erfc(referenceCellOccup/
sqrt(referenceCellOccup))
517 if( nFailingLayers == 4) {
524 if(nFailingSLs == nSL) {
525 chamberPercentage = 0;
528 chamberPercentage = 1.-(float)nFailingSLs/(
float)nSL;
533 if(failLayer)
return 2;
534 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