44 int main(
int argc,
char **argv)
48 using namespace KM3NETDAQ;
51 JMultipleFileScanner<JAAnetTypes_t> inputFile;
52 JFileRecorder <JTYPELIST<JAAnetTypes_t, JDAQTimeslice, JMeta, JRootTypes_t>::typelist>
outputFile;
56 JPMTParametersMap pmtParameters;
64 JParser<> zap(
"Auxiliary program to convert multiple Monte Carlo events to time slices.");
68 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
79 catch(
const exception &error) {
80 FATAL(error.what() << endl);
83 gRandom->SetSeed(seed);
89 if (pmtParameters.getQE() != 1.0) {
91 WARNING(
"Correct background rates with global efficiency " << pmtParameters.getQE() << endl);
93 rates_Hz.correct(pmtParameters.getQE());
98 DEBUG(
"PMT paramaters: " << endl << pmtParameters << endl);
99 DEBUG(
"K40 rates: " << endl << rates_Hz << endl);
101 if (eventRate_Hz < 0.0) {
102 FATAL(
"Invalid event rate " << eventRate_Hz <<
"; consider using JRandomTimesliceWriter." << endl);
110 load(detectorFile, detector);
112 catch(
const JException& error) {
124 FATAL(
"MC header is invalid");
129 if (liveTimeMC < 0) {
130 FATAL(
"MC live time is negative; input file may be corrupted.");
135 JPMTParametersMap::Throw(
false);
137 JDetectorSimulator simbad(detector);
139 simbad.reset(
new JPMTDefaultSimulator(pmtParameters, detector));
140 simbad.reset(
new JK40DefaultSimulator(rates_Hz));
141 simbad.reset(
new JCLBDefaultSimulator());
155 bool absTime =
false;
157 JTreeScannerInterface<Evt>* scan;
159 if (eventRate_Hz == 0.0 && liveTimeMC == 0.0) {
161 NOTICE(
"Event will be timed according to absolute MC time." << endl);
166 scan =
new JTreeScanner<Evt, JEvtEvaluator>(inputFile);
172 scan =
new JTreeScanner<Evt>(inputFile);
175 if (eventRate_Hz == 0.0 && liveTimeMC > 0.0) {
176 int nEntries = scan->getEntries();
177 eventRate_Hz = nEntries / liveTimeMC;
178 DEBUG(nEntries <<
" events to be written." << endl);
179 NOTICE(
"MC live time is " << liveTimeMC <<
" s" << endl);
180 NOTICE(
"Event rate set to " << eventRate_Hz <<
" Hz from MC header." << endl);
187 bool pendingEvt =
false;
188 bool pendingTimeslice =
false;
202 while (pendingEvt || scan->hasNext()) {
204 if (!pendingTimeslice) {
209 DEBUG(
"evt count: " << setw(10) << evtCount << endl);
210 STATUS(
"frame index: " << setw(10) << frame_index <<
" | evt count: " << setw(10) << evtCount <<
"\r");
DEBUG(endl);
211 pendingTimeslice =
true;
216 event = scan->next();
218 tOff = timeRange.is_valid() ? timeRange.getLowerLimit() : 0;
223 tDAQ += gRandom->Exp(1.0e9 / eventRate_Hz);
225 DEBUG(
"event time [s] " << setprecision(5) << tDAQ * 1.0e-9 << endl);
233 if (timeRange.is_valid()) {
236 event->mc_t = tDAQ - tOff;
245 DEBUG(timeslice << endl);
247 pendingTimeslice =
false;
252 if (pendingTimeslice) {
253 DEBUG(timeslice << endl);
255 pendingTimeslice =
false;
263 NOTICE(evtCount <<
" events written over " << frame_index <<
" timeslices. " << endl);
Timeslice with random data.
Utility class to parse command line options.
Timeslice with Monte Carlo event.
Recording of objects on file according a format that follows from the file name extension.
Structure to store the ToT mean and standard deviation of the hits produced by a nanobeacon in a sour...
Empty structure for specification of parser element that is initialised (i.e.
Long64_t counter_type
Type definition for counter.
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.
JTimeRange getTimeRange(const Evt &event)
Get time range (i.e.
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
JLimit JLimit_t
Type definition of limit.
void setDAQLongprint(const bool option)
Set DAQ print option.
Exception for null pointer operation.
static const JEvtEvaluator getEvtValue
Function object for evaluation of DAQ objects.
JAANET::livetime livetime
int getFrameIndex(const double t_ns)
Get frame index for a given time in ns.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
General purpose messaging.
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Utility class to parse command line options.
ROOT TTree parameter settings.
const JLimit & getLimit() const
Get limit.
double numberOfSeconds
Live time [s].
#define DEBUG(A)
Message macros.
int main(int argc, char *argv[])