102 double T0_ns = numeric_limits<double>::max();
105 for (
const JPMT& pmt : module) {
107 if (pmt.getT0() < T0_ns) {
149 JLimit_t& numberOfEvents = inputFile.getLimit();
150 string detectorFileA;
151 string detectorFileB;
155 bool triggeredEventsOnly;
166 JParser<> zap(
"Auxiliary program to trigger Monte Carlo events.");
168 zap[
'f'] =
make_field(inputFile,
"input file (output of detector simulation)");
171 zap[
'a'] =
make_field(detectorFileA,
"detector used for conversion from Monte Carlo truth to raw data.");
172 zap[
'b'] =
make_field(detectorFileB,
"detector used for conversion of raw data to calibrated data.") =
"";
173 zap[
'm'] =
make_field(margin_m,
"margin to the can for the computation of visible energy [m]") = 20.0;
174 zap[
'R'] =
make_field(run,
"run number") = -1;
177 zap[
'O'] =
make_field(triggeredEventsOnly,
"optionally write only triggered events.");
187 catch(
const exception &error) {
188 FATAL(error.what() << endl);
197 if (detectorFileB ==
"") {
198 detectorFileB = detectorFileA;
206 load(detectorFileA, detectorA);
207 load(detectorFileB, detectorB);
213 const double TA_ns = getT0(detectorA);
214 const double TB_ns = getT0(detectorB);
219 FATAL(
"Invalid PMT parameters " << pmtParameters << endl);
222 if (pmtParameters.
getQE() != 1.0) {
224 WARNING(
"Correct background rates with global efficiency " << pmtParameters.
getQE() << endl);
248 if (runbyrun !=
"") {
250 NOTICE(
"Using run-by-run: " << runbyrun << endl);
252 scanner.configure(runbyrun);
254 if (!scanner.empty()) {
255 UTC = scanner.begin()->getTimesliceStart();
257 FATAL(
"Run-by-run simulation misses summary data." << endl);
273 NOTICE(
"Set trigger parameters from run-by-run input." << endl);
276 WARNING(
"No trigger parameters from run-by-run input;\nrun with default/user input." << endl);
281 JHead buffer(header);
286 copy(buffer, header);
290 NOTICE(
"Using fixed rates [Hz]: " << rates_Hz << endl);
304 if (parameters.disableHighRateVeto) {
306 NOTICE(
"Disabling high-rate veto of all PMTs." << endl);
313 DEBUG(
"Trigger:" << endl << parameters << endl);
314 DEBUG(
"PMT parameters:" << endl << pmtParameters << endl);
319 const JTimeRange period(-(Tmax + parameters.TMaxLocal_ns),
320 +(Tmax + parameters.TMaxLocal_ns));
330 typedef JTimeslice <hit_type> JTimeslice_t;
331 typedef JBuildL1 <hit_type> JBuildL1_t;
332 typedef JBuildL2 <hit_type> JBuildL2_t;
334 const JBuildL1_t buildL1(parameters);
335 const JBuildL2_t buildL2(parameters.L2);
336 const JBuildL2_t buildSN(parameters.SN);
345 TH1D h1(
"Trigger bits", NULL, NUMBER_OF_TRIGGER_BITS, -0.5, NUMBER_OF_TRIGGER_BITS - 0.5);
360 int trigger_counter = 0;
363 can.addMargin(margin_m);
365 for (
string file_name; inputFile.
hasNext(); ) {
371 DEBUG(*event << endl);
381 const double Ehad = Evis - Elep;
396 run =
event->mc_run_id;
405 if (runbyrun !=
"") {
407 if (event->mc_event_time == TTimeStamp(0)) {
408 FATAL(
"Monte Carlo event time undefined." << endl);
414 if (!frame_time(t1)) {
416 const Long64_t index = scanner.find(utc);
420 p = scanner.getEntry(index - 1);
434 <<
FIXED(15,3) << event->mc_event_time.AsDouble() <<
" [s] "
436 <<
FIXED(12,0) << t1 <<
" [ns] "
437 << frame_time(t1) << endl);
440 if (!event->mc_hits.empty() && frame_time(t1)) {
446 DEBUG(
"Start time: " <<
FIXED(12,2) << t0 <<
' ' <<
FIXED(12,2) << t1 <<
' ' <<
FIXED(9,2) << TA_ns << endl);
452 timeRange.
add(event->mc_t);
453 timeRange.
add(period);
459 DEBUG(timeslice << endl);
469 for (JDAQTimeslice::const_iterator super_frame = timeslice.begin(); super_frame != timeslice.end(); ++super_frame) {
471 if (moduleRouter.
hasModule(super_frame->getModuleID())) {
476 const JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(*super_frame, module);
480 timesliceL0.push_back(JSuperFrame1D_t(buffer));
482 DEBUG(
"L0 " << setw(8) << timesliceL0.rbegin()->getModuleID() <<
' ' << setw(8) << timesliceL0.rbegin()->size() <<
LAMBDA([ps = timesliceL0.rbegin()](ostream& out) { for (const auto& i : *ps) { out <<
" " << i; } }) << endl);
486 timesliceL1.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
487 super_frame->getModuleIdentifier(),
488 module.getPosition()));
490 buildL1(*timesliceL0.rbegin(), back_inserter(*timesliceL1.rbegin()));
492 DEBUG(
"L1 " << setw(8) << timesliceL1.rbegin()->getModuleID() <<
' ' << setw(8) << timesliceL1.rbegin()->size() <<
LAMBDA([ps = timesliceL1.rbegin()](ostream& out) { for (const auto& i : *ps) { out <<
" " << i; } }) << endl);
496 timesliceL2.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
497 super_frame->getModuleIdentifier(),
498 module.getPosition()));
500 buildL2(buffer, *timesliceL1.rbegin(), back_inserter(*timesliceL2.rbegin()));
502 DEBUG(
"L2 " << setw(8) << timesliceL2.rbegin()->getModuleID() <<
' ' << setw(8) << timesliceL2.rbegin()->size() <<
LAMBDA([ps = timesliceL2.rbegin()](ostream& out) { for (const auto& i : *ps) { out <<
" " << i; } }) << endl);
506 JTimeslice_t::value_type tv(super_frame->getDAQChronometer(),
507 super_frame->getModuleIdentifier(),
508 module.getPosition());
510 buildSN(buffer, *timesliceL1.rbegin(), back_inserter(tv));
514 timesliceSN.push_back(tv);
516 DEBUG(
"SN " << setw(8) << timesliceSN.rbegin()->getModuleID() <<
' ' << setw(8) << timesliceSN.rbegin()->size() << endl);
517 DEBUG(
"L2 " << setw(8) << timesliceL2.rbegin()->getModuleID() <<
' ' << setw(8) << timesliceL2.rbegin()->size() <<
LAMBDA([ps = timesliceL2.rbegin()](ostream& out) { for (const auto& i : *ps) { out <<
" " << i; } }) << endl);
529 trigger3DMuon (trigger_input, back_inserter(trigger_output));
530 trigger3DShower(trigger_input, back_inserter(trigger_output));
531 triggerMXShower(trigger_input, timesliceL0, back_inserter(trigger_output));
535 for (JTriggerOutput::const_iterator to = trigger_output.begin(); to != trigger_output.end(); ++to) {
537 for (
int i = 0; i != h1.GetNbinsX(); ++i) {
538 if (to->hasTriggerBit(i)) {
545 eventTime.
add(TA_ns);
546 eventTime.
sub(TB_ns);
549 cout <<
"Event time: "
550 << to->getFrameIndex() <<
' '
553 << (timeRange.overlap(eventTime) ?
"Y" :
"N") << endl;
556 if (timeRange.overlap(eventTime)) {
561 parameters.TMaxLocal_ns,
562 getTimeRange(parameters));
564 tev.setCounter(trigger_counter);
573 if (!triggeredEventsOnly ||
trigger) {
575 if (parameters.writeL0()) {
579 if (parameters.writeL1()) {
583 if (parameters.writeL2()) {
587 if (parameters.writeSN()) {
591 if (parameters.writeSummary()) {
593 if (fs.count(chronometer.getFrameIndex()) == 0) {
597 fs.insert(chronometer.getFrameIndex());
603 if (!triggeredEventsOnly ||
trigger) {
Data structure for detector geometry and calibration.
Recording of objects on file according a format that follows from the file name extension.
Basic data structure for L0 hit.
Basic data structure for L1 hit.
General purpose messaging.
#define DEBUG(A)
Message macros.
Map of associated modules in detector.
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Direct access to PMT in detector data structure.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
I/O formatting auxiliaries.
Auxiliaries for creation of summary data.
ROOT TTree parameter settings of various packages.
Basic data structure for time and time over threshold information of hit.
JAANET::start_run start_run
void push(T JHead::*pd)
Push given data member to Head.
void merge(const JMatch_t &match)
Merge events.
void reset(JK40Simulator *k40Simulator)
Reset K40 simulator.
const JPMTSimulator & getPMTSimulator() const
Get PMT simulator.
void setPMTStatus(const int bit)
Set status of all PMTs.
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.
Router for direct addressing of module data in detector data structure.
bool hasModule(const JModuleIdentifier &id) const
Has module.
const JModule & getModule(const JModuleIdentifier &id) const
Get module parameters.
Data structure for a composite optical module.
Default PMT simulation interface.
Auxiliary class for map of PMT parameters.
double getQE(const JPMTIdentifier &id) const
Get QE of given PMT.
bool is_valid() const
Check validity of PMT parameters.
Data structure for PMT geometry, calibration and status.
virtual const char * what() const override
Get error message.
int getID() const
Get identifier.
static void Throw(const bool option)
Enable/disable throw option.
Utility class to parse command line options.
General purpose class for object reading from a list of file names.
virtual bool hasNext() override
Check availability of next element.
counter_type getCounter() const
Get counter.
virtual const pointer_type & next() override
Get next element.
const std::string & getFilename() const
Get current file name.
Router for fast addressing of summary data in KM3NETDAQ::JDAQSummaryslice data structure as a functio...
void update(const JDAQSummaryslice *ps)
Update router.
Template definition for direct access of elements in ROOT TChain.
CLB simulation based on run-by-run information.
K40 simulation based on run-by-run information.
PMT simulation based on run-by-run information.
1-dimensional frame with time calibrated data from one optical module.
2-dimensional frame with time calibrated data from one optical module.
Auxiliary class to build JDAQTimeslice for L1 timeslice.
Auxiliary class to build KM3NETDAQ::JDAQEvent for a triggered event.
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
int getRunNumber() const
Get run number.
JDAQUTCExtended getTimesliceStart() const
Get start of timeslice.
int getFrameIndex() const
Get frame index.
Data structure for UTC time.
static const JDAQUTCExtended & getInstance()
Get arbitrary offset (e.g.
double getTimeNanoSecond() const
Get time (limited to 16 ns cycles).
bool has_primary(const Evt &evt)
Auxiliary function to check if an event contains a primary track.
JTimeRange getTimeRange(const Evt &event)
Get time range (i.e. time between earliest and latest hit) of Monte Carlo event.
bool has_leading_lepton(const Evt &event)
Auxiliary function to check if an event contains the leading lepton of a neutrino interaction.
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.
double getMaximalDistance(const JDetector &detector, const bool option=false)
Get maximal distance between modules in detector.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
double getVisibleEnergyLeadingLepton(const Trk &, const JCylinder3D &)
double getVisibleEnergy(const Trk &, const JCylinder3D &)
Get the visible energy of a track.
double getTimeDuration(const JDAQUTCTimeRange &utc)
Get time duration of given UTC time range.
JDAQUTCTimeRange getUTCTimeRange()
Get UTC time range.
JTriggerParameters getTriggerParameters(const JMultipleFileScanner_t &file_list)
Get trigger parameters.
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
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.
double getMaximalTime(const double R_Hz)
Get maximal time for given rate.
double getTimeDifference(const JDAQChronometer &first, const JDAQChronometer &second)
Get time difference between two chronometers.
JDAQUTCExtended getDAQUTCExtended(const TTimeStamp &t0, const double t1=0.0)
Get DAQ UTC time.
static const int HIGH_RATE_VETO_DISABLE
Enable (disable) use of high-rate veto test if this status bit is 0 (1);.
static const int PMT_DISABLE
ile KM3NeT Data Definitions v3.6.3-10-g854d59a https://git.km3net.de/common/km3net-dataformat
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Auxiliary data structure for floating point format specification.
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
double livetime_s
Live time [s].
The cylinder used for photon tracking.
Match of two events considering overlap in time and position.
Transmission with position.
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.
void correct(const double QE)
Correct rates for global efficiency,.
Auxiliary class for mixed-L1/L0 K40 rates.
Auxiliary class for defining the range of iterations of objects.
static counter_type max()
Get maximum counter value.
Router for fast addressing of hits in KM3NETDAQ::JDAQTimeslice data structure as a function of the op...
void configure(const JDAQTimeslice ×lice)
Configure.
Timeslice with Monte Carlo event.
Auxiliary class to create summary data.
Auxiliary data structure to convert (lambda) function to printable object.
static const int WEIGHTLIST_VISIBLE_ENERGY_HADRON
visible energy from the hadron deposited inside the instrumented volume [GeV] see JVisibleEnergyToolk...
static const int WEIGHTLIST_VISIBLE_ENERGY_LEPTON
visible energy from the lepton deposited inside the instrumented volume [GeV] see JVisibleEnergyToolk...