DetectorClocksStandardGAr.cxx
Go to the documentation of this file.
2 
4 
5 namespace gar {
6 
7  //-------------------------------------------------------------------------
9  : fConfigName (detinfo::kInheritConfigTypeMax, "")
10  , fConfigValue (detinfo::kInheritConfigTypeMax, 0)
11  , fTrigModuleName ("")
12  , fG4RefTime (detinfo::kDEFAULT_MC_CLOCK_T0)
13  , fFramePeriod (detinfo::kDEFAULT_FRAME_PERIOD)
17  , fTriggerOffsetTPC(detinfo::kDEFAULT_TRIG_OFFSET_TPC)
18  , fTriggerTime (0)
19  , fBeamGateTime (0)
20  {
21 
22  fConfigName.at(detinfo::kG4RefTime) = "G4RefTime";
23  fConfigName.at(detinfo::kTriggerOffsetTPC) = "TriggerOffsetTPC";
24  fConfigName.at(detinfo::kFramePeriod) = "FramePeriod";
25  fConfigName.at(detinfo::kClockSpeedTPC) = "ClockSpeedTPC";
26  fConfigName.at(detinfo::kClockSpeedTrigger) = "ClockSpeedTrigger";
27  fConfigName.at(detinfo::kClockSpeedExternal) = "ClockSpeedExternal";
28  fConfigName.at(detinfo::kDefaultTrigTime) = "DefaultTrigTime";
29  fConfigName.at(detinfo::kDefaultBeamTime) = "DefaultBeamTime";
30  fConfigName.at(detinfo::kDefaultSpillLength) = "DefaultSpillLength";
31 
32  fInheritClockConfig = false;
33  }
34 
35  //-------------------------------------------------------------------------
38  {
39  // In a constructor, the version of virtual method that is called
40  // is always the one specific of the class being constructed
41  // (the one mentioned in the name of the constructor itself).
42  // For clarity, we explicitly show that:
44 
45  }
46 
47 
48  //------------------------------------------------------------------
50  {
51  return true;
52  }
53 
54  //------------------------------------------------------------------
56  {
57 
58  // Read fcl parameters
59  fTrigModuleName = pset.get< std::string >( "TrigModuleName" );
60  fInheritClockConfig = pset.get< bool >( "InheritClockConfig" );
61  fConfigValue.at(kG4RefTime) = pset.get< double >( fConfigName.at(kG4RefTime) .c_str() );
62  fConfigValue.at(kFramePeriod) = pset.get< double >( fConfigName.at(kFramePeriod) .c_str() );
63  fConfigValue.at(kTriggerOffsetTPC) = pset.get< double >( fConfigName.at(kTriggerOffsetTPC) .c_str() );
64  fConfigValue.at(kClockSpeedTPC) = pset.get< double >( fConfigName.at(kClockSpeedTPC) .c_str() );
65  fConfigValue.at(kClockSpeedTrigger) = pset.get< double >( fConfigName.at(kClockSpeedTrigger) .c_str() );
66  fConfigValue.at(kClockSpeedExternal) = pset.get< double >( fConfigName.at(kClockSpeedExternal).c_str() );
67  fConfigValue.at(kDefaultTrigTime) = pset.get< double >( fConfigName.at(kDefaultTrigTime) .c_str() );
68  fConfigValue.at(kDefaultBeamTime) = pset.get< double >( fConfigName.at(kDefaultBeamTime) .c_str() );
69  fConfigValue.at(kDefaultSpillLength) = pset.get< double >( fConfigName.at(kDefaultSpillLength).c_str() );
70 
71  // Save fcl parameters in a container to check for inheritance
73 
74  ApplyParams();
75 
76  return true;
77  }
78 
79  //-----------------------------------
81  //-----------------------------------
82  {
83 
87 
90 
91  }
92 
93  //------------------------------------------------------------------------
95  //------------------------------------------------------------------------
96  {
97  std::string s;
98  double d;
99 
100  bool result = !ps.get_if_present("module_label", s);
101  for(size_t i = 0; result && i < kInheritConfigTypeMax; ++i)
102 
103  result = result && ps.get_if_present(fConfigName.at(i).c_str(),d);
104 
105  return result;
106  }
107 
108  //-----------------------------------------
110  //-----------------------------------------
111  {
112  MF_LOG_VERBATIM("DetectorClocksStandardGAr")
113  << "fConfigValues contents: ";
114 
115  for(size_t i = 0; i < kInheritConfigTypeMax; ++i)
116  MF_LOG_VERBATIM("DetectorClocksStandardGAr")
117  << " "
118  << fConfigName.at(i).c_str()
119  << " ... "
120  << fConfigValue.at(i);
121 
122  MF_LOG_VERBATIM("DetectorClocksStandardGAr")
123  << "Trigger time @ " << fTriggerTime
124  << "\nBeamGate time @ " << fBeamGateTime
125  << "\nTrigOffsetTPC @ " << TriggerOffsetTPC()
126  << "\nG4RefTime @ " << fG4RefTime
127  << "\nTPC Freq. @ " << fTPCClock.Frequency()
128  << "\nTrigger Freq. @ " << fTriggerClock.Frequency()
129  << "\nExternal Freq. @ " << fExternalClock.Frequency()
130  << "\nTPC start tick [tdc] : " << TPCTick2TDC(0)
131  << "\nTPC start tick from trigger [ns] : " << TPCTick2TrigTime(0)
132  << "\nTPC start tick from beam [ns] : " << TPCTick2BeamTime(0)
133  << "\nTPC tdc=0 in tick : " << TPCTDC2Tick(0)
134  << "\nTPC G4 time 0 in tick : " << TPCG4Time2Tick(0);
135 
136  }
137 
138 }
const double kDEFAULT_FREQUENCY_TRIGGER
Default Trigger clock speed in MHz.
virtual double TPCTick2TrigTime(double tick) const
Given TPC time-tick (waveform index), returns time [ns] w.r.t. trigger time stamp.
static QCString result
bool IsRightConfig(const fhicl::ParameterSet &ps) const
Internal function used to search for the right configuration set in the data file.
std::string string
Definition: nybbler.cc:12
const double kDEFAULT_FRAME_PERIOD
Default Frame period in nano-second.
const double kDEFAULT_MC_CLOCK_T0
Default G4 reference time in nano-second.
void ApplyParams()
Internal function to apply loaded parameters to member attributes.
const double kDEFAULT_FREQUENCY_TPC
Default TPC clock speed in MHz.
double fG4RefTime
Electronics clock counting start time in G4 time frame [us].
virtual double TPCG4Time2Tick(double g4time) const
Given G4 time returns electronics clock count [tdc].
double fTriggerOffsetTPC
Time offset from trigger to TPC readout start.
bool Configure(fhicl::ParameterSet const &pset)
T get(std::string const &key) const
Definition: ParameterSet.h:271
General LArSoft Utilities.
static constexpr double ps
Definition: Units.h:99
const double kDEFAULT_FREQUENCY_EXTERNAL
Default External clock speed in MHz.
const double kDEFAULT_TRIG_OFFSET_TPC
Default TPC readout start time offset from trigger in nano-second.
General GArSoft Utilities.
#define MF_LOG_VERBATIM(category)
double Frequency() const
Frequency in MHz.
Definition: ElecClock.h:89
virtual double TPCTDC2Tick(double tdc) const
Given electronics clock count [tdc] returns TPC time-tick.
virtual double TPCTick2TDC(double tick) const
Given TPC time-tick (waveform index), returns electronics clock count [tdc].
virtual double TPCTick2BeamTime(double tick) const
Given TPC time-tick (waveform index), returns time [ns] w.r.t. beam gate time.
static QCString * s
Definition: config.cpp:1042