Jpp  18.2.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
examples/JDAQ/JDAQEvent.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 #include <limits>
6 #include <set>
7 
8 #include "TROOT.h"
9 #include "TFile.h"
10 #include "TH1D.h"
11 
12 #include "JDAQ/JDAQEventIO.hh"
13 
15 #include "JSupport/JSupport.hh"
16 
17 #include "Jeep/JParser.hh"
18 #include "Jeep/JMessage.hh"
19 
20 
21 /**
22  * \file
23  *
24  * Example program to analyse KM3NETDAQ::JDAQEvent.
25  * \author mdejong
26  */
27 int main(int argc, char **argv)
28 {
29  using namespace std;
30  using namespace JPP;
31  using namespace KM3NETDAQ;
32 
34  JLimit_t& numberOfEvents = inputFile.getLimit();
35  string outputFile;
36  JDAQTriggerMask trigger_mask;
37  int debug;
38 
39  try {
40 
41  JParser<> zap("Example program to histogram event data.");
42 
43  zap['f'] = make_field(inputFile);
44  zap['o'] = make_field(outputFile) = "event.root";
45  zap['n'] = make_field(numberOfEvents) = JLimit::max();
46  zap['T'] = make_field(trigger_mask) = TRIGGER_MASK_ON;
47  zap['d'] = make_field(debug) = 1;
48 
49  zap(argc, argv);
50  }
51  catch(const exception& error) {
52  FATAL(error.what() << endl);
53  }
54 
55 
56  TFile out(outputFile.c_str(), "recreate");
57 
58 
59  TH1D h0("h0", NULL, numeric_limits<JDAQHit::JPMT_t>::max(), -0.5, numeric_limits<JDAQHit::JPMT_t>::max() - 0.5);
60  TH1D h1("h1", NULL, numeric_limits<JDAQHit::JTOT_t>::max(), -0.5, numeric_limits<JDAQHit::JTOT_t>::max() - 0.5);
61  TH1D h2("h2", NULL, 1000, 0.0, getFrameTime());
62 
63  TH1D hn("hn", NULL, 1001, -0.5, 1000.5);
64  TH1D hs("hs", NULL, 1001, -0.5, 1000.5);
65  TH1D ho("ho", NULL, 101, -0.5, 100.5);
66 
67  TH1D ha("ha", NULL, 101, -0.5, 100.5);
68  TH1D hb("hb", NULL, 101, -0.5, 100.5);
69 
70 
71  while (inputFile.hasNext()) {
72 
73  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
74 
75  JDAQEvent* event = inputFile.next();
76 
77  if (event->hasTriggerMask(trigger_mask)) {
78 
79  {
80  typedef JDAQTriggeredHit JHit_t;
81 
82  for (JDAQEvent::const_iterator<JHit_t> hit = event->begin<JHit_t>(); hit != event->end<JHit_t>(); ++hit) {
83  h0.Fill(hit->getPMT());
84  h1.Fill(hit->getToT());
85  h2.Fill(hit->getT());
86  }
87  }
88 
89  hn.Fill((double) event->size<JDAQTriggeredHit>());
90  hs.Fill((double) event->size<JDAQSnapshotHit>());
91  ho.Fill((double) event->getOverlays());
92 
93  {
94  set<int> buffer;
95 
96  for (JDAQEvent::const_iterator<JDAQTriggeredHit> hit = event->begin<JDAQTriggeredHit>(); hit != event->end<JDAQTriggeredHit>(); ++hit) {
97  if (hit->hasTriggerMask(trigger_mask)) {
98  buffer.insert(hit->getModuleID());
99  }
100  }
101 
102  ha.Fill((double) buffer.size());
103  }
104 
105  {
106  set<int> buffer;
107 
108  for (JDAQEvent::const_iterator<JDAQSnapshotHit> hit = event->begin<JDAQSnapshotHit>(); hit != event->end<JDAQSnapshotHit>(); ++hit) {
109  buffer.insert(hit->getModuleID());
110  }
111 
112  hb.Fill((double) buffer.size());
113  }
114  }
115  }
116  STATUS(endl);
117 
118  out.Write();
119  out.Close();
120 }
Utility class to parse command line options.
Definition: JParser.hh:1514
DAQ key hit.
Definition: JDAQKeyHit.hh:19
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
Auxiliary class for trigger mask.
#define STATUS(A)
Definition: JMessage.hh:63
Template const_iterator.
Definition: JDAQEvent.hh:68
string outputFile
static const JDAQTriggerMask TRIGGER_MASK_ON
Trigger mask on;.
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
double getFrameTime()
Get frame time duration.
Definition: JDAQClock.hh:162
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Scanning of objects from multiple files according a format that follows from the extension of each fi...
General purpose class for object reading from a list of file names.
Utility class to parse command line options.
Auxiliary class to set-up Hit.
Definition: JSirene.hh:57
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:84
int debug
debug level
JTriggerCounter_t next()
Increment trigger counter.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62