Jpp 20.0.0
the software that should make you happy
Loading...
Searching...
No Matches
JTimeConverterRunByRun.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <iomanip>
4
5#include "TROOT.h"
6#include "TFile.h"
7#include "TH1D.h"
8
10#include "JDAQ/JDAQEventIO.hh"
11#include "JDAQ/JDAQToolkit.hh"
12
16
18#include "JSupport/JSupport.hh"
19
20#include "JTools/JStats.hh"
21
22#include "Jeep/JParser.hh"
23#include "Jeep/JMessage.hh"
24
25
26/**
27 * \file
28 *
29 * Example program to test conversion between Monte Carlo and DAQ times.
30 * \author mdejong
31 */
32int main(int argc, char **argv)
33{
34 using namespace std;
35 using namespace JPP;
36 using namespace KM3NETDAQ;
37
39 JLimit_t& numberOfEvents = inputFile.getLimit();
40 string detectorFile;
41 string outputFile;
42 int debug;
43
44 try {
45
46 JParser<> zap("Example program to test conversion between Monte Carlo and DAQ times.");
47
48 zap['f'] = make_field(inputFile);
49 zap['a'] = make_field(detectorFile) = "";
50 zap['o'] = make_field(outputFile) = "histogram.root";
51 zap['n'] = make_field(numberOfEvents) = JLimit::max();
52 zap['d'] = make_field(debug) = 2;
53
54 zap(argc, argv);
55 }
56 catch(const exception &error) {
57 FATAL(error.what() << endl);
58 }
59
61
62 if (detectorFile != "") {
63 try {
64 load(detectorFile, detector);
65 }
66 catch(const JException& error) {
67 FATAL(error);
68 }
69 }
70
71 const JModuleRouter router(detector);
72
73 TFile out(outputFile.c_str(), "recreate");
74
75 TH1D h0("h0", NULL, 501, -1.0, +1.0);
76 TH1D h1("h1", NULL, 501, -1.0, +1.0);
77
78 while (inputFile.hasNext()) {
79
80 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
81
83
84 const JDAQEvent* tev = ps;
85 const Evt* event = ps;
86
87 JStats t0; // time of event in time slice
88
90
91 for (JDAQEvent::const_iterator<JHit_t> i = tev->begin<JHit_t>(); i != tev->end<JHit_t>(); ++i) {
92
93 if (router.hasModule(i->getModuleID())) {
94
95 const JModule& module = router.getModule(i->getModuleID());
96 const JPMT& pmt = module.getPMT(i->getPMT());
97
98 t0.put(getTime(*i, pmt));
99 }
100 }
101
102 h0.Fill(getTimeDifference(tev->getTimesliceStart(), getDAQUTCExtended(event->mc_event_time)));
103 h1.Fill(getTimeDifference(tev->getTimesliceStart(), getDAQUTCExtended(event->mc_event_time)) - t0.getMean(0.0) * 1.0e-9);
104 }
105 STATUS(endl);
106
107 out.Write();
108 out.Close();
109}
string outputFile
Data structure for detector geometry and calibration.
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define STATUS(A)
Definition JMessage.hh:63
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Direct access to module in detector data structure.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
ROOT TTree parameter settings of various packages.
int main(int argc, char **argv)
Synchronously read DAQ events and Monte Carlo events (and optionally other events).
Detector data structure.
Definition JDetector.hh:96
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.
Definition JModule.hh:76
Data structure for PMT geometry, calibration and status.
Definition JPMT.hh:49
General exception.
Definition JException.hh:24
Utility class to parse command line options.
Definition JParser.hh:1698
counter_type getCounter() const
Get counter.
JDAQUTCExtended getTimesliceStart() const
Get start of timeslice.
Template const_iterator.
Definition JDAQEvent.hh:68
const_iterator< T > end() const
Get end of data.
const_iterator< T > begin() const
Get begin of data.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
const char * getTime()
Get current local time conform ISO-8601 standard.
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
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.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition Evt.hh:21
Detector file.
Definition JHead.hh:227
General purpose class for multiple pointers.
Auxiliary class to set-up Hit.
Definition JSirene.hh:60
Auxiliary class for defining the range of iterations of objects.
Definition JLimit.hh:45
static counter_type max()
Get maximum counter value.
Definition JLimit.hh:128
Auxiliary class to synchronously read DAQ events and Monte Carlo events (and optionally other events)...
virtual bool hasNext() override
Check availability of next element.
virtual const multi_pointer_type & next() override
Get next element.
Auxiliary data structure for running average and standard deviation.
Definition JStats.hh:44
void put(const double x, const double w=1.0)
Put value.
Definition JStats.hh:119
double getMean() const
Get mean value.
Definition JStats.hh:234