Jpp
 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  cout.tie(&cerr);
73 
75 
76  try {
77  load(detectorFile, detector);
78  }
79  catch(const JException& error) {
80  FATAL(error);
81  }
82 
83  JPMTParametersMap::Throw(true);
84 
85  if (!pmtParameters.is_valid()) {
86  FATAL("Invalid PMT parameters " << pmtParameters << endl);
87  }
88 
89  const JModuleRouter moduleRouter(detector);
91  JSummaryRouter summaryRouter;
92 
93  try {
94  simbad.reset(new JK40RunByRunSimulator(summaryRouter, JK40Rates()));
95  simbad.reset(new JPMTRunByRunSimulator(summaryRouter, pmtParameters, detector));
96  simbad.reset(new JCLBRunByRunSimulator(summaryRouter));
97  }
98  catch(const JException& error) {
99  FATAL(error.what() << endl);
100  }
101 
102  outputFile.open();
103 
104  if (!outputFile.is_open()) {
105  FATAL("Error opening file " << outputFile << endl);
106  }
107 
108  outputFile.put(JMeta(argc, argv));
109 
110  while (inputFile.hasNext()) {
111 
112  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
113 
114  JDAQSummaryslice* summary = inputFile.next();
115 
116  summaryRouter.update(summary);
117 
118  summaryRouter.correct(dynamic_cast<const JPMTDefaultSimulatorInterface&>(simbad.getPMTSimulator()));
119 
120  outputFile.put(JSummaryslice(summary->getDAQChronometer(),simbad));
121  }
122  STATUS(endl);
123 
124  outputFile.close();
125 }
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:1500
General exception.
Definition: JException.hh:23
ROOT TTree parameter settings of various packages.
#define STATUS(A)
Definition: JMessage.hh:63
Detector data structure.
Definition: JDetector.hh:80
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:66
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:196
Auxiliaries for creation of summary data.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
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.
int debug
debug level
Definition: JSirene.cc:63
Router for fast addressing of summary data in JDAQSummaryslice data structure as a function of the op...
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:48
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:73
do set_variable DETECTOR_TXT $WORKDIR detector
Auxiliary class for K40 rates.
Definition: JK40Rates.hh:41
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
int main(int argc, char *argv[])
Definition: Main.cpp:15