Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JDAQHitRouter.cc
Go to the documentation of this file.
1
2#include <string>
3#include <iostream>
4#include <iomanip>
5
6#include "TROOT.h"
7#include "TFile.h"
8#include "TH1D.h"
9#include "TH2D.h"
10
11#include "JTools/JRange.hh"
12
13#include "JROOT/JManager.hh"
14#include "JROOT/JRootToolkit.hh"
15
16#include "JDAQ/JDAQEventIO.hh"
21
23#include "JSupport/JSupport.hh"
24
25#include "Jeep/JParser.hh"
26#include "Jeep/JMessage.hh"
27
28
29/**
30 * \file
31 *
32 * Example program to histogram string and floor hits.
33 * \author mdejong
34 */
35int main(int argc, char **argv)
36{
37 using namespace std;
38 using namespace JPP;
39 using namespace KM3NETDAQ;
40
42 JLimit_t& numberOfEvents = inputFile.getLimit();
43 string outputFile;
44 string detectorFile;
45 int debug;
46
47 try {
48
49 JParser<> zap("Example program to histogram string and floor hits.");
50
51 zap['f'] = make_field(inputFile);
52 zap['o'] = make_field(outputFile) = "router.root";
53 zap['a'] = make_field(detectorFile);
54 zap['n'] = make_field(numberOfEvents) = JLimit::max();
55 zap['d'] = make_field(debug) = 2;
56
57 zap(argc, argv);
58 }
59 catch(const exception& error) {
60 FATAL(error.what() << endl);
61 }
62
63
65
66 try {
67 load(detectorFile, detector);
68 }
69 catch(const JException& error) {
70 FATAL(error);
71 }
72
74
75 const JDAQHitRouter router(detector);
76 const JStringRouter string(detector);
77
78
79 TH1D h1("h1", NULL, 100, 0.0, 1.0e1);
80
81 JManager<int, TH2D> H2(new TH2D("h2[%]", NULL,
82 string.size(), -0.5, string.size() - 0.5,
83 range.getUpperLimit(), 1 - 0.5, range.getUpperLimit() + 0.5));
84
85 for (Int_t i = 1; i <= H2->GetXaxis()->GetNbins(); ++i) {
86 H2->GetXaxis()->SetBinLabel(i, MAKE_CSTRING(string.at(i-1)));
87 }
88 for (Int_t i = 1; i <= H2->GetYaxis()->GetNbins(); ++i) {
89 H2->GetYaxis()->SetBinLabel(i, MAKE_CSTRING(i));
90 }
91
92 TH2D* h3 = (TH2D*) H2->Clone("h3");
93
94 while (inputFile.hasNext()) {
95
96 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
97
98 JDAQEvent* event = inputFile.next();
99
101
102 {
103 typedef JDAQTriggeredHit JHit_t;
104
105 for (JDAQEvent::const_iterator<JHit_t> hit = event->begin<JHit_t>(); hit != event->end<JHit_t>(); ++hit) {
106
107 const JPMTChannel& channel = router.getPMTChannel(*hit);
108
109 H2->Fill((double) string.getIndex(channel.getString()), (double) channel.getFloor());
110
111 for (int i = 0; i != NUMBER_OF_TRIGGER_BITS; ++i) {
112 if (hit->hasTriggerBit(i)) {
113 H2[i]->Fill((double) string.getIndex(channel.getString()), (double) channel.getFloor());
114 }
115 }
116
117 tx.include(getTime(*hit, router.getPMT(*hit)));
118 }
119 }
120
121 h1.Fill(tx.getLength() * 1.0e-3);
122
123 {
124 typedef JDAQSnapshotHit JHit_t;
125
126 for (JDAQEvent::const_iterator<JHit_t> hit = event->begin<JHit_t>(); hit != event->end<JHit_t>(); ++hit) {
127
128 const JPMTChannel& channel = router.getPMTChannel(*hit);
129
130 h3->Fill((double) string.getIndex(channel.getString()), (double) channel.getFloor());
131 }
132 }
133 }
134 STATUS(endl);
135
136 TFile out(outputFile.c_str(), "recreate");
137
138 out << h1;
139 out << *H2;
140 out << H2;
141 out << *h3;
142
143 out.Write();
144 out.Close();
145}
int main(int argc, char **argv)
Direct access to PMT data in detector data structure for DAQ hits.
string outputFile
Data structure for detector geometry and calibration.
Dynamic ROOT object management.
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
#define MAKE_CSTRING(A)
Make C-string.
Definition JPrint.hh:72
Auxiliary class to define a range between two values.
Direct access to string in detector data structure.
ROOT TTree parameter settings of various packages.
Simple wrapper around JModuleRouter class for direct addressing of PMT data in detector data structur...
JPMTChannel getPMTChannel(const JDAQKeyHit &hit) const
Get PMT channel.
const JPMT & getPMT(const JDAQKeyHit &hit) const
Get PMT parameters.
Detector data structure.
Definition JDetector.hh:96
int getFloor() const
Get floor number.
Definition JLocation.hh:146
int getString() const
Get string number.
Definition JLocation.hh:135
Auxiliary class to uniquely identify PMT readout channel.
General exception.
Definition JException.hh:24
Utility class to parse command line options.
Definition JParser.hh:1698
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys.
Definition JManager.hh:47
void Write(TDirectory &out, const bool wm=false)
Write objects to file.
Definition JManager.hh:304
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.
T getLength() const
Get length (difference between upper and lower limit).
Definition JRange.hh:289
static JRange< double, std::less< double > > DEFAULT_RANGE()
Definition JRange.hh:555
range_type & include(argument_type x)
Include given value to range.
Definition JRange.hh:397
T getUpperLimit() const
Get upper limit.
Definition JRange.hh:213
Template const_iterator.
Definition JDAQEvent.hh:68
floor_range getRangeOfFloors(const JDetector &detector)
Get range of floors.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
int getIndex()
Get index for user I/O manipulation.
Definition JManip.hh:26
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
const char * getTime()
Get current local time conform ISO-8601 standard.
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
static const unsigned int NUMBER_OF_TRIGGER_BITS
Number of trigger bits.
Detector file.
Definition JHead.hh:227
Router for mapping of string identifier to index.
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