CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
DTOccupancyTestML Class Reference

#include <DTOccupancyTestML.h>

Inheritance diagram for DTOccupancyTestML:
DQMEDHarvester edm::one::EDProducer< edm::EndLuminosityBlockProducer, edm::EndRunProducer, edm::EndProcessBlockProducer, edm::one::WatchLuminosityBlocks, edm::one::WatchRuns, edm::one::SharedResources, edm::Accumulator > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 DTOccupancyTestML (const edm::ParameterSet &ps)
 Constructor. More...
 
 ~DTOccupancyTestML () override
 Destructor. More...
 
- Public Member Functions inherited from DQMEDHarvester
void accumulate (edm::Event const &ev, edm::EventSetup const &es) final
 
void beginJob () override
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &) final
 
void beginRun (edm::Run const &run, edm::EventSetup const &) override
 
virtual void dqmAnalyze (DQMStore::IBooker &, DQMStore::IGetter &, edm::Event const &, edm::EventSetup const &)
 
 DQMEDHarvester ()
 
 DQMEDHarvester (edm::ParameterSet const &iConfig)
 
virtual void dqmEndRun (DQMStore::IBooker &, DQMStore::IGetter &, edm::Run const &, edm::EventSetup const &)
 
void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
void endLuminosityBlockProduce (edm::LuminosityBlock &lumi, edm::EventSetup const &es) final
 
void endProcessBlockProduce (edm::ProcessBlock &) final
 
void endRun (edm::Run const &, edm::EventSetup const &) override
 
void endRunProduce (edm::Run &run, edm::EventSetup const &es) final
 
 ~DQMEDHarvester () override=default
 
- Public Member Functions inherited from edm::one::EDProducer< edm::EndLuminosityBlockProducer, edm::EndRunProducer, edm::EndProcessBlockProducer, edm::one::WatchLuminosityBlocks, edm::one::WatchRuns, edm::one::SharedResources, edm::Accumulator >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Protected Member Functions

void beginRun (edm::Run const &run, edm::EventSetup const &context) override
 BeginRun. More...
 
void dqmEndJob (DQMStore::IBooker &, DQMStore::IGetter &) override
 Endjob. More...
 
void dqmEndLuminosityBlock (DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
 DQM Client Diagnostic. More...
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Private Member Functions

void bookHistos (DQMStore::IBooker &, const int wheelId, std::string folder, std::string histoTag)
 book the summary histograms More...
 
int getIntegral (TH2F *histo, int, int, int, int, bool)
 
std::string getMEName (std::string histoTag, const DTChamberId &chId)
 Get the ME name. More...
 
std::vector< float > interpolateLayers (std::vector< float > const &inputs, int size, int targetSize)
 
int runOccupancyTest (TH2F *histo, const DTChamberId &chId, float &chamberPercentage, tensorflow::GraphDef *graphDef, tensorflow::Session *session)
 
std::string topFolder (bool isBooking) const
 

Private Attributes

bool bookingdone
 
MonitorElementglbSummaryHisto
 
int lsCounter
 
std::set< DTLayerIdmonitoredLayers
 
const DTGeometrymuonGeom
 
edm::ESGetToken< DTGeometry, MuonGeometryRecordmuonGeomToken_
 
std::string nameMonitoredHisto
 
int nChannelDead
 
int nChannelTotal
 
int nevents
 
int nMinEvts
 
int nMinEvtsPC
 
TNtuple * ntuple
 
int nZeroEvtsPC
 
TFile * rootFile
 
bool runOnAllHitsOccupancies
 
bool runOnInTimeOccupancies
 
bool runOnNoiseOccupancies
 
MonitorElementsummaryHisto
 
bool tpMode
 
std::map< int, MonitorElement * > wheelHistos
 
bool writeRootFile
 

Additional Inherited Members

- Public Types inherited from DQMEDHarvester
typedef dqm::harvesting::DQMStore DQMStore
 
typedef dqm::harvesting::MonitorElement MonitorElement
 
- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Attributes inherited from DQMEDHarvester
DQMStoredqmstore_
 
edm::GetterOfProducts< DQMTokenjobmegetter_
 
edm::EDPutTokenT< DQMTokenjobToken_
 
edm::GetterOfProducts< DQMTokenlumimegetter_
 
edm::EDPutTokenT< DQMTokenlumiToken_
 
edm::GetterOfProducts< DQMTokenrunmegetter_
 
edm::EDPutTokenT< DQMTokenrunToken_
 

Detailed Description

Definition at line 38 of file DTOccupancyTestML.h.

Constructor & Destructor Documentation

◆ DTOccupancyTestML()

DTOccupancyTestML::DTOccupancyTestML ( const edm::ParameterSet ps)

Constructor.

Definition at line 29 of file DTOccupancyTestML.cc.

30  : muonGeomToken_(esConsumes<edm::Transition::BeginRun>()) {
31  LogVerbatim("DTDQM|DTMonitorClient|DTOccupancyTestML") << "[DTOccupancyTestML]: Constructor";
32 
33  // Get the DQM service
34 
35  lsCounter = 0;
36 
37  writeRootFile = ps.getUntrackedParameter<bool>("writeRootFile", false);
38  if (writeRootFile) {
39  rootFile = new TFile("MLDTOccupancyTest.root", "RECREATE");
40  ntuple = new TNtuple("OccupancyNtuple",
41  "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");
45  }
46 
47  // switch on the mode for running on test pulses (different top folder)
48  tpMode = ps.getUntrackedParameter<bool>("testPulseMode", false);
49 
50  runOnAllHitsOccupancies = ps.getUntrackedParameter<bool>("runOnAllHitsOccupancies", true);
51  runOnNoiseOccupancies = ps.getUntrackedParameter<bool>("runOnNoiseOccupancies", false);
52  runOnInTimeOccupancies = ps.getUntrackedParameter<bool>("runOnInTimeOccupancies", false);
53  nMinEvts = ps.getUntrackedParameter<int>("nEventsCert", 5000);
54  nMinEvtsPC = ps.getUntrackedParameter<int>("nEventsMinPC", 2200);
55  nZeroEvtsPC = ps.getUntrackedParameter<int>("nEventsZeroPC", 30);
56 
57  bookingdone = false;
58 
59  // Event counter
60  nevents = 0;
61 }

References bookingdone, edm::ParameterSet::getUntrackedParameter(), lsCounter, nevents, nMinEvts, nMinEvtsPC, nZeroEvtsPC, rootFile, runOnAllHitsOccupancies, runOnInTimeOccupancies, runOnNoiseOccupancies, tpMode, and writeRootFile.

◆ ~DTOccupancyTestML()

DTOccupancyTestML::~DTOccupancyTestML ( )
override

Destructor.

Definition at line 63 of file DTOccupancyTestML.cc.

63  {
64  LogVerbatim("DTDQM|DTMonitorClient|MLDTOccupancyTest") << " destructor called" << endl;
65 }

Member Function Documentation

◆ beginRun()

void DTOccupancyTestML::beginRun ( edm::Run const &  run,
edm::EventSetup const &  context 
)
overrideprotected

BeginRun.

Definition at line 67 of file DTOccupancyTestML.cc.

67  {
68  LogVerbatim("DTDQM|DTMonitorClient|DTOccupancyTestML") << "[DTOccupancyTestML]: BeginRun";
69 
70  // Get the geometry
71  muonGeom = &context.getData(muonGeomToken_);
72 }

References visDQMUpload::context, muonGeom, and muonGeomToken_.

◆ bookHistos()

void DTOccupancyTestML::bookHistos ( DQMStore::IBooker ,
const int  wheelId,
std::string  folder,
std::string  histoTag 
)
private

book the summary histograms

Definition at line 217 of file DTOccupancyTestML.cc.

217  {
218  // Set the current folder
219  stringstream wheel;
220  wheel << wheelId;
221 
222  ibooker.setCurrentFolder(topFolder(true));
223 
224  // build the histo name
225  string histoName = histoTag + "_W" + wheel.str();
226 
227  LogVerbatim("DTDQM|DTMonitorClient|DTOccupancyTestML")
228  << "[DTOccupancyTestML]: booking wheel histo:" << histoName << " (tag " << histoTag
229  << ") in: " << topFolder(true) + "Wheel" + wheel.str() + "/" + folder << endl;
230 
231  string histoTitle = "Occupancy summary WHEEL: " + wheel.str();
232  if (tpMode) {
233  histoTitle = "TP Occupancy summary WHEEL: " + wheel.str();
234  }
235 
236  wheelHistos[wheelId] = ibooker.book2D(histoName, histoTitle, 12, 1, 13, 4, 1, 5);
237  wheelHistos[wheelId]->setBinLabel(1, "MB1", 2);
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);
242 }

References dqm::implementation::IBooker::book2D(), printsummarytable::folder, HltBtagPostValidation_cff::histoName, dtResolutionTest_cfi::histoTag, dqm::implementation::NavigatorBase::setCurrentFolder(), topFolder(), tpMode, makeMuonMisalignmentScenario::wheel, and wheelHistos.

Referenced by dqmEndLuminosityBlock().

◆ dqmEndJob()

void DTOccupancyTestML::dqmEndJob ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter 
)
overrideprotectedvirtual

Endjob.

Implements DQMEDHarvester.

Definition at line 206 of file DTOccupancyTestML.cc.

206  {
207  LogVerbatim("DTDQM|DTMonitorClient|DTOccupancyTestML") << "[DTOccupancyTestML] endjob called!";
208  if (writeRootFile) {
209  rootFile->cd();
210  ntuple->Write();
211  rootFile->Close();
212  }
213 }

References rootFile, and writeRootFile.

◆ dqmEndLuminosityBlock()

void DTOccupancyTestML::dqmEndLuminosityBlock ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter,
edm::LuminosityBlock const &  lumiSeg,
edm::EventSetup const &  context 
)
overrideprotectedvirtual

DQM Client Diagnostic.

Reimplemented from DQMEDHarvester.

Definition at line 74 of file DTOccupancyTestML.cc.

77  {
78  if (!bookingdone) {
79  // Book the summary histos
80  // - one summary per wheel
81  for (int wh = -2; wh <= 2; ++wh) { // loop over wheels
82  bookHistos(ibooker, wh, string("MLDTOccupancies"), "MLOccupancySummary");
83  }
84 
85  ibooker.setCurrentFolder(topFolder(true));
86  string title = "Occupancy Summary";
87  if (tpMode) {
88  title = "Test Pulse Occupancy Summary";
89  }
90  // - global summary with alarms
91  summaryHisto = ibooker.book2D("MLOccupancySummary", title.c_str(), 12, 1, 13, 5, -2, 3);
92  summaryHisto->setAxisTitle("sector", 1);
93  summaryHisto->setAxisTitle("wheel", 2);
94 
95  // - global summary with percentages
96  glbSummaryHisto = ibooker.book2D("MLOccupancyGlbSummary", title.c_str(), 12, 1, 13, 5, -2, 3);
97  glbSummaryHisto->setAxisTitle("sector", 1);
98  glbSummaryHisto->setAxisTitle("wheel", 2);
99 
100  // assign the name of the input histogram
102  nameMonitoredHisto = "OccupancyAllHits_perCh";
103  } else if (runOnNoiseOccupancies) {
104  nameMonitoredHisto = "OccupancyNoise_perCh";
105  } else if (runOnInTimeOccupancies) {
106  nameMonitoredHisto = "OccupancyInTimeHits_perCh";
107  } else { // default is AllHits histo
108  nameMonitoredHisto = "OccupancyAllHits_perCh";
109  }
110  }
111  bookingdone = true;
112 
113  LogVerbatim("DTDQM|DTMonitorClient|DTOccupancyTestML")
114  << "[DTOccupancyTestML]: End of LS transition, performing the DQM client operation";
115  lsCounter++;
116 
117  // Reset the global summary
118  summaryHisto->Reset();
120 
121  nChannelTotal = 0;
122  nChannelDead = 0;
123 
124  // Get all the DT chambers
125  vector<const DTChamber*> chambers = muonGeom->chambers();
126 
127  // Load graph
129  edm::FileInPath modelFilePath("DQM/DTMonitorClient/data/occupancy_cnn_v1.pb");
130  tensorflow::GraphDef* graphDef = tensorflow::loadGraphDef(modelFilePath.fullPath());
131 
132  // Create session
133  tensorflow::Session* session = tensorflow::createSession(graphDef);
134 
135  for (vector<const DTChamber*>::const_iterator chamber = chambers.begin(); chamber != chambers.end();
136  ++chamber) { // Loop over all chambers
137  DTChamberId chId = (*chamber)->id();
138 
139  MonitorElement* chamberOccupancyHisto = igetter.get(getMEName(nameMonitoredHisto, chId));
140 
141  // Run the tests on the plot for the various granularities
142  if (chamberOccupancyHisto != nullptr) {
143  // Get the 2D histo
144  TH2F* histo = chamberOccupancyHisto->getTH2F();
145 
146  float chamberPercentage = 1.;
147  int result = runOccupancyTest(histo, chId, chamberPercentage, graphDef, session);
148  int sector = chId.sector();
149 
150  if (sector == 13) {
151  sector = 4;
152  float resultSect4 = wheelHistos[chId.wheel()]->getBinContent(sector, chId.station());
153  if (resultSect4 > result) {
154  result = (int)resultSect4;
155  }
156  } else if (sector == 14) {
157  sector = 10;
158  float resultSect10 = wheelHistos[chId.wheel()]->getBinContent(sector, chId.station());
159  if (resultSect10 > result) {
160  result = (int)resultSect10;
161  }
162  }
163 
164  // the 2 MB4 of Sect 4 and 10 count as half a chamber
165  if ((sector == 4 || sector == 10) && chId.station() == 4)
166  chamberPercentage = chamberPercentage / 2.;
167 
168  wheelHistos[chId.wheel()]->setBinContent(sector, chId.station(), result);
169  if (result > summaryHisto->getBinContent(sector, chId.wheel() + 3)) {
170  summaryHisto->setBinContent(sector, chId.wheel() + 3, result);
171  }
172  glbSummaryHisto->Fill(sector, chId.wheel(), chamberPercentage * 1. / 4.);
173  } else {
174  LogVerbatim("DTDQM|DTMonitorClient|DTOccupancyTestML")
175  << "[DTOccupancyTestML] ME: " << getMEName(nameMonitoredHisto, chId) << " not found!" << endl;
176  }
177  }
178 
179  // Clean up neural network graph
180  tensorflow::closeSession(session);
181  delete graphDef;
182 
183  string nEvtsName = "DT/EventInfo/Counters/nProcessedEventsDigi";
184 
185  MonitorElement* meProcEvts = igetter.get(nEvtsName);
186 
187  if (meProcEvts) {
188  int nProcEvts = meProcEvts->getFloatValue();
189  glbSummaryHisto->setEntries(nProcEvts < nMinEvts ? 10. : nProcEvts);
190  summaryHisto->setEntries(nProcEvts < nMinEvts ? 10. : nProcEvts);
191  } else {
194  LogVerbatim("DTDQM|DTMonitorClient|DTOccupancyTestML")
195  << "[DTOccupancyTestML] ME: " << nEvtsName << " not found!" << endl;
196  }
197 
198  // Fill the global summary
199  // Check for entire sectors off and report them on the global summary
200  //FIXME: TODO
201 
202  if (writeRootFile)
203  ntuple->AutoSave("SaveSelf");
204 }

References dqm::implementation::IBooker::book2D(), bookHistos(), bookingdone, relativeConstraints::chamber, DTGeometry::chambers(), chambers, tensorflow::closeSession(), tensorflow::createSession(), dqm::impl::MonitorElement::Fill(), edm::FileInPath::fullPath(), dqm::implementation::IGetter::get(), dqm::impl::MonitorElement::getBinContent(), dqm::impl::MonitorElement::getFloatValue(), getMEName(), dqm::legacy::MonitorElement::getTH2F(), glbSummaryHisto, timingPdfMaker::histo, createfilelist::int, tensorflow::loadGraphDef(), lsCounter, muonGeom, nameMonitoredHisto, nChannelDead, nChannelTotal, nMinEvts, dqm::impl::MonitorElement::Reset(), mps_fire::result, runOccupancyTest(), runOnAllHitsOccupancies, runOnInTimeOccupancies, runOnNoiseOccupancies, DTChamberId::sector(), dqm::impl::MonitorElement::setAxisTitle(), dqm::impl::MonitorElement::setBinContent(), dqm::implementation::NavigatorBase::setCurrentFolder(), dqm::impl::MonitorElement::setEntries(), tensorflow::setLogging(), DTChamberId::station(), summaryHisto, runGCPTkAlMap::title, topFolder(), tpMode, DTChamberId::wheel(), wheelHistos, and writeRootFile.

◆ getIntegral()

int DTOccupancyTestML::getIntegral ( TH2F *  histo,
int  firstBinX,
int  lastBinX,
int  firstBinY,
int  lastBinY,
bool  doall 
)
private

Definition at line 263 of file DTOccupancyTestML.cc.

263  {
264  int sum = 0;
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) {
268  if (!doall)
269  return 1;
270  sum += histo->GetBinContent(i, j);
271  }
272  }
273  }
274 
275  return sum;
276 }

References DTRecHitClients_cfi::doall, timingPdfMaker::histo, mps_fire::i, and dqmiolumiharvest::j.

◆ getMEName()

string DTOccupancyTestML::getMEName ( std::string  histoTag,
const DTChamberId chId 
)
private

Get the ME name.

Definition at line 244 of file DTOccupancyTestML.cc.

244  {
245  stringstream wheel;
246  wheel << chId.wheel();
247  stringstream station;
248  station << chId.station();
249  stringstream sector;
250  sector << chId.sector();
251 
252  string folderRoot =
253  topFolder(false) + "Wheel" + wheel.str() + "/Sector" + sector.str() + "/Station" + station.str() + "/";
254 
255  // build the histo name
256  string histoName = histoTag + "_W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str();
257 
258  string histoname = folderRoot + histoName;
259 
260  return histoname;
261 }

References dtChamberEfficiencyTest_cfi::folderRoot, HltBtagPostValidation_cff::histoName, dtResolutionTest_cfi::histoTag, DTChamberId::sector(), DTChamberId::station(), relativeConstraints::station, topFolder(), DTChamberId::wheel(), and makeMuonMisalignmentScenario::wheel.

Referenced by dqmEndLuminosityBlock().

◆ interpolateLayers()

std::vector< float > DTOccupancyTestML::interpolateLayers ( std::vector< float > const &  inputs,
int  size,
int  targetSize 
)
private

Definition at line 351 of file DTOccupancyTestML.cc.

351  {
352  // Reshape layers with linear interpolation
353  int interpolationFloor = 0;
354  float interpolationPoint = 0.;
355  float step = static_cast<float>(size) / targetSize;
356  std::vector<float> reshapedInput(targetSize);
357 
358  for (int i = 0; i < targetSize; i++) {
359  interpolationFloor = static_cast<int>(std::floor(interpolationPoint));
360  // Interpolating here
361  reshapedInput.at(i) =
362  (interpolationPoint - interpolationFloor) * (inputs[interpolationFloor + 1] - inputs[interpolationFloor]) +
363  inputs[interpolationFloor];
364  interpolationPoint = step + interpolationPoint;
365  }
366  return reshapedInput;
367 }

References mps_fire::i, PixelMapPlotter::inputs, and findQualityFiles::size.

Referenced by runOccupancyTest().

◆ runOccupancyTest()

int DTOccupancyTestML::runOccupancyTest ( TH2F *  histo,
const DTChamberId chId,
float &  chamberPercentage,
tensorflow::GraphDef *  graphDef,
tensorflow::Session *  session 
)
private

Definition at line 278 of file DTOccupancyTestML.cc.

282  {
283  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTestML") << "--- Occupancy test for chamber: " << chId << endl;
284 
285  // Initialize counters
286  int totalLayers = 0;
287  int badLayers = 0;
288 
289  // Loop over the super layers
290  for (int superLayer = 1; superLayer <= 3; superLayer++) {
291  int binYlow = ((superLayer - 1) * 4) + 1;
292 
293  // Skip for non-existent super layers
294  if (chId.station() == 4 && superLayer == 2)
295  continue;
296 
297  // Loop over layers
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);
304  int channelId = 0;
305 
306  // Loop over cells within a layer
307  for (int cell = firstWire; cell != (nWires + firstWire); cell++) {
308  double cellOccupancy = histo->GetBinContent(cell, binY);
309  layerOccupancy.at(channelId) = cellOccupancy;
310  channelId++;
311  }
312 
313  int targetSize = 47;
314  std::vector<float> reshapedLayerOccupancy = interpolateLayers(layerOccupancy, nWires, targetSize);
315 
316  // Scale occupancy
317  float maxOccupancyInLayer = *std::max_element(reshapedLayerOccupancy.begin(), reshapedLayerOccupancy.end());
318 
319  if (maxOccupancyInLayer != 0) {
320  for (auto& val : reshapedLayerOccupancy)
321  val /= maxOccupancyInLayer;
322  }
323 
324  // Define input
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];
328 
329  std::vector<tensorflow::Tensor> outputs;
330  tensorflow::run(session, {{"input_cnn_input", input}}, {"output_cnn/Softmax"}, &outputs);
331 
332  totalLayers++;
333  bool isBad = outputs[0].matrix<float>()(0, 1) > 0.95;
334  if (isBad)
335  badLayers++;
336  }
337  }
338 
339  // Calculate a fraction of good layers
340  chamberPercentage = 1.0 - static_cast<float>(badLayers) / totalLayers;
341 
342  if (badLayers > 8)
343  return 3; // 3 SL
344  if (badLayers > 4)
345  return 2; // 2 SL
346  if (badLayers > 0)
347  return 1; // 1 SL
348  return 0;
349 }

References DTTopology::channels(), DTTopology::firstChannel(), timingPdfMaker::histo, mps_fire::i, input, interpolateLayers(), DTGeometry::layer(), phase1PixelTopology::layer, LogTrace, muonGeom, PatBasicFWLiteJetAnalyzer_Selector_cfg::outputs, tensorflow::run(), DTLayer::specificTopology(), DTChamberId::station(), and heppy_batch::val.

Referenced by dqmEndLuminosityBlock().

◆ topFolder()

string DTOccupancyTestML::topFolder ( bool  isBooking) const
private

Definition at line 369 of file DTOccupancyTestML.cc.

369  {
370  if (tpMode)
371  return string("DT/10-TestPulses/");
372  if (isBooking)
373  return string("DT/01-Digi/ML");
374  return string("DT/01-Digi/");
375 }

References AlCaHLTBitMon_QueryRunRegistry::string, and tpMode.

Referenced by bookHistos(), dqmEndLuminosityBlock(), and getMEName().

Member Data Documentation

◆ bookingdone

bool DTOccupancyTestML::bookingdone
private

Definition at line 107 of file DTOccupancyTestML.h.

Referenced by dqmEndLuminosityBlock(), and DTOccupancyTestML().

◆ glbSummaryHisto

MonitorElement* DTOccupancyTestML::glbSummaryHisto
private

Definition at line 88 of file DTOccupancyTestML.h.

Referenced by dqmEndLuminosityBlock().

◆ lsCounter

int DTOccupancyTestML::lsCounter
private

Definition at line 92 of file DTOccupancyTestML.h.

Referenced by dqmEndLuminosityBlock(), and DTOccupancyTestML().

◆ monitoredLayers

std::set<DTLayerId> DTOccupancyTestML::monitoredLayers
private

Definition at line 90 of file DTOccupancyTestML.h.

◆ muonGeom

const DTGeometry* DTOccupancyTestML::muonGeom
private

Definition at line 83 of file DTOccupancyTestML.h.

Referenced by beginRun(), dqmEndLuminosityBlock(), and runOccupancyTest().

◆ muonGeomToken_

edm::ESGetToken<DTGeometry, MuonGeometryRecord> DTOccupancyTestML::muonGeomToken_
private

Definition at line 82 of file DTOccupancyTestML.h.

Referenced by beginRun().

◆ nameMonitoredHisto

std::string DTOccupancyTestML::nameMonitoredHisto
private

Definition at line 105 of file DTOccupancyTestML.h.

Referenced by dqmEndLuminosityBlock().

◆ nChannelDead

int DTOccupancyTestML::nChannelDead
private

Definition at line 110 of file DTOccupancyTestML.h.

Referenced by dqmEndLuminosityBlock().

◆ nChannelTotal

int DTOccupancyTestML::nChannelTotal
private

Definition at line 109 of file DTOccupancyTestML.h.

Referenced by dqmEndLuminosityBlock().

◆ nevents

int DTOccupancyTestML::nevents
private

Definition at line 80 of file DTOccupancyTestML.h.

Referenced by DTOccupancyTestML().

◆ nMinEvts

int DTOccupancyTestML::nMinEvts
private

Definition at line 93 of file DTOccupancyTestML.h.

Referenced by dqmEndLuminosityBlock(), and DTOccupancyTestML().

◆ nMinEvtsPC

int DTOccupancyTestML::nMinEvtsPC
private

Definition at line 94 of file DTOccupancyTestML.h.

Referenced by DTOccupancyTestML().

◆ ntuple

TNtuple* DTOccupancyTestML::ntuple
private

◆ nZeroEvtsPC

int DTOccupancyTestML::nZeroEvtsPC
private

Definition at line 95 of file DTOccupancyTestML.h.

Referenced by DTOccupancyTestML().

◆ rootFile

TFile* DTOccupancyTestML::rootFile
private

Definition at line 98 of file DTOccupancyTestML.h.

Referenced by dqmEndJob(), and DTOccupancyTestML().

◆ runOnAllHitsOccupancies

bool DTOccupancyTestML::runOnAllHitsOccupancies
private

Definition at line 102 of file DTOccupancyTestML.h.

Referenced by dqmEndLuminosityBlock(), and DTOccupancyTestML().

◆ runOnInTimeOccupancies

bool DTOccupancyTestML::runOnInTimeOccupancies
private

Definition at line 104 of file DTOccupancyTestML.h.

Referenced by dqmEndLuminosityBlock(), and DTOccupancyTestML().

◆ runOnNoiseOccupancies

bool DTOccupancyTestML::runOnNoiseOccupancies
private

Definition at line 103 of file DTOccupancyTestML.h.

Referenced by dqmEndLuminosityBlock(), and DTOccupancyTestML().

◆ summaryHisto

MonitorElement* DTOccupancyTestML::summaryHisto
private

Definition at line 87 of file DTOccupancyTestML.h.

Referenced by dqmEndLuminosityBlock().

◆ tpMode

bool DTOccupancyTestML::tpMode
private

◆ wheelHistos

std::map<int, MonitorElement *> DTOccupancyTestML::wheelHistos
private

Definition at line 86 of file DTOccupancyTestML.h.

Referenced by bookHistos(), and dqmEndLuminosityBlock().

◆ writeRootFile

bool DTOccupancyTestML::writeRootFile
private

Definition at line 97 of file DTOccupancyTestML.h.

Referenced by dqmEndJob(), dqmEndLuminosityBlock(), and DTOccupancyTestML().

DTOccupancyTestML::topFolder
std::string topFolder(bool isBooking) const
Definition: DTOccupancyTestML.cc:369
tensorflow::createSession
Session * createSession(SessionOptions &sessionOptions)
Definition: TensorFlow.cc:85
DTOccupancyTestML::bookHistos
void bookHistos(DQMStore::IBooker &, const int wheelId, std::string folder, std::string histoTag)
book the summary histograms
Definition: DTOccupancyTestML.cc:217
runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
mps_fire.i
i
Definition: mps_fire.py:428
input
static const std::string input
Definition: EdmProvDump.cc:48
DTOccupancyTestML::nameMonitoredHisto
std::string nameMonitoredHisto
Definition: DTOccupancyTestML.h:105
dqm::impl::MonitorElement::setEntries
virtual void setEntries(double nentries)
set # of entries
Definition: MonitorElement.cc:729
step
step
Definition: StallMonitor.cc:94
DTOccupancyTestML::nMinEvtsPC
int nMinEvtsPC
Definition: DTOccupancyTestML.h:94
printsummarytable.folder
folder
Definition: printsummarytable.py:7
relativeConstraints.station
station
Definition: relativeConstraints.py:67
DTOccupancyTestML::interpolateLayers
std::vector< float > interpolateLayers(std::vector< float > const &inputs, int size, int targetSize)
Definition: DTOccupancyTestML.cc:351
PatBasicFWLiteJetAnalyzer_Selector_cfg.outputs
outputs
Definition: PatBasicFWLiteJetAnalyzer_Selector_cfg.py:48
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:278
DTTopology::channels
int channels() const
Returns the number of wires in the layer.
Definition: DTTopology.h:76
dqm::legacy::MonitorElement
Definition: MonitorElement.h:462
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
DTOccupancyTestML::runOnInTimeOccupancies
bool runOnInTimeOccupancies
Definition: DTOccupancyTestML.h:104
visDQMUpload.context
context
Definition: visDQMUpload.py:37
edm::FileInPath
Definition: FileInPath.h:61
DTOccupancyTestML::tpMode
bool tpMode
Definition: DTOccupancyTestML.h:100
tensorflow::closeSession
bool closeSession(Session *&session)
Definition: TensorFlow.cc:198
DTOccupancyTestML::nChannelDead
int nChannelDead
Definition: DTOccupancyTestML.h:110
DTOccupancyTestML::glbSummaryHisto
MonitorElement * glbSummaryHisto
Definition: DTOccupancyTestML.h:88
DTOccupancyTestML::summaryHisto
MonitorElement * summaryHisto
Definition: DTOccupancyTestML.h:87
DTTopology::firstChannel
int firstChannel() const
Returns the wire number of the first wire.
Definition: DTTopology.h:79
DTOccupancyTestML::muonGeom
const DTGeometry * muonGeom
Definition: DTOccupancyTestML.h:83
DTOccupancyTestML::getMEName
std::string getMEName(std::string histoTag, const DTChamberId &chId)
Get the ME name.
Definition: DTOccupancyTestML.cc:244
DTGeometry::chambers
const std::vector< const DTChamber * > & chambers() const
Return a vector of all Chamber.
Definition: DTGeometry.cc:84
DTOccupancyTestML::nZeroEvtsPC
int nZeroEvtsPC
Definition: DTOccupancyTestML.h:95
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
dqm::impl::MonitorElement::Reset
virtual void Reset()
Remove all data from the ME, keept the empty histogram with all its settings.
Definition: MonitorElement.cc:345
DTOccupancyTestML::runOccupancyTest
int runOccupancyTest(TH2F *histo, const DTChamberId &chId, float &chamberPercentage, tensorflow::GraphDef *graphDef, tensorflow::Session *session)
Definition: DTOccupancyTestML.cc:278
DTLayerId
Definition: DTLayerId.h:12
DTOccupancyTestML::nChannelTotal
int nChannelTotal
Definition: DTOccupancyTestML.h:109
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
dqm::impl::MonitorElement::getFloatValue
virtual double getFloatValue() const
Definition: MonitorElement.cc:920
DTOccupancyTestML::nevents
int nevents
Definition: DTOccupancyTestML.h:80
DTGeometry::layer
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
Definition: DTGeometry.cc:96
DTOccupancyTestML::rootFile
TFile * rootFile
Definition: DTOccupancyTestML.h:98
dtResolutionTest_cfi.histoTag
histoTag
Definition: dtResolutionTest_cfi.py:21
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
createfilelist.int
int
Definition: createfilelist.py:10
PixelMapPlotter.inputs
inputs
Definition: PixelMapPlotter.py:490
chambers
static char chambers[264][20]
Definition: ReadPGInfo.cc:243
tensorflow::setLogging
void setLogging(const std::string &level="3")
Definition: TensorFlow.cc:15
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
tensorflow::loadGraphDef
GraphDef * loadGraphDef(const std::string &pbFile)
Definition: TensorFlow.cc:68
dqm::impl::MonitorElement::setBinContent
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
Definition: MonitorElement.cc:682
DTChamberId::sector
int sector() const
Definition: DTChamberId.h:49
heppy_batch.val
val
Definition: heppy_batch.py:351
DTOccupancyTestML::runOnAllHitsOccupancies
bool runOnAllHitsOccupancies
Definition: DTOccupancyTestML.h:102
DTOccupancyTestML::runOnNoiseOccupancies
bool runOnNoiseOccupancies
Definition: DTOccupancyTestML.h:103
DTOccupancyTestML::nMinEvts
int nMinEvts
Definition: DTOccupancyTestML.h:93
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
DTRecHitClients_cfi.doall
doall
Definition: DTRecHitClients_cfi.py:9
dqm::implementation::IBooker::book2D
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
tensorflow::run
void run(Session *session, const NamedTensorList &inputs, const std::vector< std::string > &outputNames, std::vector< Tensor > *outputs, const thread::ThreadPoolOptions &threadPoolOptions)
Definition: TensorFlow.cc:213
dqm::implementation::IGetter::get
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
HltBtagPostValidation_cff.histoName
histoName
Definition: HltBtagPostValidation_cff.py:17
DTOccupancyTestML::bookingdone
bool bookingdone
Definition: DTOccupancyTestML.h:107
dtChamberEfficiencyTest_cfi.folderRoot
folderRoot
Definition: dtChamberEfficiencyTest_cfi.py:9
DTLayer::specificTopology
const DTTopology & specificTopology() const
Definition: DTLayer.cc:37
DTOccupancyTestML::wheelHistos
std::map< int, MonitorElement * > wheelHistos
Definition: DTOccupancyTestML.h:86
mps_fire.result
result
Definition: mps_fire.py:311
ntuple
Definition: ntuple.py:1
DTChamberId
Definition: DTChamberId.h:14
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
DTOccupancyTestML::writeRootFile
bool writeRootFile
Definition: DTOccupancyTestML.h:97
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
dqm::impl::MonitorElement::setAxisTitle
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:791
dqm::impl::MonitorElement::getBinContent
virtual double getBinContent(int binx) const
get content of bin (1-D)
Definition: MonitorElement.cc:583
DTChamberId::wheel
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
DTOccupancyTestML::lsCounter
int lsCounter
Definition: DTOccupancyTestML.h:92
DTOccupancyTestML::muonGeomToken_
edm::ESGetToken< DTGeometry, MuonGeometryRecord > muonGeomToken_
Definition: DTOccupancyTestML.h:82
DTChamberId::station
int station() const
Return the station number.
Definition: DTChamberId.h:42
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
dqm::legacy::MonitorElement::getTH2F
virtual TH2F * getTH2F() const
Definition: MonitorElement.h:491