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");
60 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" destructor called" << endl;
69 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest]: BeginJob";
76 for(
int wh = -2; wh <= 2; ++wh) {
77 bookHistos(wh,
string(
"Occupancies"),
"OccupancySummary");
80 dbe->setCurrentFolder(topFolder());
81 string title =
"Occupancy Summary";
83 title =
"Test Pulse Occupancy Summary";
86 summaryHisto = dbe->book2D(
"OccupancySummary",title.c_str(),12,1,13,5,-2,3);
87 summaryHisto->setAxisTitle(
"sector",1);
88 summaryHisto->setAxisTitle(
"wheel",2);
91 glbSummaryHisto = dbe->book2D(
"OccupancyGlbSummary",title.c_str(),12,1,13,5,-2,3);
92 glbSummaryHisto->setAxisTitle(
"sector",1);
93 glbSummaryHisto->setAxisTitle(
"wheel",2);
97 if(runOnAllHitsOccupancies) {
98 nameMonitoredHisto =
"OccupancyAllHits_perCh";
99 }
else if(runOnNoiseOccupancies) {
100 nameMonitoredHisto =
"OccupancyNoise_perCh";
101 }
else if(runOnInTimeOccupancies) {
102 nameMonitoredHisto =
"OccupancyInTimeHits_perCh";
104 nameMonitoredHisto =
"OccupancyAllHits_perCh";
114 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest]: BeginRun";
125 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest]: Begin of LS transition";
141 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest")
142 <<
"[DTOccupancyTest]: End of LS transition, performing the DQM client operation";
148 summaryHisto->Reset();
149 glbSummaryHisto->Reset();
152 vector<DTChamber*>
chambers = muonGeom->chambers();
154 for(vector<DTChamber*>::const_iterator chamber = chambers.begin();
155 chamber != chambers.end(); ++chamber) {
158 MonitorElement * chamberOccupancyHisto = dbe->get(getMEName(nameMonitoredHisto, chId));
161 if(chamberOccupancyHisto != 0) {
164 float chamberPercentage = 1.;
165 int result = runOccupancyTest(histo, chId, chamberPercentage);
166 int sector = chId.
sector();
170 float resultSect4 = wheelHistos[chId.
wheel()]->getBinContent(sector, chId.
station());
171 if(resultSect4 > result) {
172 result = (int)resultSect4;
174 }
else if(sector == 14) {
176 float resultSect10 = wheelHistos[chId.
wheel()]->getBinContent(sector, chId.
station());
177 if(resultSect10 > result) {
178 result = (int)resultSect10;
183 if((sector == 4 || sector == 10) && chId.
station() == 4)
184 chamberPercentage = chamberPercentage/2.;
187 if(result > summaryHisto->getBinContent(sector, chId.
wheel()+3)) {
188 summaryHisto->setBinContent(sector, chId.
wheel()+3,
result);
190 glbSummaryHisto->Fill(sector, chId.
wheel(), chamberPercentage*1./4.);
192 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest] ME: "
193 << getMEName(nameMonitoredHisto, chId) <<
" not found!" << endl;
202 if(writeRootFile) ntuple->AutoSave(
"SaveSelf");
209 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest] endjob called!";
222 stringstream wheel; wheel << wheelId;
223 dbe->setCurrentFolder(topFolder());
226 string histoName = histoTag +
"_W" + wheel.str();
229 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest]: booking wheel histo:"
234 << topFolder() +
"Wheel"+ wheel.str() +
"/" + folder << endl;
236 string histoTitle =
"Occupancy summary WHEEL: "+wheel.str();
238 histoTitle =
"TP Occupancy summary WHEEL: "+wheel.str();
240 wheelHistos[wheelId] = dbe->book2D(histoName,histoTitle,12,1,13,4,1,5);
241 wheelHistos[wheelId]->setBinLabel(1,
"MB1",2);
242 wheelHistos[wheelId]->setBinLabel(2,
"MB2",2);
243 wheelHistos[wheelId]->setBinLabel(3,
"MB3",2);
244 wheelHistos[wheelId]->setBinLabel(4,
"MB4",2);
245 wheelHistos[wheelId]->setAxisTitle(
"sector",1);
252 stringstream wheel; wheel << chId.
wheel();
254 stringstream sector; sector << chId.
sector();
257 string folderRoot = topFolder() +
"Wheel" + wheel.str() +
258 "/Sector" + sector.str() +
259 "/Station" + station.str() +
"/";
261 string folder =
"Occupancies/";
264 string histoName = histoTag
266 +
"_St" + station.str()
267 +
"_Sec" + sector.str();
269 string histoname = folderRoot + histoName;
285 float& chamberPercentage) {
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;
307 values[0] = lsCounter;
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;
391 if(writeRootFile) ntuple->Fill(values);
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;
418 if(monitoredLayers.find(lid) == monitoredLayers.end()) monitoredLayers.insert(lid);
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;
467 if(monitoredLayers.find(layID) != monitoredLayers.end()) alreadyMonitored =
true;
470 if(layerInteg == 0) {
471 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" fail layer: no entries" << endl;
473 if(!alreadyMonitored) monitoredLayers.insert(layID);
476 histo->SetBinContent(nBinsX+1,binY,-1.);
494 if(monitoredLayers.find(layID) == monitoredLayers.end()) monitoredLayers.insert(layID);
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;
596 if(tpMode)
return string(
"DT/10-TestPulses/");
597 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.
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