Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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  TH1D* p0 = h0[getClassname(timeslice->GetName())];
80  TH1D* p1 = h1[getClassname(timeslice->GetName())];
81  TH1D* p2 = h2[getClassname(timeslice->GetName())];
82 
83  for (JDAQTimeslice::const_iterator frame = timeslice->begin(); frame != timeslice->end(); ++frame) {
84  for (JDAQSuperFrame::const_iterator hit = frame->begin(); hit != frame->end(); ++hit) {
85 
86  if (JDAQPMTIdentifier::compare(PMT, JDAQPMTIdentifier(frame->getModuleID(), hit->getPMT()))) {
87  p0->Fill(hit->getPMT());
88  p1->Fill(hit->getToT());
89  p2->Fill(hit->getT());
90  }
91  }
92  }
93  }
94  STATUS(endl);
95 
96  TFile out(outputFile.c_str(), "recreate");
97 
98  h0.Write(out);
99  h1.Write(out);
100  h2.Write(out);
101 
102  out.Write();
103  out.Close();
104 }
Utility class to parse command line options.
Definition: JParser.hh:1493
ROOT TTree parameter settings.
TPaveText * p1
#define STATUS(A)
Definition: JMessage.hh:63
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69
Long64_t counter_type
Type definition for counter.
Dynamic ROOT object management.
Auxiliary class for multiplexing object iterators.
string outputFile
Auxiliary class to manage set of compatible ROOT objects (e.g.
Definition: JManager.hh:42
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
std::string getClassname(const std::string &type_name)
Get type name, i.e. part after JEEP::TYPENAME_SEPARATOR.
Definition: JeepToolkit.hh:244
Hit data structure.
Definition: JDAQHit.hh:34
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
void Write(TDirectory &out, const bool wm=false)
Write objects to file.
Definition: JManager.hh:294
double getFrameTime()
Get frame time duration.
Definition: JDAQClock.hh:162
Auxiliary methods for handling file names, type names and environment.
Data time slice.
virtual const pointer_type & next()
Get next element.
int debug
debug level
Definition: JSirene.cc:61
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Scanning of objects from multiple files according a format that follows from the extension of each fi...
General purpose class for object reading from a list of file names.
Utility class to parse command line options.
JDAQPMTIdentifier PMT
Command line options.
virtual bool hasNext()
Check availability of next element.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
int main(int argc, char *argv[])
Definition: Main.cpp:15