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

Program to correct detector file for inconsistencies in configuration of data filter. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include "TROOT.h"
#include "TFile.h"
#include "JDAQ/JDAQEventIO.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.hh"
#include "JSupport/JSingleFileScanner.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

Program to correct detector file for inconsistencies in configuration of data filter.

Author
mdejong

Definition in file JCoelacanth.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 29 of file JCoelacanth.cc.

30{
31 using namespace std;
32 using namespace JPP;
33 using namespace KM3NETDAQ;
34
35 vector<string> inputFile;
36 JLimit_t numberOfEvents;
37 string outputFile;
38 string detectorFile;
39 double stdev;
40 bool overwriteDetector;
41 int qaqc;
42 int debug;
43
44 try {
45
46 JParser<> zap("Program to correct detector file for inconsistencies in configuration of data filter.");
47
48 zap['f'] = make_field(inputFile, "original raw data file and reprocessed raw data file");
49 zap['a'] = make_field(detectorFile);
50 zap['n'] = make_field(numberOfEvents) = JLimit::max();
51 zap['S'] = make_field(stdev, "number of standard deviations for comparison of counts per optical module.") = 10.0;
52 zap['A'] = make_field(overwriteDetector, "overwrite detector file provided through '-a'.");
53 zap['Q'] = make_field(qaqc) = 0;
54 zap['d'] = make_field(debug) = 2;
55
56 zap(argc, argv);
57 }
58 catch(const exception& error) {
59 FATAL(error.what() << endl);
60 }
61
62
63 if (inputFile.size() != 2) {
64 FATAL("Wrong number of input files " << inputFile.size() << " != " << 2 << endl);
65 }
66
68
69 try {
70 load(detectorFile, detector);
71 }
72 catch(const JException& error) {
73 FATAL(error);
74 }
75
76 const JModuleRouter router(detector);
77
79
80 map_type zmap[2];
81
82 for (int i = 0; i != 2; ++i) {
83
84 STATUS("Processing " << inputFile[i] << endl);
85
86 for (JSingleFileScanner<JDAQEvent> in(inputFile[i], numberOfEvents); in.hasNext(); ) {
87
88 STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl);
89
90 const JDAQEvent* event = in.next();
91
92 for (JDAQEvent::const_iterator<JDAQTriggeredHit> hit = event->begin<JDAQTriggeredHit>(); hit != event->end<JDAQTriggeredHit>(); ++hit) {
93 zmap[i][hit->getModuleID()] += 1;
94 }
95 }
96 STATUS(endl);
97 }
98
99 size_t ns = 0;
100
101 for (map_type::const_iterator
102 p = zmap[0].begin(),
103 q = zmap[1].begin(); (p != zmap[0].end() &&
104 q != zmap[1].end()); ) {
105
106 if (p->first < q->first) { ++p; }
107 else if (q->first < p->first) { ++q; }
108 else {
109
110 if (max ((double) p->second, (double) q->second) > stdev * sqrt(p->second + q->second) &&
111 fabs((double) p->second - (double) q->second) > stdev * sqrt(p->second + q->second)) {
112
113 ns += 1;
114
115 NOTICE("Module " << setw(8) << p->first << ' ' << setw(6) << p->second << " <> " << setw(6) << q->second << ' ' << (overwriteDetector ? "-> set position to (0,0,0)" : "") << endl);
116
117 if (overwriteDetector) {
118 detector[router.getIndex(p->first)].set(JVector3D(0.0,0.0,0.0));
119 }
120 }
121
122 ++p;
123 ++q;
124 }
125 }
126
127 if (overwriteDetector) {
128
129 NOTICE("Store calibration data on file " << detectorFile << endl);
130
131 store(detectorFile, detector);
132 }
133
134 QAQC(ns << endl);
135
136 return 0;
137}
string outputFile
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define STATUS(A)
Definition JMessage.hh:63
#define QAQC(A)
QA/QC output macro.
Definition JMessage.hh:100
int qaqc
QA/QC file descriptor.
#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
Router for direct addressing of module data in detector data structure.
Data structure for vector in three dimensions.
Definition JVector3D.hh:36
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.
Template const_iterator.
Definition JDAQEvent.hh:68
JTriggerCounter_t next()
Increment trigger counter.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
std::map< int, range_type > map_type
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