100 int main(
int argc,
char **argv)
104 using namespace KM3NETDAQ;
111 string detectorFileA;
112 string detectorFileB;
115 bool triggeredEventsOnly;
125 JParser<> zap(
"Auxiliary program to trigger Monte Carlo events.");
127 zap[
'f'] =
make_field(inputFile,
"input file (output of detector simulation)");
129 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
130 zap[
'a'] =
make_field(detectorFileA,
"detector used for conversion from Monte Carlo truth to raw data.");
131 zap[
'b'] =
make_field(detectorFileB,
"detector used for conversion of raw data to calibrated data.") =
"";
132 zap[
'R'] =
make_field(run,
"run number") = -1;
135 zap[
'O'] =
make_field(triggeredEventsOnly,
"optionally write only triggered events.");
144 catch(
const exception &error) {
145 FATAL(error.what() << endl);
148 gRandom->SetSeed(seed);
150 JK40DefaultSimulatorInterface::setSigma(sigma_ns);
154 if (detectorFileB ==
"") {
155 detectorFileB = detectorFileA;
163 load(detectorFileA, detectorA);
164 load(detectorFileB, detectorB);
170 JPMTParametersMap::Throw(
true);
172 if (!pmtParameters.is_valid()) {
173 FATAL(
"Invalid PMT parameters " << pmtParameters << endl);
176 if (pmtParameters.getQE() != 1.0) {
178 WARNING(
"Correct background rates with global efficiency " << pmtParameters.getQE() << endl);
180 rates_Hz.correct(pmtParameters.getQE());
196 if (runbyrun.is_valid()) {
198 NOTICE(
"Using run-by-run:" << endl << runbyrun << endl);
200 if (!runbyrun.hasNext()) {
201 FATAL(
"Run-by-run simulation yields no input." << endl);
204 if (rates_Hz.getSinglesRate() != 0.0) {
205 WARNING(
"Run-by-run simulation discards singles rate [Hz] " << rates_Hz.getSinglesRate() << endl);
221 NOTICE(
"Set trigger parameters from run-by-run input." << endl);
224 WARNING(
"No trigger parameters from run-by-run input;\nrun with default/user input." << endl);
229 JHead buffer(header);
234 copy(buffer, header);
238 NOTICE(
"Using fixed rates [Hz]: " << rates_Hz << endl);
254 NOTICE(
"Disabling high-rate veto of all PMTs." << endl);
262 DEBUG(
"PMT parameters:" << endl << pmtParameters << endl);
288 const JPosition3D center = get<JPosition3D>(header);
290 NOTICE(
"Apply detector offset from Monte Carlo run header (" << center <<
")" << endl);
311 int trigger_counter = 0;
329 limit.setLowerLimit(limit.getLowerLimit() - in.
skip(limit.getLowerLimit()));
331 for ( ; in.
hasNext() && number_of_events != limit; ++number_of_events) {
333 STATUS(
"event: " << setw(10) << number_of_events <<
'\r');
DEBUG(endl);
337 event->mc_run_id = mc_run_id;
339 DEBUG(*event << endl);
341 bool trigger =
false;
343 if (!event->mc_hits.empty()) {
347 if (runbyrun.is_valid() && runbyrun.hasNext()) {
349 summaryRouter.update(runbyrun.next());
351 summaryRouter.correct(dynamic_cast<const JPMTDefaultSimulatorInterface&>(simbad.
getPMTSimulator()));
353 frame_index = summaryRouter.getFrameIndex();
354 run = summaryRouter.getRunNumber();
370 timeRange.
add(event->mc_t);
371 timeRange.
add(period);
375 if (event->mc_event_time != TTimeStamp(0)) {
379 const JDAQChronometer chronometer(detectorB.getID(), (run != -1 ? run : mc_run_id), frame_index, utc);
383 DEBUG(timeslice << endl);
393 for (JDAQTimeslice::const_iterator super_frame = timeslice.begin(); super_frame != timeslice.end(); ++super_frame) {
395 if (moduleRouter.
hasModule(super_frame->getModuleID())) {
400 const JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(*super_frame, module);
404 timesliceL0.push_back(JSuperFrame1D_t(buffer));
408 timesliceL1.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
409 super_frame->getModuleIdentifier(),
412 buildL1(*timesliceL0.rbegin(), back_inserter(*timesliceL1.rbegin()));
416 timesliceL2.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
417 super_frame->getModuleIdentifier(),
420 buildL2(buffer, *timesliceL1.rbegin(), back_inserter(*timesliceL2.rbegin()));
424 timesliceSN.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
425 super_frame->getModuleIdentifier(),
428 buildSN(buffer, *timesliceL1.rbegin(), back_inserter(*timesliceSN.rbegin()));
430 DEBUG(
"L0 " << setw(8) << timesliceL0.rbegin()->getModuleID() <<
' ' << setw(8) << timesliceL0.rbegin()->size() << endl);
431 DEBUG(
"L1 " << setw(8) << timesliceL1.rbegin()->getModuleID() <<
' ' << setw(8) << timesliceL1.rbegin()->size() << endl);
432 DEBUG(
"L2 " << setw(8) << timesliceL2.rbegin()->getModuleID() <<
' ' << setw(8) << timesliceL2.rbegin()->size() << endl);
433 DEBUG(
"SN " << setw(8) << timesliceSN.rbegin()->getModuleID() <<
' ' << setw(8) << timesliceSN.rbegin()->size() << endl);
443 trigger3DMuon (trigger_input, back_inserter(trigger_output));
444 trigger3DShower(trigger_input, back_inserter(trigger_output));
445 triggerMXShower(trigger_input, timesliceL0, back_inserter(trigger_output));
449 for (JTriggerOutput::const_iterator to = trigger_output.begin(); to != trigger_output.end(); ++to) {
451 for (
int i = 0;
i != h1.GetNbinsX(); ++
i) {
452 if (to->hasTriggerBit(
i)) {
460 << to->getFrameIndex() <<
' '
462 << timeRange << endl);
464 if (timeRange.
overlap(eventTime)) {
483 if (!triggeredEventsOnly || trigger) {
507 if (!triggeredEventsOnly || trigger) {
Auxiliary class to select summary data (KM3NETDAQ::JDAQSummaryslice) from the specified raw data file...
Utility class to parse command line options.
int main(int argc, char *argv[])
ROOT TTree parameter settings of various packages.
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.
Router for fast addressing of hits in KM3NETDAQ::JDAQTimeslice data structure as a function of the op...
then usage $script[< detector identifier >< run range >]< QA/QCfile > nExample script to produce data quality plots nWhen a detector identifier and run range are data are downloaded from the database nand subsequently stored in the given QA QC file
double getSigma(vector< double > &v)
get standard deviation of vector content
void configure(const JDAQTimeslice ×lice)
Configure.
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.
static const int HIGH_RATE_VETO_DISABLE
Enable (disable) use of high-rate veto test if this status bit is 0 (1);.
*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
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Long64_t counter_type
Type definition for counter.
double livetime_s
Live time [s].
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.
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.
void push(T JHead::*pd)
Push given data member to Head.
I/O formatting auxiliaries.
Auxiliaries for creation of summary data.
virtual bool hasNext() override
Check availability of next element.
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.
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.
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 KM3NETDAQ::JDAQSummaryslice data structure as a functio...
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.
void setCounter(const JTriggerCounter_t counter)
Set trigger counter.
virtual const char * what() const override
Get error message.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Auxiliary class to build JDAQTimeslice for L1 timeslice.
double getLivetime(const std::string &file_name)
Get data taking live time.
Utility class to parse command line options.
Map of associated modules in detector.
virtual const pointer_type & next() override
Get next element.
bool hasModule(const JObjectID &id) const
Has module.
void copy(const Head &from, JHead &to)
Copy header from from to to.
double getMaximalDistance(const JDetector &detector, const bool option=false)
Get maximal distance between modules in detector.
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.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
JDAQUTCExtended getDAQUTCExtended(const TTimeStamp &t0, const double t1=0.0)
Get DAQ UTC time.
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.
Auxiliary class for K40 rates.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
virtual skip_type skip(const skip_type ns) override
Skip items.
Time slice with calibrated data.
#define DEBUG(A)
Message macros.