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;
270 for (Int_t
i = firstBinX;
i < lastBinX+1;
i++) {
271 for (Int_t
j = firstBinY;
j < lastBinY+1;
j++) {
273 if (histo->GetBinContent(
i,
j) >0){
274 if (!doall)
return 1;
275 sum += histo->GetBinContent(
i,
j);
294 float& chamberPercentage) {
295 int nBinsX = histo->GetNbinsX();
296 int nBinsY = histo->GetNbinsY();
300 bool failLayer =
false;
301 bool failCells =
false;
304 if (getIntegral(histo,1,nBinsX,1,nBinsY,
false) == 0) {
305 chamberPercentage = 0;
309 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"--- Occupancy test for chamber: " << chId << endl;
312 if(chId.
station() == 4) nSL = 2;
317 values[0] = lsCounter;
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;
353 if(getIntegral(histo,1,nBinsX,binYlow,binYhigh,
false) == 0) {
354 chamberPercentage = 1.-1./(float)nSL;
358 for(
int lay = 1; lay <= 4; ++lay) {
361 int binY = binYlow+(lay-1);
363 double layerInteg = getIntegral(histo,1,nBinsX,binY,binY,
true);
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;
401 if(writeRootFile) ntuple->Fill(values);
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;
424 if(monitoredLayers.find(lid) == monitoredLayers.end()) monitoredLayers.insert(lid);
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);
454 double layerInteg = getIntegral(histo,1,nBinsX,binY,binY,
true);
456 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" layer: " << layID <<
" integral: " << layerInteg << endl;
459 bool alreadyMonitored =
false;
460 if(monitoredLayers.find(layID) != monitoredLayers.end()) alreadyMonitored =
true;
463 if(layerInteg == 0) {
464 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" fail layer: no entries" << endl;
466 if(!alreadyMonitored) monitoredLayers.insert(layID);
469 histo->SetBinContent(nBinsX+1,binY,-1.);
477 if(monitoredLayers.find(layID) == monitoredLayers.end()) monitoredLayers.insert(layID);
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;
559 if(tpMode)
return string(
"DT/10-TestPulses/");
560 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)
int getIntegral(TH2F *histo, int, int, int, int, bool)
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