LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
detinfo::DetectorClocksServiceStandard Class Reference

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

#include "DetectorClocksServiceStandard.h"

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

Public Types

typedef detinfo::DetectorClocks provider_type
 

Public Member Functions

 DetectorClocksServiceStandard (fhicl::ParameterSet const &pset, art::ActivityRegistry &reg)
 
virtual void reconfigure (fhicl::ParameterSet const &pset) override
 
void preBeginRun (const art::Run &run)
 
void preProcessEvent (const art::Event &evt)
 
void postOpenFile (const std::string &filename)
 
virtual const provider_typeprovider () const override
 

Private Attributes

std::unique_ptr< detinfo::DetectorClocksStandardfClocks
 

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:

if the past jobs (explicitly excluding the current job) had inconsistent

configuration, an exception is thrown claiming an "historical disagreement"

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:

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

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 85 of file DetectorClocksServiceStandard.h.

Member Typedef Documentation

Constructor & Destructor Documentation

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

Definition at line 9 of file DetectorClocksServiceStandard_service.cc.

References art::ActivityRegistry::sPostOpenFile, art::ActivityRegistry::sPreBeginRun, and art::ActivityRegistry::sPreProcessEvent.

10  : fClocks(std::make_unique<detinfo::DetectorClocksStandard>(pset))
11 {
12 
16 
17 }
GlobalSignal< detail::SignalResponseType::FIFO, void(Run const &)> sPreBeginRun
GlobalSignal< detail::SignalResponseType::FIFO, void(Event const &)> sPreProcessEvent
GlobalSignal< detail::SignalResponseType::LIFO, void(std::string const &)> sPostOpenFile
std::unique_ptr< detinfo::DetectorClocksStandard > fClocks

Member Function Documentation

void detinfo::DetectorClocksServiceStandard::postOpenFile ( const std::string &  filename)

Definition at line 45 of file DetectorClocksServiceStandard_service.cc.

References DEFINE_ART_SERVICE_INTERFACE_IMPL, fClocks, file, fhicl::ParameterSet::get(), detinfo::kInheritConfigTypeMax, and fhicl::make_ParameterSet().

47 {
48 
49  // Method inheriting from DetectorProperties
50 
51  if(!fClocks->InheritClockConfig()) return;
52 
53  // The only way to access art service metadata from the input file
54  // is to open it as a separate TFile object. Do that now.
55 
56  if(!filename.empty()) {
57 
58  TFile* file = TFile::Open(filename.c_str(), "READ");
59  if(file != 0 && !file->IsZombie() && file->IsOpen()) {
60 
61  std::vector<std::string> cfgName = fClocks->ConfigNames();
62  std::vector<double> cfgValue = fClocks->ConfigValues();
63 
64  // Open the sqlite datatabase.
65 
66  art::SQLite3Wrapper sqliteDB(file, "RootFileDB");
67 
68  // Loop over all stored ParameterSets.
69 
70  std::vector<size_t> config_count(detinfo::kInheritConfigTypeMax,0);
71  std::vector<double> config_value(detinfo::kInheritConfigTypeMax,0);
72 
73  sqlite3_stmt * stmt = 0;
74  sqlite3_prepare_v2(sqliteDB, "SELECT PSetBlob from ParameterSets;", -1, &stmt, NULL);
75 
76  while (sqlite3_step(stmt) == SQLITE_ROW) {
77 
79  fhicl::make_ParameterSet(reinterpret_cast<char const *>(sqlite3_column_text(stmt, 0)), ps);
80 
81  if(!fClocks->IsRightConfig(ps)) continue;
82 
83  for(size_t i=0; i<detinfo::kInheritConfigTypeMax; ++i) {
84 
85  double value_from_file = ps.get<double>(cfgName.at(i).c_str());
86 
87  if(!(config_count.at(i)))
88 
89  config_value.at(i) = value_from_file;
90 
91  else if(config_value.at(i) != value_from_file)
92 
93  throw cet::exception(__FUNCTION__) << Form("\033[95mFound historical value disagreement for %s ... %g != %g",
94  cfgName.at(i).c_str(),
95  config_value.at(i),
96  value_from_file)
97  << "\033[00m" << std::endl;
98  config_count.at(i) +=1;
99 
100  }
101 
102  }
103 
104  // Override parameters
105 
106  for(size_t i=0; i<detinfo::kInheritConfigTypeMax; ++i)
107 
108  if(config_count.at(i) && cfgValue.at(i) != config_value.at(i)) {
109 
110  std::cout << Form("\033[93mOverriding configuration parameter %s ... %g (fcl) => %g (data file)\033[00m",
111  cfgName.at(i).c_str(),
112  cfgValue.at(i),
113  config_value.at(i))
114  << std::endl;
115 
116  fClocks->SetConfigValue(i,config_value.at(i));
117 
118  }
119  }
120 
121  // Close file.
122  if(file != 0) {
123  if(file->IsOpen())
124  file->Close();
125  delete file;
126  }
127  }
128 
129  // Reset parameters
130  fClocks->ApplyParams();
131 
132 }
void make_ParameterSet(intermediate_table const &tbl, ParameterSet &ps)
T get(std::string const &key) const
Definition: ParameterSet.h:231
TFile * file
std::unique_ptr< detinfo::DetectorClocksStandard > fClocks
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void detinfo::DetectorClocksServiceStandard::preBeginRun ( const art::Run run)

Definition at line 35 of file DetectorClocksServiceStandard_service.cc.

References fClocks.

37 {
38 
39  fClocks->ApplyParams();
40 
41 }
std::unique_ptr< detinfo::DetectorClocksStandard > fClocks
void detinfo::DetectorClocksServiceStandard::preProcessEvent ( const art::Event evt)

Definition at line 28 of file DetectorClocksServiceStandard_service.cc.

References fClocks, and detinfo::setDetectorClocksStandardTrigger().

30 {
32 }
bool setDetectorClocksStandardTrigger(detinfo::DetectorClocksStandard &detClocks, Event const &event)
Loads DetectorClocksStandard trigger times.
std::unique_ptr< detinfo::DetectorClocksStandard > fClocks
virtual const provider_type* detinfo::DetectorClocksServiceStandard::provider ( ) const
inlineoverridevirtual

Implements detinfo::DetectorClocksService.

Definition at line 94 of file DetectorClocksServiceStandard.h.

References fClocks.

94 { return fClocks.get();}
std::unique_ptr< detinfo::DetectorClocksStandard > fClocks
void detinfo::DetectorClocksServiceStandard::reconfigure ( fhicl::ParameterSet const &  pset)
overridevirtual

Implements detinfo::DetectorClocksService.

Definition at line 20 of file DetectorClocksServiceStandard_service.cc.

References fClocks.

22 {
23  fClocks->Configure(pset);
24 
25 }
std::unique_ptr< detinfo::DetectorClocksStandard > fClocks

Member Data Documentation

std::unique_ptr<detinfo::DetectorClocksStandard> detinfo::DetectorClocksServiceStandard::fClocks
private

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