32 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");
59 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" destructor called" << endl;
68 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest]: BeginJob";
75 for(
int wh = -2; wh <= 2; ++wh) {
76 bookHistos(wh,
string(
"Occupancies"),
"OccupancySummary");
79 dbe->setCurrentFolder(topFolder());
80 string title =
"Occupancy Summary";
82 title =
"Test Pulse Occupancy Summary";
85 summaryHisto = dbe->book2D(
"OccupancySummary",title.c_str(),12,1,13,5,-2,3);
86 summaryHisto->setAxisTitle(
"sector",1);
87 summaryHisto->setAxisTitle(
"wheel",2);
90 glbSummaryHisto = dbe->book2D(
"OccupancyGlbSummary",title.c_str(),12,1,13,5,-2,3);
91 glbSummaryHisto->setAxisTitle(
"sector",1);
92 glbSummaryHisto->setAxisTitle(
"wheel",2);
96 if(runOnAllHitsOccupancies) {
97 nameMonitoredHisto =
"OccupancyAllHits_perCh";
98 }
else if(runOnNoiseOccupancies) {
99 nameMonitoredHisto =
"OccupancyNoise_perCh";
100 }
else if(runOnInTimeOccupancies) {
101 nameMonitoredHisto =
"OccupancyInTimeHits_perCh";
103 nameMonitoredHisto =
"OccupancyAllHits_perCh";
113 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest]: BeginRun";
124 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest]: Begin of LS transition";
140 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest")
141 <<
"[DTOccupancyTest]: End of LS transition, performing the DQM client operation";
147 summaryHisto->Reset();
148 glbSummaryHisto->Reset();
151 vector<const DTChamber*>
chambers = muonGeom->chambers();
153 for(vector<const DTChamber*>::const_iterator chamber = chambers.begin();
154 chamber != chambers.end(); ++chamber) {
157 MonitorElement * chamberOccupancyHisto = dbe->get(getMEName(nameMonitoredHisto, chId));
160 if(chamberOccupancyHisto != 0) {
163 float chamberPercentage = 1.;
164 int result = runOccupancyTest(histo, chId, chamberPercentage);
165 int sector = chId.
sector();
169 float resultSect4 = wheelHistos[chId.
wheel()]->getBinContent(sector, chId.
station());
170 if(resultSect4 > result) {
171 result = (int)resultSect4;
173 }
else if(sector == 14) {
175 float resultSect10 = wheelHistos[chId.
wheel()]->getBinContent(sector, chId.
station());
176 if(resultSect10 > result) {
177 result = (int)resultSect10;
182 if((sector == 4 || sector == 10) && chId.
station() == 4)
183 chamberPercentage = chamberPercentage/2.;
186 if(result > summaryHisto->getBinContent(sector, chId.
wheel()+3)) {
187 summaryHisto->setBinContent(sector, chId.
wheel()+3,
result);
189 glbSummaryHisto->Fill(sector, chId.
wheel(), chamberPercentage*1./4.);
191 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest] ME: "
192 << getMEName(nameMonitoredHisto, chId) <<
" not found!" << endl;
197 string nEvtsName =
"DT/EventInfo/Counters/nProcessedEventsDigi";
202 glbSummaryHisto->setEntries(nProcEvts < nMinEvts ? 10. : nProcEvts);
203 summaryHisto->setEntries(nProcEvts < nMinEvts ? 10. : nProcEvts);
205 glbSummaryHisto->setEntries(nMinEvts +1);
206 summaryHisto->setEntries(nMinEvts + 1);
207 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest] ME: "
208 << nEvtsName <<
" not found!" << endl;
215 if(writeRootFile) ntuple->AutoSave(
"SaveSelf");
222 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest] endjob called!";
235 stringstream wheel; wheel << wheelId;
236 dbe->setCurrentFolder(topFolder());
239 string histoName = histoTag +
"_W" + wheel.str();
242 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest]: booking wheel histo:"
247 << topFolder() +
"Wheel"+ wheel.str() +
"/" + folder << endl;
249 string histoTitle =
"Occupancy summary WHEEL: "+wheel.str();
251 histoTitle =
"TP Occupancy summary WHEEL: "+wheel.str();
253 wheelHistos[wheelId] = dbe->book2D(histoName,histoTitle,12,1,13,4,1,5);
254 wheelHistos[wheelId]->setBinLabel(1,
"MB1",2);
255 wheelHistos[wheelId]->setBinLabel(2,
"MB2",2);
256 wheelHistos[wheelId]->setBinLabel(3,
"MB3",2);
257 wheelHistos[wheelId]->setBinLabel(4,
"MB4",2);
258 wheelHistos[wheelId]->setAxisTitle(
"sector",1);
265 stringstream wheel; wheel << chId.
wheel();
267 stringstream sector; sector << chId.
sector();
270 string folderRoot = topFolder() +
"Wheel" + wheel.str() +
271 "/Sector" + sector.str() +
272 "/Station" + station.str() +
"/";
274 string folder =
"Occupancies/";
277 string histoName = histoTag
279 +
"_St" + station.str()
280 +
"_Sec" + sector.str();
282 string histoname = folderRoot + histoName;
298 float& chamberPercentage) {
299 int nBinsX = histo->GetNbinsX();
303 bool failLayer =
false;
304 bool failCells =
false;
307 if(histo->Integral() == 0) {
308 chamberPercentage = 0;
312 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"--- Occupancy test for chamber: " << chId << endl;
315 if(chId.
station() == 4) nSL = 2;
320 values[0] = lsCounter;
321 values[1] = chId.
wheel();
323 values[3] = chId.
sector();
329 double totalChamberOccupp = 0;
330 double squaredLayerOccupSum = 0;
332 map<DTLayerId, pair<double, double> > averageCellOccupAndRMS;
333 map<DTLayerId, double> layerOccupancyMap;
336 for(
int slay = 1; slay <= 3; ++slay) {
338 if(chId.
station() == 4 && slay == 2) {
353 int binYlow = ((slay-1)*4)+1;
354 int binYhigh = binYlow+3;
355 double slInteg = histo->Integral(1,nBinsX,binYlow,binYhigh);
357 chamberPercentage = 1.-1./(float)nSL;
361 for(
int lay = 1; lay <= 4; ++lay) {
364 int binY = binYlow+(lay-1);
366 double layerInteg = histo->Integral(1,nBinsX,binY,binY);
367 squaredLayerOccupSum += layerInteg*layerInteg;
368 totalChamberOccupp+= layerInteg;
370 layerOccupancyMap[layID] = layerInteg;
373 int nWires = muonGeom->layer(layID)->specificTopology().channels();
374 int firstWire = muonGeom->layer(layID)->specificTopology().firstChannel();
375 double layerSquaredSum = 0;
377 histo->SetBinContent(nBinsX+1,binY,0.);
379 for(
int cell = firstWire; cell != (nWires+firstWire); ++cell) {
380 double cellOccup = histo->GetBinContent(cell,binY);
381 layerSquaredSum+=cellOccup*cellOccup;
387 double averageCellOccup = layerInteg/nWires;
388 double averageSquaredCellOccup = layerSquaredSum/nWires;
389 double rmsCellOccup =
sqrt(averageSquaredCellOccup - averageCellOccup*averageCellOccup);
390 averageCellOccupAndRMS[layID] = make_pair(averageCellOccup, rmsCellOccup);
391 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" " << layID
392 <<
" average cell occ.: " << averageCellOccup
393 <<
" RMS: " << rmsCellOccup << endl;
396 values[
index] = averageCellOccup;
398 values[
index] = rmsCellOccup;
404 if(writeRootFile) ntuple->Fill(values);
410 double minCellRMS = 99999999;
411 double referenceCellOccup = -1;
416 for(
map<
DTLayerId, pair<double, double> >::const_iterator layAndValues = averageCellOccupAndRMS.begin();
417 layAndValues != averageCellOccupAndRMS.end(); layAndValues++) {
420 double rms = (*layAndValues).second.second;
421 double lOcc = layerOccupancyMap[lid];
422 double avCellOcc = (*layAndValues).second.first;
423 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" " << lid <<
" tot. occ: " << lOcc
424 <<
" average cell occ: " << avCellOcc
425 <<
" RMS: " << rms << endl;
431 if(monitoredLayers.find(lid) == monitoredLayers.end()) monitoredLayers.insert(lid);
441 double safeFactor = 3.;
444 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" Reference cell occup.: " << referenceCellOccup
445 <<
" RMS: " << minCellRMS << endl;
457 for(
int slay = 1; slay <= 3; ++slay) {
459 if(chId.
station() == 4 && slay == 2)
continue;
461 int binYlow = ((slay-1)*4)+1;
465 int nFailingLayers = 0;
467 for(
int lay = 1; lay <= 4; ++lay) {
469 int nWires = muonGeom->layer(layID)->specificTopology().channels();
470 int firstWire = muonGeom->layer(layID)->specificTopology().firstChannel();
471 int binY = binYlow+(lay-1);
474 double layerInteg = histo->Integral(1,nBinsX,binY,binY);
476 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" layer: " << layID <<
" integral: " << layerInteg << endl;
479 bool alreadyMonitored =
false;
480 if(monitoredLayers.find(layID) != monitoredLayers.end()) alreadyMonitored =
true;
483 if(layerInteg == 0) {
484 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" fail layer: no entries" << endl;
486 if(!alreadyMonitored) monitoredLayers.insert(layID);
489 histo->SetBinContent(nBinsX+1,binY,-1.);
507 if(monitoredLayers.find(layID) == monitoredLayers.end()) monitoredLayers.insert(layID);
510 int totalDeadCells = 0;
511 int nDeadCellsInARow = 1;
512 int nDeadCellsInARowMax = 0;
513 int nCellsZeroCount = 0;
514 bool previousIsDead =
false;
516 int interDeadCells = 0;
517 for(
int cell = firstWire; cell != (nWires+firstWire); ++cell) {
518 double cellOccup = histo->GetBinContent(cell,binY);
519 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" cell occup: " << cellOccup;
520 if(cellOccup == 0 || cellOccup < (referenceCellOccup-safeFactor*
sqrt(referenceCellOccup))) {
521 if(cellOccup == 0) nCellsZeroCount++;
523 if(previousIsDead) nDeadCellsInARow++;
524 previousIsDead =
true;
526 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" below reference" << endl;
528 previousIsDead =
false;
532 if(interDeadCells > 3) {
533 if(nDeadCellsInARow > nDeadCellsInARowMax) nDeadCellsInARowMax = nDeadCellsInARow;
534 nDeadCellsInARow = 1;
538 if(nDeadCellsInARow > nDeadCellsInARowMax) nDeadCellsInARowMax = nDeadCellsInARow;
539 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" # wires: " << nWires
540 <<
" # cells 0 count: " << nCellsZeroCount
541 <<
" # dead cells in a row: " << nDeadCellsInARowMax
542 <<
" total # of dead cells: " << totalDeadCells;
554 if((TMath::Erfc(referenceCellOccup/
sqrt(referenceCellOccup)) < 10./(
double)nWires &&
555 nDeadCellsInARowMax>= 10.) ||
556 (TMath::Erfc(referenceCellOccup/
sqrt(referenceCellOccup)) < 0.5 &&
557 totalDeadCells > nWires/2.)) {
558 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" -> fail layer!" << endl;
561 histo->SetBinContent(nBinsX+1,binY,-1.);
562 }
else if(referenceCellOccup > 10 &&
563 nCellsZeroCount > nWires/3. &&
564 (
double)nCellsZeroCount/(
double)nWires >
565 2.*TMath::Erfc(referenceCellOccup/
sqrt(referenceCellOccup))) {
566 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" -> would fail cells!" << endl;
567 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" # of cells with 0 count: " << nCellsZeroCount
568 <<
" # wires: " << nWires
570 << TMath::Erfc(referenceCellOccup/
sqrt(referenceCellOccup))
585 if( nFailingLayers == 4) {
592 if(nFailingSLs == nSL) {
593 chamberPercentage = 0;
596 chamberPercentage = 1.-(float)nFailingSLs/(
float)nSL;
601 if(failLayer)
return 2;
602 if(failCells)
return 1;
609 if(tpMode)
return string(
"DT/10-TestPulses/");
610 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)
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
static char chambers[264][20]
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