286 int nBinsX =
histo->GetNbinsX();
290 bool failLayer =
false;
291 bool failCells =
false;
294 if(
histo->Integral() == 0) {
295 chamberPercentage = 0;
299 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"--- Occupancy test for chamber: " << chId << endl;
302 if(chId.
station() == 4) nSL = 2;
308 values[1] = chId.
wheel();
310 values[3] = chId.
sector();
316 double totalChamberOccupp = 0;
317 double squaredLayerOccupSum = 0;
319 map<DTLayerId, pair<double, double> > averageCellOccupAndRMS;
320 map<DTLayerId, double> layerOccupancyMap;
323 for(
int slay = 1; slay <= 3; ++slay) {
325 if(chId.
station() == 4 && slay == 2) {
340 int binYlow = ((slay-1)*4)+1;
341 int binYhigh = binYlow+3;
342 double slInteg =
histo->Integral(1,nBinsX,binYlow,binYhigh);
344 chamberPercentage = 1.-1./(float)nSL;
348 for(
int lay = 1; lay <= 4; ++lay) {
351 int binY = binYlow+(lay-1);
353 double layerInteg =
histo->Integral(1,nBinsX,binY,binY);
354 squaredLayerOccupSum += layerInteg*layerInteg;
355 totalChamberOccupp+= layerInteg;
357 layerOccupancyMap[layID] = layerInteg;
360 int nWires =
muonGeom->layer(layID)->specificTopology().channels();
361 int firstWire =
muonGeom->layer(layID)->specificTopology().firstChannel();
362 double layerSquaredSum = 0;
364 histo->SetBinContent(nBinsX+1,binY,0.);
366 for(
int cell = firstWire; cell != (nWires+firstWire); ++cell) {
367 double cellOccup =
histo->GetBinContent(cell,binY);
368 layerSquaredSum+=cellOccup*cellOccup;
374 double averageCellOccup = layerInteg/nWires;
375 double averageSquaredCellOccup = layerSquaredSum/nWires;
376 double rmsCellOccup =
sqrt(averageSquaredCellOccup - averageCellOccup*averageCellOccup);
377 averageCellOccupAndRMS[layID] = make_pair(averageCellOccup, rmsCellOccup);
378 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" " << layID
379 <<
" average cell occ.: " << averageCellOccup
380 <<
" RMS: " << rmsCellOccup << endl;
383 values[
index] = averageCellOccup;
385 values[
index] = rmsCellOccup;
397 double minCellRMS = 99999999;
398 double referenceCellOccup = -1;
403 for(
map<
DTLayerId, pair<double, double> >::const_iterator layAndValues = averageCellOccupAndRMS.begin();
404 layAndValues != averageCellOccupAndRMS.end(); layAndValues++) {
407 double rms = (*layAndValues).second.second;
408 double lOcc = layerOccupancyMap[lid];
409 double avCellOcc = (*layAndValues).second.first;
410 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" " << lid <<
" tot. occ: " << lOcc
411 <<
" average cell occ: " << avCellOcc
412 <<
" RMS: " << rms << endl;
428 double safeFactor = 3.;
431 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" Reference cell occup.: " << referenceCellOccup
432 <<
" RMS: " << minCellRMS << endl;
444 for(
int slay = 1; slay <= 3; ++slay) {
446 if(chId.
station() == 4 && slay == 2)
continue;
448 int binYlow = ((slay-1)*4)+1;
452 int nFailingLayers = 0;
454 for(
int lay = 1; lay <= 4; ++lay) {
456 int nWires =
muonGeom->layer(layID)->specificTopology().channels();
457 int firstWire =
muonGeom->layer(layID)->specificTopology().firstChannel();
458 int binY = binYlow+(lay-1);
461 double layerInteg =
histo->Integral(1,nBinsX,binY,binY);
463 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" layer: " << layID <<
" integral: " << layerInteg << endl;
466 bool alreadyMonitored =
false;
470 if(layerInteg == 0) {
471 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" fail layer: no entries" << endl;
476 histo->SetBinContent(nBinsX+1,binY,-1.);
497 int totalDeadCells = 0;
498 int nDeadCellsInARow = 1;
499 int nDeadCellsInARowMax = 0;
500 int nCellsZeroCount = 0;
501 bool previousIsDead =
false;
503 int interDeadCells = 0;
504 for(
int cell = firstWire; cell != (nWires+firstWire); ++cell) {
505 double cellOccup =
histo->GetBinContent(cell,binY);
506 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" cell occup: " << cellOccup;
507 if(cellOccup == 0 || cellOccup < (referenceCellOccup-safeFactor*
sqrt(referenceCellOccup))) {
508 if(cellOccup == 0) nCellsZeroCount++;
510 if(previousIsDead) nDeadCellsInARow++;
511 previousIsDead =
true;
513 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" below reference" << endl;
515 previousIsDead =
false;
519 if(interDeadCells > 3) {
520 if(nDeadCellsInARow > nDeadCellsInARowMax) nDeadCellsInARowMax = nDeadCellsInARow;
521 nDeadCellsInARow = 1;
525 if(nDeadCellsInARow > nDeadCellsInARowMax) nDeadCellsInARowMax = nDeadCellsInARow;
526 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" # wires: " << nWires
527 <<
" # cells 0 count: " << nCellsZeroCount
528 <<
" # dead cells in a row: " << nDeadCellsInARowMax
529 <<
" total # of dead cells: " << totalDeadCells;
541 if((TMath::Erfc(referenceCellOccup/
sqrt(referenceCellOccup)) < 10./(
double)nWires &&
542 nDeadCellsInARowMax>= 10.) ||
543 (TMath::Erfc(referenceCellOccup/
sqrt(referenceCellOccup)) < 0.5 &&
544 totalDeadCells > nWires/2.)) {
545 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" -> fail layer!" << endl;
548 histo->SetBinContent(nBinsX+1,binY,-1.);
549 }
else if(referenceCellOccup > 10 &&
550 nCellsZeroCount > nWires/3. &&
551 (
double)nCellsZeroCount/(
double)nWires >
552 2.*TMath::Erfc(referenceCellOccup/
sqrt(referenceCellOccup))) {
553 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" -> would fail cells!" << endl;
554 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" # of cells with 0 count: " << nCellsZeroCount
555 <<
" # wires: " << nWires
557 << TMath::Erfc(referenceCellOccup/
sqrt(referenceCellOccup))
572 if( nFailingLayers == 4) {
579 if(nFailingSLs == nSL) {
580 chamberPercentage = 0;
583 chamberPercentage = 1.-(float)nFailingSLs/(
float)nSL;
588 if(failLayer)
return 2;
589 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