33 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest]: Constructor";
41 rootFile =
new TFile(
"DTOccupancyTest.root",
"RECREATE");
42 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;
67 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest]: BeginRun";
80 for(
int wh = -2; wh <= 2; ++wh) {
81 bookHistos(ibooker,wh,
string(
"Occupancies"),
"OccupancySummary");
85 string title =
"Occupancy Summary";
87 title =
"Test Pulse Occupancy Summary";
90 summaryHisto = ibooker.
book2D(
"OccupancySummary",title.c_str(),12,1,13,5,-2,3);
92 summaryHisto->setAxisTitle(
"wheel",2);
95 glbSummaryHisto = ibooker.
book2D(
"OccupancyGlbSummary",title.c_str(),12,1,13,5,-2,3);
97 glbSummaryHisto->setAxisTitle(
"wheel",2);
101 if(runOnAllHitsOccupancies) {
102 nameMonitoredHisto =
"OccupancyAllHits_perCh";
103 }
else if(runOnNoiseOccupancies) {
104 nameMonitoredHisto =
"OccupancyNoise_perCh";
105 }
else if(runOnInTimeOccupancies) {
106 nameMonitoredHisto =
"OccupancyInTimeHits_perCh";
108 nameMonitoredHisto =
"OccupancyAllHits_perCh";
115 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest")
116 <<
"[DTOccupancyTest]: End of LS transition, performing the DQM client operation";
122 summaryHisto->Reset();
123 glbSummaryHisto->Reset();
126 vector<const DTChamber*>
chambers = muonGeom->chambers();
128 for(vector<const DTChamber*>::const_iterator chamber = chambers.begin();
129 chamber != chambers.end(); ++chamber) {
132 MonitorElement * chamberOccupancyHisto = igetter.
get(getMEName(nameMonitoredHisto, chId));
135 if(chamberOccupancyHisto != 0) {
138 float chamberPercentage = 1.;
139 int result = runOccupancyTest(histo, chId, chamberPercentage);
140 int sector = chId.
sector();
144 float resultSect4 = wheelHistos[chId.
wheel()]->getBinContent(sector, chId.
station());
145 if(resultSect4 > result) {
146 result = (int)resultSect4;
148 }
else if(sector == 14) {
150 float resultSect10 = wheelHistos[chId.
wheel()]->getBinContent(sector, chId.
station());
151 if(resultSect10 > result) {
152 result = (int)resultSect10;
157 if((sector == 4 || sector == 10) && chId.
station() == 4)
158 chamberPercentage = chamberPercentage/2.;
161 if(result > summaryHisto->getBinContent(sector, chId.
wheel()+3)) {
162 summaryHisto->setBinContent(sector, chId.
wheel()+3,
result);
164 glbSummaryHisto->Fill(sector, chId.
wheel(), chamberPercentage*1./4.);
166 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest] ME: "
167 << getMEName(nameMonitoredHisto, chId) <<
" not found!" << endl;
172 string nEvtsName =
"DT/EventInfo/Counters/nProcessedEventsDigi";
178 glbSummaryHisto->setEntries(nProcEvts < nMinEvts ? 10. : nProcEvts);
179 summaryHisto->setEntries(nProcEvts < nMinEvts ? 10. : nProcEvts);
181 glbSummaryHisto->setEntries(nMinEvts +1);
182 summaryHisto->setEntries(nMinEvts + 1);
183 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest] ME: "
184 << nEvtsName <<
" not found!" << endl;
191 if(writeRootFile) ntuple->AutoSave(
"SaveSelf");
197 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest] endjob called!";
210 string folder,
string histoTag) {
212 stringstream wheel; wheel << wheelId;
217 string histoName = histoTag +
"_W" + wheel.str();
220 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest]: booking wheel histo:"
225 << topFolder() +
"Wheel"+ wheel.str() +
"/" + folder << endl;
227 string histoTitle =
"Occupancy summary WHEEL: "+wheel.str();
229 histoTitle =
"TP Occupancy summary WHEEL: "+wheel.str();
232 wheelHistos[wheelId] = ibooker.
book2D(histoName,histoTitle,12,1,13,4,1,5);
234 wheelHistos[wheelId]->setBinLabel(2,
"MB2",2);
235 wheelHistos[wheelId]->setBinLabel(3,
"MB3",2);
236 wheelHistos[wheelId]->setBinLabel(4,
"MB4",2);
237 wheelHistos[wheelId]->setAxisTitle(
"sector",1);
244 stringstream wheel; wheel << chId.
wheel();
246 stringstream sector; sector << chId.
sector();
249 string folderRoot = topFolder() +
"Wheel" + wheel.str() +
250 "/Sector" + sector.str() +
251 "/Station" + station.str() +
"/";
253 string folder =
"Occupancies/";
256 string histoName = histoTag
258 +
"_St" + station.str()
259 +
"_Sec" + sector.str();
261 string histoname = folderRoot + histoName;
277 float& chamberPercentage) {
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;
299 values[0] = lsCounter;
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;
383 if(writeRootFile) ntuple->Fill(values);
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;
406 if(monitoredLayers.find(lid) == monitoredLayers.end()) monitoredLayers.insert(lid);
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;
442 if(monitoredLayers.find(layID) != monitoredLayers.end()) alreadyMonitored =
true;
445 if(layerInteg == 0) {
446 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" fail layer: no entries" << endl;
448 if(!alreadyMonitored) monitoredLayers.insert(layID);
451 histo->SetBinContent(nBinsX+1,binY,-1.);
459 if(monitoredLayers.find(layID) == monitoredLayers.end()) monitoredLayers.insert(layID);
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;
541 if(tpMode)
return string(
"DT/10-TestPulses/");
542 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 dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &)
DQM Client Diagnostic.
int runOccupancyTest(TH2F *histo, const DTChamberId &chId, float &chamberPercentage)
MonitorElement * get(const std::string &path)
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &)
Endjob.
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
virtual ~DTOccupancyTest()
Destructor.
double averageRMS() const
average RMS of the cell occpuancy distributions of the layers in the cluster
DTOccupancyTest(const edm::ParameterSet &ps)
Constructor.
void bookHistos(DQMStore::IBooker &, const int wheelId, std::string folder, std::string histoTag)
book the summary histograms
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
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 setCurrentFolder(const std::string &fullpath)
MonitorElement * book2D(Args &&...args)
bool isProblematic(DTLayerId layerId) const
std::string topFolder() const
int station() const
Return the station number.
TH2F * getTH2F(void) const
static char chambers[264][20]
int wheel() const
Return the wheel number.
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
*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