Jpp  18.2.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JSimbad.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 
7 
8 #include "JPhysics/JK40Rates.hh"
9 
10 #include "JDetector/JDetector.hh"
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  */
42 int 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 
82  JPMTParametersMap::Throw(true);
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 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:70
Object writing to file.
Utility class to parse command line options.
Definition: JParser.hh:1514
General exception.
Definition: JException.hh:24
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
#define STATUS(A)
Definition: JMessage.hh:63
Detector data structure.
Definition: JDetector.hh:89
Recording of objects on file according a format that follows from the file name extension.
Router for direct addressing of module data in detector data structure.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:83
const JPMTSimulator & getPMTSimulator() const
Get PMT simulator.
string outputFile
Data structure for detector geometry and calibration.
K40 simulation based on run-by-run information.
Scanning of objects from a single file according a format that follows from the extension of each fil...
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
I/O formatting auxiliaries.
Detector file.
Definition: JHead.hh:226
Auxiliaries for creation of summary data.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
CLB simulation based on run-by-run information.
ROOT I/O of application specific meta data.
Auxiliary class to create summary data.
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
Auxiliary class for map of PMT parameters.
Router for fast addressing of summary data in KM3NETDAQ::JDAQSummaryslice data structure as a functio...
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
void reset(JK40Simulator *k40Simulator)
Reset K40 simulator.
PMT simulation based on run-by-run information.
virtual const char * what() const override
Get error message.
Definition: JException.hh:64
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Auxiliary class to define a range between two values.
Utility class to parse command line options.
Map of associated modules in detector.
Object reading from a list of files.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:84
do set_variable DETECTOR_TXT $WORKDIR detector
int debug
debug level
Auxiliary class for K40 rates.
Definition: JK40Rates.hh:41
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62