Evaluation_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: Evaluation
3 // Module Type: analyzer
4 // File: Evaluation_module.cc
5 //
6 // Generated at Mon Mar 4 13:36:31 2013 by Martin Frank using artmod
7 // from art v1_02_06.
8 ////////////////////////////////////////////////////////////////////////
9 
14 
18 
19 #include <algorithm>
20 #include <fstream>
21 
22 namespace novaddt {
23  class Evaluation;
24  struct Hit;
25  struct CompareHit;
26 }
27 
29 public:
30  explicit Evaluation(fhicl::ParameterSet const & p);
31  virtual ~Evaluation();
32 
33  void analyze(art::Event const & e) override;
34 
35 
36 private:
39 };
40 
41 struct novaddt::Hit
42 {
43  Hit(unsigned short p, unsigned short c, int32_t t, int16_t a) :
44  plane(p), cell(c), tdc(t), adc(a) {}
45 
46  unsigned short plane, cell;
47  int32_t tdc;
48  int16_t adc;
49 };
50 
52 {
53  // sort in this order: 1. plane 2. cell 3. tdc
54  bool operator() (Hit const& lhs, Hit const& rhs)
55  {
56  if (lhs.plane == rhs.plane)
57  {
58  if (lhs.cell == rhs.cell)
59  return lhs.tdc < rhs.tdc;
60 
61  return lhs.cell < rhs.cell;
62  }
63 
64  return lhs.plane < rhs.plane;
65  }
66 };
67 
69  EDAnalyzer(p),
70  _slicelabel(p.get<std::string>("slice_label")),
71  _sliceinstance(p.get<std::string>("slice_instance"))
72 {
73 }
74 
76 {
77 }
78 
80 {
83 
84  std::vector<Hit> ohits;
85 
86  unsigned n_slices = slices->n_groups();
87  for (unsigned slice = 0; slice != n_slices; ++slice)
88  {
89  HitList hits = slices->get(slice);
90  // TDC t0 = hits.at(0).TDC();
91 
92  for (auto const& hit : hits)
93  {
94  std::cout << "\nPlane = " << hit.Plane().val
95  << "\nView = " << hit.View().val
96  << std::endl;
97  ohits.emplace_back(hit.Plane().val, hit.Cell().val,
98  hit.TDC().val, hit.ADC().val);
99  }
100  }
101 
102  static unsigned n_event = 1;
103  HitList first_hits = slices->get(0);
104  HitList last_hits = slices->get(n_slices - 1);
105  std::cout << "\nEvent " << n_event++
106  << "\nFirst:"
107  << "\n\tt_begin = " << first_hits.front().TDC().val
108  << "\nLast:"
109  << "\n\tt_end = " << last_hits.back().TDC().val
110  << std::endl;
111 
112  sort(ohits.begin(), ohits.end(), CompareHit());
113 
114  std::ofstream outfile("ddt.txt");
115  std::string spacer = " ";
116  for (auto const& ohit : ohits)
117  outfile << ohit.plane << spacer
118  << ohit.cell << spacer
119  << ohit.tdc << spacer
120  << ohit.adc << std::endl;
121 
122  outfile.close();
123 }
124 
void analyze(art::Event const &e) override
std::vector< DAQHit > HitList
Definition: HitList.h:15
const char * p
Definition: xmltok.h:285
DEFINE_ART_MODULE(TestTMapFile)
unsigned short plane
void hits()
Definition: readHits.C:15
const double a
Hit(unsigned short p, unsigned short c, int32_t t, int16_t a)
unsigned short cell
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
Evaluation(fhicl::ParameterSet const &p)
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
FILE * outfile
Definition: dump_event.C:13
enum BeamMode string