|
|
Go to the documentation of this file.
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 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/");
std::string topFolder(bool isBooking) const
Session * createSession(SessionOptions &sessionOptions)
void bookHistos(DQMStore::IBooker &, const int wheelId, std::string folder, std::string histoTag)
book the summary histograms
static const std::string input
std::string nameMonitoredHisto
virtual void setEntries(double nentries)
set # of entries
DTOccupancyTestML(const edm::ParameterSet &ps)
Constructor.
std::vector< float > interpolateLayers(std::vector< float > const &inputs, int size, int targetSize)
virtual void setCurrentFolder(std::string const &fullpath)
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
DQM Client Diagnostic.
int getIntegral(TH2F *histo, int, int, int, int, bool)
int channels() const
Returns the number of wires in the layer.
T getUntrackedParameter(std::string const &, T const &) const
bool runOnInTimeOccupancies
bool closeSession(Session *&session)
MonitorElement * glbSummaryHisto
MonitorElement * summaryHisto
int firstChannel() const
Returns the wire number of the first wire.
const DTGeometry * muonGeom
std::string getMEName(std::string histoTag, const DTChamberId &chId)
Get the ME name.
const std::vector< const DTChamber * > & chambers() const
Return a vector of all Chamber.
virtual void Reset()
Remove all data from the ME, keept the empty histogram with all its settings.
int runOccupancyTest(TH2F *histo, const DTChamberId &chId, float &chamberPercentage, tensorflow::GraphDef *graphDef, tensorflow::Session *session)
constexpr std::array< uint8_t, layerIndexSize > layer
virtual double getFloatValue() const
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
static char chambers[264][20]
void setLogging(const std::string &level="3")
void beginRun(edm::Run const &run, edm::EventSetup const &context) override
BeginRun.
GraphDef * loadGraphDef(const std::string &pbFile)
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
bool runOnAllHitsOccupancies
bool runOnNoiseOccupancies
Log< level::Info, true > LogVerbatim
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
void run(Session *session, const NamedTensorList &inputs, const std::vector< std::string > &outputNames, std::vector< Tensor > *outputs, const thread::ThreadPoolOptions &threadPoolOptions)
virtual MonitorElement * get(std::string const &fullpath) const
const DTTopology & specificTopology() const
std::map< int, MonitorElement * > wheelHistos
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
Endjob.
~DTOccupancyTestML() override
Destructor.
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
virtual double getBinContent(int binx) const
get content of bin (1-D)
int wheel() const
Return the wheel number.
edm::ESGetToken< DTGeometry, MuonGeometryRecord > muonGeomToken_
std::string fullPath() const
int station() const
Return the station number.
virtual TH2F * getTH2F() const