92 int main(
int argc,
char **argv)
96 using namespace KM3NETDAQ;
103 string detectorFileA;
104 string detectorFileB;
107 bool triggeredEventsOnly;
116 JParser<> zap(
"Auxiliary program to trigger Monte Carlo events.");
118 zap[
'f'] =
make_field(inputFile,
"input file (output of detector simulation)");
120 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
121 zap[
'a'] =
make_field(detectorFileA,
"detector used for conversion from Monte Carlo truth to raw data.");
122 zap[
'b'] =
make_field(detectorFileB,
"detector used for conversion of raw data to calibrated data.") =
"";
123 zap[
'R'] =
make_field(run,
"run number") = -1;
126 zap[
'O'] =
make_field(triggeredEventsOnly,
"optionally write only triggered events.");
134 catch(
const exception &error) {
135 FATAL(error.what() << endl);
138 gRandom->SetSeed(seed);
144 if (detectorFileB ==
"") {
145 detectorFileB = detectorFileA;
153 load(detectorFileA, detectorA);
154 load(detectorFileB, detectorB);
160 JPMTParametersMap::Throw(
true);
162 if (!pmtParameters.is_valid()) {
163 FATAL(
"Invalid PMT parameters " << pmtParameters << endl);
166 if (pmtParameters.getQE() != 1.0) {
168 WARNING(
"Correct background rates with global efficiency " << pmtParameters.getQE() << endl);
170 rates_Hz.correct(pmtParameters.getQE());
177 if (runbyrun.is_valid()) {
179 NOTICE(
"Using run-by-run:" << endl << runbyrun << endl);
181 if (!runbyrun.hasNext()) {
182 FATAL(
"Run-by-run simulation yields no input." << endl);
185 if (rates_Hz.getSinglesRate() != 0.0) {
186 WARNING(
"Run-by-run simulation discards singles rate [Hz] " << rates_Hz.getSinglesRate() << endl);
202 NOTICE(
"Set trigger parameters from run-by-run input." << endl);
205 WARNING(
"No trigger parameters from run-by-run input;\nrun with default/user input." << endl);
210 NOTICE(
"Using fixed rates [Hz]: " << rates_Hz << endl);
225 DEBUG(
"PMT parameters:" << endl << pmtParameters << endl);
233 typedef double hit_type;
261 const JPosition3D center = get<JPosition3D>(header);
263 NOTICE(
"Apply detector offset from Monte Carlo run header (" << center <<
")" << endl);
302 limit.setLowerLimit(limit.getLowerLimit() - in.
skip(limit.getLowerLimit()));
304 for ( ; in.
hasNext() && number_of_events != limit; ++number_of_events) {
306 STATUS(
"event: " << setw(10) << number_of_events <<
'\r');
DEBUG(endl);
310 event->mc_run_id = mc_run_id;
312 DEBUG(*event << endl);
314 bool trigger =
false;
316 if (!event->mc_hits.empty()) {
320 if (runbyrun.is_valid() && runbyrun.hasNext()) {
322 summaryRouter.update(runbyrun.next());
324 summaryRouter.correct(dynamic_cast<const JPMTDefaultSimulatorInterface&>(simbad.
getPMTSimulator()));
326 frame_index = summaryRouter.getFrameIndex();
327 run = summaryRouter.getRunNumber();
341 event->mc_t = t1 - t0;
343 timeRange.
add(event->mc_t);
344 timeRange.
add(period);
350 DEBUG(timeslice << endl);
360 for (JDAQTimeslice::const_iterator super_frame = timeslice.begin(); super_frame != timeslice.end(); ++super_frame) {
362 if (moduleRouter.
hasModule(super_frame->getModuleID())) {
367 const JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(*super_frame, module);
371 timesliceL0.push_back(JSuperFrame1D_t(buffer));
375 timesliceL1.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
376 super_frame->getModuleIdentifier(),
379 buildL1(*timesliceL0.rbegin(), back_inserter(*timesliceL1.rbegin()));
383 timesliceL2.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
384 super_frame->getModuleIdentifier(),
387 buildL2(buffer, *timesliceL1.rbegin(), back_inserter(*timesliceL2.rbegin()));
391 timesliceSN.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
392 super_frame->getModuleIdentifier(),
395 buildSN(buffer, *timesliceL1.rbegin(), back_inserter(*timesliceSN.rbegin()));
397 DEBUG(
"L0 " << setw(8) << timesliceL0.rbegin()->getModuleID() <<
' ' << setw(8) << timesliceL0.rbegin()->size() << endl);
398 DEBUG(
"L1 " << setw(8) << timesliceL1.rbegin()->getModuleID() <<
' ' << setw(8) << timesliceL1.rbegin()->size() << endl);
399 DEBUG(
"L2 " << setw(8) << timesliceL2.rbegin()->getModuleID() <<
' ' << setw(8) << timesliceL2.rbegin()->size() << endl);
400 DEBUG(
"SN " << setw(8) << timesliceSN.rbegin()->getModuleID() <<
' ' << setw(8) << timesliceSN.rbegin()->size() << endl);
410 trigger3DMuon (trigger_input, back_inserter(trigger_output));
411 trigger3DShower(trigger_input, back_inserter(trigger_output));
412 triggerMXShower(trigger_input, timesliceL0, back_inserter(trigger_output));
416 for (JTriggerOutput::const_iterator to = trigger_output.begin(); to != trigger_output.end(); ++to) {
418 for (
int i = 0; i != h1.GetNbinsX(); ++i) {
419 if (to->hasTriggerBit(i)) {
427 << to->getFrameIndex() <<
' '
429 << timeRange << endl);
431 if (timeRange.
overlap(eventTime)) {
450 if (!triggeredEventsOnly || trigger) {
474 if (!triggeredEventsOnly || trigger) {
Utility class to parse command line options.
virtual const pointer_type & next()
Get next element.
ROOT TTree parameter settings.
static const unsigned int NUMBER_OF_TRIGGER_BITS
Number of trigger bits.
Default implementation of the simulation of K40 background.
const JModule & getModule(const JObjectID &id) const
Get module parameters.
Data structure for a composite optical module.
void configure(const JDAQTimeslice ×lice)
Configure.
Auxiliary class to handle run by run options.
Recording of objects on file according a format that follows from the file name extension.
Router for direct addressing of module data in detector data structure.
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
then for HISTOGRAM in h0 h1
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Long64_t counter_type
Type definition for counter.
virtual skip_type skip(const skip_type ns)
Skip items.
const JPMTSimulator & getPMTSimulator() const
Get PMT simulator.
double getTimeOfRTS(const JDAQChronometer &chronometer)
Get time of last RTS in ns since start of run for a given chronometer.
Basic data structure for time and time over threshold information of hit.
Data structure for UTC time.
Data structure for detector geometry and calibration.
unsigned long long int JTriggerCounter_t
Type definition of trigger counter.
double getTimeOfFrame(const int frame_index)
Get start time of frame in ns since start of run for a given frame index.
1-dimensional frame with time calibrated data from one optical module.
JTimeRange getTimeRange(const Evt &event)
Get time range (i.e. time between earliest and latest hit) of Monte Carlo event.
K40 simulation based on run-by-run information.
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
Basic data structure for L0 hit.
void setDAQLongprint(const bool option)
Set DAQ print option.
Auxiliary class for defining the range of iterations of objects.
double getMaximalDistance(const JDetector &detector)
Get maximal distance between modules in detector.
I/O formatting auxiliaries.
Auxiliaries for creation of summary data.
void merge(const JMatch_t &match)
Merge events.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
CLB simulation based on run-by-run information.
Router for fast addressing of hits in KM3NETDAQ::JDAQTimeslice data structure as a function of the op...
double getFrameTime()
Get frame time duration.
JAANET::start_run start_run
Auxiliary class to create summary data.
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
Auxiliary class to build JDAQEvent for a triggered event.
Auxiliary class for map of PMT parameters.
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
Direct access to PMT in detector data structure.
const JPosition3D & getPosition() const
Get position.
double getMaximalTime(const double R_Hz)
Get maximal time for given rate.
Router for fast addressing of summary data in JDAQSummaryslice data structure as a function of the op...
General purpose messaging.
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
Scanning of objects from multiple files according a format that follows from the extension of each fi...
void reset(JK40Simulator *k40Simulator)
Reset K40 simulator.
PMT simulation based on run-by-run information.
virtual bool hasNext()
Check availability of next element.
void setCounter(const JTriggerCounter_t counter)
Set trigger counter.
Auxiliary class to build JDAQTimeslice for L1 timeslice.
Utility class to parse command line options.
Map of associated modules in detector.
bool hasModule(const JObjectID &id) const
Has module.
2-dimensional frame with time calibrated data from one optical module.
counter_type getCounter() const
Get counter.
Data structure for position in three dimensions.
const JLimit & getLimit() const
Get limit.
virtual const char * what() const
Get error message.
Match of two events considering overlap in time.
Timeslice with Monte Carlo event.
JTriggerParameters getTriggerParameters(const JMultipleFileScanner_t &file_list)
Get trigger parameters.
Basic data structure for L1 hit.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Time slice with calibrated data.
#define DEBUG(A)
Message macros.
Auxiliary class for K40 rates.
int main(int argc, char *argv[])