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";
129 edm::FileInPath modelFilePath(
"DQM/DTMonitorClient/data/occupancy_cnn_v1.pb");
142 if (chamberOccupancyHisto !=
nullptr) {
146 float chamberPercentage = 1.;
148 int sector = chId.
sector();
153 if (resultSect4 >
result) {
156 }
else if (sector == 14) {
159 if (resultSect10 >
result) {
165 if ((sector == 4 || sector == 10) && chId.
station() == 4)
166 chamberPercentage = chamberPercentage / 2.;
174 LogVerbatim(
"DTDQM|DTMonitorClient|DTOccupancyTestML")
183 string nEvtsName =
"DT/EventInfo/Counters/nProcessedEventsDigi";
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 231 string histoTitle =
"Occupancy summary WHEEL: " +
wheel.str();
233 histoTitle =
"TP Occupancy summary WHEEL: " +
wheel.str();
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)
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 int limitInLoop =
inputs.size();
359 limitInLoop =
std::min(limitInLoop, targetSize) - 1;
360 for (
int i = 0;
i < limitInLoop;
i++) {
361 interpolationFloor =
static_cast<int>(std::floor(interpolationPoint));
363 reshapedInput.at(
i) =
364 (interpolationPoint - interpolationFloor) * (
inputs[interpolationFloor + 1] -
inputs[interpolationFloor]) +
365 inputs[interpolationFloor];
366 interpolationPoint =
step + interpolationPoint;
368 return reshapedInput;
373 return string(
"DT/10-TestPulses/");
375 return string(
"DT/01-Digi/ML");
376 return string(
"DT/01-Digi/");
Session * createSession(SessionOptions &sessionOptions)
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
constexpr std::array< uint8_t, layerIndexSize > layer
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)
void setLogging(const std::string &level="3")
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)