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

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

#include <DetectorClocksServiceStandard.h>

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

Public Member Functions

 DetectorClocksServiceStandard (fhicl::ParameterSet const &pset, art::ActivityRegistry &reg)
 
- Public Member Functions inherited from detinfo::DetectorClocksService
virtual ~DetectorClocksService ()=default
 

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
 

Additional Inherited Members

- Public Types inherited from detinfo::DetectorClocksService
using provider_type = detinfo::DetectorClocks
 

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.

Constructor & Destructor Documentation

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

Definition at line 35 of file DetectorClocksServiceStandard.cc.

37  : fClocks{pset}, fInheritClockConfig{pset.get<bool>("InheritClockConfig")}
38  {
39  reg.sPostOpenFile.watch(this, &DetectorClocksServiceStandard::postOpenFile);
40  reg.sPreBeginRun.watch(this, &DetectorClocksServiceStandard::preBeginRun);
41  }
void postOpenFile(std::string const &filename)

Member Function Documentation

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

Implements detinfo::DetectorClocksService.

Definition at line 129 of file DetectorClocksServiceStandard.cc.

detinfo::DetectorClocksData detectorClocksStandardDataFor(detinfo::DetectorClocksStandard const &detClocks, Event const &event)
Returns DetectorClocksData tuned on the specified event.
do i e
DetectorClocksData detinfo::DetectorClocksServiceStandard::DataForJob ( ) const
inlineoverrideprivatevirtual

Implements detinfo::DetectorClocksService.

Definition at line 96 of file DetectorClocksServiceStandard.h.

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

Definition at line 51 of file DetectorClocksServiceStandard.cc.

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

Definition at line 44 of file DetectorClocksServiceStandard.cc.

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

Member Data Documentation

DetectorClocksStandard detinfo::DetectorClocksServiceStandard::fClocks
private

Definition at line 104 of file DetectorClocksServiceStandard.h.

bool detinfo::DetectorClocksServiceStandard::fInheritClockConfig
private

Definition at line 105 of file DetectorClocksServiceStandard.h.


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