97 double T0_ns = numeric_limits<double>::max();
100 for (
const JPMT& pmt : module) {
102 if (pmt.getT0() < T0_ns) {
144 JLimit_t& numberOfEvents = inputFile.getLimit();
145 string detectorFileA;
146 string detectorFileB;
149 bool triggeredEventsOnly;
159 JParser<> zap(
"Auxiliary program to trigger Monte Carlo events.");
161 zap[
'f'] =
make_field(inputFile,
"input file (output of detector simulation)");
164 zap[
'a'] =
make_field(detectorFileA,
"detector used for conversion from Monte Carlo truth to raw data.");
165 zap[
'b'] =
make_field(detectorFileB,
"detector used for conversion of raw data to calibrated data.") =
"";
166 zap[
'R'] =
make_field(run,
"run number") = -1;
169 zap[
'O'] =
make_field(triggeredEventsOnly,
"optionally write only triggered events.");
178 catch(
const exception &error) {
179 FATAL(error.what() << endl);
188 if (detectorFileB ==
"") {
189 detectorFileB = detectorFileA;
197 load(detectorFileA, detectorA);
198 load(detectorFileB, detectorB);
204 const double TA_ns = getT0(detectorA);
205 const double TB_ns = getT0(detectorB);
210 FATAL(
"Invalid PMT parameters " << pmtParameters << endl);
213 if (pmtParameters.
getQE() != 1.0) {
215 WARNING(
"Correct background rates with global efficiency " << pmtParameters.
getQE() << endl);
235 NOTICE(
"Using run-by-run:" << endl << runbyrun << endl);
238 FATAL(
"Run-by-run simulation yields no input." << endl);
258 NOTICE(
"Set trigger parameters from run-by-run input." << endl);
261 WARNING(
"No trigger parameters from run-by-run input;\nrun with default/user input." << endl);
266 JHead buffer(header);
271 copy(buffer, header);
275 NOTICE(
"Using fixed rates [Hz]: " << rates_Hz << endl);
289 if (parameters.disableHighRateVeto) {
291 NOTICE(
"Disabling high-rate veto of all PMTs." << endl);
298 DEBUG(
"Trigger:" << endl << parameters << endl);
299 DEBUG(
"PMT parameters:" << endl << pmtParameters << endl);
304 const JTimeRange period(-(Tmax + parameters.TMaxLocal_ns),
305 +(Tmax + parameters.TMaxLocal_ns));
311 typedef JTimeslice <hit_type> JTimeslice_t;
312 typedef JBuildL1 <hit_type> JBuildL1_t;
313 typedef JBuildL2 <hit_type> JBuildL2_t;
315 const JBuildL1_t buildL1(parameters);
316 const JBuildL2_t buildL2(parameters.L2);
317 const JBuildL2_t buildSN(parameters.SN);
326 TH1D h1(
"Trigger bits", NULL, NUMBER_OF_TRIGGER_BITS, -0.5, NUMBER_OF_TRIGGER_BITS - 0.5);
340 JLimit_t limit = inputFile.getLimit();
342 int trigger_counter = 0;
362 for ( ; in.
hasNext() && number_of_events != limit; ++number_of_events) {
364 STATUS(
"event: " << setw(10) << number_of_events <<
'\r');
DEBUG(endl);
368 event->mc_run_id = mc_run_id;
370 DEBUG(*event << endl);
374 if (!event->mc_hits.empty()) {
384 frame_index = summaryRouter.getFrameIndex();
385 run = summaryRouter.getRunNumber();
397 const double t1 = gRandom->Rndm() *
getFrameTime() + TA_ns;
399 DEBUG(
"Start time: " <<
FIXED(12,2) << t0 <<
' ' <<
FIXED(12,2) << t1 <<
' ' <<
FIXED(9,2) << TA_ns << endl);
403 timeRange.
add(event->mc_t);
404 timeRange.
add(period);
409 if (event->mc_event_time != TTimeStamp(0)) {
413 const JDAQChronometer chronometer(detectorB.
getID(), (run != -1 ? run : mc_run_id), frame_index, utc);
417 DEBUG(timeslice << endl);
427 for (JDAQTimeslice::const_iterator super_frame = timeslice.begin(); super_frame != timeslice.end(); ++super_frame) {
429 if (moduleRouter.
hasModule(super_frame->getModuleID())) {
434 const JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(*super_frame, module);
438 timesliceL0.push_back(JSuperFrame1D_t(buffer));
442 timesliceL1.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
443 super_frame->getModuleIdentifier(),
446 buildL1(*timesliceL0.rbegin(), back_inserter(*timesliceL1.rbegin()));
450 timesliceL2.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
451 super_frame->getModuleIdentifier(),
454 buildL2(buffer, *timesliceL1.rbegin(), back_inserter(*timesliceL2.rbegin()));
458 timesliceSN.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
459 super_frame->getModuleIdentifier(),
462 buildSN(buffer, *timesliceL1.rbegin(), back_inserter(*timesliceSN.rbegin()));
464 DEBUG(
"L0 " << setw(8) << timesliceL0.rbegin()->getModuleID() <<
' ' << setw(8) << timesliceL0.rbegin()->size() << endl);
465 DEBUG(
"L1 " << setw(8) << timesliceL1.rbegin()->getModuleID() <<
' ' << setw(8) << timesliceL1.rbegin()->size() << endl);
466 DEBUG(
"L2 " << setw(8) << timesliceL2.rbegin()->getModuleID() <<
' ' << setw(8) << timesliceL2.rbegin()->size() << endl);
467 DEBUG(
"SN " << setw(8) << timesliceSN.rbegin()->getModuleID() <<
' ' << setw(8) << timesliceSN.rbegin()->size() << endl);
477 trigger3DMuon (trigger_input, back_inserter(trigger_output));
478 trigger3DShower(trigger_input, back_inserter(trigger_output));
479 triggerMXShower(trigger_input, timesliceL0, back_inserter(trigger_output));
483 for (JTriggerOutput::const_iterator to = trigger_output.begin(); to != trigger_output.end(); ++to) {
485 for (
int i = 0; i != h1.GetNbinsX(); ++i) {
486 if (to->hasTriggerBit(i)) {
493 eventTime.
add(TA_ns);
494 eventTime.
sub(TB_ns);
497 << to->getFrameIndex() <<
' '
500 << (timeRange.
overlap(eventTime) ?
"Y" :
"N") << endl);
502 if (timeRange.
overlap(eventTime)) {
507 parameters.TMaxLocal_ns,
508 getTimeRange(parameters));
521 if (!triggeredEventsOnly ||
trigger) {
523 if (parameters.writeL0()) {
527 if (parameters.writeL1()) {
531 if (parameters.writeL2()) {
535 if (parameters.writeSN()) {
539 if (parameters.writeSummary()) {
545 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.
int main(int argc, char **argv)
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 JObjectID &id) const
Has module.
const JModule & getModule(const JObjectID &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.
const JPosition3D & getPosition() const
Get position.
virtual const char * what() const override
Get error message.
int getID() const
Get identifier.
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.
virtual bool hasNext() override
Check availability of next element.
counter_type getCounter() const
Get counter.
virtual const pointer_type & next() override
Get next element.
virtual skip_type skip(const skip_type ns) override
Skip items.
Router for fast addressing of summary data in KM3NETDAQ::JDAQSummaryslice data structure as a functio...
void update(const JDAQSummaryslice *ps)
Update router.
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 JDAQEvent for a triggered event.
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
void setCounter(const JTriggerCounter_t counter)
Set trigger counter.
Data structure for UTC time.
static const JDAQUTCExtended & getInstance()
Get arbitrary offset (e.g.
JTimeRange getTimeRange(const Evt &event)
Get time range (i.e. time between earliest and latest hit) of Monte Carlo event.
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).
Long64_t counter_type
Type definition for counter.
double getLivetime(const std::string &file_name)
Get data taking live time.
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.
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
KM3NeT Data Definitions v3.6.0 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].
Match of two events considering overlap in time and 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.
double getSinglesRate() const
Get singles rate.
void correct(const double QE)
Correct rates for global efficiency,.
Auxiliary class for defining the range of iterations of objects.
static counter_type max()
Get maximum counter value.
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.
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.