HighETrigger_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: HighETrigger
3 // Module Type: filter
4 // File: HighETrigger_module.cc
5 //
6 // Generated at Mon Dec 17 15:29:53 2012 by Zukai Wang using artmod
7 // from art v1_02_06.
8 ////////////////////////////////////////////////////////////////////////
9 
15 
20 
21 #include <string>
22 #include <vector>
23 #include <algorithm>
24 
25 namespace novaddt {
26  class HighETrigger;
27 }
28 
30 public:
31  explicit HighETrigger(fhicl::ParameterSet const & p);
32  virtual ~HighETrigger();
33 
34  virtual bool filter(art::Event & e) override;
35 
36 private:
37  bool send_trigger(unsigned const sum_adc,
38  unsigned const n_hits_total) const;
39 
44 };
45 
47  slice_label_(p.get<std::string>("slice_label")),
48  slice_instance_(p.get<std::string>("slice_instance")),
49  prescale_(p.get<unsigned>("prescale")),
50  trigger_counts_(0),
52  (p.get<unsigned>("sum_adc_trigger_threshold")),
54  (p.get<unsigned>("n_hits_trigger_threshold"))
55 {
56  produces<std::vector<TriggerDecision>>();
57 }
58 
60 {
61  std::cout << "\n\tNumber of High Energy Triggers = " << trigger_counts_
62  << "\n" << std::endl;
63 }
64 
66 {
67  std::unique_ptr<std::vector<TriggerDecision>>
68  trigger_decisions(new std::vector<TriggerDecision>);
69 
72 
73  std::vector<novaddt::HitList> triggered_slices;
74 
75  for (auto const& slice : *slices)
76  {
77  unsigned sum_adc = 0;
78 
79  for (auto const& hit : slice)
80  sum_adc += hit.ADC().val;
81 
82  double n_hits_total = slice.size();
83 
84  if (send_trigger(sum_adc, n_hits_total))
85  triggered_slices.push_back(slice);
86  }
87 
88  if (triggered_slices.size() == 0)
89  {
90  e.put(std::move(trigger_decisions));
91  return false;
92  }
93 
94  // initialize the absolute min and max to a reasonable TDC value,
95  // so let's just use the first hit:
96  novaddt::TDC absolute_t0 = triggered_slices.front().front().TDC();
97  novaddt::TDC absolute_t1 = absolute_t0;
98  for (auto const& t_slice : triggered_slices)
99  {
100  auto time_interval =
101  std::minmax_element(t_slice.begin(), t_slice.end(), CompareDAQHit<TDC>());
102  auto t0 = time_interval.first->TDC();
103  auto t1 = time_interval.second->TDC();
104 
105  if (t0 < absolute_t0)
106  absolute_t0 = t0;
107 
108  if (t1 > absolute_t1)
109  absolute_t1 = t1;
110  }
111 
112  ++trigger_counts_;
113  if (trigger_counts_ % prescale_ == prescale_ - 1)
114  {
115  auto dt = absolute_t1 - absolute_t0;
116 
117  trigger_decisions->emplace_back
119  }
120 
121  e.put(std::move(trigger_decisions));
122  return true;
123 }
124 
126 (unsigned const sum_adc,
127  unsigned const n_hits_total) const
128 {
129  if (sum_adc < sum_adc_trigger_threshold_)
130  return false;
131 
132  if (n_hits_total < n_hits_trigger_threshold_)
133  return false;
134 
135  return true;
136 }
137 
const char * p
Definition: xmltok.h:285
bool send_trigger(unsigned const sum_adc, unsigned const n_hits_total) const
virtual bool filter(art::Event &e) override
DEFINE_ART_MODULE(TestTMapFile)
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
Definition: Cand.cxx:23
TDC()=default
OStream cout
Definition: OStream.cxx:6
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Definition: structs.h:12
Float_t e
Definition: plot.C:35
HighETrigger(fhicl::ParameterSet const &p)
enum BeamMode string