34 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest]: Constructor";
43 rootFile =
new TFile(
"DTOccupancyTest.root",
"RECREATE");
44 ntuple =
new TNtuple(
"OccupancyNtuple",
"OccupancyNtuple",
"ls:wh:st:se:lay1MeanCell:lay1RMS:lay2MeanCell:lay2RMS:lay3MeanCell:lay3RMS:lay4MeanCell:lay4RMS:lay5MeanCell:lay5RMS:lay6MeanCell:lay6RMS:lay7MeanCell:lay7RMS:lay8MeanCell:lay8RMS:lay9MeanCell:lay9RMS:lay10MeanCell:lay10RMS:lay11MeanCell:lay11RMS:lay12MeanCell:lay12RMS");
61 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" destructor called" << endl;
70 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest]: BeginJob";
77 for(
int wh = -2; wh <= 2; ++wh) {
78 bookHistos(wh,
string(
"Occupancies"),
"OccupancySummary");
81 dbe->setCurrentFolder(topFolder());
82 string title =
"Occupancy Summary";
84 title =
"Test Pulse Occupancy Summary";
87 summaryHisto = dbe->book2D(
"OccupancySummary",title.c_str(),12,1,13,5,-2,3);
88 summaryHisto->setAxisTitle(
"sector",1);
89 summaryHisto->setAxisTitle(
"wheel",2);
92 glbSummaryHisto = dbe->book2D(
"OccupancyGlbSummary",title.c_str(),12,1,13,5,-2,3);
93 glbSummaryHisto->setAxisTitle(
"sector",1);
94 glbSummaryHisto->setAxisTitle(
"wheel",2);
98 if(runOnAllHitsOccupancies) {
99 nameMonitoredHisto =
"OccupancyAllHits_perCh";
100 }
else if(runOnNoiseOccupancies) {
101 nameMonitoredHisto =
"OccupancyNoise_perCh";
102 }
else if(runOnInTimeOccupancies) {
103 nameMonitoredHisto =
"OccupancyInTimeHits_perCh";
105 nameMonitoredHisto =
"OccupancyAllHits_perCh";
115 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest]: BeginRun";
126 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest]: Begin of LS transition";
142 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest")
143 <<
"[DTOccupancyTest]: End of LS transition, performing the DQM client operation";
149 summaryHisto->Reset();
150 glbSummaryHisto->Reset();
153 vector<DTChamber*>
chambers = muonGeom->chambers();
155 for(vector<DTChamber*>::const_iterator chamber = chambers.begin();
156 chamber != chambers.end(); ++chamber) {
159 MonitorElement * chamberOccupancyHisto = dbe->get(getMEName(nameMonitoredHisto, chId));
162 if(chamberOccupancyHisto != 0) {
165 float chamberPercentage = 1.;
166 int result = runOccupancyTest(histo, chId, chamberPercentage);
167 int sector = chId.
sector();
171 float resultSect4 = wheelHistos[chId.
wheel()]->getBinContent(sector, chId.
station());
172 if(resultSect4 > result) {
173 result = (int)resultSect4;
175 }
else if(sector == 14) {
177 float resultSect10 = wheelHistos[chId.
wheel()]->getBinContent(sector, chId.
station());
178 if(resultSect10 > result) {
179 result = (int)resultSect10;
184 if((sector == 4 || sector == 10) && chId.
station() == 4)
185 chamberPercentage = chamberPercentage/2.;
188 if(result > summaryHisto->getBinContent(sector, chId.
wheel()+3)) {
189 summaryHisto->setBinContent(sector, chId.
wheel()+3,
result);
191 glbSummaryHisto->Fill(sector, chId.
wheel(), chamberPercentage*1./4.);
193 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest] ME: "
194 << getMEName(nameMonitoredHisto, chId) <<
" not found!" << endl;
199 string nEvtsName =
"DT/EventInfo/Counters/nProcessedEventsDigi";
204 glbSummaryHisto->setEntries(nProcEvts < nMinEvts ? 10. : nProcEvts);
205 summaryHisto->setEntries(nProcEvts < nMinEvts ? 10. : nProcEvts);
207 glbSummaryHisto->setEntries(nMinEvts +1);
208 summaryHisto->setEntries(nMinEvts + 1);
209 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest] ME: "
210 << nEvtsName <<
" not found!" << endl;
217 if(writeRootFile) ntuple->AutoSave(
"SaveSelf");
224 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest] endjob called!";
237 stringstream wheel; wheel << wheelId;
238 dbe->setCurrentFolder(topFolder());
241 string histoName = histoTag +
"_W" + wheel.str();
244 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest]: booking wheel histo:"
249 << topFolder() +
"Wheel"+ wheel.str() +
"/" + folder << endl;
251 string histoTitle =
"Occupancy summary WHEEL: "+wheel.str();
253 histoTitle =
"TP Occupancy summary WHEEL: "+wheel.str();
255 wheelHistos[wheelId] = dbe->book2D(histoName,histoTitle,12,1,13,4,1,5);
256 wheelHistos[wheelId]->setBinLabel(1,
"MB1",2);
257 wheelHistos[wheelId]->setBinLabel(2,
"MB2",2);
258 wheelHistos[wheelId]->setBinLabel(3,
"MB3",2);
259 wheelHistos[wheelId]->setBinLabel(4,
"MB4",2);
260 wheelHistos[wheelId]->setAxisTitle(
"sector",1);
267 stringstream wheel; wheel << chId.
wheel();
269 stringstream sector; sector << chId.
sector();
272 string folderRoot = topFolder() +
"Wheel" + wheel.str() +
273 "/Sector" + sector.str() +
274 "/Station" + station.str() +
"/";
276 string folder =
"Occupancies/";
279 string histoName = histoTag
281 +
"_St" + station.str()
282 +
"_Sec" + sector.str();
284 string histoname = folderRoot + histoName;
300 float& chamberPercentage) {
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;
322 values[0] = lsCounter;
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;
406 if(writeRootFile) ntuple->Fill(values);
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;
433 if(monitoredLayers.find(lid) == monitoredLayers.end()) monitoredLayers.insert(lid);
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;
482 if(monitoredLayers.find(layID) != monitoredLayers.end()) alreadyMonitored =
true;
485 if(layerInteg == 0) {
486 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" fail layer: no entries" << endl;
488 if(!alreadyMonitored) monitoredLayers.insert(layID);
491 histo->SetBinContent(nBinsX+1,binY,-1.);
509 if(monitoredLayers.find(layID) == monitoredLayers.end()) monitoredLayers.insert(layID);
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;
611 if(tpMode)
return string(
"DT/10-TestPulses/");
612 return string(
"DT/01-Digi/");
DTOccupancyCluster getBestCluster() const
get the cluster correspondig to "normal" cell occupancy.
T getUntrackedParameter(std::string const &, T const &) const
void analyze(const edm::Event &event, const edm::EventSetup &context)
Analyze.
int runOccupancyTest(TH2F *histo, const DTChamberId &chId, float &chamberPercentage)
static char chambers[TOTALCHAMBERS][20]
virtual ~DTOccupancyTest()
Destructor.
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context)
double averageRMS() const
average RMS of the cell occpuancy distributions of the layers in the cluster
DTOccupancyTest(const edm::ParameterSet &ps)
Constructor.
std::string getMEName(std::string histoTag, const DTChamberId &chId)
Get the ME name.
void beginRun(edm::Run const &run, edm::EventSetup const &context)
BeginRun.
double getFloatValue(void) const
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context)
DQM Client Diagnostic.
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
void bookHistos(const int wheelId, std::string folder, std::string histoTag)
book the summary histograms
bool isProblematic(DTLayerId layerId) const
std::string topFolder() const
int station() const
Return the station number.
TH2F * getTH2F(void) const
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