LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
DetectorClocksStandard.h
Go to the documentation of this file.
1 //
3 // DetectorClocks.h
4 //
5 // This class provides electronics various electronics clocks. Currently supports
6 // three types of clocks: TPC, Optical, and Trigger in order to support the
7 // MicroBooNE experiment.
8 //
9 // Formally known as TimeService.
10 //
12 
13 #ifndef LARDATAALG_DETECTORINFO_DETECTORCLOCKSSTANDARD_H
14 #define LARDATAALG_DETECTORINFO_DETECTORCLOCKSSTANDARD_H
15 
16 #include <stddef.h>
17 #include <string>
18 #include <vector>
19 
20 #include "fhiclcpp/fwd.h"
24 
25 namespace detinfo {
26 
122  class DetectorClocksStandard final : public DetectorClocks {
123  public:
126 
127  void SetConfigValue(size_t i, double val) { fConfigValue[i] = val; }
128 
136  std::string const& TrigModuleName() const { return fTrigModuleName; }
137 
145  std::string G4RefCorrTrigModuleName() const { return fG4RefCorrTrigModuleName; }
146 
147  std::vector<std::string> const& ConfigNames() const override { return fConfigName; }
148  std::vector<double> const& ConfigValues() const override { return fConfigValue; }
149 
151  {
152  return DetectorClocksData{
153  fConfigValue[kG4RefTime], // FIXME: Should be run-dependent?
155  fTriggerTime,
158  ElecClock{fTriggerTime, fConfigValue[kFramePeriod], fConfigValue[kClockSpeedOptical]},
159  ElecClock{fTriggerTime, fConfigValue[kFramePeriod], fConfigValue[kClockSpeedTrigger]},
161  }
162 
163  DetectorClocksData DataFor(double const g4_ref_time,
164  double const trigger_time,
165  double const beam_time) const override
166  {
167  return DetectorClocksData{
168  g4_ref_time,
170  trigger_time,
171  beam_time,
173  ElecClock{trigger_time, fConfigValue[kFramePeriod], fConfigValue[kClockSpeedOptical]},
174  ElecClock{trigger_time, fConfigValue[kFramePeriod], fConfigValue[kClockSpeedTrigger]},
176  }
177 
179  void ApplyParams();
180 
183  bool IsRightConfig(const fhicl::ParameterSet& ps) const;
184 
186  void debugReport() const;
187 
188  private:
200  void SetTriggerTime(double const trig_time, double const beam_time)
201  {
202  fTriggerTime = trig_time;
203  fBeamGateTime = beam_time;
205  }
206 
207  double TriggerOffsetTPC() const
208  {
209  if (fTriggerOffsetTPC < 0)
210  return fTriggerOffsetTPC;
211  else
212  return -fTriggerOffsetTPC / fTPCClock.Frequency(); // convert ticks to
213  // us
214  }
215 
216  std::vector<std::string> fConfigName;
217  std::vector<double> fConfigValue;
218 
219  std::string fTrigModuleName;
221 
224 
226  double fTriggerTime;
227 
230 
232  double fFramePeriod;
233 
235  }; // class DetectorClocksStandard
236 
237 } // namespace detinfo
238 
239 #endif // LARDATAALG_DETECTORINFO_DETECTORCLOCKSSTANDARD_H
DetectorClocksData DataFor(double const g4_ref_time, double const trigger_time, double const beam_time) const override
Returns a complete detinfo::DetectorClocksData object.
DetectorClocksData DataForJob() const override
Returns a complete detinfo::DetectorClocksData object.
bool IsRightConfig(const fhicl::ParameterSet &ps) const
void debugReport() const
Dumps the current configuration to screen.
std::vector< std::string > fConfigName
std::string const & TrigModuleName() const
Returns the input tag of the trigger data product.
std::vector< std::string > const & ConfigNames() const override
pure virtual base interface for detector clocks
std::vector< double > const & ConfigValues() const override
double fTriggerTime
Trigger time in [us].
timescale_traits< TriggerTimeCategory >::time_point_t trigger_time
A point in time on the trigger time scale.
void ApplyParams()
Internal function to apply loaded parameters to member attributes.
double fBeamGateTime
BeamGate time in [us].
std::string G4RefCorrTrigModuleName() const
Returns the input tag of the trigger data product for G4Ref correctons.
double fTriggerOffsetTPC
Time offset from trigger to TPC readout start.
General LArSoft Utilities.
Class used for the conversion of times between different formats and references.
constexpr double kDEFAULT_FREQUENCY_EXTERNAL
Default External clock speed in MHz.
void SetConfigValue(size_t i, double val)
Contains all timing reference information for the detector.
constexpr double kDEFAULT_FRAME_PERIOD
Default Frame period in micro-second.
void SetTriggerTime(double const trig_time, double const beam_time)
Setter for trigger times.
Implementation of detinfo::DetectorClocks interface with fixed settings from configuration.
constexpr double Frequency() const
Frequency in MHz.
Definition: ElecClock.h:176
Class def header for a class ElecClock.
DetectorClocksStandard(fhicl::ParameterSet const &pset)
Class representing the time measured by an electronics clock.
Definition: ElecClock.h:91
Functions to load trigger time in detinfo::DetectorClocksStandard.