Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JDAQTimesliceSelector.cc
Go to the documentation of this file.
1
2#include <string>
3#include <iostream>
4#include <iomanip>
5#include <limits>
6
7#include "TROOT.h"
8#include "TFile.h"
9#include "TH1D.h"
10
13
15#include "JSupport/JSupport.hh"
16
20#include "JLang/JPipe.hh"
22
23#include "Jeep/JParser.hh"
24#include "Jeep/JMessage.hh"
25
26
27using namespace std;
28using namespace JPP;
29using namespace KM3NETDAQ;
30
31
32/**
33 * Command line options.
34 */
38
39
40/**
41 * Example class for data analysis.
42 */
43struct JAnalysis :
44 public JObjectOutput<JDAQTimeslice>
45{
46 /**
47 * Constructor.
48 */
50 //
51 // Book histograms
52 //
53 h0("h0", NULL, numeric_limits<JDAQHit::JPMT_t>::max(), -0.5, numeric_limits<JDAQHit::JPMT_t>::max() - 0.5),
54 h1("h1", NULL, numeric_limits<JDAQHit::JTOT_t>::max(), -0.5, numeric_limits<JDAQHit::JTOT_t>::max() - 0.5),
55 h2("h2", NULL, 100, -0.5, getFrameTime() + 0.5),
56 //
57 counter(0)
58 {}
59
60
61 /**
62 * Destructior.
63 */
65 {
66 STATUS(endl);
67
68 // save histograms
69
70 TFile out(outputFile.c_str(), "recreate");
71
72 out << h0 << h1 << h2;
73
74 out.Write();
75 out.Close();
76 }
77
78
79 /**
80 * Process data.
81 *
82 * \param timeslice timeslice
83 * \return true
84 */
85 virtual bool put(const JDAQTimeslice& timeslice)
86 {
87 STATUS("event: " << setw(10) << ++counter << '\r'); DEBUG(endl);
88
89 for (JDAQTimeslice::const_iterator frame = timeslice.begin(); frame != timeslice.end(); ++frame) {
90 for (JDAQSuperFrame::const_iterator hit = frame->begin(); hit != frame->end(); ++hit) {
91
92 if (JDAQPMTIdentifier::compare(PMT, JDAQPMTIdentifier(frame->getModuleID(), hit->getPMT()))) {
93 h0.Fill(hit->getPMT());
94 h1.Fill(hit->getToT());
95 h2.Fill(hit->getT());
96 }
97 }
98 }
99
100 return true;
101 }
102
103 TH1D h0;
104 TH1D h1;
105 TH1D h2;
106
108};
109
110
111/**
112 * \file
113 *
114 * Example program to histogram KM3NETDAQ::JDAQTimeslice.
115 * \author mdejong
116 */
117int main(int argc, char **argv)
118{
119 using namespace std;
120 using namespace JPP;
121 using namespace KM3NETDAQ;
122
124 JLimit_t& numberOfEvents = inputFile.getLimit();
125 JROOTClassSelector selector;
126
127 try {
128
129 JParser<> zap("Example program to histogram timeslice data.");
130
131 zap['f'] = make_field(inputFile);
132 zap['o'] = make_field(outputFile) = "timeslice.root";
133 zap['n'] = make_field(numberOfEvents) = JLimit::max();
134 zap['P'] = make_field(PMT) = JDAQPMTIdentifier(-1, -1);
136 zap['d'] = make_field(debug) = 1;
137
138 zap(argc, argv);
139 }
140 catch(const exception& error) {
141 FATAL(error.what() << endl);
142 }
143
144
145 JAnalysis analysis;
146
147 inputFile | JValve<JDAQTimesliceTypes_t>(selector) | JType<JDAQTimeslice>() | analysis;
148}
int main(int argc, char **argv)
JDAQPMTIdentifier PMT
Command line options.
string outputFile
int debug
debug level
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
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
Implementation of pipe operation for object iterators.
ROOT TTree parameter settings of various packages.
Template interface of object output for single data type.
Auxiliary class for selection of data type.
Definition JValve.hh:23
Utility class to parse command line options.
Definition JParser.hh:1698
General purpose class for object reading from a list of file names.
Hit data structure.
Definition JDAQHit.hh:35
static bool compare(const JDAQPMTIdentifier &first, const JDAQPMTIdentifier &second)
Compare PMT identifiers.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
std::set< JROOTClassSelector > getROOTClassSelection(const bool option=false)
Get ROOT class selection.
Long64_t counter_type
Type definition for counter.
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
Example class for data analysis.
~JAnalysis()
Destructior.
counter_type counter
JAnalysis()
Constructor.
virtual bool put(const JDAQTimeslice &timeslice)
Process data.
Auxiliary class for a type holder.
Definition JType.hh:19
Auxiliary class to select ROOT class based on class name.
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