Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JSimbad.cc
Go to the documentation of this file.
1
2#include <string>
3#include <iostream>
4#include <iomanip>
5
7
9
18
22
25#include "JSupport/JSupport.hh"
26#include "JSupport/JMeta.hh"
28
29#include "JTools/JRange.hh"
30
31#include "Jeep/JPrint.hh"
32#include "Jeep/JParser.hh"
33#include "Jeep/JMessage.hh"
34
35
36/**
37 * \file
38 * Example program to simulate summary data.
39 *
40 * \author mdejong
41 */
42int main(int argc, char **argv)
43{
44 using namespace std;
45 using namespace JPP;
46 using namespace KM3NETDAQ;
47
50 JLimit_t& numberOfEvents = inputFile.getLimit();
51 string detectorFile;
52 JPMTParametersMap pmtParameters;
53 int debug;
54
55 try {
56
57 JParser<> zap("Example program to simulate summary data.");
58
59 zap['f'] = make_field(inputFile, "input DAQ file");
60 zap['o'] = make_field(outputFile, "output file") = "simbad.root";
61 zap['n'] = make_field(numberOfEvents) = JLimit::max();
62 zap['a'] = make_field(detectorFile , "detector file");
63 zap['P'] = make_field(pmtParameters, "PMT simulation data (or corresponding file name)") = JPARSER::initialised();
64 zap['d'] = make_field(debug, "debug") = 0;
65
66 zap(argc, argv);
67 }
68 catch(const exception &error) {
69 FATAL(error.what() << endl);
70 }
71
72
74
75 try {
76 load(detectorFile, detector);
77 }
78 catch(const JException& error) {
79 FATAL(error);
80 }
81
83
84 if (!pmtParameters.is_valid()) {
85 FATAL("Invalid PMT parameters " << pmtParameters << endl);
86 }
87
88 const JModuleRouter moduleRouter(detector);
90 JSummaryRouter summaryRouter;
91
92 try {
93 simbad.reset(new JK40RunByRunSimulator(summaryRouter, JK40Rates()));
94 simbad.reset(new JPMTRunByRunSimulator(summaryRouter, pmtParameters, detector));
95 simbad.reset(new JCLBRunByRunSimulator(summaryRouter));
96 }
97 catch(const JException& error) {
98 FATAL(error.what() << endl);
99 }
100
101 outputFile.open();
102
103 if (!outputFile.is_open()) {
104 FATAL("Error opening file " << outputFile << endl);
105 }
106
107 outputFile.put(JMeta(argc, argv));
108
109 while (inputFile.hasNext()) {
110
111 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
112
113 JDAQSummaryslice* summary = inputFile.next();
114
115 summaryRouter.update(summary);
116
117 summaryRouter.correct(dynamic_cast<const JPMTDefaultSimulatorInterface&>(simbad.getPMTSimulator()));
118
119 outputFile.put(JSummaryslice(summary->getDAQChronometer(),simbad));
120 }
121 STATUS(endl);
122
123 outputFile.close();
124}
string outputFile
Data structure for detector geometry and calibration.
Recording of objects on file according a format that follows from the file name extension.
General purpose messaging.
#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
ROOT I/O of application specific meta data.
Map of associated modules in detector.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
I/O formatting auxiliaries.
Auxiliary class to define a range between two values.
int main(int argc, char **argv)
Definition JSimbad.cc:42
Scanning of objects from a single file according a format that follows from the extension of each fil...
Auxiliaries for creation of summary data.
ROOT TTree parameter settings of various packages.
void reset(JK40Simulator *k40Simulator)
Reset K40 simulator.
const JPMTSimulator & getPMTSimulator() const
Get PMT simulator.
Detector data structure.
Definition JDetector.hh:96
Router for direct addressing of module data in detector data structure.
Auxiliary class for map of PMT parameters.
bool is_valid() const
Check validity of PMT parameters.
General exception.
Definition JException.hh:24
static void Throw(const bool option)
Enable/disable throw option.
Definition JThrow.hh:37
Utility class to parse command line options.
Definition JParser.hh:1698
Object writing to file.
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.
Router for fast addressing of summary data in KM3NETDAQ::JDAQSummaryslice data structure as a functio...
void update(const JDAQSummaryslice *ps)
Update router.
CLB simulation based on run-by-run information.
K40 simulation based on run-by-run information.
PMT simulation based on run-by-run information.
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
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
Detector file.
Definition JHead.hh:227
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition JParser.hh:68
Auxiliary class for K40 rates.
Definition JK40Rates.hh:41
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 class for ROOT I/O of application specific meta data.
Definition JMeta.hh:72
Auxiliary class to create summary data.