LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
detinfo::DetectorClocksServiceStandard Class Reference

art service managing detinfo::DetectorClocksStandard. More...

#include "DetectorClocksServiceStandard.h"

Inheritance diagram for detinfo::DetectorClocksServiceStandard:
detinfo::DetectorClocksService

Public Types

using provider_type = detinfo::DetectorClocks
 

Public Member Functions

 DetectorClocksServiceStandard (fhicl::ParameterSet const &pset, art::ActivityRegistry &reg)
 

Private Member Functions

void preBeginRun (art::Run const &run)
 
void postOpenFile (std::string const &filename)
 
DetectorClocksData DataForJob () const override
 
DetectorClocksData DataFor (art::Event const &e) const override
 

Private Attributes

DetectorClocksStandard fClocks
 
bool fInheritClockConfig
 

Detailed Description

art service managing detinfo::DetectorClocksStandard.

See also
detinfo::DetectorClocksStandard, detinfo::DetectorClocks

This art service manages LArSoft's service provider detinfo::DetectorClocksStandard, which implements detinfo::DetectorClocks interface.

For information about functionality of the service, see the documentation of its interface, detinfo::DetectorClocks. For information of the configuration, see also detinfo::DetectorClocksStandard.

Configuration

The configuration parameters are documented in the service provider implementation: detinfo::DetectorClocksStandard.

Consistency check

This service manager honors the InheritClockConfig configuration option in the following way:

  1. if the past jobs (explicitly excluding the current job) had inconsistent configuration, an exception is thrown claiming an "historical disagreement"
  2. after the verification that the past configuration is consistent, the values from that configurations override the ones in the configuration of the current job; a value from the configuration of the current job is retained only if it was not present in the past (i.e. it is a new configuration parameter added since the input file was produced).

The "past jobs" are the jobs that have produced the input file, and whose configuration is stored by art in the input file itself. The check and reconfiguration is performed on each new input file.

Timing specifics

The trigger and beam gate times are set by this service before each event is processed. The logic is the following:

  1. if the event contains a raw trigger (raw::Trigger) data product with input tag TriggerName() (from the configuration), that data product is read and the trigger and beam gate times stored in it are imported in the current service provider configuration; if there are more than one raw::Trigger objects in the data product, an exception is thrown
  2. if no raw trigger is found with the specified label, the configuration of the service provider is updated using the default values of trigger and beam times specified in the service configuration

The first set up happens on opening the first run in the first input file. Accessing this service before (e.g. during beginJob() phase) yields undefined behaviour.

Definition at line 87 of file DetectorClocksServiceStandard.h.

Member Typedef Documentation

Constructor & Destructor Documentation

detinfo::DetectorClocksServiceStandard::DetectorClocksServiceStandard ( fhicl::ParameterSet const &  pset,
art::ActivityRegistry reg 
)

Definition at line 35 of file DetectorClocksServiceStandard.cc.

References fInheritClockConfig, postOpenFile(), and preBeginRun().

37  : fClocks{pset}, fInheritClockConfig{pset.get<bool>("InheritClockConfig")}
38  {
41  }
void postOpenFile(std::string const &filename)
GlobalSignal< detail::SignalResponseType::FIFO, void(Run const &)> sPreBeginRun
GlobalSignal< detail::SignalResponseType::LIFO, void(std::string const &)> sPostOpenFile

Member Function Documentation

DetectorClocksData detinfo::DetectorClocksServiceStandard::DataFor ( art::Event const &  e) const
overrideprivatevirtual

Implements detinfo::DetectorClocksService.

Definition at line 125 of file DetectorClocksServiceStandard.cc.

References detinfo::detectorClocksStandardDataFor(), and fClocks.

126  {
128  }
detinfo::DetectorClocksData detectorClocksStandardDataFor(detinfo::DetectorClocksStandard const &detClocks, Event const &event)
Returns DetectorClocksData tuned on the specified event.
Float_t e
Definition: plot.C:35
DetectorClocksData detinfo::DetectorClocksServiceStandard::DataForJob ( ) const
inlineoverrideprivatevirtual

Implements detinfo::DetectorClocksService.

Definition at line 95 of file DetectorClocksServiceStandard.h.

References e.

95 { return fClocks.DataForJob(); }
DetectorClocksData DataForJob() const override
Returns a complete detinfo::DetectorClocksData object.
void detinfo::DetectorClocksServiceStandard::postOpenFile ( std::string const &  filename)
private

Definition at line 49 of file DetectorClocksServiceStandard.cc.

References detinfo::DetectorClocksStandard::ApplyParams(), detinfo::DetectorClocksStandard::ConfigNames(), detinfo::DetectorClocksStandard::ConfigValues(), fClocks, file, fInheritClockConfig, detinfo::DetectorClocksStandard::IsRightConfig(), detinfo::kConfigTypeMax, fhicl::ParameterSet::make(), art::rootNames::metaDataTreeName(), and detinfo::DetectorClocksStandard::SetConfigValue().

Referenced by DetectorClocksServiceStandard().

50  {
51  if (!fInheritClockConfig) { return; }
52  if (filename.empty()) { return; }
53  std::unique_ptr<TFile> file{TFile::Open(filename.c_str(), "READ")};
54  if (!file || file->IsZombie() || !file->IsOpen()) { return; }
55  std::unique_ptr<TTree> metaDataTree{
56  file->Get<TTree>(art::rootNames::metaDataTreeName().c_str())};
57  if (metaDataTree == nullptr) {
58  throw cet::exception("DetectorClocksServiceStandard",
59  "Input file does not contain a metadata tree!");
60  }
61  auto const fileFormatVersion =
62  art::detail::readMetadata<art::FileFormatVersion>(metaDataTree.get());
64  vector<string> const cfgName(fClocks.ConfigNames());
65  vector<double> const cfgValue(fClocks.ConfigValues());
66  bitset<kConfigTypeMax> config_set;
67  vector<double> config_value(kConfigTypeMax, 0);
68 
69  auto count_configuration_changes =
70  [&cfgName, &config_set, &config_value](fhicl::ParameterSet const& ps) {
71  for (size_t i = 0; i < kConfigTypeMax; ++i) {
72  auto const value_from_file = ps.get<double>(cfgName[i]);
73  if (not config_set[i]) {
74  config_value[i] = value_from_file;
75  config_set[i] = true;
76  }
77  else if (config_value[i] != value_from_file) {
78  throw cet::exception("DetectorClocksServiceStandard")
79  << "Found historical value disagreement for " << cfgName[i] << " ... "
80  << config_value[i] << " != " << value_from_file;
81  }
82  }
83  };
84 
85  if (fileFormatVersion.value_ < 5) {
86  art::ParameterSetMap psetMap;
87  if (!art::detail::readMetadata(metaDataTree.get(), psetMap)) {
88  throw cet::exception("DetectorClocksServiceStandard",
89  "Could not read ParameterSetMap from metadata tree!");
90  }
91 
92  for (auto const& psEntry : psetMap) {
94  ps = fhicl::ParameterSet::make(psEntry.second.pset_);
95  if (!fClocks.IsRightConfig(ps)) { continue; }
96 
97  count_configuration_changes(ps);
98  }
99  }
100  else {
101  art::SQLite3Wrapper sqliteDB(file.get(), "RootFileDB");
102  sqlite3_stmt* stmt{nullptr};
103  sqlite3_prepare_v2(sqliteDB, "SELECT PSetBlob from ParameterSets;", -1, &stmt, nullptr);
104  while (sqlite3_step(stmt) == SQLITE_ROW) {
106  ps = fhicl::ParameterSet::make(reinterpret_cast<const char*>(sqlite3_column_text(stmt, 0)));
107  if (!fClocks.IsRightConfig(ps)) { continue; }
108 
109  count_configuration_changes(ps);
110  }
111  sqlite3_finalize(stmt);
112  }
113 
114  for (size_t i = 0; i < kConfigTypeMax; ++i) {
115  if (not config_set[i]) continue;
116  if (cfgValue[i] == config_value[i]) continue;
117 
118  cout << "Overriding configuration parameter " << cfgName[i] << " ... " << cfgValue[i]
119  << " (fcl) => " << config_value[i] << " (data file)" << endl;
120  fClocks.SetConfigValue(i, config_value[i]);
121  }
123  } // DetectorClocksServiceStandard::postOpenFile()
bool IsRightConfig(const fhicl::ParameterSet &ps) const
static ParameterSet make(intermediate_table const &tbl)
Definition: ParameterSet.cc:68
std::vector< std::string > const & ConfigNames() const override
std::vector< double > const & ConfigValues() const override
std::map< fhicl::ParameterSetID, ParameterSetBlob > ParameterSetMap
std::string const & metaDataTreeName()
Definition: rootNames.cc:42
void ApplyParams()
Internal function to apply loaded parameters to member attributes.
void SetConfigValue(size_t i, double val)
TFile * file
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void detinfo::DetectorClocksServiceStandard::preBeginRun ( art::Run const &  run)
private

Definition at line 43 of file DetectorClocksServiceStandard.cc.

References detinfo::DetectorClocksStandard::ApplyParams(), and fClocks.

Referenced by DetectorClocksServiceStandard().

44  {
45  // This callback probably is not necessary.
47  }
void ApplyParams()
Internal function to apply loaded parameters to member attributes.

Member Data Documentation

DetectorClocksStandard detinfo::DetectorClocksServiceStandard::fClocks
private

Definition at line 99 of file DetectorClocksServiceStandard.h.

Referenced by DataFor(), postOpenFile(), and preBeginRun().

bool detinfo::DetectorClocksServiceStandard::fInheritClockConfig
private

Definition at line 100 of file DetectorClocksServiceStandard.h.

Referenced by DetectorClocksServiceStandard(), and postOpenFile().


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