Jpp
examples/JDAQ/JDAQTimeslice.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 
12 #include "JDAQ/JDAQTimesliceIO.hh"
13 
15 #include "JSupport/JSupport.hh"
16 #include "JGizmo/JManager.hh"
17 #include "Jeep/JeepToolkit.hh"
18 
20 
21 #include "Jeep/JParser.hh"
22 #include "Jeep/JMessage.hh"
23 
24 
25 /**
26  * \file
27  *
28  * Example program to histogram KM3NETDAQ::JDAQTimeslice.
29  * \author mdejong
30  */
31 int main(int argc, char **argv)
32 {
33  using namespace std;
34  using namespace JPP;
35  using namespace KM3NETDAQ;
36 
38  JLimit_t& numberOfEvents = inputFile.getLimit();
39  string outputFile;
41  int debug;
42 
43  try {
44 
45  JParser<> zap("Example program to histogram timeslice data.");
46 
47  zap['f'] = make_field(inputFile);
48  zap['o'] = make_field(outputFile) = "timeslice.root";
49  zap['n'] = make_field(numberOfEvents) = JLimit::max();
50  zap['P'] = make_field(PMT) = JDAQPMTIdentifier(-1, -1);
51  zap['d'] = make_field(debug) = 1;
52 
53  zap(argc, argv);
54  }
55  catch(const exception& error) {
56  FATAL(error.what() << endl);
57  }
58 
59 
60  cout.tie(&cerr);
61 
62 
63  JManager<string, TH1D> h0(new TH1D("h0[%]", NULL, numeric_limits<JDAQHit::JPMT_t>::max(), -0.5, numeric_limits<JDAQHit::JPMT_t>::max() - 0.5));
64  JManager<string, TH1D> h1(new TH1D("h1[%]", NULL, numeric_limits<JDAQHit::JTOT_t>::max(), -0.5, numeric_limits<JDAQHit::JTOT_t>::max() - 0.5));
65  JManager<string, TH1D> h2(new TH1D("h2[%]", NULL, 1000, -0.5, getFrameTime() + 0.5));
66 
67  h0->Sumw2();
68  h1->Sumw2();
69  h2->Sumw2();
70 
72 
73  for (counter_type counter = 0; in.hasNext(); ++counter) {
74 
75  STATUS("event: " << setw(10) << counter << '\r'); DEBUG(endl);
76 
77  JDAQTimeslice* timeslice = in.next();
78 
79  for (JDAQTimeslice::const_iterator frame = timeslice->begin(); frame != timeslice->end(); ++frame) {
80  for (JDAQSuperFrame::const_iterator hit = frame->begin(); hit != frame->end(); ++hit) {
81 
82  if (JDAQPMTIdentifier::compare(PMT, JDAQPMTIdentifier(frame->getModuleID(), hit->getPMT()))) {
83  h0[getClassname(timeslice->GetName())]->Fill(hit->getPMT());
84  h1[getClassname(timeslice->GetName())]->Fill(hit->getToT());
85  h2[getClassname(timeslice->GetName())]->Fill(hit->getT());
86  }
87  }
88  }
89  }
90  STATUS(endl);
91 
92  TFile out(outputFile.c_str(), "recreate");
93 
94  h0.Write(out);
95  h1.Write(out);
96  h2.Write(out);
97 
98  out.Write();
99  out.Close();
100 }
JManager::Write
void Write(TFile &out)
Write histograms to file.
Definition: JHistogramToolkit.hh:227
JManager< string, TH1D >
JSUPPORT::JLimit
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
JMessage.hh
JLANG::JObjectMultiplexer::hasNext
virtual bool hasNext()
Check availability of next element.
Definition: JObjectMultiplexer.hh:62
KM3NETDAQ::JDAQTimeslice
Data time slice.
Definition: JDAQTimeslice.hh:30
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
PMT
JDAQPMTIdentifier PMT
Command line options.
Definition: JDAQTimesliceSelector.cc:35
JManager.hh
JLANG::JObjectMultiplexer::next
virtual const pointer_type & next()
Get next element.
Definition: JObjectMultiplexer.hh:76
KM3NETDAQ::getFrameTime
double getFrameTime()
Get frame time duration.
Definition: JDAQClock.hh:162
JSupport.hh
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
KM3NETDAQ::JDAQSuperFrame::const_iterator
JDAQFrame::const_iterator const_iterator
Definition: JDAQSuperFrame.hh:29
main
int main(int argc, char **argv)
Definition: examples/JDAQ/JDAQTimeslice.cc:31
JDAQTimesliceIO.hh
debug
int debug
debug level
Definition: JSirene.cc:59
JLANG::JObjectMultiplexer
Auxiliary class for multiplexing object iterators.
Definition: JObjectIterator.hh:35
JObjectMultiplexer.hh
JMultipleFileScanner.hh
STATUS
#define STATUS(A)
Definition: JMessage.hh:63
JParser.hh
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
KM3NETDAQ::JDAQPMTIdentifier
PMT identifier.
Definition: JDAQPMTIdentifier.hh:20
JSUPPORT::JMultipleFileScanner
General purpose class for object reading from a list of file names.
Definition: JMultipleFileScanner.hh:167
JEEP::getClassname
std::string getClassname(const std::string &type_name)
Get type name, i.e.
Definition: JeepToolkit.hh:242
DEBUG
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
std
Definition: jaanetDictionary.h:36
KM3NETDAQ
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
JeepToolkit.hh
JDAQPMTIdentifier.hh
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
outputFile
string outputFile
Definition: JDAQTimesliceSelector.cc:37
JROOT::counter_type
Long64_t counter_type
Type definition for counter.
Definition: JCounter.hh:24