All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
sbn::DumpTrigger Class Reference

Dumps on console the content of trigger data products. More...

Inheritance diagram for sbn::DumpTrigger:

Classes

struct  Config
 

Public Types

using Parameters = art::EDAnalyzer::Table< Config >
 

Public Member Functions

 DumpTrigger (Parameters const &config)
 
virtual void analyze (art::Event const &event) override
 Does the dumping. More...
 

Private Types

using electronics_time = detinfo::timescales::electronics_time
 
using simulation_time = detinfo::timescales::simulation_time
 

Private Member Functions

void dumpTrigger (std::vector< raw::Trigger > const &triggers) const
 Dumps a simple LArSoft trigger data product. More...
 
void dumpTrigger (std::vector< raw::ExternalTrigger > const &triggers) const
 Dumps a LArSoft external trigger data product. More...
 
void dumpBeamGate (std::vector< sim::BeamGateInfo > const &gates) const
 Dumps a LArSoft beam gate information data product. More...
 
void dumpTrigger (sbn::ExtraTriggerInfo const &trigger) const
 Dumps a SBN trigger information data product. More...
 
std::pair< art::InputTag, bool > inputTag (std::optional< art::InputTag > const &tag) const
 Returns the tag to try, and whether it is mandatory to find it. More...
 
template<typename T >
unsigned int countConsume (std::optional< art::InputTag > const &param)
 

Private Attributes

std::optional< art::InputTag >
const 
fTriggerTag
 Input trigger tag. More...
 
std::optional< art::InputTag >
const 
fBeamGateTag
 Input beam gate tag. More...
 
std::optional< art::InputTag >
const 
fExternalTag
 Input additional trigger tag. More...
 
std::optional< art::InputTag >
const 
fExtraTag
 
unsigned int const fVerbosity
 Input extra trigger tag. More...
 
std::string const fOutputCategory
 Category used for message facility stream. More...
 

Detailed Description

Dumps on console the content of trigger data products.

Supported trigger types are:

Input data products

Configuration parameters

All data product tags are optional, but at least one needs to be specified. If a tag is not specified, the same tag as TriggerTag will be attempted (if specified). A terse description of the parameters is printed by running lar --print-description DumpTrigger.

Definition at line 95 of file DumpTrigger_module.cc.

Member Typedef Documentation

Definition at line 164 of file DumpTrigger_module.cc.

using sbn::DumpTrigger::Parameters = art::EDAnalyzer::Table<Config>

Definition at line 143 of file DumpTrigger_module.cc.

Definition at line 165 of file DumpTrigger_module.cc.

Constructor & Destructor Documentation

sbn::DumpTrigger::DumpTrigger ( Parameters const &  config)
explicit

Definition at line 235 of file DumpTrigger_module.cc.

236  : art::EDAnalyzer(config)
237  // configuration
238  , fTriggerTag { config().TriggerTag() }
239  , fBeamGateTag { config().BeamGateTag() }
240  , fExternalTag { config().ExternalTriggerTag() }
241  , fExtraTag { config().ExtraTriggerTag() }
242  , fVerbosity { config().Verbosity() }
243  , fOutputCategory{ config().OutputCategory() }
244 {
245 
246  unsigned int nRequiredTriggers = 0U; // count of required data products
247 
248  /*
249  * data product usage declaration
250  */
251  nRequiredTriggers += countConsume<std::vector<raw::Trigger>>(fTriggerTag);
252  nRequiredTriggers
253  += countConsume<std::vector<sim::BeamGateInfo>>(fBeamGateTag);
254  nRequiredTriggers
255  += countConsume<std::vector<raw::ExternalTrigger>>(fExternalTag);
256  nRequiredTriggers += countConsume<sbn::ExtraTriggerInfo>(fExtraTag);
257 
258  /*
259  * parameter check
260  */
261  if (nRequiredTriggers == 0U) {
262  throw art::Exception{ art::errors::Configuration }
263  << "At least one trigger data product needs to be specified.\n";
264  }
265 
266  /*
267  * print configuration
268  */
269  mf::LogInfo log{ fOutputCategory };
270  log << "Configuration:\n * dump:";
271 
272  if (fTriggerTag) log << "\n - '" << fTriggerTag->encode() << "' (raw::Trigger)";
273 
274  if (auto const [ tag, req ] = inputTag(fExternalTag); !tag.empty()) {
275  log << "\n - '" << tag.encode() << "' (raw::ExternalTrigger)";
276  if (!req) log << " (if available)";
277  }
278 
279  if (auto const [ tag, req ] = inputTag(fExtraTag); !tag.empty()) {
280  log << "\n - '" << tag.encode() << "' (sbn::ExtraTriggerInfo)";
281  if (!req) log << " (if available)";
282  }
283 
284  if (auto const [ tag, req ] = inputTag(fBeamGateTag); !tag.empty()) {
285  log << "\n - '" << tag.encode() << "' (sim::BeamGateInfo)";
286  if (!req) log << " (if available)";
287  }
288 
289 } // sbn::DumpTrigger::DumpTrigger()
std::string const fOutputCategory
Category used for message facility stream.
std::optional< art::InputTag > const fExtraTag
std::pair< art::InputTag, bool > inputTag(std::optional< art::InputTag > const &tag) const
Returns the tag to try, and whether it is mandatory to find it.
std::optional< art::InputTag > const fExternalTag
Input additional trigger tag.
unsigned int const fVerbosity
Input extra trigger tag.
std::optional< art::InputTag > const fTriggerTag
Input trigger tag.
std::optional< art::InputTag > const fBeamGateTag
Input beam gate tag.

Member Function Documentation

void sbn::DumpTrigger::analyze ( art::Event const &  event)
overridevirtual

Does the dumping.

Definition at line 293 of file DumpTrigger_module.cc.

293  {
294 
295  mf::LogVerbatim{ fOutputCategory }
296  << "Trigger information in " << event.id() << ":";
297 
298  if (auto const [ tag, req ] = inputTag(fTriggerTag); !tag.empty()) {
299 
300  auto const& handle = event.getHandle<std::vector<raw::Trigger>>(tag);
301  if (handle) {
302  mf::LogVerbatim{ fOutputCategory }
303  << "* raw::Trigger ('" << tag.encode() << "'):";
304  dumpTrigger(*handle);
305  }
306  else if (req) throw *(handle.whyFailed());
307  } // simple trigger
308 
309 
310  if (auto const [ tag, req ] = inputTag(fExternalTag); !tag.empty()) {
311 
312  auto const& handle
313  = event.getHandle<std::vector<raw::ExternalTrigger>>(tag);
314  if (handle) {
315  mf::LogVerbatim{ fOutputCategory }
316  << "* raw::ExternalTrigger ('" << tag.encode() << "'):";
317  dumpTrigger(*handle);
318  }
319  else if (req) throw *(handle.whyFailed());
320  } // external trigger info
321 
322 
323  if (auto const [ tag, req ] = inputTag(fExtraTag); !tag.empty()) {
324 
325  auto const& handle = event.getHandle<sbn::ExtraTriggerInfo>(tag);
326  if (handle) {
327  mf::LogVerbatim{ fOutputCategory }
328  << "* sbn::ExtraTriggerInfo ('" << tag.encode() << "'):";
329  dumpTrigger(*handle);
330  }
331  else if (req) throw *(handle.whyFailed());
332  } // extra trigger info
333 
334 
335  if (auto const [ tag, req ] = inputTag(fBeamGateTag); !tag.empty()) {
336 
337  auto const& handle = event.getHandle<std::vector<sim::BeamGateInfo>>(tag);
338  if (handle) {
339  mf::LogVerbatim{ fOutputCategory }
340  << "* sim::BeamGateInfo ('" << tag.encode() << "'):";
341  dumpBeamGate(*handle);
342  }
343  else if (req) throw *(handle.whyFailed());
344  } // beam gate
345 
346 
347 } // sbn::DumpTrigger::analyze()
std::string const fOutputCategory
Category used for message facility stream.
std::optional< art::InputTag > const fExtraTag
std::pair< art::InputTag, bool > inputTag(std::optional< art::InputTag > const &tag) const
Returns the tag to try, and whether it is mandatory to find it.
std::optional< art::InputTag > const fExternalTag
Input additional trigger tag.
Additional information on trigger.
void dumpBeamGate(std::vector< sim::BeamGateInfo > const &gates) const
Dumps a LArSoft beam gate information data product.
std::optional< art::InputTag > const fTriggerTag
Input trigger tag.
void dumpTrigger(std::vector< raw::Trigger > const &triggers) const
Dumps a simple LArSoft trigger data product.
std::optional< art::InputTag > const fBeamGateTag
Input beam gate tag.
template<typename T >
unsigned int sbn::DumpTrigger::countConsume ( std::optional< art::InputTag > const &  param)
private

Returns 1 if the data product of type T specified by param must be available, 0 otherwise. It also declares it will consume it.

Definition at line 472 of file DumpTrigger_module.cc.

473 {
474  auto const [ tag, required ] = inputTag(param);
475  if (tag.empty()) return 0;
476  if (required) consumes<T>(tag);
477  else mayConsume<T>(tag);
478  return required? 1: 0;
479 } // sbn::DumpTrigger::countConsume()
std::pair< art::InputTag, bool > inputTag(std::optional< art::InputTag > const &tag) const
Returns the tag to try, and whether it is mandatory to find it.
void sbn::DumpTrigger::dumpBeamGate ( std::vector< sim::BeamGateInfo > const &  gates) const
private

Dumps a LArSoft beam gate information data product.

Definition at line 415 of file DumpTrigger_module.cc.

416 {
417 
418  static std::string const indent(4U, ' ');
419 
420  if (gates.empty()) {
421  mf::LogVerbatim{ fOutputCategory } << indent << "no beam gates.";
422  return;
423  }
424  if (gates.size() > 1) {
425  mf::LogVerbatim{ fOutputCategory }
426  << indent << "[" << gates.size() << " beam gates]";
427  }
428 
429  for (auto const& [ iGate, gate]: util::enumerate(gates)) {
430  mf::LogVerbatim log { fOutputCategory };
431  log << indent;
432  simulation_time const start { gate.Start() };
433  simulation_time const end { gate.Start() + gate.Width() };
434  if (gates.size() > 1) log << "[" << iGate << "] ";
435  log << "beam gate [ " << start << " -- " << end << " ] (duration: "
436  << (end - start) << ") of type ";
437  switch (gate.BeamType()) {
438  case sim::kBNB: log << "BNB"; break;
439  case sim::kNuMI: log << "NuMI"; break;
440  case sim::kUnknown: log << "unknown"; break;
441  default:
442  log << "unsupported [code=" << static_cast<int>(gate.BeamType()) << "]";
443  } // switch
444 
445  } // for
446 
447 } // sbn::DumpTrigger::dumpBeamGate()
std::string const fOutputCategory
Category used for message facility stream.
Unknown beam type.
Definition: BeamTypes.h:10
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
NuMI.
Definition: BeamTypes.h:12
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
BNB.
Definition: BeamTypes.h:11
detinfo::timescales::simulation_time simulation_time
void sbn::DumpTrigger::dumpTrigger ( std::vector< raw::Trigger > const &  triggers) const
private

Dumps a simple LArSoft trigger data product.

Definition at line 352 of file DumpTrigger_module.cc.

353 {
354  static std::string const indent(4U, ' ');
355 
356  if (triggers.empty()) {
357  mf::LogVerbatim{ fOutputCategory } << indent << "no triggers.";
358  return;
359  }
360  if (triggers.size() > 1) {
361  mf::LogVerbatim{ fOutputCategory }
362  << indent << "[" << triggers.size() << " triggers]";
363  }
364 
365  for (auto const& [ iTrigger, trigger]: util::enumerate(triggers)) {
366  mf::LogVerbatim log { fOutputCategory };
367  log << indent;
368  if (triggers.size() > 1) log << "[" << iTrigger << "] ";
369  log << "trigger #" << trigger.TriggerNumber() << " at "
370  << electronics_time{ trigger.TriggerTime() }
371  << ", beam gate at " << electronics_time{ trigger.BeamGateTime() }
372  << ", bits:";
373  if (sbn::bits::triggerSourceMask const bitMask{ trigger.TriggerBits() }) {
374  log << " {";
375  for (std::string const& name: names(bitMask)) log << " " << name;
376  log << " }";
377  }
378  else log << " none";
379 
380  } // for
381 
382 } // sbn::DumpTrigger::dumpTrigger()
std::string const fOutputCategory
Category used for message facility stream.
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
static const std::vector< std::string > names
detinfo::timescales::electronics_time electronics_time
then echo fcl name
void sbn::DumpTrigger::dumpTrigger ( std::vector< raw::ExternalTrigger > const &  triggers) const
private

Dumps a LArSoft external trigger data product.

Definition at line 387 of file DumpTrigger_module.cc.

388 {
389 
390  static std::string const indent(4U, ' ');
391 
392  if (triggers.empty()) {
393  mf::LogVerbatim{ fOutputCategory } << indent << "no triggers.";
394  return;
395  }
396  if (triggers.size() > 1) {
397  mf::LogVerbatim{ fOutputCategory }
398  << indent << "[" << triggers.size() << " triggers]";
399  }
400 
401  for (auto const& [ iTrigger, trigger]: util::enumerate(triggers)) {
402  mf::LogVerbatim log { fOutputCategory };
403  log << indent;
404  if (triggers.size() > 1) log << "[" << iTrigger << "] ";
405  log << "trigger ID=" << trigger.GetTrigID()
406  << " at " << dumpTimestamp(trigger.GetTrigTime());
407 
408  } // for
409 
410 } // sbn::DumpTrigger::dumpTrigger(ExternalTrigger)
std::string const fOutputCategory
Category used for message facility stream.
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
void sbn::DumpTrigger::dumpTrigger ( sbn::ExtraTriggerInfo const &  trigger) const
private

Dumps a SBN trigger information data product.

Definition at line 451 of file DumpTrigger_module.cc.

451  {
452 
453  static std::string const indent(4U, ' ');
454 
455  mf::LogVerbatim{ fOutputCategory } << util::addIndent(indent) << trigger;
456 
457 } // sbn::DumpTrigger::dumpTrigger(ExtraTriggerInfo)
std::string const fOutputCategory
Category used for message facility stream.
Stream modifier that makes it &quot;indented&quot;.
std::pair< art::InputTag, bool > sbn::DumpTrigger::inputTag ( std::optional< art::InputTag > const &  tag) const
private

Returns the tag to try, and whether it is mandatory to find it.

Definition at line 462 of file DumpTrigger_module.cc.

463 {
464  return
465  { tag.value_or(fTriggerTag.value_or(art::InputTag{})), tag.has_value() };
466 } // sbn::DumpTrigger::inputTag()
std::optional< art::InputTag > const fTriggerTag
Input trigger tag.

Member Data Documentation

std::optional<art::InputTag> const sbn::DumpTrigger::fBeamGateTag
private

Input beam gate tag.

Definition at line 172 of file DumpTrigger_module.cc.

std::optional<art::InputTag> const sbn::DumpTrigger::fExternalTag
private

Input additional trigger tag.

Definition at line 175 of file DumpTrigger_module.cc.

std::optional<art::InputTag> const sbn::DumpTrigger::fExtraTag
private

Definition at line 177 of file DumpTrigger_module.cc.

std::string const sbn::DumpTrigger::fOutputCategory
private

Category used for message facility stream.

Definition at line 182 of file DumpTrigger_module.cc.

std::optional<art::InputTag> const sbn::DumpTrigger::fTriggerTag
private

Input trigger tag.

Definition at line 170 of file DumpTrigger_module.cc.

unsigned int const sbn::DumpTrigger::fVerbosity
private

Input extra trigger tag.

Verbosity level used for dumping.

Definition at line 179 of file DumpTrigger_module.cc.


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