52 using namespace KM3NETDAQ;
58 Long64_t numberOfSlices;
72 JParser<> zap(
"Auxiliary program to write time slices with random data.");
76 zap[
'a'] =
make_field(detectorFile,
"detector.");
81 zap[
'T'] =
make_field(TCLB_ns,
"CLB state-machine time jitter") = 256;
82 zap[
'N'] =
make_field(recycling,
"number of recycles / time interval for sampling data [ns]") = make_pair(0, 0.0);
84 zap[
'F'] =
make_field(fast,
"fast - disable PMT simulation");
90 catch(
const exception &error) {
91 FATAL(error.what() << endl);
97 FATAL(
"Invalid number of output files; should be 1 or 2." << endl);
100 gRandom->SetSeed(seed);
102 JK40DefaultSimulatorInterface::setSigma(sigma_ns);
107 if (pmtParameters.getQE() != 1.0) {
109 WARNING(
"Correct background rates with global efficiency " << pmtParameters.getQE() << endl);
111 rates_Hz.correct(pmtParameters.getQE());
114 DEBUG(
"PMT parameters: " << endl << pmtParameters << endl);
115 DEBUG(
"K40 rates: " << endl << rates_Hz << endl);
126 JPMTParametersMap::Throw(
false);
131 if (runbyrun.is_valid()) {
133 NOTICE(
"Using run-by-run:" << endl << runbyrun << endl);
135 if (!runbyrun.hasNext()) {
136 FATAL(
"Run-by-run simulation yields no input." << endl);
139 if (rates_Hz.getSinglesRate() != 0.0) {
140 WARNING(
"Run-by-run simulation discards singles rate [Hz] " << rates_Hz.getSinglesRate() << endl);
154 NOTICE(
"Using fixed rates [Hz]: " << rates_Hz << endl);
169 JTimer timerco(
"constructor");
170 JTimer timerrc(
"recycle");
173 for (
size_t i = 0; i !=
outputFile.size(); ++i) {
187 for ( ; counter != numberOfSlices; ) {
189 STATUS(
"slice: " << setw(10) << counter <<
'\r');
DEBUG(endl);
191 int frame_index = counter + 1;
193 if (runbyrun.hasNext()) {
195 summaryRouter.update(runbyrun.next());
197 summaryRouter.correct(dynamic_cast<const JPMTDefaultSimulatorInterface&>(simbad.getPMTSimulator()));
199 frame_index = summaryRouter.getFrameIndex();
200 run = summaryRouter.getRunNumber();
213 outputFile.rbegin()->put(timeslice); ++counter;
217 for (
size_t i = 1; i <= recycling.first && counter != numberOfSlices; ++i) {
219 STATUS(
"slice: " << setw(10) << counter <<
'\r');
DEBUG(endl);
223 timeslice.recycle(recycling.second);
229 outputFile.rbegin()->put(timeslice); ++counter;
237 timerco.print(cout,
true);
238 timerrc.print(cout,
true);
239 timerIO.print(cout,
true);
251 buffer.
push(&JHead::K40);
253 copy(buffer, header);
259 for (
size_t i = 0; i !=
outputFile.size(); ++i) {
Auxiliary class to select summary data (KM3NETDAQ::JDAQSummaryslice) from the specified raw data file...
Utility class to parse command line options.
Default implementation of the simulation of K40 background.
double getSigma(vector< double > &v)
get standard deviation of vector content
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
double livetime_s
Live time [s].
Data structure for UTC time.
unsigned int JTDC_t
leading edge [ns]
double getTimeOfFrame(const int frame_index)
Get start time of frame in ns since start of run for a given frame index.
K40 simulation based on run-by-run information.
void setDAQLongprint(const bool option)
Set DAQ print option.
void push(T JHead::*pd)
Push given data member to Head.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
double getFrameTime()
Get frame time duration.
Auxiliary class for CPU timing and usage.
Auxiliary class for map of PMT parameters.
Router for fast addressing of summary data in KM3NETDAQ::JDAQSummaryslice data structure as a functio...
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
PMT simulation based on run-by-run information.
virtual const char * what() const override
Get error message.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
double getLivetime(const std::string &file_name)
Get data taking live time.
void copy(const Head &from, JHead &to)
Copy header from from to to.
do set_variable DETECTOR_TXT $WORKDIR detector
Timeslice with random data.
Default PMT simulation interface.
double livetime_s
Live time [s].
Auxiliary class for K40 rates.
#define DEBUG(A)
Message macros.