DDTStreamer_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: DDTStreamer
3 // Module Type: filter
4 // File: DDTStreamer_module.cc
5 //
6 // an extra line
7 // Generated at Wed Sep 12 16:15:01 2012 by Nova DDT using artmod
8 // from art v1_01_01.
9 ////////////////////////////////////////////////////////////////////////
10 
16 
23 
24 #include <string>
25 #include <algorithm>
26 
27 //---------------------------------------------------------------------
28 namespace novaddt {
29  class DDTStreamer;
30 }
31 //---------------------------------------------------------------------
33  public:
34  explicit DDTStreamer(fhicl::ParameterSet const & p);
35  virtual ~DDTStreamer();
36  virtual bool filter(art::Event & e);
37  void endJob() override;
38  private:
39  unsigned int _prescale; ///< prescale factor (1 out of every this many passes are issued as real triggers)
42  unsigned int _nEvents = 0;
43  unsigned int _trigger_counts = 0;
44  unsigned int _prescaled_trigger_counts = 0;
45 };
46 //---------------------------------------------------------------------
47 
49  : _prescale (p.get<unsigned int>("prescale")),
50  _slicelabel(p.get<std::string>("slice_label")),
51  _sliceinstance(p.get<std::string>("slice_instance"))
52 {
53  std::cout << "--- novaddt::DDTStreamer instantiate" << std::endl;
54  std::cout << "\t prescale: " << _prescale << std::endl;
55  std::cout << "\t SliceModuleLabel: " << _slicelabel << std::endl;
56  std::cout << "\t SliceInstanceLabel: " << _sliceinstance << std::endl;
57  produces<std::vector<TriggerDecision>>();
58 }
59 //---------------------------------------------------------------------
61 {
62  // Clean up dynamic memory and other resources here.
63 }
64 //---------------------------------------------------------------------
66 {
67  //std::cout << " DDTStreamer::filter. Event: "
68  // << e.id().event()
69  // << std::endl;
70  _nEvents++;
71  bool result = false;
72 
73  // static unsigned event = 1;
74  // event++;
75  // if (event == 13)
76  // {
77  // std::cout << "\nSleeping now!\n" << std::endl;
78  // sleep(60);
79  // }
80 
81  std::unique_ptr<std::vector<TriggerDecision>>
82  trigger_decisions(new std::vector<TriggerDecision>);
83 
86 
87  //std::cout << "\tgot " << hits->size() << " hits" << std::endl;
88  // This event contains at least one useful slice, so let's keep it around:
89  result = true;
91 
92  // check the prescale
95  //std::cout<< "\t\t - not prescaled" << std::endl;
96 
97  TDC t_begin = hits->front().TDC();
98  TDC t_end = hits->back().TDC();
99 
100  std::cout << "\tbegin: " << t_begin.val
101  << ", end: " << t_end.val
102  << std::endl;
103 
104  /*
105  This streamer trigger will NOT WORK because of the GT design.
106  In DDT, we send all of our trigger messages to the DDTServerMailbox,
107  but the manual bit, which is being sent below, needs to be sent
108  to the ManServerMailbox.
109 
110  Alec suggests that we use the ManSender instead to collect streamer
111  data.
112  */
113 
114  // trigger_decisions->emplace_back(t_begin, t_end - t_begin,
115  // daqdataformats::trigID::TRIG_ID_SOFT_MANUAL,
116  // _prescale);
117  } // end of check on prescale
118 
119  e.put(std::move(trigger_decisions));
120 
121  return result;
122 }
123 //---------------------------------------------------------------------
125 {
126  std::cout << "--- novaddt::DDTStreamer endJob" << std::endl;
127  std::cout << "\tNumber of events seen: " << _nEvents << std::endl;
128  std::cout << "\tNumber that pass the trigger: " << _trigger_counts << std::endl;
129  std::cout << "\t after prescale: " << _prescaled_trigger_counts << std::endl;
130 }
131 //---------------------------------------------------------------------
value_type val
Definition: BaseProducts.h:34
unsigned int _prescaled_trigger_counts
const char * p
Definition: xmltok.h:285
DDTStreamer(fhicl::ParameterSet const &p)
virtual bool filter(art::Event &e)
DEFINE_ART_MODULE(TestTMapFile)
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
void hits()
Definition: readHits.C:15
unsigned int _prescale
prescale factor (1 out of every this many passes are issued as real triggers)
OStream cout
Definition: OStream.cxx:6
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Float_t e
Definition: plot.C:35
enum BeamMode string