Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JSimbad.cc File Reference

Example program to simulate summary data. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "JDAQ/JDAQSummarysliceIO.hh"
#include "JPhysics/JK40Rates.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JDetectorSimulator.hh"
#include "JDetector/JModuleMapper.hh"
#include "JDetector/JPMTParametersMap.hh"
#include "JDetector/JK40DefaultSimulator.hh"
#include "JDetector/JPMTDefaultSimulator.hh"
#include "JDetector/JCLBDefaultSimulator.hh"
#include "JTrigger/JK40RunByRunSimulator.hh"
#include "JTrigger/JPMTRunByRunSimulator.hh"
#include "JTrigger/JCLBRunByRunSimulator.hh"
#include "JSupport/JSingleFileScanner.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JMeta.hh"
#include "JSummaryslice/JSummaryslice.hh"
#include "JTools/JRange.hh"
#include "Jeep/JPrint.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

Example program to simulate summary data.

Author
mdejong

Definition in file JSimbad.cc.

Function Documentation

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  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
#define STATUS(A)
Definition: JMessage.hh:63
Detector data structure.
Definition: JDetector.hh:80
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
string outputFile
K40 simulation based on run-by-run information.
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Detector file.
Definition: JHead.hh:196
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
CLB simulation based on run-by-run information.
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...
#define FATAL(A)
Definition: JMessage.hh:67
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.
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