Classes | Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
sim::POTaccumulator Class Reference

Prints on console the total Protons On Target from the input subruns. More...

Inheritance diagram for sim::POTaccumulator:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Classes

struct  Config
 Collection of configuration parameters for the module. More...
 

Public Types

using Parameters = art::EDAnalyzer::Table< Config >
 Type to enable module parameters description by art. More...
 
- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 POTaccumulator (Parameters const &config)
 Configuration-checking constructor. More...
 
 POTaccumulator (POTaccumulator const &)=delete
 
 POTaccumulator (POTaccumulator &&)=delete
 
POTaccumulatoroperator= (POTaccumulator const &)=delete
 
POTaccumulatoroperator= (POTaccumulator &&)=delete
 
virtual void analyze (art::Event const &event) override
 
virtual void endSubRun (art::SubRun const &subRun) override
 Collects information from each subrun. More...
 
virtual void endJob () override
 Prints the general summary. More...
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
fhicl::ParameterSetID selectorConfig () const
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

void printMissingSubrunList () const
 Prints the list of subruns with partial or missing POT information. More...
 
void printRunSummary () const
 Prints the list of POT per run. More...
 
void printSummary (sumdata::POTSummary const &totalPOT) const
 Prints the total POT summary totalPOT. More...
 

Static Private Member Functions

static std::string to_string (sumdata::POTSummary const &POT)
 Converts the information from POT in a compact string. More...
 

Private Attributes

art::InputTag fPOTtag
 Name of sumdata::POTSummary data product. More...
 
std::string fSummaryOutputCategory
 Name of the main stream for output. More...
 
std::string fRunOutputCategory
 Name of the run stream for output. More...
 
std::map< art::SubRunID, unsigned int > fPresentSubrunFragments
 Count of subrun fragments with POT information. More...
 
std::map< art::SubRunID, unsigned int > fMissingSubrunFragments
 Count of subrun fragments without POT information. More...
 
std::map< art::RunID, art::SummedValue< sumdata::POTSummary > > fRunPOT
 Partial count of POT in the run, per run. More...
 

Additional Inherited Members

- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Prints on console the total Protons On Target from the input subruns.

This module collects information from each of the subrun in the input files and prints the total of the protons on target. It also optionally prints the total for each observed run. If a subrun is met more than once, the information from all subrun fragments are added together (i.e. it is assumed that summary information is complementary rather than duplicate).

The output can be printed to the console or a file via the appropriate message facility configuration.

Two output streams are used: the one for the run summary and the one for the total summary. They may coincide.

Input

The module reads information from objects of type sumdata::POTSummary stored in each subrun.

Configuration

The output streams can be managed by configuring message facility to deal with the relevant category names. All messages are sent with the INFO level.

Definition at line 71 of file POTaccumulator_module.cc.

Member Typedef Documentation

Type to enable module parameters description by art.

Definition at line 98 of file POTaccumulator_module.cc.

Constructor & Destructor Documentation

sim::POTaccumulator::POTaccumulator ( Parameters const &  config)
explicit

Configuration-checking constructor.

Definition at line 160 of file POTaccumulator_module.cc.

161  : EDAnalyzer(config)
162  , fPOTtag(config().SummaryTag())
163  , fSummaryOutputCategory(config().SummaryCategory())
164  , fRunOutputCategory(config().RunSummaryCategory())
165 {}
std::string fSummaryOutputCategory
Name of the main stream for output.
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
static Config * config
Definition: config.cpp:1054
std::string fRunOutputCategory
Name of the run stream for output.
art::InputTag fPOTtag
Name of sumdata::POTSummary data product.
sim::POTaccumulator::POTaccumulator ( POTaccumulator const &  )
delete
sim::POTaccumulator::POTaccumulator ( POTaccumulator &&  )
delete

Member Function Documentation

virtual void sim::POTaccumulator::analyze ( art::Event const &  event)
inlineoverridevirtual

Implements art::EDAnalyzer.

Definition at line 111 of file POTaccumulator_module.cc.

112  {}
void sim::POTaccumulator::endJob ( )
overridevirtual

Prints the general summary.

Reimplemented from art::EDAnalyzer.

Definition at line 201 of file POTaccumulator_module.cc.

202 {
203 
204  //
205  // print the run summary
206  //
207 
208  if (!fRunOutputCategory.empty()) {
209 
211 
212  printRunSummary();
213 
214  } // if
215 
216  //
217  // print the total summary
218  //
219 
220  // here we skip _art_ aggregation mechanism
221  // because it can't handle multiple runs
222  sumdata::POTSummary totalPOT;
223  for (auto const& POT : fRunPOT | ranges::views::values)
224  totalPOT.aggregate(POT.value());
225 
226  printSummary(totalPOT);
227 
228 } // sim::POTaccumulator::endJob()
std::map< art::RunID, art::SummedValue< sumdata::POTSummary > > fRunPOT
Partial count of POT in the run, per run.
void printRunSummary() const
Prints the list of POT per run.
std::string fRunOutputCategory
Name of the run stream for output.
void printMissingSubrunList() const
Prints the list of subruns with partial or missing POT information.
Q_UINT16 values[128]
void aggregate(POTSummary const &other)
Definition: POTSummary.cxx:15
void printSummary(sumdata::POTSummary const &totalPOT) const
Prints the total POT summary totalPOT.
std::map< art::SubRunID, unsigned int > fMissingSubrunFragments
Count of subrun fragments without POT information.
void sim::POTaccumulator::endSubRun ( art::SubRun const &  subRun)
overridevirtual

Collects information from each subrun.

Reimplemented from art::EDAnalyzer.

Definition at line 169 of file POTaccumulator_module.cc.

170 {
171 
172  auto const& ID = subRun.id();
173 
174  //
175  // get the information from the subrun and update the subrun counts
176  //
177  art::Handle<sumdata::POTSummary> summaryHandle;
178  if (!subRun.getByLabel(fPOTtag, summaryHandle)) {
181  << "Fragment of subrun " << ID << " has no '" << fPOTtag.encode() << "' POT summary.";
182  return;
183  }
184 
186 
187  //
188  // accumulate the information by run
189  //
190  sumdata::POTSummary const& subRunPOT = *summaryHandle;
191 
192  fRunPOT[ID.runID()].update(summaryHandle);
194  << "Fragment #" << fPresentSubrunFragments[ID] << " of subrun " << ID << ": "
195  << sim::POTaccumulator::to_string(subRunPOT);
196 
197 } // sim::POTaccumulator::endSubRun()
unsigned int ID
std::string fSummaryOutputCategory
Name of the main stream for output.
std::map< art::RunID, art::SummedValue< sumdata::POTSummary > > fRunPOT
Partial count of POT in the run, per run.
std::string encode() const
Definition: InputTag.cc:97
static std::string to_string(sumdata::POTSummary const &POT)
Converts the information from POT in a compact string.
#define MF_LOG_TRACE(id)
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
std::map< art::SubRunID, unsigned int > fPresentSubrunFragments
Count of subrun fragments with POT information.
art::InputTag fPOTtag
Name of sumdata::POTSummary data product.
std::map< art::SubRunID, unsigned int > fMissingSubrunFragments
Count of subrun fragments without POT information.
POTaccumulator& sim::POTaccumulator::operator= ( POTaccumulator const &  )
delete
POTaccumulator& sim::POTaccumulator::operator= ( POTaccumulator &&  )
delete
void sim::POTaccumulator::printMissingSubrunList ( ) const
private

Prints the list of subruns with partial or missing POT information.

Definition at line 232 of file POTaccumulator_module.cc.

233 {
234 
235  //
236  // missing fragments information
237  //
239  log << size(fMissingSubrunFragments) << " subruns lack POT information:";
240 
241  auto const fend = fPresentSubrunFragments.cend();
242 
243  for (auto const& [id, nMissing] : fMissingSubrunFragments) {
244 
245  // add to the count of fragments the ones which we have actually found
246  unsigned int nFragments = nMissing;
247  auto const iFound = fPresentSubrunFragments.find(id);
248  if (iFound != fend) nFragments += iFound->second;
249 
250  log << "\n" << id << ": " << nMissing << " / " << nFragments << " \"fragments\"";
251 
252  } // for
253 
254 } // sim::POTaccumulator::printMissingSubrunList()
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
std::string fRunOutputCategory
Name of the run stream for output.
std::map< art::SubRunID, unsigned int > fPresentSubrunFragments
Count of subrun fragments with POT information.
std::map< art::SubRunID, unsigned int > fMissingSubrunFragments
Count of subrun fragments without POT information.
void sim::POTaccumulator::printRunSummary ( ) const
private

Prints the list of POT per run.

Definition at line 258 of file POTaccumulator_module.cc.

259 {
260 
261  // count subruns in run
262  std::map<art::RunID, unsigned int> subrunCount;
264  ++subrunCount[ID.runID()];
265 
267  log << "POT from " << size(fRunPOT) << " runs:";
268  for (auto const& [id, POT] : fRunPOT) {
269  log << "\n " << id << " (" << subrunCount[id]
270  << " subruns): " << sim::POTaccumulator::to_string(POT.value());
271  } // for
272 
273 } // sim::POTaccumulator::printRunSummary()
unsigned int ID
std::map< art::RunID, art::SummedValue< sumdata::POTSummary > > fRunPOT
Partial count of POT in the run, per run.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
static std::string to_string(sumdata::POTSummary const &POT)
Converts the information from POT in a compact string.
std::string fRunOutputCategory
Name of the run stream for output.
std::map< art::SubRunID, unsigned int > fPresentSubrunFragments
Count of subrun fragments with POT information.
void sim::POTaccumulator::printSummary ( sumdata::POTSummary const &  totalPOT) const
private

Prints the total POT summary totalPOT.

Definition at line 277 of file POTaccumulator_module.cc.

278 {
279 
280  // aggregate all run summaries
282  << "Aggregated POT from " << fRunPOT.size() << " runs (" << fPresentSubrunFragments.size()
283  << " subruns): " << sim::POTaccumulator::to_string(totalPOT);
284 
285 } // sim::POTaccumulator::printSummary()
std::string fSummaryOutputCategory
Name of the main stream for output.
std::map< art::RunID, art::SummedValue< sumdata::POTSummary > > fRunPOT
Partial count of POT in the run, per run.
static std::string to_string(sumdata::POTSummary const &POT)
Converts the information from POT in a compact string.
std::map< art::SubRunID, unsigned int > fPresentSubrunFragments
Count of subrun fragments with POT information.
std::string sim::POTaccumulator::to_string ( sumdata::POTSummary const &  POT)
staticprivate

Converts the information from POT in a compact string.

Definition at line 289 of file POTaccumulator_module.cc.

290 {
291  using namespace std::string_literals;
292  return std::to_string(POT.totgoodpot) + " good POT ( "s + std::to_string(POT.goodspills) +
293  " spills); total: " + std::to_string(POT.totpot) + " POT ( "s +
294  std::to_string(POT.totspills) + " spills)";
295 } // sim::POTaccumulator::to_string(sumdata::POTSummary)
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
static QCString * s
Definition: config.cpp:1042

Member Data Documentation

std::map<art::SubRunID, unsigned int> sim::POTaccumulator::fMissingSubrunFragments
private

Count of subrun fragments without POT information.

Definition at line 135 of file POTaccumulator_module.cc.

art::InputTag sim::POTaccumulator::fPOTtag
private

Name of sumdata::POTSummary data product.

Definition at line 123 of file POTaccumulator_module.cc.

std::map<art::SubRunID, unsigned int> sim::POTaccumulator::fPresentSubrunFragments
private

Count of subrun fragments with POT information.

Definition at line 132 of file POTaccumulator_module.cc.

std::string sim::POTaccumulator::fRunOutputCategory
private

Name of the run stream for output.

Definition at line 125 of file POTaccumulator_module.cc.

std::map<art::RunID, art::SummedValue<sumdata::POTSummary> > sim::POTaccumulator::fRunPOT
private

Partial count of POT in the run, per run.

Definition at line 138 of file POTaccumulator_module.cc.

std::string sim::POTaccumulator::fSummaryOutputCategory
private

Name of the main stream for output.

Definition at line 124 of file POTaccumulator_module.cc.


The documentation for this class was generated from the following file: