Jpp  15.0.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
examples/JDAQ/JDAQEvent.cc File Reference

Example program to analyse KM3NETDAQ::JDAQEvent. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <limits>
#include <set>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "JDAQ/JDAQEventIO.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JSupport.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to analyse KM3NETDAQ::JDAQEvent.

Author
mdejong

Definition in file examples/JDAQ/JDAQEvent.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 27 of file examples/JDAQ/JDAQEvent.cc.

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  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 
65  TH1D hn("hn", NULL, 1001, -0.5, 1000.5);
66  TH1D hs("hs", NULL, 1001, -0.5, 1000.5);
67  TH1D ho("ho", NULL, 101, -0.5, 100.5);
68 
69  TH1D ha("ha", NULL, 101, -0.5, 100.5);
70  TH1D hb("hb", NULL, 101, -0.5, 100.5);
71 
72 
73  while (inputFile.hasNext()) {
74 
75  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
76 
77  JDAQEvent* event = inputFile.next();
78 
79  if (event->hasTriggerMask(trigger_mask)) {
80 
81  {
82  typedef JDAQTriggeredHit JHit_t;
83 
84  for (JDAQEvent::const_iterator<JHit_t> hit = event->begin<JHit_t>(); hit != event->end<JHit_t>(); ++hit) {
85  h0.Fill(hit->getPMT());
86  h1.Fill(hit->getToT());
87  h2.Fill(hit->getT());
88  }
89  }
90 
91  hn.Fill((double) event->size<JDAQTriggeredHit>());
92  hs.Fill((double) event->size<JDAQSnapshotHit>());
93  ho.Fill((double) event->getOverlays());
94 
95  {
96  set<int> buffer;
97 
98  for (JDAQEvent::const_iterator<JDAQTriggeredHit> hit = event->begin<JDAQTriggeredHit>(); hit != event->end<JDAQTriggeredHit>(); ++hit) {
99  if (hit->hasTriggerMask(trigger_mask)) {
100  buffer.insert(hit->getModuleID());
101  }
102  }
103 
104  ha.Fill((double) buffer.size());
105  }
106 
107  {
108  set<int> buffer;
109 
110  for (JDAQEvent::const_iterator<JDAQSnapshotHit> hit = event->begin<JDAQSnapshotHit>(); hit != event->end<JDAQSnapshotHit>(); ++hit) {
111  buffer.insert(hit->getModuleID());
112  }
113 
114  hb.Fill((double) buffer.size());
115  }
116  }
117  }
118  STATUS(endl);
119 
120  out.Write();
121  out.Close();
122 }
Auxiliary class to set-up Hit.
Definition: JHit_t.hh:25
Utility class to parse command line options.
Definition: JParser.hh:1500
DAQ key hit.
Definition: JDAQKeyHit.hh:19
Auxiliary class for trigger mask.
#define STATUS(A)
Definition: JMessage.hh:63
Template const_iterator.
Definition: JDAQEvent.hh:68
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:71
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:1961
double getFrameTime()
Get frame time duration.
Definition: JDAQClock.hh:162
int debug
debug level
Definition: JSirene.cc:63
#define FATAL(A)
Definition: JMessage.hh:67
General purpose class for object reading from a list of file names.
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
JTriggerCounter_t next()
Increment trigger counter.