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";
113 LogVerbatim(
"DTDQM|DTMonitorClient|DTOccupancyTestML")
114 <<
"[DTOccupancyTestML]: End of LS transition, performing the DQM client operation";
128 edm::FileInPath modelFilePath(
"DQM/DTMonitorClient/data/occupancy_cnn_v1.pb");
141 if (chamberOccupancyHisto !=
nullptr) {
145 float chamberPercentage = 1.;
152 if (resultSect4 >
result) {
155 }
else if (
sector == 14) {
158 if (resultSect10 >
result) {
165 chamberPercentage = chamberPercentage / 2.;
173 LogVerbatim(
"DTDQM|DTMonitorClient|DTOccupancyTestML")
182 string nEvtsName =
"DT/EventInfo/Counters/nProcessedEventsDigi";
193 LogVerbatim(
"DTDQM|DTMonitorClient|DTOccupancyTestML")
194 <<
"[DTOccupancyTestML] ME: " << nEvtsName <<
" not found!" << endl;
202 ntuple->AutoSave(
"SaveSelf");
206 LogVerbatim(
"DTDQM|DTMonitorClient|DTOccupancyTestML") <<
"[DTOccupancyTestML] endjob called!";
226 LogVerbatim(
"DTDQM|DTMonitorClient|DTOccupancyTestML")
227 <<
"[DTOccupancyTestML]: booking wheel histo:" <<
histoName <<
" (tag " <<
histoTag 230 string histoTitle =
"Occupancy summary WHEEL: " +
wheel.str();
232 histoTitle =
"TP Occupancy summary WHEEL: " +
wheel.str();
264 for (Int_t
i = firstBinX;
i < lastBinX + 1;
i++) {
265 for (Int_t
j = firstBinY;
j < lastBinY + 1;
j++) {
266 if (
histo->GetBinContent(
i,
j) > 0) {
269 sum +=
histo->GetBinContent(
i,
j);
279 float& chamberPercentage,
280 tensorflow::GraphDef* graphDef,
281 tensorflow::Session* session) {
282 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTestML") <<
"--- Occupancy test for chamber: " << chId << endl;
301 int binY = binYlow + (
layer - 1);
302 std::vector<float> layerOccupancy(nWires);
306 for (
int cell = firstWire; cell != (nWires + firstWire); cell++) {
307 double cellOccupancy =
histo->GetBinContent(cell, binY);
308 layerOccupancy.at(channelId) = cellOccupancy;
313 std::vector<float> reshapedLayerOccupancy =
interpolateLayers(layerOccupancy, nWires, targetSize);
316 float maxOccupancyInLayer = *std::max_element(reshapedLayerOccupancy.begin(), reshapedLayerOccupancy.end());
318 if (maxOccupancyInLayer != 0) {
319 for (
auto&
val : reshapedLayerOccupancy)
320 val /= maxOccupancyInLayer;
324 tensorflow::Tensor
input(tensorflow::DT_FLOAT, {1, targetSize});
325 for (
int i = 0;
i < targetSize;
i++)
326 input.matrix<
float>()(0,
i) = reshapedLayerOccupancy[
i];
328 std::vector<tensorflow::Tensor>
outputs;
332 bool isBad =
outputs[0].matrix<
float>()(0, 1) > 0.95;
339 chamberPercentage = 1.0 -
static_cast<float>(badLayers) / totalLayers;
352 int interpolationFloor = 0;
353 float interpolationPoint = 0.;
354 float step =
static_cast<float>(
size) / targetSize;
355 std::vector<float> reshapedInput(targetSize);
357 int limitInLoop =
inputs.size();
358 limitInLoop =
std::min(limitInLoop, targetSize) - 1;
359 for (
int i = 0;
i < limitInLoop;
i++) {
360 interpolationFloor =
static_cast<int>(std::floor(interpolationPoint));
362 reshapedInput.at(
i) =
363 (interpolationPoint - interpolationFloor) * (
inputs[interpolationFloor + 1] -
inputs[interpolationFloor]) +
364 inputs[interpolationFloor];
365 interpolationPoint =
step + interpolationPoint;
367 return reshapedInput;
372 return string(
"DT/10-TestPulses/");
374 return string(
"DT/01-Digi/ML");
375 return string(
"DT/01-Digi/");
Log< level::Info, true > LogVerbatim
int station() const
Return the station number.
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
Endjob.
int getIntegral(TH2F *histo, int, int, int, int, bool)
std::string fullPath() const
virtual void setCurrentFolder(std::string const &fullpath)
virtual void setEntries(double nentries)
set # of entries
GraphDef * loadGraphDef(const std::string &pbFile)
void bookHistos(DQMStore::IBooker &, const int wheelId, std::string folder, std::string histoTag)
book the summary histograms
std::vector< float > interpolateLayers(std::vector< float > const &inputs, int size, int targetSize)
MonitorElement * summaryHisto
bool runOnInTimeOccupancies
static std::string const input
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
DQM Client Diagnostic.
T getUntrackedParameter(std::string const &, T const &) const
int firstChannel() const
Returns the wire number of the first wire.
virtual TH2F * getTH2F() const
virtual void Reset()
Remove all data from the ME, keept the empty histogram with all its settings.
std::string getMEName(std::string histoTag, const DTChamberId &chId)
Get the ME name.
const DTGeometry * muonGeom
virtual double getFloatValue() const
void run(Session *session, const NamedTensorList &inputs, const std::vector< std::string > &outputNames, std::vector< Tensor > *outputs, const thread::ThreadPoolOptions &threadPoolOptions)
bool closeSession(Session *&session)
void beginRun(edm::Run const &run, edm::EventSetup const &context) override
BeginRun.
MonitorElement * glbSummaryHisto
const DTTopology & specificTopology() const
int runOccupancyTest(TH2F *histo, const DTChamberId &chId, float &chamberPercentage, tensorflow::GraphDef *graphDef, tensorflow::Session *session)
Session * createSession()
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
bool runOnNoiseOccupancies
bool runOnAllHitsOccupancies
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
virtual MonitorElement * get(std::string const &fullpath) const
~DTOccupancyTestML() override
Destructor.
int wheel() const
Return the wheel number.
edm::ESGetToken< DTGeometry, MuonGeometryRecord > muonGeomToken_
std::map< int, MonitorElement * > wheelHistos
std::string topFolder(bool isBooking) const
const std::vector< const DTChamber * > & chambers() const
Return a vector of all Chamber.
static char chambers[264][20]
std::string nameMonitoredHisto
DTOccupancyTestML(const edm::ParameterSet &ps)
Constructor.
int channels() const
Returns the number of wires in the layer.
virtual double getBinContent(int binx) const
get content of bin (1-D)
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)