Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JMonitorDOM.cc
Go to the documentation of this file.
1
2#include <string>
3#include <iostream>
4#include <iomanip>
5#include <limits>
6#include <map>
7
9#include "JDAQ/JDAQEventIO.hh"
10
15
16#include "JTools/JQuantile.hh"
17
20#include "JSupport/JSupport.hh"
21
22#include "Jeep/JParser.hh"
23#include "Jeep/JMessage.hh"
24
25
26/**
27 * \file
28 *
29 * Auxiliary program to monitor optical module response.
30 * \author mdejong
31 */
32int main(int argc, char **argv)
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 string pmtFile;
43 double factor;
44 int debug;
45
46 try {
47
48 JParser<> zap("Auxiliary program to monitor optical module response.");
49
50 zap['f'] = make_field(inputFile);
51 zap['a'] = make_field(detectorFile);
52 zap['n'] = make_field(numberOfEvents) = JLimit::max();
53 zap['P'] = make_field(pmtFile) = "";
54 zap['s'] = make_field(factor) = 5.0e-2;
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
73
74 map<int, int> zmap;
75
76 for (JDetector::const_iterator i = detector.begin(); i != detector.end(); ++i) {
77 zmap[i->getID()] = 0;
78 }
79
80
81 while (inputFile.hasNext()) {
82
83 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
84
85 JDAQEvent* event = inputFile.next();
86
87 for (JDAQEvent::const_iterator<JDAQTriggeredHit> hit = event->begin<JDAQTriggeredHit>(); hit != event->end<JDAQTriggeredHit>(); ++hit) {
88 zmap[hit->getModuleID()] += 1;
89 }
90 }
91 STATUS(endl);
92
93
94 JQuantile Q("DOM", true);
95
96 for (JDetector::const_iterator i = detector.begin(); i != detector.end(); ++i) {
97 Q.put(zmap[i->getID()]);
98 }
99
100 const double Rmin = factor * Q.getQuantile(0.5);
101
102 NOTICE("Minimal DOM count " << Rmin << endl);
103
104 for (JDetector::const_iterator i = detector.begin(); i != detector.end(); ++i) {
105 NOTICE("module "
106 << setw(3) << i->getString() << ' '
107 << setw(2) << i->getFloor() << ' '
108 << setw(8) << i->getID() << ' '
109 << setw(6) << zmap[i->getID()] << ' '
110 << (zmap[i->getID()] < Rmin ? "***" : "") << endl);
111 }
112
113
114 if (pmtFile != "") {
115
116 JPMTParametersMap parameters;
117
118 try {
119 parameters.load(pmtFile.c_str());
120 }
121 catch(const JException& error) {}
122
123 for (JDetector::const_iterator i = detector.begin(); i != detector.end(); ++i) {
124 if (zmap[i->getID()] < Rmin) {
125 for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
126 parameters[JPMTIdentifier(i->getID(), pmt)].QE = 0.0;
127 }
128 }
129 }
130
131 parameters.store(pmtFile.c_str());
132 }
133}
string outputFile
KM3NeT DAQ constants, bit handling, etc.
Data structure for detector geometry and calibration.
General purpose messaging.
#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
Direct access to module in detector data structure.
int main(int argc, char **argv)
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Scanning of objects from a single file according a format that follows from the extension of each fil...
ROOT TTree parameter settings of various packages.
Detector data structure.
Definition JDetector.hh:96
Auxiliary class for map of PMT parameters.
General exception.
Definition JException.hh:24
Utility class to parse command line options.
Definition JParser.hh:1698
Object reading from a list of files.
virtual bool hasNext() override
Check availability of next element.
counter_type getCounter() const
Get counter.
virtual const pointer_type & next() override
Get next element.
Template const_iterator.
Definition JDAQEvent.hh:68
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).
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
void store(const char *file_name) const
Store to output file.
void load(const char *file_name)
Load from input file.
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 running average, standard deviation and quantiles.
Definition JQuantile.hh:46
double getQuantile(const double Q, const Quantile_t option=forward_t) const
Get quantile.
Definition JQuantile.hh:349
void put(const double x, const double w=1.0)
Put value.
Definition JQuantile.hh:133