85 int main(
int argc,
char **argv)
95 JLimit_t& numberOfEvents = inputFile.getLimit();
100 bool triggeredEventsOnly;
109 JParser<> zap(
"Auxiliary program to trigger Monte Carlo events.");
111 zap[
'f'] =
make_field(inputFile,
"input file (output of detector simulation)");
113 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
114 zap[
'a'] =
make_field(detectorFileA,
"detector used for conversion from Monte Carlo truth to raw data.");
115 zap[
'b'] =
make_field(detectorFileB,
"detector used for conversion of raw data to calibrated data.") =
"";
116 zap[
'R'] =
make_field(run,
"run number") = -1;
119 zap[
'O'] =
make_field(triggeredEventsOnly,
"optionally write only triggered events.");
127 catch(
const exception &error) {
128 FATAL(error.what() << endl);
131 gRandom->SetSeed(seed);
137 if (detectorFileB ==
"") {
138 detectorFileB = detectorFileA;
146 load(detectorFileA, detectorA);
147 load(detectorFileB, detectorB);
153 JPMTParametersMap::Throw(
true);
156 FATAL(
"Invalid PMT parameters " << pmtParameters << endl);
159 if (pmtParameters.
getQE() != 1.0) {
161 WARNING(
"Correct background rates with global efficiency " << pmtParameters.
getQE() << endl);
172 NOTICE(
"Using run-by-run:" << endl << runbyrun << endl);
175 FATAL(
"Run-by-run simulation yields no input." << endl);
195 NOTICE(
"Set trigger parameters from run-by-run input." << endl);
198 WARNING(
"No trigger parameters from run-by-run input;\nrun with default/user input." << endl);
203 NOTICE(
"Using fixed rates [Hz]: " << rates_Hz << endl);
217 DEBUG(
"Trigger:" << endl << parameters << endl);
218 DEBUG(
"PMT parameters:" << endl << pmtParameters << endl);
225 typedef double hit_type;
233 const JBuildL1_t buildL1(parameters);
234 const JBuildL2_t buildL2(parameters.
L2);
235 const JBuildL2_t buildSN(parameters.
SN);
253 const JPosition3D center = get<JPosition3D>(header);
255 NOTICE(
"Apply detector offset from Monte Carlo run header (" << center <<
")" << endl);
274 JLimit_t limit = inputFile.getLimit();
296 for ( ; in.
hasNext() && number_of_events != limit; ++number_of_events) {
298 STATUS(
"event: " << setw(10) << number_of_events <<
'\r');
DEBUG(endl);
302 event->mc_run_id = mc_run_id;
304 DEBUG(*event << endl);
306 bool trigger =
false;
308 if (!event->mc_hits.empty()) {
333 event->mc_t = t1 - t0;
335 timeRange.
add(event->mc_t);
336 timeRange.
add(period);
342 DEBUG(timeslice << endl);
352 for (JDAQTimeslice::const_iterator super_frame = timeslice.begin(); super_frame != timeslice.end(); ++super_frame) {
354 if (moduleRouter.
hasModule(super_frame->getModuleID())) {
359 const JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(*super_frame, module);
363 timesliceL0.push_back(JSuperFrame1D_t(buffer));
367 timesliceL1.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
368 super_frame->getModuleIdentifier(),
371 buildL1(*timesliceL0.rbegin(), back_inserter(*timesliceL1.rbegin()));
375 timesliceL2.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
376 super_frame->getModuleIdentifier(),
379 buildL2(buffer, *timesliceL1.rbegin(), back_inserter(*timesliceL2.rbegin()));
383 timesliceSN.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
384 super_frame->getModuleIdentifier(),
387 buildSN(buffer, *timesliceL1.rbegin(), back_inserter(*timesliceSN.rbegin()));
389 DEBUG(
"L0 " << setw(8) << timesliceL0.rbegin()->getModuleID() <<
' ' << setw(8) << timesliceL0.rbegin()->size() << endl);
390 DEBUG(
"L1 " << setw(8) << timesliceL1.rbegin()->getModuleID() <<
' ' << setw(8) << timesliceL1.rbegin()->size() << endl);
391 DEBUG(
"L2 " << setw(8) << timesliceL2.rbegin()->getModuleID() <<
' ' << setw(8) << timesliceL2.rbegin()->size() << endl);
392 DEBUG(
"SN " << setw(8) << timesliceSN.rbegin()->getModuleID() <<
' ' << setw(8) << timesliceSN.rbegin()->size() << endl);
402 trigger3DMuon (trigger_input, back_inserter(trigger_output));
403 trigger3DShower(trigger_input, back_inserter(trigger_output));
404 triggerMXShower(trigger_input, timesliceL0, back_inserter(trigger_output));
408 for (JTriggerOutput::const_iterator to = trigger_output.begin(); to != trigger_output.end(); ++to) {
410 for (
int i = 0; i != h1.GetNbinsX(); ++i) {
411 if (to->hasTriggerBit(i)) {
419 << to->getFrameIndex() <<
' '
421 << timeRange << endl);
423 if (timeRange.
overlap(eventTime)) {
442 if (!triggeredEventsOnly || trigger) {
466 if (!triggeredEventsOnly || trigger) {