Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
examples/JTrigger/JChecksum.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"
16
22
24
25#include "JTrigger/JChecksum.hh"
26
28#include "JSupport/JSupport.hh"
29
30#include "Jeep/JParser.hh"
31#include "Jeep/JMessage.hh"
32
33
34/**
35 * \file
36 *
37 * Example program to histogram string and floor hits.
38 * \author mdejong
39 */
40int main(int argc, char **argv)
41{
42 using namespace std;
43 using namespace JPP;
44 using namespace KM3NETDAQ;
45
47 JLimit_t& numberOfEvents = inputFile.getLimit();
48 string outputFile;
49 string detectorFile;
50 JROOTClassSelector selector;
51 int debug;
52
53 try {
54
55 JParser<> zap("Example program to histogram string and floor hits.");
56
57 zap['f'] = make_field(inputFile);
58 zap['o'] = make_field(outputFile) = "checksum.root";
59 zap['a'] = make_field(detectorFile);
60 zap['n'] = make_field(numberOfEvents) = JLimit::max();
62 zap['d'] = make_field(debug) = 2;
63
64 zap(argc, argv);
65 }
66 catch(const exception& error) {
67 FATAL(error.what() << endl);
68 }
69
70
72
73 try {
74 load(detectorFile, detector);
75 }
76 catch(const JException& error) {
77 FATAL(error);
78 }
79
81
82 const JModuleRouter router(detector);
83 const JStringRouter string(detector);
84
85
86 JManager<int, TH2D> H2(new TH2D("h2[%]", NULL,
87 string.size(), -0.5, string.size() - 0.5,
88 range.getUpperLimit(), 1 - 0.5, range.getUpperLimit() + 0.5));
89
90 for (Int_t i = 1; i <= H2->GetXaxis()->GetNbins(); ++i) {
91 H2->GetXaxis()->SetBinLabel(i, MAKE_CSTRING(string.at(i-1)));
92 }
93 for (Int_t i = 1; i <= H2->GetYaxis()->GetNbins(); ++i) {
94 H2->GetYaxis()->SetBinLabel(i, MAKE_CSTRING(i));
95 }
96
97
99
100 for (counter_type counter = 0; in.hasNext() && counter != inputFile.getLimit(); ++counter) {
101
102 STATUS("event: " << setw(10) << counter << '\r'); DEBUG(endl);
103
104 const JDAQTimeslice* timeslice = in.next();
105
106 for (JDAQTimeslice::const_iterator frame = timeslice->begin(); frame != timeslice->end(); ++frame) {
107
108 const JModule module = router.getModule(frame->getModuleID());
109
110 const JChecksum::result_type& result = checksum(*frame);
111
112 for (JChecksum::const_iterator error = result.begin(); error != result.end(); ++error) {
113 H2[error->type]->Fill((double) string.getIndex(module.getString()), (double) module.getFloor());
114 }
115 }
116 }
117 STATUS(endl);
118
119 TFile out(outputFile.c_str(), "recreate");
120
121 out << H2;
122
123 out.Write();
124 out.Close();
125}
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
Direct access to module in detector data structure.
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.
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
Router for direct addressing of module data in detector data structure.
const JModule & getModule(const JObjectID &id) const
Get module parameters.
Data structure for a composite optical module.
Definition JModule.hh:75
General exception.
Definition JException.hh:24
Auxiliary class for multiplexing object iterators.
virtual bool hasNext() override
Check availability of next element.
virtual const pointer_type & next() override
Get next element.
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.
T getUpperLimit() const
Get upper limit.
Definition JRange.hh:213
int main(int argc, char **argv)
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).
std::set< JROOTClassSelector > getROOTClassSelection(const bool option=false)
Get ROOT class selection.
Long64_t counter_type
Type definition for counter.
return result
Definition JPolint.hh:862
static const JChecksum checksum
Function object to perform check-sum of raw data.
Definition JChecksum.hh:200
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
Detector file.
Definition JHead.hh:227
Router for mapping of string identifier to index.
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
Auxiliary data structure for result of checksum.
Definition JChecksum.hh:90
result_type::const_iterator const_iterator
Definition JChecksum.hh:119