CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
ModuleAllocMonitor Class Reference

Public Member Functions

 ModuleAllocMonitor (edm::ParameterSet const &iPS, edm::ActivityRegistry &iAR)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &iDesc)
 

Private Member Functions

bool forThisModule (unsigned int iID)
 

Private Attributes

edm::service::moduleAlloc::Filter filter_
 
std::vector< int > moduleIDs_
 
std::vector< std::string > moduleNames_
 
std::atomic< unsigned int > nEventsStarted_ {0}
 
unsigned int nEventsToSkip_ = 0
 

Detailed Description

Definition at line 135 of file ModuleAllocMonitor.cc.

Constructor & Destructor Documentation

◆ ModuleAllocMonitor()

ModuleAllocMonitor::ModuleAllocMonitor ( edm::ParameterSet const &  iPS,
edm::ActivityRegistry iAR 
)
inline

Definition at line 137 of file ModuleAllocMonitor.cc.

References cms::perftools::AllocMonitorRegistry::createAndRegisterMonitor(), makeListRunsInFiles::description, spr::find(), newFWLiteAna::found, edm::ParameterSet::getUntrackedParameter(), cms::perftools::AllocMonitorRegistry::instance(), label, edm::service::moduleAlloc::setupFile(), jetUpdater_cfi::sort, AlCaHLTBitMon_QueryRunRegistry::string, funct::void, edm::ActivityRegistry::watchPostESModuleRegistration(), edm::ActivityRegistry::watchPreModuleConstruction(), and edm::ActivityRegistry::watchPreSourceEvent().

138  : moduleNames_(iPS.getUntrackedParameter<std::vector<std::string>>("moduleNames")),
139  nEventsToSkip_(iPS.getUntrackedParameter<unsigned int>("nEventsToSkip")),
140  filter_(&moduleIDs_) {
142 
143  if (nEventsToSkip_ > 0) {
144  filter_.setGlobalKeep(false);
145  }
146  if (not moduleNames_.empty()) {
147  iAR.watchPreModuleConstruction([this](auto const& description) {
148  auto found = std::find(moduleNames_.begin(), moduleNames_.end(), description.moduleLabel());
149  if (found != moduleNames_.end()) {
150  moduleIDs_.push_back(description.id());
151  std::sort(moduleIDs_.begin(), moduleIDs_.end());
152  }
153  });
154 
155  iAR.watchPostESModuleRegistration([this](auto const& iDescription) {
156  auto label = iDescription.label_;
157  if (label.empty()) {
158  label = iDescription.type_;
159  }
160  auto found = std::find(moduleNames_.begin(), moduleNames_.end(), label);
161  if (found != moduleNames_.end()) {
162  //NOTE: we want the id to start at 1 not 0
163  moduleIDs_.push_back(-1 * (iDescription.id_ + 1));
164  std::sort(moduleIDs_.begin(), moduleIDs_.end());
165  }
166  });
167  }
168  if (nEventsToSkip_ > 0) {
169  iAR.watchPreSourceEvent([this](auto) {
170  ++nEventsStarted_;
172  filter_.setGlobalKeep(true);
173  }
174  });
175  }
176  edm::service::moduleAlloc::setupFile(iPS.getUntrackedParameter<std::string>("fileName"), iAR, &filter_);
177  }
void watchPostESModuleRegistration(PostESModuleRegistration::slot_type const &iSlot)
void watchPreModuleConstruction(PreModuleConstruction::slot_type const &iSlot)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::atomic< unsigned int > nEventsStarted_
TEMPL(T2) struct Divides void
Definition: Factorize.h:24
char const * label
static AllocMonitorRegistry & instance()
void setupFile(std::string const &iFileName, edm::ActivityRegistry &iRegistry, Filter const *iFilter)
edm::service::moduleAlloc::Filter filter_
std::vector< int > moduleIDs_
std::vector< std::string > moduleNames_
void watchPreSourceEvent(PreSourceEvent::slot_type const &iSlot)

Member Function Documentation

◆ fillDescriptions()

static void ModuleAllocMonitor::fillDescriptions ( edm::ConfigurationDescriptions iDesc)
inlinestatic

Definition at line 179 of file ModuleAllocMonitor.cc.

References edm::ConfigurationDescriptions::addDefault(), edm::ParameterSetDescription::addUntracked(), and AlCaHLTBitMon_QueryRunRegistry::string.

179  {
181  ps.addUntracked<std::string>("fileName");
182  ps.addUntracked<std::vector<std::string>>("moduleNames", std::vector<std::string>());
183  ps.addUntracked<unsigned int>("nEventsToSkip", 0);
184  iDesc.addDefault(ps);
185  }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void addDefault(ParameterSetDescription const &psetDescription)

◆ forThisModule()

bool ModuleAllocMonitor::forThisModule ( unsigned int  iID)
inlineprivate

Definition at line 188 of file ModuleAllocMonitor.cc.

References or.

188  {
189  return (moduleNames_.empty() or std::binary_search(moduleIDs_.begin(), moduleIDs_.end(), iID));
190  }
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
std::vector< int > moduleIDs_
std::vector< std::string > moduleNames_

Member Data Documentation

◆ filter_

edm::service::moduleAlloc::Filter ModuleAllocMonitor::filter_
private

Definition at line 195 of file ModuleAllocMonitor.cc.

◆ moduleIDs_

std::vector<int> ModuleAllocMonitor::moduleIDs_
private

Definition at line 192 of file ModuleAllocMonitor.cc.

◆ moduleNames_

std::vector<std::string> ModuleAllocMonitor::moduleNames_
private

Definition at line 191 of file ModuleAllocMonitor.cc.

◆ nEventsStarted_

std::atomic<unsigned int> ModuleAllocMonitor::nEventsStarted_ {0}
private

Definition at line 194 of file ModuleAllocMonitor.cc.

◆ nEventsToSkip_

unsigned int ModuleAllocMonitor::nEventsToSkip_ = 0
private

Definition at line 193 of file ModuleAllocMonitor.cc.