53{
57
59
61 string detectorFile;
62 Long64_t numberOfSlices;
66 int run;
69 double sigma_ns;
70 bool fast;
73
74 try {
75
76 JParser<> zap(
"Auxiliary program to write time slices with random data.");
77
80 zap[
'a'] =
make_field(detectorFile,
"detector.");
85 zap[
'T'] =
make_field(TCLB_ns,
"CLB state-machine time jitter") = 256;
86 zap[
'N'] =
make_field(recycling,
"number of recycles / time interval for sampling data [ns]") = make_pair(0, 0.0);
88 zap[
'F'] =
make_field(fast,
"fast - disable PMT simulation");
91
92 zap(argc, argv);
93 }
94 catch(const exception &error) {
95 FATAL(error.what() << endl);
96 }
97
98
101 FATAL(
"Invalid number of output files; should be 1 or 2." << endl);
102 }
103
104 seed.set(gRandom);
105
107
108
110
111 if (pmtParameters.
getQE() != 1.0) {
112
113 WARNING(
"Correct background rates with global efficiency " << pmtParameters.
getQE() << endl);
114
116 }
117
118 DEBUG(
"PMT parameters: " << endl << pmtParameters << endl);
119 DEBUG(
"K40 rates: " << endl << rates_Hz << endl);
120
122
123 try {
125 }
128 }
129
131
134
136
137 NOTICE(
"Using run-by-run:" << endl << runbyrun << endl);
138
140 FATAL(
"Run-by-run simulation yields no input." << endl);
141 }
142
145 }
146
147 try {
151 }
154 }
155
156 } else {
157
158 NOTICE(
"Using fixed rates [Hz]: " << rates_Hz << endl);
159
160 try {
162 simbad.reset(fast ?
166 }
169 }
170 }
171
172
173 JTimer timerco(
"constructor");
174 JTimer timerrc(
"recycle");
176
177 for (
size_t i = 0; i !=
outputFile.size(); ++i) {
178
180
183 }
184 }
185
188
189 int counter = 0;
190
191 for ( ; counter != numberOfSlices; ) {
192
193 STATUS(
"slice: " << setw(10) << counter <<
'\r');
DEBUG(endl);
194
195 int frame_index = counter + 1;
196
198
200
202
203 frame_index = summaryRouter.getFrameIndex();
204 run = summaryRouter.getRunNumber();
205 }
206
209
211
212 timerco.start();
213
215
216 timerco.stop();
217
218 timerIO.start();
219
220 outputFile.rbegin()->put(timeslice); ++counter;
221
222 timerIO.stop();
223
224 for (size_t i = 1; i <= recycling.first && counter != numberOfSlices; ++i) {
225
226 STATUS(
"slice: " << setw(10) << counter <<
'\r');
DEBUG(endl);
227
228 timerrc.start();
229
230 timeslice.recycle(recycling.second);
231
232 timerrc.stop();
233
234 timerIO.start();
235
236 outputFile.rbegin()->put(timeslice); ++counter;
237
238 timerIO.stop();
239 }
240 }
242
244 timerco.print(cout, true);
245 timerrc.print(cout, true);
246 timerIO.print(cout, true);
247 }
248
250
251 {
253
256
259
260 copy(buffer, header);
261 }
262
265
266 for (
size_t i = 0; i !=
outputFile.size(); ++i) {
268 }
269}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
void push(T JHead::*pd)
Push given data member to Head.
static double getSigma()
Get intrinsic time smearing of K40 coincidences.
static void setSigma(const double sigma)
Set intrinsic time smearing of K40 coincidences.
Default implementation of the simulation of K40 background.
Default PMT simulation interface.
Auxiliary class for map of PMT parameters.
double getQE(const JPMTIdentifier &id) const
Get QE of given PMT.
Auxiliary class for CPU timing and usage.
virtual const char * what() const override
Get error message.
virtual bool hasNext() override
Check availability of next element.
virtual const pointer_type & next() override
Get next element.
static void Throw(const bool option)
Enable/disable throw option.
Utility class to parse command line options.
Router for fast addressing of summary data in KM3NETDAQ::JDAQSummaryslice data structure as a functio...
void update(const JDAQSummaryslice *ps)
Update router.
K40 simulation based on run-by-run information.
unsigned int JTDC_t
leading edge [ns]
Data structure for UTC time.
static const JDAQUTCExtended & getInstance()
Get arbitrary offset (e.g.
void copy(const Head &from, JHead &to)
Copy header from from to to.
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).
double getLivetime(const std::string &file_name)
Get data taking live time.
KM3NeT DAQ data structures and auxiliaries.
double getFrameTime()
Get frame time duration.
void setDAQLongprint(const bool option)
Set DAQ print option.
double getTimeOfFrame(const int frame_index)
Get start time of frame in ns since start of run for a given frame index.
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
double livetime_s
Live time [s].
double livetime_s
Live time [s].
Template definition of random value generator.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Auxiliary class for K40 rates.
double getSinglesRate() const
Get singles rate.
void correct(const double QE)
Correct rates for global efficiency,.
Auxiliary class to select summary data (KM3NETDAQ::JDAQSummaryslice) from the specified raw data file...
bool is_valid() const
Check validity of run by run options.
Timeslice with random data.