Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
novaddt::SendTriggerSignal Class Reference
Inheritance diagram for novaddt::SendTriggerSignal:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Types

using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 SendTriggerSignal (fhicl::ParameterSet const &p)
 
virtual ~SendTriggerSignal ()
 
virtual void analyze (art::Event const &e)
 
void startHeartbeat ()
 
void stopHeartbeat ()
 
double convertTDCtoSeconds (uint64_t tdc)
 
std::string workerType () const
 
void doBeginJob ()
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
std::string const & processName () const
 
bool wantAllEvents () const
 
bool wantEvent (Event const &e)
 
fhicl::ParameterSetID selectorConfig () const
 
Handle< TriggerResults > getTriggerResults (Event const &e) const
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< TconsumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< TmayConsumeView (InputTag const &tag)
 

Public Attributes

nova::novadaqmonitorclient::NdmcClient _daqMonClient
 

Protected Member Functions

detail::ProcessAndEventSelectors & processAndEventSelectors ()
 
ConsumesCollector & consumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< Tconsumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< TmayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Private Member Functions

uint32_t cast_to_32_bits (uint64_t const &x) const
 

Private Attributes

std::vector< std::stringtrigger_labels_
 
bool send_trigger_messages_
 
bool verbose_
 
int rms_partition_
 
std::string rms_mailbox_
 
boost::shared_ptr< provider::DDSConnectionrms_connection_
 
base::RmsDestination rms_destination_
 
RmsSender< provider::DDSConnection, ddtmessages::DDTTriggerMessage > rms_sender_
 
bool make_ganglia_metrics_
 
int32_t OverallTriggerRate
 
std::map< std::string, int32_t > m_trigger_rates
 
std::map< std::string, int32_t > m_trigger_lengths
 
std::map< std::string, int32_t > m_trigger_delays
 
int32_t _monIdPartitionHeartbeat
 

Detailed Description

Definition at line 53 of file SendTriggerSignal_module.cc.

Member Typedef Documentation

Definition at line 25 of file EDAnalyzer.h.

using art::EDAnalyzer::WorkerType = WorkerT<EDAnalyzer>
inherited

Definition at line 24 of file EDAnalyzer.h.

Constructor & Destructor Documentation

novaddt::SendTriggerSignal::SendTriggerSignal ( fhicl::ParameterSet const &  p)
explicit

Definition at line 91 of file SendTriggerSignal_module.cc.

References _daqMonClient, AVERAGE, om::cout, allTimeWatchdog::endl, m_trigger_delays, m_trigger_lengths, m_trigger_rates, make_ganglia_metrics_, OverallTriggerRate, RATE, rms_mailbox_, rms_partition_, startHeartbeat(), and trigger_labels_.

91  :
92  EDAnalyzer(p),
93  trigger_labels_(p.get<std::vector<std::string>>("trigger_labels")),
94  send_trigger_messages_(p.get<bool>("send_trigger_messages", true)),
95  verbose_(p.get<bool>("verbose", false)),
96  rms_partition_(p.get<int>("rms_partition_number")),
97  rms_mailbox_(p.get<std::string>("rms_mailbox")),
99  ("GlobalTriggerTestApplication", rms_partition_)),
101  base::RmsDestination::TRIGGER_CHANNEL),
103  make_ganglia_metrics_(p.get<bool>("make_ganglia_metrics", true))
104 {
105  std::cout << "\nUsing Partition: " << rms_partition_
106  << "\nUsing Mailbox: " << rms_mailbox_ << "\n" << std::endl;
107 
109  // set ganglia partition.
110  _daqMonClient.setPartition(rms_partition_);
111  _daqMonClient.setGroupName("DDT");
112  // starting ganglia heartbeat
113  startHeartbeat();
114 
115  OverallTriggerRate = _daqMonClient.createMetric<double>(
116  "Overall Trigger Rate", "Hz",
118  "Combined rate of all triggers");
119  } // end of make_ganglia_metrics
120 
121  std::cout << "\nSending Messages for the following trigger modules:"
122  << std::endl;
123  for (auto const & trig : trigger_labels_){
124  std::cout << "\t" << trig << std::endl;
126  // setup ganglia metrics
127  // This would be nice to do using the names from TriggerDefines.h,
128  // but at this stage all we have are the module name strings.
129  // The modules themselves have trigger masks hard coded into them, so they're
130  // impossible to access from here, only from the decisions they issue.
131  // As a stop gap we can use the module label
132  m_trigger_rates[trig] = _daqMonClient.createMetric<double>(
133  trig+" Trigger Rate", "Hz",
135  "rate of the "+trig+" trigger");
136 
137  m_trigger_lengths[trig] = _daqMonClient.createMetric<uint32_t>(
138  trig+" Trigger average length", "TDC",
140  "Average length of the "+trig+" trigger");
141 
142  m_trigger_delays[trig] = _daqMonClient.createMetric<double>(
143  trig+" Trigger average delay", "ms",
145  "Average delay of the "+trig+" trigger");
146  } // end of make_ganglia_metrics
147  } // end of loop on trigger_labels_
148 }
std::map< std::string, int32_t > m_trigger_lengths
std::map< std::string, int32_t > m_trigger_rates
const char * p
Definition: xmltok.h:285
Definition: Ndmc.h:37
boost::shared_ptr< provider::DDSConnection > rms_connection_
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:27
std::map< std::string, int32_t > m_trigger_delays
Definition: Ndmc.h:38
nova::novadaqmonitorclient::NdmcClient _daqMonClient
OStream cout
Definition: OStream.cxx:6
RmsSender< provider::DDSConnection, ddtmessages::DDTTriggerMessage > rms_sender_
std::vector< std::string > trigger_labels_
enum BeamMode string
novaddt::SendTriggerSignal::~SendTriggerSignal ( )
virtual

Definition at line 150 of file SendTriggerSignal_module.cc.

References om::cerr, gov::fnal::cd::rms::RmsSender< C, M >::close(), allTimeWatchdog::endl, make_ganglia_metrics_, rms_connection_, rms_sender_, and stopHeartbeat().

151 {
152  try
153  {
154  rms_sender_.close();
155  rms_connection_->close();
156  } catch (...) {
157  std::cerr << "\nAn exception occured when closeing the DDS connections.\n"
158  << std::endl;
159  }
161  // stop ganglia heartbeat
162  stopHeartbeat();
163  } // end of make_ganglia_metrics
164 }
OStream cerr
Definition: OStream.cxx:7
boost::shared_ptr< provider::DDSConnection > rms_connection_
RmsSender< provider::DDSConnection, ddtmessages::DDTTriggerMessage > rms_sender_

Member Function Documentation

void novaddt::SendTriggerSignal::analyze ( art::Event const &  e)
virtual

Implements art::EDAnalyzer.

Definition at line 166 of file SendTriggerSignal_module.cc.

References _daqMonClient, cast_to_32_bits(), convertTDCtoSeconds(), novadaq::timeutils::convertUnixTimeToNovaTime(), om::cout, allTimeWatchdog::endl, art::Handle< T >::failedToGet(), art::DataViewImpl::getByLabel(), m_trigger_delays, m_trigger_lengths, m_trigger_rates, make_ganglia_metrics_, lem_server::msg, recentWatchdog::now, OverallTriggerRate, rms_sender_, send_trigger_messages_, gov::fnal::cd::rms::RmsSender< C, M >::sendMessage(), trigger_labels_, daqdataformats::TRIGSRC_ID_BUFFNODE_1, and verbose_.

167 {
168 
169  for (auto const& trigger_label : trigger_labels_)
170  {
171  art::Handle<std::vector<TriggerDecision>> trigger_decisions;
172  e.getByLabel(trigger_label, trigger_decisions);
173  if (trigger_decisions.failedToGet()){
174  if (verbose_) std::cout << "\tno trigger decision objects found for trigger module " << trigger_label << std::endl;
175  continue;
176  }
177  if (verbose_ && trigger_decisions->size() > 0)
178  std::cout << "\tsending " << trigger_decisions->size()
179  << " trigger messages for trigger module "
180  << trigger_label << std::endl;
181 
182  unsigned n_decision(0);
183  for (auto const& decision : *trigger_decisions)
184  {
185  if (verbose_)
186  std::cout << "\tTrigger Decision "
187  << "(N, T0, dT, Bit, Prescale, Extra_Info) = ("
188  << ++n_decision
189  << ", " << decision.start()
190  << ", " << decision.duration()
191  << ", " << decision.mask()
192  << ", " << decision.prescale()
193  << ", 0x" << std::hex << decision.extra_info() << std::dec
194  << ")" << std::endl;
195 
196  ddtmessages::DDTTriggerMessage msg;
197 
198  // get the current time and convert it to NOvA time:
199  // daqdataformats::RawTriggerTime triggerTime;
200  timeval now;
201  gettimeofday(&now,0);
202  uint64_t nova_now;
204 
205  msg.trigger_type = decision.mask();
206  msg.start_time = decision.start();
207  msg.enabled = true;
208  msg.decision_time = nova_now;
209 
210  // convert the 64 MHz TDC counts into 2 MHz (500 ns) time windows
211  // and round up by one:
212  msg.duration = cast_to_32_bits(decision.duration() / 32 + 1);
213 
214  msg.time_to_decision = cast_to_32_bits(nova_now - decision.start());
215 
216  msg.prescale = decision.prescale();
217 
218  msg.process_id = decision.extra_info();
219 
220  // the following values have to be obtained from the environment:
221  msg.detector_id = 49;
223 
227  // Send the trigger metrics to ganglia
228  _daqMonClient.setValue(OverallTriggerRate,double(1.));
229  _daqMonClient.setValue(m_trigger_rates[trigger_label],double(1.));
230  _daqMonClient.setValue(m_trigger_lengths[trigger_label],(uint32_t)decision.duration());
231  // convert the delay (which is in TDC) to ms
232  double time_to_decisions_ms = convertTDCtoSeconds(nova_now - msg.start_time)*1000.;
233  _daqMonClient.setValue(m_trigger_delays[trigger_label],time_to_decisions_ms);
234  } // end of make_ganglia_metrics
235  }
236  }
237 }
std::map< std::string, int32_t > m_trigger_lengths
double convertTDCtoSeconds(uint64_t tdc)
std::map< std::string, int32_t > m_trigger_rates
std::map< std::string, int32_t > m_trigger_delays
void sendMessage(M &message)
Definition: RmsSender.h:117
uint32_t cast_to_32_bits(uint64_t const &x) const
nova::novadaqmonitorclient::NdmcClient _daqMonClient
OStream cout
Definition: OStream.cxx:6
RmsSender< provider::DDSConnection, ddtmessages::DDTTriggerMessage > rms_sender_
Float_t e
Definition: plot.C:35
std::vector< std::string > trigger_labels_
bool failedToGet() const
Definition: Handle.h:190
bool convertUnixTimeToNovaTime(struct timespec const &inputUnixTime, uint64_t &outputNovaTime)
uint32_t novaddt::SendTriggerSignal::cast_to_32_bits ( uint64_t const &  x) const
private

Definition at line 239 of file SendTriggerSignal_module.cc.

References fillBadChanDBTables::result.

Referenced by analyze().

240 {
241  uint32_t result;
242  uint32_t down_caster = 0xFFFFFFFF;
243 
244  // Let's grab the lowe 32 bits of the 64-bit input:
245  result = x & down_caster;
246 
247  return result;
248 }
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::consumes ( InputTag const &  tag)
protectedinherited

Definition at line 55 of file ModuleBase.h.

References art::ModuleBase::collector_, art::ConsumesCollector::consumes(), T, and getGoodRuns4SAM::tag.

56  {
57  return collector_.consumes<T, BT>(tag);
58  }
ConsumesCollector collector_
Definition: ModuleBase.h:50
ProductToken< T > consumes(InputTag const &)
double T
Definition: Xdiff_gwt.C:5
ConsumesCollector& art::ModuleBase::consumesCollector ( )
protectedinherited
template<typename T , BranchType BT>
void art::ModuleBase::consumesMany ( )
protectedinherited

Definition at line 69 of file ModuleBase.h.

References art::ModuleBase::collector_, art::ConsumesCollector::consumesMany(), and T.

70  {
71  collector_.consumesMany<T, BT>();
72  }
ConsumesCollector collector_
Definition: ModuleBase.h:50
double T
Definition: Xdiff_gwt.C:5
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::consumesView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::consumesView ( InputTag const &  tag)
inherited

Definition at line 62 of file ModuleBase.h.

References art::ModuleBase::collector_, art::ConsumesCollector::consumesView(), T, and getGoodRuns4SAM::tag.

63  {
64  return collector_.consumesView<T, BT>(tag);
65  }
ConsumesCollector collector_
Definition: ModuleBase.h:50
ViewToken< Element > consumesView(InputTag const &)
double T
Definition: Xdiff_gwt.C:5
double novaddt::SendTriggerSignal::convertTDCtoSeconds ( uint64_t  tdc)

Definition at line 263 of file SendTriggerSignal_module.cc.

References DEFINE_ART_MODULE().

Referenced by analyze().

264 {
265  // TDC clock ticks at 64 MHz
266  double one_tdc = 1. / 64e6;
267  return double(TDC) * one_tdc;
268 }
void art::detail::Analyzer::doBeginJob ( )
inherited
bool art::detail::Analyzer::doBeginRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited
bool art::detail::Analyzer::doBeginSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited
void art::detail::Analyzer::doEndJob ( )
inherited
bool art::detail::Analyzer::doEndRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited
bool art::detail::Analyzer::doEndSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited
bool art::detail::Analyzer::doEvent ( EventPrincipal ep,
ModuleContext const &  mc,
std::atomic< std::size_t > &  counts_run,
std::atomic< std::size_t > &  counts_passed,
std::atomic< std::size_t > &  counts_failed 
)
inherited
void art::detail::Analyzer::doRespondToCloseInputFile ( FileBlock const &  fb)
inherited
void art::detail::Analyzer::doRespondToCloseOutputFiles ( FileBlock const &  fb)
inherited
void art::detail::Analyzer::doRespondToOpenInputFile ( FileBlock const &  fb)
inherited
void art::detail::Analyzer::doRespondToOpenOutputFiles ( FileBlock const &  fb)
inherited
void art::Observer::fillDescriptions ( ModuleDescription const &  )
inherited
std::array<std::vector<ProductInfo>, NumBranchTypes> const& art::ModuleBase::getConsumables ( ) const
inherited
Handle<TriggerResults> art::Observer::getTriggerResults ( Event const &  e) const
inherited
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::mayConsume ( InputTag const &  tag)
protectedinherited

Definition at line 76 of file ModuleBase.h.

References art::ModuleBase::collector_, art::ConsumesCollector::mayConsume(), T, and getGoodRuns4SAM::tag.

77  {
78  return collector_.mayConsume<T, BT>(tag);
79  }
ProductToken< T > mayConsume(InputTag const &)
ConsumesCollector collector_
Definition: ModuleBase.h:50
double T
Definition: Xdiff_gwt.C:5
template<typename T , BranchType BT>
void art::ModuleBase::mayConsumeMany ( )
protectedinherited

Definition at line 90 of file ModuleBase.h.

References art::ModuleBase::collector_, art::ConsumesCollector::mayConsumeMany(), and T.

91  {
93  }
ConsumesCollector collector_
Definition: ModuleBase.h:50
double T
Definition: Xdiff_gwt.C:5
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::mayConsumeView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::mayConsumeView ( InputTag const &  tag)
inherited

Definition at line 83 of file ModuleBase.h.

References art::ModuleBase::collector_, art::ConsumesCollector::mayConsumeView(), T, and getGoodRuns4SAM::tag.

84  {
85  return collector_.mayConsumeView<T, BT>(tag);
86  }
ConsumesCollector collector_
Definition: ModuleBase.h:50
ViewToken< Element > mayConsumeView(InputTag const &)
double T
Definition: Xdiff_gwt.C:5
ModuleDescription const& art::ModuleBase::moduleDescription ( ) const
inherited
detail::ProcessAndEventSelectors& art::Observer::processAndEventSelectors ( )
protectedinherited
std::string const& art::Observer::processName ( ) const
inherited
void art::Observer::registerProducts ( ProductDescriptions ,
ModuleDescription const &   
)
inherited
fhicl::ParameterSetID art::Observer::selectorConfig ( ) const
inherited
void art::ModuleBase::setModuleDescription ( ModuleDescription const &  )
inherited
void art::ModuleBase::sortConsumables ( std::string const &  current_process_name)
inherited
void novaddt::SendTriggerSignal::startHeartbeat ( )

Definition at line 250 of file SendTriggerSignal_module.cc.

References _daqMonClient, _monIdPartitionHeartbeat, makeFirstAnaHTMLDatasetPages::description, HEARTBEAT, string, and plotROC::title.

Referenced by SendTriggerSignal().

251 {
252  std::string title ="";
253  std::string description="Activity on partition (1=active/0=inactive).";
255 }
nova::novadaqmonitorclient::NdmcClient _daqMonClient
Definition: Ndmc.h:42
enum BeamMode string
void novaddt::SendTriggerSignal::stopHeartbeat ( )

Definition at line 257 of file SendTriggerSignal_module.cc.

References _daqMonClient, and _monIdPartitionHeartbeat.

Referenced by ~SendTriggerSignal().

258 {
259  _daqMonClient.destroyMetric(_monIdPartitionHeartbeat); // silence heartbeat
261 }
nova::novadaqmonitorclient::NdmcClient _daqMonClient
bool art::Observer::wantAllEvents ( ) const
inherited
bool art::Observer::wantEvent ( Event const &  e)
inherited
std::string art::EDAnalyzer::workerType ( ) const
inherited

Member Data Documentation

nova::novadaqmonitorclient::NdmcClient novaddt::SendTriggerSignal::_daqMonClient
int32_t novaddt::SendTriggerSignal::_monIdPartitionHeartbeat
private

Definition at line 88 of file SendTriggerSignal_module.cc.

Referenced by startHeartbeat(), and stopHeartbeat().

std::map<std::string, int32_t> novaddt::SendTriggerSignal::m_trigger_delays
private

Definition at line 86 of file SendTriggerSignal_module.cc.

Referenced by analyze(), and SendTriggerSignal().

std::map<std::string, int32_t> novaddt::SendTriggerSignal::m_trigger_lengths
private

Definition at line 85 of file SendTriggerSignal_module.cc.

Referenced by analyze(), and SendTriggerSignal().

std::map<std::string, int32_t> novaddt::SendTriggerSignal::m_trigger_rates
private

Definition at line 84 of file SendTriggerSignal_module.cc.

Referenced by analyze(), and SendTriggerSignal().

bool novaddt::SendTriggerSignal::make_ganglia_metrics_
private

Definition at line 82 of file SendTriggerSignal_module.cc.

Referenced by analyze(), SendTriggerSignal(), and ~SendTriggerSignal().

int32_t novaddt::SendTriggerSignal::OverallTriggerRate
private

Definition at line 83 of file SendTriggerSignal_module.cc.

Referenced by analyze(), and SendTriggerSignal().

boost::shared_ptr<provider::DDSConnection> novaddt::SendTriggerSignal::rms_connection_
private

Definition at line 76 of file SendTriggerSignal_module.cc.

Referenced by ~SendTriggerSignal().

base::RmsDestination novaddt::SendTriggerSignal::rms_destination_
private

Definition at line 77 of file SendTriggerSignal_module.cc.

std::string novaddt::SendTriggerSignal::rms_mailbox_
private

Definition at line 75 of file SendTriggerSignal_module.cc.

Referenced by SendTriggerSignal().

int novaddt::SendTriggerSignal::rms_partition_
private

Definition at line 74 of file SendTriggerSignal_module.cc.

Referenced by SendTriggerSignal().

RmsSender<provider::DDSConnection, ddtmessages::DDTTriggerMessage> novaddt::SendTriggerSignal::rms_sender_
private

Definition at line 79 of file SendTriggerSignal_module.cc.

Referenced by analyze(), and ~SendTriggerSignal().

bool novaddt::SendTriggerSignal::send_trigger_messages_
private

Definition at line 73 of file SendTriggerSignal_module.cc.

Referenced by analyze().

std::vector<std::string> novaddt::SendTriggerSignal::trigger_labels_
private

Definition at line 70 of file SendTriggerSignal_module.cc.

Referenced by analyze(), and SendTriggerSignal().

bool novaddt::SendTriggerSignal::verbose_
private

Definition at line 73 of file SendTriggerSignal_module.cc.

Referenced by analyze().


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