LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
DetectorClocksStandard.cxx
Go to the documentation of this file.
2 
3 //-------------------------------------------------------------------------
5  : fConfigName(detinfo::kInheritConfigTypeMax,""),
6  fConfigValue(detinfo::kInheritConfigTypeMax,0),
7  fInheritClockConfig(false),
8  fTrigModuleName(""),
9  fG4RefTime (detinfo::kDEFAULT_MC_CLOCK_T0),
10  fFramePeriod (detinfo::kDEFAULT_FRAME_PERIOD),
15  fTriggerOffsetTPC (detinfo::kDEFAULT_TRIG_OFFSET_TPC),
16  fTriggerTime(detinfo::kDEFAULT_TRIG_TIME),
17  fBeamGateTime(detinfo::kDEFAULT_BEAM_TIME)
18 {
19 
20  fConfigName.at(detinfo::kG4RefTime) = "G4RefTime";
21  fConfigName.at(detinfo::kTriggerOffsetTPC) = "TriggerOffsetTPC";
22  fConfigName.at(detinfo::kFramePeriod) = "FramePeriod";
23  fConfigName.at(detinfo::kClockSpeedTPC) = "ClockSpeedTPC";
24  fConfigName.at(detinfo::kClockSpeedOptical) = "ClockSpeedOptical";
25  fConfigName.at(detinfo::kClockSpeedTrigger) = "ClockSpeedTrigger";
26  fConfigName.at(detinfo::kClockSpeedExternal) = "ClockSpeedExternal";
27  fConfigName.at(detinfo::kDefaultTrigTime) = "DefaultTrigTime";
28  fConfigName.at(detinfo::kDefaultBeamTime) = "DefaultBeamTime";
29 }
30 
31 //-------------------------------------------------------------------------
34 {
35  // In a constructor, the version of virtual method that is called
36  // is always the one specific of the class being constructed
37  // (the one mentioned in the name of the constructor itself).
38  // For clarity, we explicitly show that:
40 
41 }
42 
43 
44 //------------------------------------------------------------------
46 {
47  return true;
48 }
49 
50 //------------------------------------------------------------------
52 {
53 
54  // Read fcl parameters
55  fInheritClockConfig = pset.get< bool >( "InheritClockConfig" );
56  fTrigModuleName = pset.get< std::string >( "TrigModuleName" );
57  fConfigValue.at(kG4RefTime) = pset.get< double >( fConfigName.at(kG4RefTime).c_str() );
58  fConfigValue.at(kFramePeriod) = pset.get< double >( fConfigName.at(kFramePeriod).c_str() );
59  fConfigValue.at(kTriggerOffsetTPC) = pset.get< double >( fConfigName.at(kTriggerOffsetTPC).c_str());
60  fConfigValue.at(kClockSpeedTPC) = pset.get< double >( fConfigName.at(kClockSpeedTPC).c_str() );
61  fConfigValue.at(kClockSpeedOptical) = pset.get< double >( fConfigName.at(kClockSpeedOptical).c_str());
62  fConfigValue.at(kClockSpeedTrigger) = pset.get< double >( fConfigName.at(kClockSpeedTrigger).c_str() );
63  fConfigValue.at(kClockSpeedExternal)= pset.get< double >( fConfigName.at(kClockSpeedExternal).c_str());
64  fConfigValue.at(kDefaultTrigTime) = pset.get< double >( fConfigName.at(kDefaultTrigTime).c_str() );
65  fConfigValue.at(kDefaultBeamTime) = pset.get< double >( fConfigName.at(kDefaultBeamTime).c_str() );
66  ApplyParams();
68  return true;
69 }
70 
71 //-----------------------------------
73 //-----------------------------------
74 {
75 
81  // FIXME: fExternalClock is not initialized!!!
85 }
86 
87 //------------------------------------------------------------------------
89 //------------------------------------------------------------------------
90 {
91  std::string s;
92  double d;
93 
94  // TODO replace with has_key()
95  bool result = !ps.get_if_present("module_label", s);
96  for(size_t i=0; result && i<kInheritConfigTypeMax; ++i)
97 
98  result = result && ps.get_if_present(fConfigName.at(i).c_str(),d);
99 
100  return result;
101 }
102 
103 //-----------------------------------------
105 //-----------------------------------------
106 {
107  std::cout << "fConfigValues contents: "<<std::endl;
108  for(size_t i=0;i<kInheritConfigTypeMax; ++i)
109 
110  std::cout<<" "<<fConfigName.at(i).c_str()<<" ... "<<fConfigValue.at(i)<<std::endl;
111 
112  std::cout<<std::endl;
113 
114  std::cout
115  << "Trigger time @ " << fTriggerTime << std::endl
116  << "BeamGate time @ " << fBeamGateTime << std::endl
117  << "TrigOffsetTPC @ " << TriggerOffsetTPC() << std::endl
118  << "G4RefTime @ " << fG4RefTime << std::endl
119  << "TPC Freq. @ " << fTPCClock.Frequency() << std::endl
120  << "Optical Freq. @ " << fOpticalClock.Frequency() << std::endl
121  << "Trigger Freq. @ " << fTriggerClock.Frequency() << std::endl
122  << "External Freq. @ " << fExternalClock.Frequency() << std::endl
123  << "TPC start tick [tdc] : " << TPCTick2TDC(0) <<std::endl
124  << "TPC start tick from trigger [us] : " << TPCTick2TrigTime(0) <<std::endl
125  << "TPC start tick from beam [us] : " << TPCTick2BeamTime(0) <<std::endl
126  << "TPC tdc=0 in tick : " << TPCTDC2Tick(0) << std::endl
127  << "TPC G4 time 0 in tick : " << TPCG4Time2Tick(0) << std::endl
128  << std::endl;
129 
130 }
131 
132 //-----------------------------------------
134 //-----------------------------------------
135 {
136  std::vector<double> const& cfgValues = ConfigValues();
137 
139  cfgValues.at(detinfo::kDefaultTrigTime),
140  cfgValues.at(detinfo::kDefaultBeamTime)
141  );
142 
143 } // detinfo::DetectorClocksStandard::SetDefaultTriggerTime()
144 
145 
Float_t s
Definition: plot.C:23
::detinfo::ElecClock fTPCClock
TPC clock.
bool Configure(fhicl::ParameterSet const &pset)
bool IsRightConfig(const fhicl::ParameterSet &ps) const
Internal function used to search for the right configuration set in the data file.
virtual double TPCTDC2Tick(double tdc) const override
Given electronics clock count [tdc] returns TPC time-tick.
const double kDEFAULT_MC_CLOCK_T0
Default G4 reference time in micro-second.
std::vector< std::string > fConfigName
const double kDEFAULT_FREQUENCY_EXTERNAL
Default External clock speed in MHz.
::detinfo::ElecClock fOpticalClock
Optical clock.
::detinfo::ElecClock fTriggerClock
Trigger clock.
virtual void SetTriggerTime(double trig_time, double beam_time)
Setter for trigger times.
double fTriggerTime
Trigger time in [us].
double fG4RefTime
Electronics clock counting start time in G4 time frame [us].
const double kDEFAULT_FREQUENCY_OPTICAL
Default Optical clock speed in MHz.
const double kDEFAULT_FRAME_PERIOD
Default Frame period in micro-second.
void ApplyParams()
Internal function to apply loaded parameters to member attributes.
const double kDEFAULT_FREQUENCY_TRIGGER
Default Trigger clock speed in MHz.
T get(std::string const &key) const
Definition: ParameterSet.h:231
virtual double TPCTick2TDC(double tick) const override
Given TPC time-tick (waveform index), returns electronics clock count [tdc].
virtual std::vector< double > ConfigValues() const override
double fBeamGateTime
BeamGate time in [us].
virtual double TriggerOffsetTPC() const override
Float_t d
Definition: plot.C:237
double fTriggerOffsetTPC
Time offset from trigger to TPC readout start.
General LArSoft Utilities.
void SetDefaultTriggerTime()
Sets trigger and beam gate time from default configuration values.
const double kDEFAULT_FREQUENCY_TPC
Default TPC clock speed in MHz.
const double kDEFAULT_TRIG_OFFSET_TPC
Default TPC readout start time offset from trigger in micro-second.
::detinfo::ElecClock fExternalClock
External clock.
Implementation of detinfo::DetectorClocks interface with fixed settings from configuration.
virtual double TPCG4Time2Tick(double g4time) const override
Given G4 time returns electronics clock count [tdc].
const double kDEFAULT_TRIG_TIME
Default TriggerTime in micro-second.
Class representing the time measured by an electronics clock.
Definition: ElecClock.h:91
virtual double TPCTick2BeamTime(double tick) const override
Given TPC time-tick (waveform index), returns time [us] w.r.t. beam gate time.
double Frequency() const
Frequency in MHz.
Definition: ElecClock.h:229
const double kDEFAULT_BEAM_TIME
Default BeamGateTime in micro-second.
virtual double TPCTick2TrigTime(double tick) const override
Given TPC time-tick (waveform index), returns time [us] w.r.t. trigger time stamp.