Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JDAQModuleRouter.cc File Reference

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

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "TH2D.h"
#include "TProfile2D.h"
#include "JTools/JHashCollection.hh"
#include "JDAQ/JDAQSummarysliceIO.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.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 rates.

Author
mdejong

Definition in file JDAQModuleRouter.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 32 of file JDAQModuleRouter.cc.

33{
34 using namespace std;
35 using namespace JPP;
36 using namespace KM3NETDAQ;
37
39 JLimit_t& numberOfEvents = inputFile.getLimit();
40 string outputFile;
41 string detectorFile;
42 int debug;
43
44 try {
45
46 JParser<> zap("Example program to histogram string and floor rates.");
47
48 zap['f'] = make_field(inputFile);
49 zap['o'] = make_field(outputFile) = "router.root";
50 zap['a'] = make_field(detectorFile);
51 zap['n'] = make_field(numberOfEvents) = JLimit::max();
52 zap['d'] = make_field(debug) = 2;
53
54 zap(argc, argv);
55 }
56 catch(const exception& error) {
57 FATAL(error.what() << endl);
58 }
59
60
62
63 try {
64 load(detectorFile, detector);
65 }
66 catch(const JException& error) {
67 FATAL(error);
68 }
69
70 const JModuleRouter router(detector);
71
72
73 typedef JTOOLS::JHashCollection<int> JHashCollection_t;
74
75 const JHashCollection_t string(make_array(detector.begin(), detector.end(), &JModule::getString));
76 const JHashCollection_t floor (make_array(detector.begin(), detector.end(), &JModule::getFloor));
77
78 TFile out(outputFile.c_str(), "recreate");
79
80 TProfile2D h2("h2", NULL,
81 string.size(), -0.5, string.size() - 0.5,
82 floor .size(), -0.5, floor .size() - 0.5);
83
84 for (Int_t i = 1; i <= h2.GetXaxis()->GetNbins(); ++i) {
85 h2.GetXaxis()->SetBinLabel(i, MAKE_CSTRING(string.at(i-1)));
86 }
87 for (Int_t i = 1; i <= h2.GetYaxis()->GetNbins(); ++i) {
88 h2.GetYaxis()->SetBinLabel(i, MAKE_CSTRING(floor .at(i-1)));
89 }
90
91 while (inputFile.hasNext()) {
92
93 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
94
95 const JDAQSummaryslice* summary = inputFile.next();
96
97 for (JDAQSummaryslice::const_iterator frame = summary->begin(); frame != summary->end(); ++frame) {
98
99 if (router.hasModule(frame->getModuleID())) {
100
101 const JModule& module = router.getModule(frame->getModuleID());
102
103 for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
104 if (!frame->testHighRateVeto(pmt) && !frame->testFIFOStatus(pmt)) {
105 h2.Fill((double) string.getIndex(module.getString()),
106 (double) floor .getIndex(module.getFloor()),
107 frame->getRate(pmt) * 1.0e-3); // [kHz]
108 }
109 }
110 } else {
111 FATAL("JModuleRouter trying to access non existing identifier: " << frame->getModuleID());
112 }
113 }
114 }
115 STATUS(endl);
116
117 out.Write();
118 out.Close();
119}
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
Utility class to parse command line options.
Definition JParser.hh:1698
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.
General purpose class for hash collection of unique elements.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
const array_type< JValue_t > & make_array(const JValue_t(&array)[N])
Method to create array of values.
Definition JVectorize.hh:54
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).
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition JDAQ.hh:26
Detector file.
Definition JHead.hh:227
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