Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
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 */
27int 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 {
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}
string outputFile
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define STATUS(A)
Definition JMessage.hh:63
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
ROOT TTree parameter settings of various packages.
Utility class to parse command line options.
Definition JParser.hh:1698
General purpose class for object reading from a list of file names.
virtual bool hasNext() override
Check availability of next element.
counter_type getCounter() const
Get counter.
virtual const pointer_type & next() override
Get next element.
Template const_iterator.
Definition JDAQEvent.hh:68
Auxiliary class for trigger mask.
int main(int argc, char **argv)
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
static const JDAQTriggerMask TRIGGER_MASK_ON
Trigger mask on;.
double getFrameTime()
Get frame time duration.
Definition JDAQClock.hh:162
Auxiliary class to set-up Hit.
Definition JSirene.hh:58
Auxiliary class for defining the range of iterations of objects.
Definition JLimit.hh:45
static counter_type max()
Get maximum counter value.
Definition JLimit.hh:128