HighEnergyFilt_module.cc
Go to the documentation of this file.
7 
12 
13 #include "RawData/RawTrigger.h"
14 
15 #include <boost/format.hpp>
16 
17 #include <string>
18 #include <vector>
19 #include <algorithm>
20 
21 namespace highe {
22  class HighEnergyFilt;
23 }
24 
26 public:
27  explicit HighEnergyFilt(fhicl::ParameterSet const & p);
28  virtual ~HighEnergyFilt();
29 
30  virtual bool filter(art::Event & e) override;
31 
32 private:
33  bool send_trigger(unsigned const sum_adc,
34  unsigned const n_hits_total) const;
35 
40 };
41 
43  EDFilter(p),
44  slice_label_(p.get<std::string>("slice_label")),
45  slice_instance_(p.get<std::string>("slice_instance")),
46  prescale_(p.get<unsigned>("prescale")),
47  trigger_counts_(0),
49  (p.get<unsigned>("sum_adc_trigger_threshold")),
51  (p.get<unsigned>("n_hits_trigger_threshold"))
52 {
53  produces<std::vector<novaddt::TriggerDecision>>();
54 }
55 
57 {
58  std::cout << "\n\tNumber of High Energy Filt Triggers = " << trigger_counts_
59  << "\n" << std::endl;
60 }
61 
63 {
64  bool result = false;
65 
66  std::unique_ptr<std::vector<novaddt::TriggerDecision>>
67  trigger_decisions(new std::vector<novaddt::TriggerDecision>);
68 
71 
72  // We need to subtract off the trigger time, so that we know what
73  // time stamp in the EVD this corresponds to:
74  // art::Handle<std::vector<rawdata::RawTrigger>> RawTriggers;
75  // e.getByLabel("daq", RawTriggers);
76  // assert(RawTriggers->size() == 1);
77  // TDC event_time(RawTriggers->at(0).fTriggerTimingMarker_TimeStart);
78  // boost::format hitform("%4u %4u %5u %20u");
79 
80  unsigned n_slice = 0;
81  unsigned n_triggered_slices = 0;
82  for (auto const& slice : *slices)
83  {
84  unsigned sum_adc = 0;
85 
86  for (auto const& hit : slice)
87  sum_adc += hit.ADC().val;
88 
89  double n_hits_total = slice.size();
90 
91  boost::format form("%5u %3u %8u %8.2f");
92  std::cout << "MF: " <<
93  form % e.id().event() % ++n_slice % n_hits_total % sum_adc
94  << std::endl;
95 
96  if (send_trigger(sum_adc, n_hits_total))
97  {
98  ++n_triggered_slices;
99 
100  ++trigger_counts_;
101  if (trigger_counts_ % prescale_ == prescale_ - 1)
102  {
103  auto time_interval =
104  std::minmax_element(slice.begin(), slice.end(),
106  auto t0 = time_interval.first->TDC();
107  auto t1 = time_interval.second->TDC();
108  auto dt = t1 - t0;
109 
110  // double tdc_to_us = 1.0 / 64e6 * 1e6;
111  // std::cout << "\nRun " << e.run()
112  // << "\nSubrun " << e.subRun()
113  // << "\nEvent " << e.id().event()
114  // << "\nt0 = " << (t0 - event_time) * tdc_to_us
115  // << "\nt1 = " << (t1 - event_time) * tdc_to_us
116  // << "\ndt = " << dt
117  // << std::endl;
118 
119  trigger_decisions->emplace_back
121 
122  result = true;
123  }
124  }
125  }
126 
127  std::cout << "MF: Event " << e.event() << " has " << n_triggered_slices
128  << " triggered slices (Space Slice)."
129  << std::endl;
130 
131  e.put(std::move(trigger_decisions));
132  return result;
133 }
134 
136 (unsigned const sum_adc,
137  unsigned const n_hits_total) const
138 {
139  if (sum_adc < sum_adc_trigger_threshold_)
140  return false;
141 
142  if (n_hits_total < n_hits_trigger_threshold_)
143  return false;
144 
145  return true;
146 }
147 
EventNumber_t event() const
const char * p
Definition: xmltok.h:285
bool send_trigger(unsigned const sum_adc, unsigned const n_hits_total) const
DEFINE_ART_MODULE(TestTMapFile)
Definition: Cand.cxx:23
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:446
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
OStream cout
Definition: OStream.cxx:6
EventNumber_t event() const
Definition: EventID.h:116
HighEnergyFilt(fhicl::ParameterSet const &p)
Definition: structs.h:12
EDFilter(fhicl::ParameterSet const &pset)
Definition: EDFilter.h:22
Float_t e
Definition: plot.C:35
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
Definition: DataViewImpl.h:730
EventID id() const
virtual bool filter(art::Event &e) override
enum BeamMode string