Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JSimbad.cc File Reference

Example program to simulate summary data. More...

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to simulate summary data.

Author
mdejong

Definition in file JSimbad.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 42 of file JSimbad.cc.

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
#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
#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.
Auxiliary class for map of PMT parameters.
bool is_valid() const
Check validity of PMT parameters.
General exception.
Definition JException.hh:24
virtual const char * what() const override
Get error message.
Definition JException.hh:64
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.