31 LogVerbatim(
"DTDQM|DTMonitorClient|DTOccupancyTestML") <<
"[DTOccupancyTestML]: Constructor";
39 rootFile =
new TFile(
"MLDTOccupancyTest.root",
"RECREATE");
40 ntuple =
new TNtuple(
"OccupancyNtuple",
42 "ls:wh:st:se:lay1MeanCell:lay1RMS:lay2MeanCell:lay2RMS:lay3MeanCell:lay3RMS:lay4MeanCell:"
43 "lay4RMS:lay5MeanCell:lay5RMS:lay6MeanCell:lay6RMS:lay7MeanCell:lay7RMS:lay8MeanCell:lay8RMS:"
44 "lay9MeanCell:lay9RMS:lay10MeanCell:lay10RMS:lay11MeanCell:lay11RMS:lay12MeanCell:lay12RMS");
64 LogVerbatim(
"DTDQM|DTMonitorClient|MLDTOccupancyTest") <<
" destructor called" << endl;
68 LogVerbatim(
"DTDQM|DTMonitorClient|DTOccupancyTestML") <<
"[DTOccupancyTestML]: BeginRun";
81 for (
int wh = -2; wh <= 2; ++wh) {
82 bookHistos(ibooker, wh,
string(
"MLDTOccupancies"),
"MLOccupancySummary");
86 string title =
"Occupancy Summary";
88 title =
"Test Pulse Occupancy Summary";
91 summaryHisto = ibooker.
book2D(
"MLOccupancySummary",
title.c_str(), 12, 1, 13, 5, -2, 3);
93 summaryHisto->setAxisTitle(
"wheel", 2);
96 glbSummaryHisto = ibooker.
book2D(
"MLOccupancyGlbSummary",
title.c_str(), 12, 1, 13, 5, -2, 3);
98 glbSummaryHisto->setAxisTitle(
"wheel", 2);
102 nameMonitoredHisto =
"OccupancyAllHits_perCh";
104 nameMonitoredHisto =
"OccupancyNoise_perCh";
106 nameMonitoredHisto =
"OccupancyInTimeHits_perCh";
108 nameMonitoredHisto =
"OccupancyAllHits_perCh";
113 LogVerbatim(
"DTDQM|DTMonitorClient|DTOccupancyTestML")
114 <<
"[DTOccupancyTestML]: End of LS transition, performing the DQM client operation";
118 summaryHisto->Reset();
119 glbSummaryHisto->Reset();
125 vector<const DTChamber*>
chambers = muonGeom->chambers();
129 edm::FileInPath modelFilePath(
"DQM/DTMonitorClient/data/occupancy_cnn_v1.pb");
139 MonitorElement* chamberOccupancyHisto = igetter.
get(getMEName(nameMonitoredHisto, chId));
142 if (chamberOccupancyHisto !=
nullptr) {
146 float chamberPercentage = 1.;
147 int result = runOccupancyTest(
histo, chId, chamberPercentage, graphDef, session);
148 int sector = chId.
sector();
152 float resultSect4 = wheelHistos[chId.
wheel()]->getBinContent(sector, chId.
station());
153 if (resultSect4 >
result) {
156 }
else if (sector == 14) {
158 float resultSect10 = wheelHistos[chId.
wheel()]->getBinContent(sector, chId.
station());
159 if (resultSect10 >
result) {
165 if ((sector == 4 || sector == 10) && chId.
station() == 4)
166 chamberPercentage = chamberPercentage / 2.;
169 if (
result > summaryHisto->getBinContent(sector, chId.
wheel() + 3)) {
170 summaryHisto->setBinContent(sector, chId.
wheel() + 3,
result);
172 glbSummaryHisto->Fill(sector, chId.
wheel(), chamberPercentage * 1. / 4.);
174 LogVerbatim(
"DTDQM|DTMonitorClient|DTOccupancyTestML")
175 <<
"[DTOccupancyTestML] ME: " << getMEName(nameMonitoredHisto, chId) <<
" not found!" << endl;
183 string nEvtsName =
"DT/EventInfo/Counters/nProcessedEventsDigi";
189 glbSummaryHisto->setEntries(nProcEvts < nMinEvts ? 10. : nProcEvts);
190 summaryHisto->setEntries(nProcEvts < nMinEvts ? 10. : nProcEvts);
192 glbSummaryHisto->setEntries(nMinEvts + 1);
193 summaryHisto->setEntries(nMinEvts + 1);
194 LogVerbatim(
"DTDQM|DTMonitorClient|DTOccupancyTestML")
195 <<
"[DTOccupancyTestML] ME: " << nEvtsName <<
" not found!" << endl;
203 ntuple->AutoSave(
"SaveSelf");
207 LogVerbatim(
"DTDQM|DTMonitorClient|DTOccupancyTestML") <<
"[DTOccupancyTestML] endjob called!";
227 LogVerbatim(
"DTDQM|DTMonitorClient|DTOccupancyTestML")
228 <<
"[DTOccupancyTestML]: booking wheel histo:" <<
histoName <<
" (tag " <<
histoTag
229 <<
") in: " << topFolder(
true) +
"Wheel" +
wheel.str() +
"/" +
folder << endl;
231 string histoTitle =
"Occupancy summary WHEEL: " +
wheel.str();
233 histoTitle =
"TP Occupancy summary WHEEL: " +
wheel.str();
236 wheelHistos[wheelId] = ibooker.
book2D(
histoName, histoTitle, 12, 1, 13, 4, 1, 5);
238 wheelHistos[wheelId]->setBinLabel(2,
"MB2", 2);
239 wheelHistos[wheelId]->setBinLabel(3,
"MB3", 2);
240 wheelHistos[wheelId]->setBinLabel(4,
"MB4", 2);
241 wheelHistos[wheelId]->setAxisTitle(
"sector", 1);
253 topFolder(
false) +
"Wheel" +
wheel.str() +
"/Sector" + sector.str() +
"/Station" +
station.str() +
"/";
265 for (Int_t
i = firstBinX;
i < lastBinX + 1;
i++) {
266 for (Int_t
j = firstBinY;
j < lastBinY + 1;
j++) {
267 if (
histo->GetBinContent(
i,
j) > 0) {
270 sum +=
histo->GetBinContent(
i,
j);
280 float& chamberPercentage,
281 tensorflow::GraphDef* graphDef,
282 tensorflow::Session* session) {
283 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTestML") <<
"--- Occupancy test for chamber: " << chId << endl;
290 for (
int superLayer = 1; superLayer <= 3; superLayer++) {
291 int binYlow = ((superLayer - 1) * 4) + 1;
294 if (chId.
station() == 4 && superLayer == 2)
298 for (
int layer = 1; layer <= 4; layer++) {
299 DTLayerId layID(chId, superLayer, layer);
300 int firstWire = muonGeom->layer(layID)->specificTopology().firstChannel();
301 int nWires = muonGeom->layer(layID)->specificTopology().channels();
302 int binY = binYlow + (layer - 1);
303 std::vector<float> layerOccupancy(nWires);
307 for (
int cell = firstWire; cell != (nWires + firstWire); cell++) {
308 double cellOccupancy =
histo->GetBinContent(cell, binY);
309 layerOccupancy.at(channelId) = cellOccupancy;
314 std::vector<float> reshapedLayerOccupancy = interpolateLayers(layerOccupancy, nWires, targetSize);
317 float maxOccupancyInLayer = *std::max_element(reshapedLayerOccupancy.begin(), reshapedLayerOccupancy.end());
319 if (maxOccupancyInLayer != 0) {
320 for (
auto&
val : reshapedLayerOccupancy)
321 val /= maxOccupancyInLayer;
325 tensorflow::Tensor
input(tensorflow::DT_FLOAT, {1, targetSize});
326 for (
int i = 0;
i < targetSize;
i++)
327 input.matrix<
float>()(0,
i) = reshapedLayerOccupancy[
i];
329 std::vector<tensorflow::Tensor>
outputs;
333 bool isBad =
outputs[0].matrix<
float>()(0, 1) > 0.95;
340 chamberPercentage = 1.0 - static_cast<float>(badLayers) / totalLayers;
353 int interpolationFloor = 0;
354 float interpolationPoint = 0.;
355 float step = static_cast<float>(
size) / targetSize;
356 std::vector<float> reshapedInput(targetSize);
358 for (
int i = 0;
i < targetSize;
i++) {
359 interpolationFloor = static_cast<int>(std::floor(interpolationPoint));
361 reshapedInput.at(
i) =
362 (interpolationPoint - interpolationFloor) * (
inputs[interpolationFloor + 1] -
inputs[interpolationFloor]) +
363 inputs[interpolationFloor];
364 interpolationPoint =
step + interpolationPoint;
366 return reshapedInput;
371 return string(
"DT/10-TestPulses/");
373 return string(
"DT/01-Digi/ML");
374 return string(
"DT/01-Digi/");