Jpp
 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/JDAQEvent.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 
33  JMultipleFileScanner<JDAQEvent> inputFile;
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  cout.tie(&cerr);
57 
58  TFile out(outputFile.c_str(), "recreate");
59 
60 
61  TH1D h0("h0", NULL, numeric_limits<JDAQHit::JPMT_t>::max(), -0.5, numeric_limits<JDAQHit::JPMT_t>::max() - 0.5);
62  TH1D h1("h1", NULL, numeric_limits<JDAQHit::JTOT_t>::max(), -0.5, numeric_limits<JDAQHit::JTOT_t>::max() - 0.5);
63  TH1D h2("h2", NULL, 1000, 0.0, getFrameTime());
64  //TH1D h2("h2", NULL, 1000, 0.5 * getFrameTime() - 1e4, 0.5 * getFrameTime() + 1e4);
65  TH1D hn("hn", NULL, 51, -0.5, 50.5);
66  TH1D hm("hm", NULL, 51, -0.5, 50.5);
67  TH1D ho("ho", NULL, 51, -0.5, 50.5);
68 
69 
70  while (inputFile.hasNext()) {
71 
72  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
73 
74  JDAQEvent* event = inputFile.next();
75 
76  if (event->hasTriggerMask(trigger_mask)) {
77 
78  {
79  typedef JDAQTriggeredHit JHit_t;
80 
81  for (JDAQEvent::const_iterator<JHit_t> hit = event->begin<JHit_t>(); hit != event->end<JHit_t>(); ++hit) {
82  h0.Fill(hit->getPMT());
83  h1.Fill(hit->getToT());
84  h2.Fill(hit->getT());
85  }
86  }
87 
88  set<int> buffer;
89 
90  for (JDAQEvent::const_iterator<JDAQTriggeredHit> hit = event->begin<JDAQTriggeredHit>(); hit != event->end<JDAQTriggeredHit>(); ++hit) {
91  if (hit->hasTriggerMask(trigger_mask)) {
92  buffer.insert(hit->getModuleID());
93  }
94  }
95 
96  hm.Fill((double) buffer.size());
97  hn.Fill((double) event->size<JDAQTriggeredHit>());
98  ho.Fill((double) event->getOverlays());
99  }
100  }
101  STATUS(endl);
102 
103  out.Write();
104  out.Close();
105 }
Utility class to parse command line options.
Definition: JParser.hh:1410
Auxiliary class for trigger mask.
#define STATUS(A)
Definition: JMessage.hh:61
Template const_iterator.
Definition: JDAQEvent.hh:69
Structure to store the ToT mean and standard deviation of the hits produced by a nanobeacon in a sour...
string outputFile
static const JDAQTriggerMask TRIGGER_MASK_ON
Trigger mask on;.
JLimit JLimit_t
Type definition of limit.
Definition: JLimit.hh:214
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
double getFrameTime()
Get frame time duration.
Definition: JDAQClock.hh:162
int debug
debug level
Definition: JSirene.cc:59
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:65
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Utility class to parse command line options.
ROOT TTree parameter settings.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:72
JTriggerCounter_t next()
Increment trigger counter.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:60
int main(int argc, char *argv[])
Definition: Main.cpp:15