DDTEva_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: DDTEva
3 // Module Type: analyzer
4 // File: DDTEva_module.cc
5 //
6 // Generated at Thu Feb 28 13:29:43 2013 by Martin Frank using artmod
7 // from art v1_02_06.
8 ////////////////////////////////////////////////////////////////////////
9 
10 #include "DAQDataFormats/TriggerDefines.h"
11 #include "RawData/RawTrigger.h"
12 #include "RecoBase/CellHit.h"
13 
18 
19 #include <fstream>
20 #include <string>
21 #include <vector>
22 
23 namespace ddt {
24  class DDTEva;
25  struct Hit;
26  struct CompareHit;
27 }
28 
29 class ddt::DDTEva : public art::EDAnalyzer {
30 public:
31  explicit DDTEva(fhicl::ParameterSet const & p);
32  virtual ~DDTEva();
33 
34  void analyze(art::Event const & e) override;
35 
36 private:
38 };
39 
40 struct ddt::Hit
41 {
42  Hit(unsigned short p, unsigned short c, int32_t t, int16_t a) :
43  plane(p), cell(c), tdc(t), adc(a) {}
44 
45  unsigned short plane, cell;
46  int32_t tdc;
47  int16_t adc;
48 };
49 
51 {
52  // sort in this order: 1. plane 2. cell 3. tdc
53  bool operator() (Hit const& lhs, Hit const& rhs)
54  {
55  if (lhs.plane == rhs.plane)
56  {
57  if (lhs.cell == rhs.cell)
58  return lhs.tdc < rhs.tdc;
59 
60  return lhs.cell < rhs.cell;
61  }
62 
63  return lhs.plane < rhs.plane;
64  }
65 };
66 
68  EDAnalyzer(p),
69  fCellHitInput(p.get<std::string>("CellHitInput"))
70 {
71 }
72 
74 {
75 }
76 
78 {
79  /*
80  This section of code prints out the trigger bit and name.
81  */
82 
84  e.getByLabel("daq", raw_triggers);
85  assert(raw_triggers->size() == 1);
86  const rawdata::RawTrigger trig_info = raw_triggers->at(0);
87 
88  // note: the conversion from uint8_t to unsigned is necessary here
89  // since uint8_t does not have the operator<< defined
90  unsigned trig_bit = trig_info.fTriggerMask_TriggerType;
91 
92  std::cout << "Trigger Info: "
93  << "\n\tBit: " << trig_bit
94  << "\n\tName: "
95  << daqdataformats::trigIDStrings[trig_bit] << "\n"
96  << std::endl;
97 
98 
99  /*
100  This code was used to run over all the hits and print information
101  for each hit to the output file.
102 
103  art::Handle<std::vector<rb::CellHit> > cell_hits;
104  e.getByLabel(fCellHitInput, cell_hits);
105  std::vector<Hit> hits;
106 
107  for (auto const& hit : *cell_hits)
108  hits.emplace_back(hit.Plane(), hit.Cell(), hit.TDC(), hit.ADC());
109 
110  std::sort(hits.begin(), hits.end(), CompareHit());
111 
112  std::ofstream outfile("mc_ddt.txt");
113  std::string spacer = " ";
114  for (auto const& hit : hits)
115  outfile << hit.plane << spacer
116  << hit.cell << spacer
117  << hit.tdc << spacer
118  << hit.adc << std::endl;
119  outfile.close();
120  */
121 }
122 
const char * trigIDStrings[]
unsigned short plane
const char * p
Definition: xmltok.h:285
DEFINE_ART_MODULE(TestTMapFile)
void analyze(art::Event const &e) override
const double a
std::string fCellHitInput
int16_t adc
unsigned short cell
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
OStream cout
Definition: OStream.cxx:6
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
DDTEva(fhicl::ParameterSet const &p)
assert(nhit_max >=nhit_nbins)
int32_t tdc
virtual ~DDTEva()
Float_t e
Definition: plot.C:35
Hit(unsigned short p, unsigned short c, int32_t t, int16_t a)
enum BeamMode string