295 int nBinsX =
histo->GetNbinsX();
296 int nBinsY =
histo->GetNbinsY();
300 bool failLayer =
false;
301 bool failCells =
false;
305 chamberPercentage = 0;
309 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"--- Occupancy test for chamber: " << chId << endl;
312 if(chId.
station() == 4) nSL = 2;
318 values[1] = chId.
wheel();
320 values[3] = chId.
sector();
326 double totalChamberOccupp = 0;
327 double squaredLayerOccupSum = 0;
329 map<DTLayerId, pair<double, double> > averageCellOccupAndRMS;
330 map<DTLayerId, double> layerOccupancyMap;
333 for(
int slay = 1; slay <= 3; ++slay) {
335 if(chId.
station() == 4 && slay == 2) {
350 int binYlow = ((slay-1)*4)+1;
351 int binYhigh = binYlow+3;
354 chamberPercentage = 1.-1./(float)nSL;
358 for(
int lay = 1; lay <= 4; ++lay) {
361 int binY = binYlow+(lay-1);
364 squaredLayerOccupSum += layerInteg*layerInteg;
365 totalChamberOccupp+= layerInteg;
367 layerOccupancyMap[layID] = layerInteg;
370 int nWires =
muonGeom->layer(layID)->specificTopology().channels();
371 int firstWire =
muonGeom->layer(layID)->specificTopology().firstChannel();
372 double layerSquaredSum = 0;
374 histo->SetBinContent(nBinsX+1,binY,0.);
376 for(
int cell = firstWire; cell != (nWires+firstWire); ++cell) {
377 double cellOccup =
histo->GetBinContent(cell,binY);
378 layerSquaredSum+=cellOccup*cellOccup;
384 double averageCellOccup = layerInteg/nWires;
385 double averageSquaredCellOccup = layerSquaredSum/nWires;
386 double rmsCellOccup =
sqrt(averageSquaredCellOccup - averageCellOccup*averageCellOccup);
387 averageCellOccupAndRMS[layID] = make_pair(averageCellOccup, rmsCellOccup);
388 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" " << layID
389 <<
" average cell occ.: " << averageCellOccup
390 <<
" RMS: " << rmsCellOccup << endl;
393 values[
index] = averageCellOccup;
395 values[
index] = rmsCellOccup;
403 double minCellRMS = 99999999;
404 double referenceCellOccup = -1;
409 for(map<
DTLayerId, pair<double, double> >::const_iterator layAndValues = averageCellOccupAndRMS.begin();
410 layAndValues != averageCellOccupAndRMS.end(); layAndValues++) {
413 double rms = (*layAndValues).second.second;
414 double lOcc = layerOccupancyMap[lid];
415 double avCellOcc = (*layAndValues).second.first;
416 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" " << lid <<
" tot. occ: " << lOcc
417 <<
" average cell occ: " << avCellOcc
418 <<
" RMS: " << rms << endl;
432 double safeFactor = 3.;
434 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" Reference cell occup.: " << referenceCellOccup
435 <<
" RMS: " << minCellRMS << endl;
440 for(
int slay = 1; slay <= 3; ++slay) {
442 if(chId.
station() == 4 && slay == 2)
continue;
444 int binYlow = ((slay-1)*4)+1;
445 int nFailingLayers = 0;
447 for(
int lay = 1; lay <= 4; ++lay) {
449 int nWires =
muonGeom->layer(layID)->specificTopology().channels();
450 int firstWire =
muonGeom->layer(layID)->specificTopology().firstChannel();
451 int binY = binYlow+(lay-1);
456 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" layer: " << layID <<
" integral: " << layerInteg << endl;
459 bool alreadyMonitored =
false;
463 if(layerInteg == 0) {
464 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" fail layer: no entries" << endl;
469 histo->SetBinContent(nBinsX+1,binY,-1.);
479 int totalDeadCells = 0;
480 int nDeadCellsInARow = 1;
481 int nDeadCellsInARowMax = 0;
482 int nCellsZeroCount = 0;
483 bool previousIsDead =
false;
485 int interDeadCells = 0;
486 for(
int cell = firstWire; cell != (nWires+firstWire); ++cell) {
487 double cellOccup =
histo->GetBinContent(cell,binY);
488 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" cell occup: " << cellOccup;
489 if(cellOccup == 0 || cellOccup < (referenceCellOccup-safeFactor*
sqrt(referenceCellOccup))) {
490 if(cellOccup == 0) nCellsZeroCount++;
492 if(previousIsDead) nDeadCellsInARow++;
493 previousIsDead =
true;
495 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" below reference" << endl;
497 previousIsDead =
false;
501 if(interDeadCells > 3) {
502 if(nDeadCellsInARow > nDeadCellsInARowMax) nDeadCellsInARowMax = nDeadCellsInARow;
503 nDeadCellsInARow = 1;
507 if(nDeadCellsInARow > nDeadCellsInARowMax) nDeadCellsInARowMax = nDeadCellsInARow;
508 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" # wires: " << nWires
509 <<
" # cells 0 count: " << nCellsZeroCount
510 <<
" # dead cells in a row: " << nDeadCellsInARowMax
511 <<
" total # of dead cells: " << totalDeadCells;
513 if((TMath::Erfc(referenceCellOccup/
sqrt(referenceCellOccup)) < 10./(
double)nWires &&
514 nDeadCellsInARowMax>= 10.) ||
515 (TMath::Erfc(referenceCellOccup/
sqrt(referenceCellOccup)) < 0.5 &&
516 totalDeadCells > nWires/2.)) {
517 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" -> fail layer!" << endl;
520 histo->SetBinContent(nBinsX+1,binY,-1.);
521 }
else if(referenceCellOccup > 10 &&
522 nCellsZeroCount > nWires/3. &&
523 (
double)nCellsZeroCount/(
double)nWires >
524 2.*TMath::Erfc(referenceCellOccup/
sqrt(referenceCellOccup))) {
525 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" -> would fail cells!" << endl;
526 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" # of cells with 0 count: " << nCellsZeroCount
527 <<
" # wires: " << nWires
529 << TMath::Erfc(referenceCellOccup/
sqrt(referenceCellOccup))
535 if( nFailingLayers == 4) {
542 if(nFailingSLs == nSL) {
543 chamberPercentage = 0;
546 chamberPercentage = 1.-(float)nFailingSLs/(
float)nSL;
551 if(failLayer)
return 2;
552 if(failCells)
return 1;
DTOccupancyCluster getBestCluster() const
get the cluster correspondig to "normal" cell occupancy.
int getIntegral(TH2F *histo, int, int, int, int, bool)
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