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::Accumulator, edm::EndLuminosityBlockProducer, edm::EndRunProducer, edm::one::WatchLuminosityBlocks, edm::one::WatchRuns, edm::one::SharedResources > 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 beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
void beginRun (edm::Run const &, edm::EventSetup const &) override
 
 DQMEDHarvester ()
 
void endJob () final
 
void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
void endLuminosityBlockProduce (edm::LuminosityBlock &, edm::EventSetup const &) final
 
void endRun (edm::Run const &, edm::EventSetup const &) override
 
void endRunProduce (edm::Run &run, edm::EventSetup const &setup) override
 
 ~DQMEDHarvester () override=default
 
- Public Member Functions inherited from edm::one::EDProducer< edm::Accumulator, edm::EndLuminosityBlockProducer, edm::EndRunProducer, edm::one::WatchLuminosityBlocks, edm::one::WatchRuns, edm::one::SharedResources >
 EDProducer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () 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
 
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)
 
 ~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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (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::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
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::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
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<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, 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
 
edm::ESHandle< DTGeometrymuonGeom
 
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 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
edm::EDPutTokenT< DQMTokenlumiToken_
 
edm::EDPutTokenT< DQMTokenrunToken_
 

Detailed Description

Definition at line 41 of file DTOccupancyTestML.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 35 of file DTOccupancyTestML.cc.

References edm::ParameterSet::getUntrackedParameter(), and indexGen::rootFile.

35  {
36  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTestML") << "[DTOccupancyTestML]: Constructor";
37 
38  // Get the DQM service
39 
40  lsCounter = 0;
41 
42  writeRootFile = ps.getUntrackedParameter<bool>("writeRootFile", false);
43  if(writeRootFile) {
44  rootFile = new TFile("MLDTOccupancyTest.root","RECREATE");
45  ntuple = new TNtuple("OccupancyNtuple", "OccupancyNtuple", "ls:wh:st:se:lay1MeanCell:lay1RMS:lay2MeanCell:lay2RMS:lay3MeanCell:lay3RMS:lay4MeanCell:lay4RMS:lay5MeanCell:lay5RMS:lay6MeanCell:lay6RMS:lay7MeanCell:lay7RMS:lay8MeanCell:lay8RMS:lay9MeanCell:lay9RMS:lay10MeanCell:lay10RMS:lay11MeanCell:lay11RMS:lay12MeanCell:lay12RMS");
46  }
47 
48  // switch on the mode for running on test pulses (different top folder)
49  tpMode = ps.getUntrackedParameter<bool>("testPulseMode", false);
50 
51  runOnAllHitsOccupancies = ps.getUntrackedParameter<bool>("runOnAllHitsOccupancies", true);
52  runOnNoiseOccupancies = ps.getUntrackedParameter<bool>("runOnNoiseOccupancies", false);
53  runOnInTimeOccupancies = ps.getUntrackedParameter<bool>("runOnInTimeOccupancies", false);
54  nMinEvts = ps.getUntrackedParameter<int>("nEventsCert", 5000);
55  nMinEvtsPC = ps.getUntrackedParameter<int>("nEventsMinPC", 2200);
56  nZeroEvtsPC = ps.getUntrackedParameter<int>("nEventsZeroPC", 30);
57 
58  bookingdone = false;
59 
60  // Event counter
61  nevents = 0;
62 
63 }
T getUntrackedParameter(std::string const &, T const &) const
Definition: ntuple.py:1
DTOccupancyTestML::~DTOccupancyTestML ( )
override

Destructor.

Definition at line 65 of file DTOccupancyTestML.cc.

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

Member Function Documentation

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

BeginRun.

Definition at line 70 of file DTOccupancyTestML.cc.

References edm::EventSetup::get().

70  {
71 
72  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTestML") << "[DTOccupancyTestML]: BeginRun";
73 
74  // Get the geometry
75  context.get<MuonGeometryRecord>().get(muonGeom);
76 
77 }
edm::ESHandle< DTGeometry > muonGeom
void DTOccupancyTestML::bookHistos ( DQMStore::IBooker ,
const int  wheelId,
std::string  folder,
std::string  histoTag 
)
private

book the summary histograms

Definition at line 230 of file DTOccupancyTestML.cc.

References DQMStore::IBooker::book2D(), MonitorElement::setBinLabel(), DQMStore::IBooker::setCurrentFolder(), and makeMuonMisalignmentScenario::wheel.

231  {
232  // Set the current folder
233  stringstream wheel; wheel << wheelId;
234 
235  ibooker.setCurrentFolder(topFolder(true));
236 
237  // build the histo name
238  string histoName = histoTag + "_W" + wheel.str();
239 
240 
241  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTestML") <<"[DTOccupancyTestML]: booking wheel histo:"
242  << histoName
243  << " (tag "
244  << histoTag
245  << ") in: "
246  << topFolder(true) + "Wheel"+ wheel.str() + "/" + folder << endl;
247 
248  string histoTitle = "Occupancy summary WHEEL: "+wheel.str();
249  if(tpMode) {
250  histoTitle = "TP Occupancy summary WHEEL: "+wheel.str();
251  }
252 
253  wheelHistos[wheelId] = ibooker.book2D(histoName,histoTitle,12,1,13,4,1,5);
254  wheelHistos[wheelId]->setBinLabel(1,"MB1",2);
255  wheelHistos[wheelId]->setBinLabel(2,"MB2",2);
256  wheelHistos[wheelId]->setBinLabel(3,"MB3",2);
257  wheelHistos[wheelId]->setBinLabel(4,"MB4",2);
258  wheelHistos[wheelId]->setAxisTitle("sector",1);
259 }
std::map< int, MonitorElement * > wheelHistos
std::string topFolder(bool isBooking) const
void DTOccupancyTestML::dqmEndJob ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter 
)
overrideprotectedvirtual

Endjob.

Implements DQMEDHarvester.

Definition at line 216 of file DTOccupancyTestML.cc.

References indexGen::rootFile.

216  {
217 
218  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTestML") << "[DTOccupancyTestML] endjob called!";
219  if(writeRootFile) {
220  rootFile->cd();
221  ntuple->Write();
222  rootFile->Close();
223  }
224 }
Definition: ntuple.py:1
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 79 of file DTOccupancyTestML.cc.

References DQMStore::IBooker::book2D(), bookHistos(), relativeConstraints::chamber, chambers, tensorflow::closeSession(), tensorflow::createSession(), edm::FileInPath::fullPath(), DQMStore::IGetter::get(), MonitorElement::getFloatValue(), MonitorElement::getTH2F(), trackerHits::histo, createfilelist::int, tensorflow::loadGraphDef(), mps_fire::result, DTChamberId::sector(), dataDML::session, MonitorElement::setAxisTitle(), DQMStore::IBooker::setCurrentFolder(), tensorflow::setLogging(), DTChamberId::station(), runGCPTkAlMap::title, and DTChamberId::wheel().

80  {
81  if (!bookingdone) {
82 
83  // Book the summary histos
84  // - one summary per wheel
85  for(int wh = -2; wh <= 2; ++wh) { // loop over wheels
86  bookHistos(ibooker,wh, string("MLDTOccupancies"), "MLOccupancySummary");
87  }
88 
89  ibooker.setCurrentFolder(topFolder(true));
90  string title = "Occupancy Summary";
91  if(tpMode) {
92  title = "Test Pulse Occupancy Summary";
93  }
94  // - global summary with alarms
95  summaryHisto = ibooker.book2D("MLOccupancySummary",title.c_str(),12,1,13,5,-2,3);
96  summaryHisto->setAxisTitle("sector",1);
97  summaryHisto->setAxisTitle("wheel",2);
98 
99  // - global summary with percentages
100  glbSummaryHisto = ibooker.book2D("MLOccupancyGlbSummary",title.c_str(),12,1,13,5,-2,3);
101  glbSummaryHisto->setAxisTitle("sector",1);
102  glbSummaryHisto->setAxisTitle("wheel",2);
103 
104 
105  // assign the name of the input histogram
107  nameMonitoredHisto = "OccupancyAllHits_perCh";
108  } else if(runOnNoiseOccupancies) {
109  nameMonitoredHisto = "OccupancyNoise_perCh";
110  } else if(runOnInTimeOccupancies) {
111  nameMonitoredHisto = "OccupancyInTimeHits_perCh";
112  } else { // default is AllHits histo
113  nameMonitoredHisto = "OccupancyAllHits_perCh";
114  }
115 
116  }
117  bookingdone = true;
118 
119 
120  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTestML")
121  <<"[DTOccupancyTestML]: End of LS transition, performing the DQM client operation";
122  lsCounter++;
123 
124 
125 
126  // Reset the global summary
127  summaryHisto->Reset();
129 
130  nChannelTotal = 0;
131  nChannelDead = 0;
132 
133  // Get all the DT chambers
134  vector<const DTChamber*> chambers = muonGeom->chambers();
135 
136  // Load graph
138  edm::FileInPath modelFilePath("DQM/DTMonitorClient/data/occupancy_cnn_v1.pb");
139  tensorflow::GraphDef* graphDef = tensorflow::loadGraphDef(modelFilePath.fullPath());
140 
141  // Create session
142  tensorflow::Session* session = tensorflow::createSession(graphDef);
143 
144  for(vector<const DTChamber*>::const_iterator chamber = chambers.begin();
145  chamber != chambers.end(); ++chamber) { // Loop over all chambers
146  DTChamberId chId = (*chamber)->id();
147 
148  MonitorElement * chamberOccupancyHisto = igetter.get(getMEName(nameMonitoredHisto, chId));
149 
150  // Run the tests on the plot for the various granularities
151  if(chamberOccupancyHisto != nullptr) {
152  // Get the 2D histo
153  TH2F *histo = chamberOccupancyHisto->getTH2F();
154 
155  float chamberPercentage = 1.;
156  int result = runOccupancyTest(histo, chId, chamberPercentage, graphDef, session);
157  int sector = chId.sector();
158 
159  if(sector == 13) {
160  sector = 4;
161  float resultSect4 = wheelHistos[chId.wheel()]->getBinContent(sector, chId.station());
162  if(resultSect4 > result) {
163  result = (int)resultSect4;
164  }
165  } else if(sector == 14) {
166  sector = 10;
167  float resultSect10 = wheelHistos[chId.wheel()]->getBinContent(sector, chId.station());
168  if(resultSect10 > result) {
169  result = (int)resultSect10;
170  }
171  }
172 
173  // the 2 MB4 of Sect 4 and 10 count as half a chamber
174  if((sector == 4 || sector == 10) && chId.station() == 4)
175  chamberPercentage = chamberPercentage/2.;
176 
177  wheelHistos[chId.wheel()]->setBinContent(sector, chId.station(),result);
178  if(result > summaryHisto->getBinContent(sector, chId.wheel()+3)) {
179  summaryHisto->setBinContent(sector, chId.wheel()+3, result);
180  }
181  glbSummaryHisto->Fill(sector, chId.wheel(), chamberPercentage*1./4.);
182  } else {
183  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTestML") << "[DTOccupancyTestML] ME: "
184  << getMEName(nameMonitoredHisto, chId) << " not found!" << endl;
185  }
186 
187  }
188 
189  // Clean up neural network graph
190  tensorflow::closeSession(session);
191  delete graphDef;
192 
193  string nEvtsName = "DT/EventInfo/Counters/nProcessedEventsDigi";
194 
195  MonitorElement * meProcEvts = igetter.get(nEvtsName);
196 
197  if (meProcEvts) {
198  int nProcEvts = meProcEvts->getFloatValue();
199  glbSummaryHisto->setEntries(nProcEvts < nMinEvts ? 10. : nProcEvts);
200  summaryHisto->setEntries(nProcEvts < nMinEvts ? 10. : nProcEvts);
201  } else {
204  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTestML") << "[DTOccupancyTestML] ME: "
205  << nEvtsName << " not found!" << endl;
206  }
207 
208  // Fill the global summary
209  // Check for entire sectors off and report them on the global summary
210  //FIXME: TODO
211 
212  if(writeRootFile) ntuple->AutoSave("SaveSelf");
213 
214 }
Session * createSession(SessionOptions &sessionOptions)
Definition: TensorFlow.cc:87
const std::vector< const DTChamber * > & chambers() const
Return a vector of all Chamber.
Definition: DTGeometry.cc:102
void setBinContent(int binx, double content)
set content of bin (1-D)
double getFloatValue() const
GraphDef * loadGraphDef(const std::string &pbFile)
Definition: TensorFlow.cc:68
void bookHistos(DQMStore::IBooker &, const int wheelId, std::string folder, std::string histoTag)
book the summary histograms
MonitorElement * summaryHisto
Definition: ntuple.py:1
void Fill(long long x)
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
std::string getMEName(std::string histoTag, const DTChamberId &chId)
Get the ME name.
std::map< int, MonitorElement * > wheelHistos
bool closeSession(Session *&session)
Definition: TensorFlow.cc:193
std::string topFolder(bool isBooking) const
MonitorElement * glbSummaryHisto
void setEntries(double nentries)
set # of entries
void Reset()
reset ME (ie. contents, errors, etc)
int runOccupancyTest(TH2F *histo, const DTChamberId &chId, float &chamberPercentage, tensorflow::GraphDef *graphDef, tensorflow::Session *session)
TH2F * getTH2F() const
MonitorElement * get(std::string const &path)
Definition: DQMStore.cc:303
void setLogging(const std::string &level="3")
Definition: TensorFlow.cc:14
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
edm::ESHandle< DTGeometry > muonGeom
double getBinContent(int binx) const
get content of bin (1-D)
int sector() const
Definition: DTChamberId.h:61
int station() const
Return the station number.
Definition: DTChamberId.h:51
static char chambers[264][20]
Definition: ReadPGInfo.cc:243
std::string nameMonitoredHisto
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
int DTOccupancyTestML::getIntegral ( TH2F *  histo,
int  firstBinX,
int  lastBinX,
int  firstBinY,
int  lastBinY,
bool  doall 
)
private

Definition at line 286 of file DTOccupancyTestML.cc.

References mps_fire::i.

286  {
287 
288  int sum = 0;
289  for (Int_t i = firstBinX; i < lastBinX+1; i++) {
290  for (Int_t j = firstBinY; j < lastBinY+1; j++) {
291 
292  if (histo->GetBinContent(i,j) >0){
293  if (!doall) return 1;
294  sum += histo->GetBinContent(i,j);
295  }
296  }
297  }
298 
299  return sum;
300 }
string DTOccupancyTestML::getMEName ( std::string  histoTag,
const DTChamberId chId 
)
private

Get the ME name.

Definition at line 263 of file DTOccupancyTestML.cc.

References DTChamberId::sector(), DTChamberId::station(), relativeConstraints::station, DTChamberId::wheel(), and makeMuonMisalignmentScenario::wheel.

263  {
264 
265  stringstream wheel; wheel << chId.wheel();
266  stringstream station; station << chId.station();
267  stringstream sector; sector << chId.sector();
268 
269 
270  string folderRoot = topFolder(false) + "Wheel" + wheel.str() +
271  "/Sector" + sector.str() +
272  "/Station" + station.str() + "/";
273 
274  // build the histo name
275  string histoName = histoTag
276  + "_W" + wheel.str()
277  + "_St" + station.str()
278  + "_Sec" + sector.str();
279 
280  string histoname = folderRoot + histoName;
281 
282  return histoname;
283 }
std::string topFolder(bool isBooking) const
int sector() const
Definition: DTChamberId.h:61
int station() const
Return the station number.
Definition: DTChamberId.h:51
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
std::vector< float > DTOccupancyTestML::interpolateLayers ( std::vector< float > const &  inputs,
int  size,
int  targetSize 
)
private

Definition at line 377 of file DTOccupancyTestML.cc.

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

377  {
378  // Reshape layers with linear interpolation
379  int interpolationFloor = 0;
380  float interpolationPoint = 0.;
381  float step = static_cast<float>(size) / targetSize;
382  std::vector<float> reshapedInput(targetSize);
383 
384  for (int i = 0; i < targetSize; i++) {
385  interpolationFloor = static_cast<int>(std::floor(interpolationPoint));
386  // Interpolating here
387  reshapedInput.at(i) = (interpolationPoint - interpolationFloor) *
388  (inputs[interpolationFloor + 1] - inputs[interpolationFloor]) +
389  inputs[interpolationFloor];
390  interpolationPoint = step + interpolationPoint;
391  }
392  return reshapedInput;
393 }
size
Write out results.
step
Definition: StallMonitor.cc:94
int DTOccupancyTestML::runOccupancyTest ( TH2F *  histo,
const DTChamberId chId,
float &  chamberPercentage,
tensorflow::GraphDef *  graphDef,
tensorflow::Session *  session 
)
private

Definition at line 302 of file DTOccupancyTestML.cc.

References mps_fire::i, input, LogTrace, PatBasicFWLiteJetAnalyzer_Selector_cfg::outputs, tensorflow::run(), DTChamberId::station(), and heppy_batch::val.

305  {
306 
307  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTestML")
308  << "--- Occupancy test for chamber: " << chId << endl;
309 
310  // Initialize counters
311  int totalLayers = 0;
312  int badLayers = 0;
313 
314  // Loop over the super layers
315  for (int superLayer = 1; superLayer <= 3; superLayer++) {
316  int binYlow = ((superLayer-1)*4)+1;
317 
318  // Skip for non-existent super layers
319  if (chId.station() == 4 && superLayer == 2) continue;
320 
321  // Loop over layers
322  for (int layer = 1; layer <= 4; layer++) {
323  DTLayerId layID(chId, superLayer, layer);
324  int firstWire = muonGeom->layer(layID)->
325  specificTopology().firstChannel();
326  int nWires = muonGeom->layer(layID)->specificTopology().channels();
327  int binY = binYlow+(layer-1);
328  std::vector<float> layerOccupancy(nWires);
329  int channelId = 0;
330 
331  // Loop over cells within a layer
332  for (int cell = firstWire; cell != (nWires + firstWire); cell++) {
333  double cellOccupancy = histo->GetBinContent(cell, binY);
334  layerOccupancy.at(channelId) = cellOccupancy;
335  channelId++;
336  }
337 
338  int targetSize = 47;
339  std::vector<float> reshapedLayerOccupancy = interpolateLayers(layerOccupancy,
340  nWires,
341  targetSize);
342 
343  // Scale occupancy
344  float maxOccupancyInLayer =
345  *std::max_element(reshapedLayerOccupancy.begin(),
346  reshapedLayerOccupancy.end());
347 
348  if (maxOccupancyInLayer != 0) {
349  for (auto &val : reshapedLayerOccupancy)
350  val /= maxOccupancyInLayer;
351  }
352 
353  // Define input
354  tensorflow::Tensor input(tensorflow::DT_FLOAT, {1, targetSize});
355  for (int i = 0; i < targetSize; i++)
356  input.matrix<float>()(0, i) = reshapedLayerOccupancy[i];
357 
358  std::vector<tensorflow::Tensor> outputs;
359  tensorflow::run(session, { { "input_cnn_input", input } },
360  { "output_cnn/Softmax" }, &outputs);
361 
362  totalLayers++;
363  bool isBad = outputs[0].matrix<float>()(0, 1) > 0.95;
364  if (isBad) badLayers++;
365  }
366  }
367 
368  // Calculate a fraction of good layers
369  chamberPercentage = 1.0 - static_cast<float>(badLayers)/totalLayers;
370 
371  if (badLayers > 8) return 3; // 3 SL
372  if (badLayers > 4) return 2; // 2 SL
373  if (badLayers > 0) return 1; // 1 SL
374  return 0;
375 }
std::vector< float > interpolateLayers(std::vector< float > const &inputs, int size, int targetSize)
static std::string const input
Definition: EdmProvDump.cc:48
const DTTopology & specificTopology() const
Definition: DTLayer.cc:42
#define LogTrace(id)
int channels() const
Returns the number of wires in the layer.
Definition: DTTopology.h:75
edm::ESHandle< DTGeometry > muonGeom
void run(Session *session, const NamedTensorList &inputs, const std::vector< std::string > &outputNames, const std::vector< std::string > &targetNodes, std::vector< Tensor > *outputs)
Definition: TensorFlow.cc:210
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
Definition: DTGeometry.cc:127
int station() const
Return the station number.
Definition: DTChamberId.h:51
string DTOccupancyTestML::topFolder ( bool  isBooking) const
private

Definition at line 395 of file DTOccupancyTestML.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

395  {
396  if(tpMode) return string("DT/10-TestPulses/");
397  if(isBooking) return string("DT/01-Digi/ML");
398  return string("DT/01-Digi/");
399 }

Member Data Documentation

bool DTOccupancyTestML::bookingdone
private

Definition at line 106 of file DTOccupancyTestML.h.

MonitorElement* DTOccupancyTestML::glbSummaryHisto
private

Definition at line 87 of file DTOccupancyTestML.h.

int DTOccupancyTestML::lsCounter
private

Definition at line 91 of file DTOccupancyTestML.h.

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

Definition at line 89 of file DTOccupancyTestML.h.

edm::ESHandle<DTGeometry> DTOccupancyTestML::muonGeom
private

Definition at line 82 of file DTOccupancyTestML.h.

std::string DTOccupancyTestML::nameMonitoredHisto
private

Definition at line 104 of file DTOccupancyTestML.h.

int DTOccupancyTestML::nChannelDead
private

Definition at line 109 of file DTOccupancyTestML.h.

int DTOccupancyTestML::nChannelTotal
private

Definition at line 108 of file DTOccupancyTestML.h.

int DTOccupancyTestML::nevents
private

Definition at line 80 of file DTOccupancyTestML.h.

int DTOccupancyTestML::nMinEvts
private

Definition at line 92 of file DTOccupancyTestML.h.

int DTOccupancyTestML::nMinEvtsPC
private

Definition at line 93 of file DTOccupancyTestML.h.

TNtuple* DTOccupancyTestML::ntuple
private
int DTOccupancyTestML::nZeroEvtsPC
private

Definition at line 94 of file DTOccupancyTestML.h.

TFile* DTOccupancyTestML::rootFile
private

Definition at line 97 of file DTOccupancyTestML.h.

bool DTOccupancyTestML::runOnAllHitsOccupancies
private

Definition at line 101 of file DTOccupancyTestML.h.

bool DTOccupancyTestML::runOnInTimeOccupancies
private

Definition at line 103 of file DTOccupancyTestML.h.

bool DTOccupancyTestML::runOnNoiseOccupancies
private

Definition at line 102 of file DTOccupancyTestML.h.

MonitorElement* DTOccupancyTestML::summaryHisto
private

Definition at line 86 of file DTOccupancyTestML.h.

bool DTOccupancyTestML::tpMode
private

Definition at line 99 of file DTOccupancyTestML.h.

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

Definition at line 85 of file DTOccupancyTestML.h.

bool DTOccupancyTestML::writeRootFile
private

Definition at line 96 of file DTOccupancyTestML.h.