LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
detinfo::DetectorClocksStandard Class Referencefinal

Implementation of detinfo::DetectorClocks interface with fixed settings from configuration. More...

#include "DetectorClocksStandard.h"

Inheritance diagram for detinfo::DetectorClocksStandard:
detinfo::DetectorClocks

Public Member Functions

 DetectorClocksStandard (fhicl::ParameterSet const &pset)
 
 DetectorClocksStandard (DetectorClocksStandard const &)=delete
 
void SetConfigValue (size_t i, double val)
 
std::string const & TrigModuleName () const
 Returns the input tag of the trigger data product. More...
 
std::string G4RefCorrTrigModuleName () const
 Returns the input tag of the trigger data product for G4Ref correctons. More...
 
std::vector< std::string > const & ConfigNames () const override
 
std::vector< double > const & ConfigValues () const override
 
DetectorClocksData DataForJob () const override
 Returns a complete detinfo::DetectorClocksData object. More...
 
DetectorClocksData DataFor (double const g4_ref_time, double const trigger_time, double const beam_time) const override
 Returns a complete detinfo::DetectorClocksData object. More...
 
void ApplyParams ()
 Internal function to apply loaded parameters to member attributes. More...
 
bool IsRightConfig (const fhicl::ParameterSet &ps) const
 
void debugReport () const
 Dumps the current configuration to screen. More...
 

Private Member Functions

void SetTriggerTime (double const trig_time, double const beam_time)
 Setter for trigger times. More...
 
double TriggerOffsetTPC () const
 

Private Attributes

std::vector< std::string > fConfigName
 
std::vector< double > fConfigValue
 
std::string fTrigModuleName
 
std::string fG4RefCorrTrigModuleName
 
double fTriggerOffsetTPC
 Time offset from trigger to TPC readout start. More...
 
double fTriggerTime
 Trigger time in [us]. More...
 
double fBeamGateTime
 BeamGate time in [us]. More...
 
double fFramePeriod
 Frame period. More...
 
ElecClock fTPCClock
 

Detailed Description

Implementation of detinfo::DetectorClocks interface with fixed settings from configuration.

In this implementation, all quantities are defined at configuration time and are unchanged for the duration of the entire job, with the exception of the trigger time (see below).

Configuration parameters

All configuration parameters are mandatory, unless explicitly stated.

  • G4RefTime (nanoseconds): simulation (Geant4) start time in electronics time scale, i.e. when time 0.0 of simulation happens in the electronics time scale
  • TriggerOffsetTPC: time elapsed between the start of the TPC readout clock and the hardware trigger; it can be expressed in one of two ways:

    • negative number [µs]: the offset of the start of the TPC readout clock start respect to the trigger time (where negative means that the clock starts before the trigger arrives)
    • positive number [ticks]: the number of TPC readout clock tick at which the trigger arrives; despite this being a tick number, it can be fractional for added precision

    For example, TriggerOffsetTPC of -1600.0 means that the TDC clock starts 1.6 milliseconds before the hardware trigger. TriggerOffsetTPC of 3200.0 means that the trigger arrives at the exact start of tick 3200 of the TPC readout. In this example, if the sampling frequency of that readout is 2 MHz, these two settings are equivalent.

  • FramePeriod (microseconds): duration of an electronics clock frame; all clocks share the same frame period
  • ClockSpeedTPC (megahertz): frequency of the TPC electronics clock
  • ClockSpeedOptical (megahertz): frequency of the optical electronics clock
  • ClockSpeedTrigger (megahertz): frequency of the trigger electronics clock
  • ClockSpeedExternal (megahertz): frequency of the external electronics clock
  • DefaultTrigTime (microseconds): the default hardware trigger time, measured in the electronics time frame
  • DefaultBeamTime (microseconds): the default beam gate opening time, measured in the electronics time frame
  • TrigModuleName (string): input tag for the trigger data product (see "Trigger time" section below)
  • InheritClockConfig (boolean): whether to inherit the configuration from previous jobs (see "Consistency check" below)

Consistency check

The consistency check feature verifies that the current configuration of detinfo::DetectorClocksStandard is compatible with the one from previous jobs. It is expected that when this feature is enabled (InheritClockConfig is configured to be true), either the configuration is overridden to follow the previous ones, or an exception is thrown in case of inconsistency.

The service provider (detinfo::DetectorClocksStandard) does not provide a facility to inherit configuration from a previous job, but it stores the expectation whether this should happen (InheritClockConfig()). The service provider manager is in charge of implementing this feature (see detinfo::DetectorClocksStandardService for the manager in the art environment).

Timing specifics

For the general timing requirements, see the documentation of detinfo::DetectorClocks.

Trigger time

In this implementation, the trigger time and the beam gate time both default to 0.0 µs.

The manager of this provider is expected to set those values by calling detinfo::DetectorClocksStandard::SetTriggerTime(). See detinfo::DetectorClocksStandardService for the manager in the art environment.

Bug:
ExternalClock() clock is never initialized!

Definition at line 122 of file DetectorClocksStandard.h.

Constructor & Destructor Documentation

detinfo::DetectorClocksStandard::DetectorClocksStandard ( fhicl::ParameterSet const &  pset)

Definition at line 9 of file DetectorClocksStandard.cxx.

References fBeamGateTime, fConfigName, fConfigValue, fFramePeriod, fG4RefCorrTrigModuleName, fTPCClock, fTriggerOffsetTPC, fTriggerTime, fTrigModuleName, detinfo::kClockSpeedExternal, detinfo::kClockSpeedOptical, detinfo::kClockSpeedTPC, detinfo::kClockSpeedTrigger, detinfo::kDefaultBeamTime, detinfo::kDefaultTrigTime, detinfo::kFramePeriod, detinfo::kG4RefTime, detinfo::kTriggerOffsetTPC, and SetTriggerTime().

10  : fConfigName{"G4RefTime",
11  "TriggerOffsetTPC",
12  "FramePeriod",
13  "ClockSpeedTPC",
14  "ClockSpeedOptical",
15  "ClockSpeedTrigger",
16  "ClockSpeedExternal",
17  "DefaultTrigTime",
18  "DefaultBeamTime"}
19  , fConfigValue{pset.get<double>(fConfigName[kG4RefTime]),
20  pset.get<double>(fConfigName[kTriggerOffsetTPC]),
21  pset.get<double>(fConfigName[kFramePeriod]),
22  pset.get<double>(fConfigName[kClockSpeedTPC]),
23  pset.get<double>(fConfigName[kClockSpeedOptical]),
24  pset.get<double>(fConfigName[kClockSpeedTrigger]),
25  pset.get<double>(fConfigName[kClockSpeedExternal]),
26  pset.get<double>(fConfigName[kDefaultTrigTime]),
27  pset.get<double>(fConfigName[kDefaultBeamTime])}
28  , fTrigModuleName{pset.get<std::string>("TrigModuleName")}
29  , fG4RefCorrTrigModuleName{pset.get<std::string>("G4RefCorrTrigModuleName", "baddefault")}
35 {
37 }
std::vector< std::string > fConfigName
double fTriggerTime
Trigger time in [us].
double fBeamGateTime
BeamGate time in [us].
double fTriggerOffsetTPC
Time offset from trigger to TPC readout start.
void SetTriggerTime(double const trig_time, double const beam_time)
Setter for trigger times.
detinfo::DetectorClocksStandard::DetectorClocksStandard ( DetectorClocksStandard const &  )
delete

Member Function Documentation

void detinfo::DetectorClocksStandard::ApplyParams ( )
std::vector<std::string> const& detinfo::DetectorClocksStandard::ConfigNames ( ) const
inlineoverridevirtual

Returns a list of provider configuration names.

See also
ConfigValues()

Implements detinfo::DetectorClocks.

Definition at line 147 of file DetectorClocksStandard.h.

References fConfigName.

Referenced by detinfo::DetectorClocksServiceStandard::postOpenFile().

147 { return fConfigName; }
std::vector< std::string > fConfigName
std::vector<double> const& detinfo::DetectorClocksStandard::ConfigValues ( ) const
inlineoverridevirtual

Returns a list of provider configuration values (same order as ConfigNames()).

See also
ConfigNames()

Implements detinfo::DetectorClocks.

Definition at line 148 of file DetectorClocksStandard.h.

References fConfigValue.

Referenced by detinfo::detectorClocksStandardDataFor(), and detinfo::DetectorClocksServiceStandard::postOpenFile().

148 { return fConfigValue; }
DetectorClocksData detinfo::DetectorClocksStandard::DataFor ( double const  g4_ref_time,
double const  trigger_time,
double const  beam_time 
) const
inlineoverridevirtual

Returns a complete detinfo::DetectorClocksData object.

Parameters
g4_ref_timestart of simulation time in electronics time scale [ns]
trigger_timethe default hardware trigger time in electronics time
beam_timethe default beam gate opening time in electronics time

The returned timing information reflects the current context, defined by the parameters passed to this method.

If the information required by the parameters is not available, users will be forced to use DataForJob() instead.

For more details on the definition of the parameters, see the documentation of detinfo::DetectorClocksData constructor.

Implements detinfo::DetectorClocks.

Definition at line 163 of file DetectorClocksStandard.h.

References ApplyParams(), debugReport(), fConfigValue, fTriggerOffsetTPC, IsRightConfig(), detinfo::kClockSpeedOptical, detinfo::kClockSpeedTPC, detinfo::kClockSpeedTrigger, detinfo::kDEFAULT_FRAME_PERIOD, detinfo::kDEFAULT_FREQUENCY_EXTERNAL, and detinfo::kFramePeriod.

Referenced by detinfo::detectorClocksStandardDataFor().

166  {
167  return DetectorClocksData{
168  g4_ref_time,
170  trigger_time,
171  beam_time,
172  ElecClock{trigger_time, fConfigValue[kFramePeriod], fConfigValue[kClockSpeedTPC]},
173  ElecClock{trigger_time, fConfigValue[kFramePeriod], fConfigValue[kClockSpeedOptical]},
174  ElecClock{trigger_time, fConfigValue[kFramePeriod], fConfigValue[kClockSpeedTrigger]},
176  }
timescale_traits< TriggerTimeCategory >::time_point_t trigger_time
A point in time on the trigger time scale.
double fTriggerOffsetTPC
Time offset from trigger to TPC readout start.
constexpr double kDEFAULT_FREQUENCY_EXTERNAL
Default External clock speed in MHz.
constexpr double kDEFAULT_FRAME_PERIOD
Default Frame period in micro-second.
DetectorClocksData detinfo::DetectorClocksStandard::DataForJob ( ) const
inlineoverridevirtual

Returns a complete detinfo::DetectorClocksData object.

The returned timing information is based on information independent of the current input file, run or event. It is recommended that DataFor() is used instead whenever possible.

Implements detinfo::DetectorClocks.

Definition at line 150 of file DetectorClocksStandard.h.

References fBeamGateTime, fConfigValue, fTriggerOffsetTPC, fTriggerTime, detinfo::kClockSpeedOptical, detinfo::kClockSpeedTPC, detinfo::kClockSpeedTrigger, detinfo::kDEFAULT_FRAME_PERIOD, detinfo::kDEFAULT_FREQUENCY_EXTERNAL, detinfo::kFramePeriod, and detinfo::kG4RefTime.

Referenced by debugReport().

151  {
152  return DetectorClocksData{
153  fConfigValue[kG4RefTime], // FIXME: Should be run-dependent?
155  fTriggerTime,
157  ElecClock{fTriggerTime, fConfigValue[kFramePeriod], fConfigValue[kClockSpeedTPC]},
158  ElecClock{fTriggerTime, fConfigValue[kFramePeriod], fConfigValue[kClockSpeedOptical]},
159  ElecClock{fTriggerTime, fConfigValue[kFramePeriod], fConfigValue[kClockSpeedTrigger]},
161  }
double fTriggerTime
Trigger time in [us].
double fBeamGateTime
BeamGate time in [us].
double fTriggerOffsetTPC
Time offset from trigger to TPC readout start.
constexpr double kDEFAULT_FREQUENCY_EXTERNAL
Default External clock speed in MHz.
constexpr double kDEFAULT_FRAME_PERIOD
Default Frame period in micro-second.
void detinfo::DetectorClocksStandard::debugReport ( ) const

Dumps the current configuration to screen.

Definition at line 54 of file DetectorClocksStandard.cxx.

References DataForJob(), detinfo::DetectorClocksData::debugReport(), fConfigName, fConfigValue, value, and util::zip().

Referenced by DataFor().

55 {
56  std::cout << "fConfigValues contents: " << std::endl;
57 
58  for (auto const& [name, value] : util::zip(fConfigName, fConfigValue))
59  std::cout << "\n " << name << " ... " << value;
60  std::cout << std::endl;
61 
62  DataForJob().debugReport(std::cout);
63  std::cout.flush();
64 
65 } // detinfo::DetectorClocksStandard::debugReport()
DetectorClocksData DataForJob() const override
Returns a complete detinfo::DetectorClocksData object.
std::vector< std::string > fConfigName
double value
Definition: spectrum.C:18
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.
Definition: zip.h:293
void debugReport(Stream &out) const
std::string detinfo::DetectorClocksStandard::G4RefCorrTrigModuleName ( ) const
inline

Returns the input tag of the trigger data product for G4Ref correctons.

Returns
the input tag of the trigger data product (as string)

The trigger module name is set directly in the configuration as G4RefCorrTrigModuleName.

Definition at line 145 of file DetectorClocksStandard.h.

References fG4RefCorrTrigModuleName.

Referenced by detinfo::detectorClocksStandardDataFor().

bool detinfo::DetectorClocksStandard::IsRightConfig ( const fhicl::ParameterSet ps) const

Internal function used to search for the right configuration set in the data file

Definition at line 46 of file DetectorClocksStandard.cxx.

References fConfigName, and fhicl::ParameterSet::has_key().

Referenced by DataFor(), and detinfo::DetectorClocksServiceStandard::postOpenFile().

47 {
48  if (ps.has_key("module_label")) { return false; }
49  return std::all_of(fConfigName.cbegin(), fConfigName.cend(), [&ps](auto const& config_name) {
50  return ps.has_key(config_name);
51  });
52 }
std::vector< std::string > fConfigName
bool has_key(std::string const &key) const
void detinfo::DetectorClocksStandard::SetConfigValue ( size_t  i,
double  val 
)
inline

Definition at line 127 of file DetectorClocksStandard.h.

References fConfigValue.

Referenced by detinfo::DetectorClocksServiceStandard::postOpenFile().

127 { fConfigValue[i] = val; }
void detinfo::DetectorClocksStandard::SetTriggerTime ( double const  trig_time,
double const  beam_time 
)
inlineprivate

Setter for trigger times.

Parameters
trig_timehardware triggertime" in @ref DetectorClocksElectronicsTime "electronics time scale" @param beam_time @ref DetectorClocksBeamGateOpening "beam gate opening time" in @ref DetectorClocksElectronicsTime "electronics time scale"

The hardware trigger and beam gate opening times are set, and the electronic clocks are updated to store the new trigger time.

Definition at line 200 of file DetectorClocksStandard.h.

References fBeamGateTime, fConfigValue, fFramePeriod, fTPCClock, fTriggerTime, and detinfo::kClockSpeedTPC.

Referenced by ApplyParams(), and DetectorClocksStandard().

201  {
202  fTriggerTime = trig_time;
203  fBeamGateTime = beam_time;
205  }
double fTriggerTime
Trigger time in [us].
double fBeamGateTime
BeamGate time in [us].
double detinfo::DetectorClocksStandard::TriggerOffsetTPC ( ) const
inlineprivate

Definition at line 207 of file DetectorClocksStandard.h.

References detinfo::ElecClock::Frequency(), fTPCClock, and fTriggerOffsetTPC.

208  {
209  if (fTriggerOffsetTPC < 0)
210  return fTriggerOffsetTPC;
211  else
212  return -fTriggerOffsetTPC / fTPCClock.Frequency(); // convert ticks to
213  // us
214  }
double fTriggerOffsetTPC
Time offset from trigger to TPC readout start.
constexpr double Frequency() const
Frequency in MHz.
Definition: ElecClock.h:176
std::string const& detinfo::DetectorClocksStandard::TrigModuleName ( ) const
inline

Returns the input tag of the trigger data product.

Returns
the input tag of the trigger data product (as string)

The trigger module name is set directly in the configuration as TrigModuleName.

Definition at line 136 of file DetectorClocksStandard.h.

References fTrigModuleName.

Referenced by detinfo::detectorClocksStandardDataFor().

Member Data Documentation

double detinfo::DetectorClocksStandard::fBeamGateTime
private

BeamGate time in [us].

Definition at line 229 of file DetectorClocksStandard.h.

Referenced by DataForJob(), DetectorClocksStandard(), and SetTriggerTime().

std::vector<std::string> detinfo::DetectorClocksStandard::fConfigName
private
std::vector<double> detinfo::DetectorClocksStandard::fConfigValue
private
double detinfo::DetectorClocksStandard::fFramePeriod
private

Frame period.

Definition at line 232 of file DetectorClocksStandard.h.

Referenced by ApplyParams(), DetectorClocksStandard(), and SetTriggerTime().

std::string detinfo::DetectorClocksStandard::fG4RefCorrTrigModuleName
private

Definition at line 220 of file DetectorClocksStandard.h.

Referenced by DetectorClocksStandard(), and G4RefCorrTrigModuleName().

ElecClock detinfo::DetectorClocksStandard::fTPCClock
private
double detinfo::DetectorClocksStandard::fTriggerOffsetTPC
private

Time offset from trigger to TPC readout start.

Definition at line 223 of file DetectorClocksStandard.h.

Referenced by ApplyParams(), DataFor(), DataForJob(), DetectorClocksStandard(), and TriggerOffsetTPC().

double detinfo::DetectorClocksStandard::fTriggerTime
private

Trigger time in [us].

Definition at line 226 of file DetectorClocksStandard.h.

Referenced by DataForJob(), DetectorClocksStandard(), and SetTriggerTime().

std::string detinfo::DetectorClocksStandard::fTrigModuleName
private

Definition at line 219 of file DetectorClocksStandard.h.

Referenced by DetectorClocksStandard(), and TrigModuleName().


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