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

Example program to determine speed of JDETECTOR::JPMTRouter. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include "TROOT.h"
#include "TFile.h"
#include "TH2D.h"
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "km3net-dataformat/offline/Hit.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JPMTRouter.hh"
#include "JDetector/JTimeRange.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JSupport.hh"
#include "Jeep/JTimer.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 determine speed of JDETECTOR::JPMTRouter.

Author
mdejong

Definition in file JPMTRouter.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 33 of file JPMTRouter.cc.

34{
35 using namespace std;
36 using namespace JPP;
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 determine speed of PMT router.");
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) = 1;
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 JPMTRouter router(detector);
71
72 typedef map<int, JLocation> map_t;
73
74 map_t zmap;
75
76 for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
77 for (JModule::const_iterator pmt = module->begin(); pmt != module->end(); ++pmt) {
78 zmap[pmt->getID()] = module->getLocation();
79 }
80 }
81
83
84 JRange_t floor = JRange_t::DEFAULT_RANGE();
85 JRange_t string = JRange_t::DEFAULT_RANGE();
86
87 for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
88 floor .include(module->getFloor());
89 string.include(module->getString());
90 }
91
92 NOTICE("String " << string.getLowerLimit() << " - " << string.getUpperLimit() << endl);
93 NOTICE("Floor " << floor .getLowerLimit() << " - " << floor .getUpperLimit() << endl);
94
95
96 TFile out(outputFile.c_str(), "recreate");
97
98 TH2D h1("h1", NULL,
99 string.getLength() + 1,
100 string.getLowerLimit() - 0.5,
101 string.getUpperLimit() + 0.5,
102 floor.getLength() + 1,
103 floor.getLowerLimit() - 0.5,
104 floor.getUpperLimit() + 0.5);
105
106 TH2D h2("h2", NULL,
107 string.getLength() + 1,
108 string.getLowerLimit() - 0.5,
109 string.getUpperLimit() + 0.5,
110 floor.getLength() + 1,
111 floor.getLowerLimit() - 0.5,
112 floor.getUpperLimit() + 0.5);
113
114 JTimer t1("map");
115 JTimer t2("router");
116
117 while (inputFile.hasNext()) {
118
119 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
120
121 const Evt* event = inputFile.next();
122
123 t1.start();
124
125 for (vector<Hit>::const_iterator hit = event->mc_hits.begin(); hit != event->mc_hits.end(); ++hit) {
126
127 const JLocation& pos = zmap[hit->pmt_id];
128
129 h1.Fill((double) pos.getString(), (double) pos.getFloor());
130 }
131
132 t1.stop();
133 }
134 STATUS(endl);
135
136 inputFile.rewind();
137
138 while (inputFile.hasNext()) {
139
140 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
141
142 const Evt* event = inputFile.next();
143
144 t2.start();
145
146 for (vector<Hit>::const_iterator hit = event->mc_hits.begin(); hit != event->mc_hits.end(); ++hit) {
147
148 const JLocation& pos = router.getParentModule(hit->pmt_id);
149
150 h2.Fill((double) pos.getString(), (double) pos.getFloor());
151 }
152
153 t2.stop();
154 }
155 STATUS(endl);
156
157 t1.print(cout);
158 t2.print(cout);
159
160 out.Write();
161 out.Close();
162}
string outputFile
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define STATUS(A)
Definition JMessage.hh:63
#define NOTICE(A)
Definition JMessage.hh:64
#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
Detector data structure.
Definition JDetector.hh:96
Logical location of module.
Definition JLocation.hh:40
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 PMT data in detector data structure.
Definition JPMTRouter.hh:37
Auxiliary class for CPU timing and usage.
Definition JTimer.hh:33
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 void rewind() override
Rewind.
virtual bool hasNext() override
Check availability of next element.
counter_type getCounter() const
Get counter.
virtual const pointer_type & next() override
Get next element.
Range of values.
Definition JRange.hh:42
T getLength() const
Get length (difference between upper and lower limit).
Definition JRange.hh:289
range_type & include(argument_type x)
Include given value to range.
Definition JRange.hh:397
T getLowerLimit() const
Get lower limit.
Definition JRange.hh:202
T getUpperLimit() const
Get upper limit.
Definition JRange.hh:213
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition Evt.hh:21
Type definition of range.
Definition JHead.hh:43
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