Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JChecksum.cc File Reference

Example program to histogram string and floor hits. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "TH2D.h"
#include "JTools/JRange.hh"
#include "JROOT/JManager.hh"
#include "JROOT/JRootToolkit.hh"
#include "JROOT/JROOTClassSelector.hh"
#include "JDAQ/JDAQTimesliceIO.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.hh"
#include "JDetector/JStringRouter.hh"
#include "JLang/JObjectMultiplexer.hh"
#include "JTrigger/JChecksum.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JSupport.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to histogram string and floor hits.

Author
mdejong

Definition in file examples/JTrigger/JChecksum.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 40 of file examples/JTrigger/JChecksum.cc.

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
#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
#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
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.
Data structure for a composite optical module.
Definition JModule.hh:75
General exception.
Definition JException.hh:24
Auxiliary class for multiplexing object iterators.
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
General purpose class for object reading from a list of file names.
T getUpperLimit() const
Get upper limit.
Definition JRange.hh:213
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