Jpp
Functions
JMonitorDOM.cc File Reference
#include <string>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include "km3net-dataformat/online/JDAQ.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.hh"
#include "JDetector/JPMTParametersMap.hh"
#include "JTools/JQuantile.hh"
#include "JSupport/JSingleFileScanner.hh"
#include "JSupport/JTreeScanner.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

Auxiliary program to monitor optical module response.

Author
mdejong

Definition in file JMonitorDOM.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 32 of file JMonitorDOM.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  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 
64 
65  cout.tie(&cerr);
66 
68 
69  try {
70  load(detectorFile, detector);
71  }
72  catch(const JException& error) {
73  FATAL(error);
74  }
75 
76 
77  map<int, int> zmap;
78 
79  for (JDetector::const_iterator i = detector.begin(); i != detector.end(); ++i) {
80  zmap[i->getID()] = 0;
81  }
82 
83 
84  while (inputFile.hasNext()) {
85 
86  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
87 
88  JDAQEvent* event = inputFile.next();
89 
90  for (JDAQEvent::const_iterator<JDAQTriggeredHit> hit = event->begin<JDAQTriggeredHit>(); hit != event->end<JDAQTriggeredHit>(); ++hit) {
91  zmap[hit->getModuleID()] += 1;
92  }
93  }
94  STATUS(endl);
95 
96 
97  JQuantile Q("DOM", 1);
98 
99  for (JDetector::const_iterator i = detector.begin(); i != detector.end(); ++i) {
100  Q.put(zmap[i->getID()]);
101  }
102 
103  const double Rmin = factor * Q.getQuantile(0.5);
104 
105  NOTICE("Minimal DOM count " << Rmin << endl);
106 
107  for (JDetector::const_iterator i = detector.begin(); i != detector.end(); ++i) {
108  NOTICE("module "
109  << setw(3) << i->getString() << ' '
110  << setw(2) << i->getFloor() << ' '
111  << setw(8) << i->getID() << ' '
112  << setw(6) << zmap[i->getID()] << ' '
113  << (zmap[i->getID()] < Rmin ? "***" : "") << endl);
114  }
115 
116 
117  if (pmtFile != "") {
118 
119  JPMTParametersMap parameters;
120 
121  try {
122  parameters.load(pmtFile.c_str());
123  }
124  catch(const JException& error) {}
125 
126  for (JDetector::const_iterator i = detector.begin(); i != detector.end(); ++i) {
127  if (zmap[i->getID()] < Rmin) {
128  for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
129  parameters[JPMTIdentifier(i->getID(), pmt)].QE = 0.0;
130  }
131  }
132  }
133 
134  parameters.store(pmtFile.c_str());
135  }
136 }
KM3NETDAQ::JDAQEvent
DAQ Event.
Definition: JDAQEvent.hh:30
JSUPPORT::JSingleFileScanner::getCounter
counter_type getCounter() const
Get counter.
Definition: JSingleFileScanner.hh:208
JSUPPORT::JLimit
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
JLANG::JObjectStreamIO::load
void load(const char *file_name)
Load from input file.
Definition: JObjectStreamIO.hh:30
JDETECTOR::load
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
Definition: JDetectorToolkit.hh:476
JSUPPORT::JSingleFileScanner::next
virtual const pointer_type & next()
Get next element.
Definition: JSingleFileScanner.hh:280
KM3NETDAQ::NUMBER_OF_PMTS
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
NOTICE
#define NOTICE(A)
Definition: JMessage.hh:64
JSUPPORT::JSingleFileScanner::hasNext
virtual bool hasNext()
Check availability of next element.
Definition: JSingleFileScanner.hh:234
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
KM3NETDAQ::JDAQTriggeredHit
DAQ triggered hit.
Definition: JDAQTriggeredHit.hh:20
debug
int debug
debug level
Definition: JSirene.cc:59
KM3NETDAQ::JDAQEvent::const_iterator
Template const_iterator.
Definition: JDAQEvent.hh:68
JLANG::JObjectStreamIO::store
void store(const char *file_name) const
Store to output file.
Definition: JObjectStreamIO.hh:41
JDETECTOR::JPMTParametersMap
Auxiliary class for map of PMT parameters.
Definition: JPMTParametersMap.hh:88
std::map
Definition: JSTDTypes.hh:16
STATUS
#define STATUS(A)
Definition: JMessage.hh:63
JTOOLS::JQuantile
Quantile calculator.
Definition: JQuantile.hh:34
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
JDETECTOR::JPMTIdentifier
PMT identifier.
Definition: JPMTIdentifier.hh:30
JDETECTOR::JDetector
Detector data structure.
Definition: JDetector.hh:80
JAANET::detector
Detector file.
Definition: JHead.hh:130
DEBUG
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
std
Definition: jaanetDictionary.h:36
KM3NETDAQ
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
outputFile
string outputFile
Definition: JDAQTimesliceSelector.cc:37
JLANG::JException
General exception.
Definition: JException.hh:23
JSUPPORT::JSingleFileScanner
Object reading from a list of files.
Definition: JSingleFileScanner.hh:75