GHLTest_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: GHLTest
3 // Module Type: analyzer
4 // File: GHLTest_module.cc
5 // /brief Make fake DAQHits to test usage of GroupedHitLists
6 //
7 // Generated at Tue Sep 18 13:03:22 2012 by Gavin Davies using artmod
8 // from art v1_01_01.
9 ////////////////////////////////////////////////////////////////////////
10 
13 
19 
20 
21 namespace novaddt {
22  class GHLTest;
23 }
24 
25 
27 public:
28  explicit GHLTest(fhicl::ParameterSet const & p);
29  virtual ~GHLTest();
30 
31  virtual void analyze(art::Event const & e);
32 
33  virtual void beginJob();
34  virtual void endJob();
35 
36 private:
37 
38  void print(DAQHit const& h) const;
39 };
40 
41 
42 
44  EDAnalyzer(p)
45 {
46 }
47 
48 
49 
51 {
52  // Clean up dynamic memory and other resources here.
53 }
54 
55 
56 
57 void novaddt::GHLTest::print(DAQHit const& h) const
58 {
59  std::cout << "TDC: " << h.TDC().val
60  <<", ADC: " << h.ADC().val
61  <<", Plane: " << h.Plane().val
62  <<std::endl;
63 }
64 
65 
66 
68 {
69  // Let's create a fake list of DAQ hits:
70  HitList dhits;
71  dhits.
73  dhits.
75  dhits.
77  dhits.
79  dhits.
81 
82 
83  // Here is how we generate a grouped hit list:
84  // 1. sort the hits (done by HitSorters)
85  std::sort(dhits.begin(), dhits.end(), CompareDAQHit<TDC>());
86 
87  // 2. create boundary list (done by HitSlicers)
88  std::vector<std::size_t> boundaries = {0, 2, dhits.size()};
89  GroupedHitList<TDC> glist(dhits.begin(), dhits.end(), boundaries);
90 
91 
92  // Now, let's take a look at our grouped hit list:
93  std::cout << "\nAll Hits." << std::endl;
94  for(auto const & hit : dhits)
95  print(hit);
96 
97  std::cout << "\nSorted Groups." << std::endl;
98  for (unsigned group = 0; group != glist.n_groups(); ++group)
99  {
100  std::cout << "\nGroup " << group
101  << " (size = " << glist.group_size(group) << "):"
102  << std::endl;
103 
104  // extract one group and loop over it:
105  HitList hit_group = glist.get(group);
106  for (auto const & h : hit_group)
107  print(h);
108  }
109 
110  std::cout << "\nWhole Sorted List." << std::endl;
111  HitList new_list = glist.get();
112  for (auto const & n : new_list)
113  print(n);
114 
115  std::cout << "First Element: " << glist.first_value()
116  << "\n Last Element: " << glist.last_value()
117  << std::endl;
118 }
119 
120 
121 
123 {
124  // Implementation of optional member function here.
125 }
126 
127 
128 
130 {
131  // Implementation of optional member function here.
132 }
133 
134 
135 
virtual void analyze(art::Event const &e)
value_type val
Definition: BaseProducts.h:34
novaddt::Plane const & Plane() const
Definition: DAQHit.h:70
novaddt::TDC const & TDC() const
Definition: DAQHit.h:74
std::vector< DAQHit > HitList
Definition: HitList.h:15
const char * p
Definition: xmltok.h:285
virtual void endJob()
GHLTest(fhicl::ParameterSet const &p)
DEFINE_ART_MODULE(TestTMapFile)
novaddt::ADC const & ADC() const
Definition: DAQHit.h:73
base_types push_back(int_type())
value_type val
Definition: BaseProducts.h:84
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
OStream cout
Definition: OStream.cxx:6
Definition: structs.h:12
virtual void beginJob()
value_type val
Definition: BaseProducts.h:65
void print(DAQHit const &h) const
Float_t e
Definition: plot.C:35