Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JToA.cc File Reference

Auxiliary program to convert acoustics data from data base into ROOT format. More...

#include "JAcoustics/JToA.hh"
#include <iomanip>
#include <iostream>
#include "JAcoustics/JSupport.hh"
#include "JDB/JDB.hh"
#include "JDB/JDBToolkit.hh"
#include "JDB/JDatabaseObjectIterator.hh"
#include "JDB/JSelector.hh"
#include "JDB/JSupport.hh"
#include "JDB/JToAshort.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JMeta.hh"
#include "Jeep/JMessage.hh"
#include "Jeep/JParser.hh"
#include "dbclient/KM3NeTDBClient.h"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to convert acoustics data from data base into ROOT format.

Example usage :

JToA -@ "minrun=16514" \ -@ "maxrun=16514" \ -@ "detid=D1ORCA015" \ -o KM3NeT_00000146_00016514_toa.root

Author
mdejong

Definition in file software/JAcoustics/JToA.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 34 of file software/JAcoustics/JToA.cc.

35{
36 using namespace std;
37 using namespace JPP;
38
40
41 JServer server;
42 string usr;
43 string pwd;
44 string cookie;
45 JSelector selection;
46 int debug;
47
48 try {
49
50 JParser<> zap("Auxiliary program to convert acoustics data from data base into ROOT format.");
51
52 // clang-format off
53 zap['o'] = make_field(outputFile);
54 zap['s'] = make_field(server) = getServernames();
55 zap['u'] = make_field(usr) = "";
56 zap['!'] = make_field(pwd) = "";
57 zap['C'] = make_field(cookie) = "";
58 zap['@'] = make_field(selection) = JPARSER::initialised();
59 zap['d'] = make_field(debug) = 1;
60 // clang-format on
61
62 zap(argc, argv);
63 }
64 catch (const exception& error) {
65 FATAL(error.what() << endl);
66 }
67
68
69 try {
70
71 JDB::reset(usr, pwd, cookie);
72
74
75 outputFile.open();
76
77 outputFile.put(JMeta(argc, argv));
78
79 outputFile.close();
80
81 auto ofile = std::unique_ptr<TFile>(TFile::Open(outputFile.getFilename().c_str(), "UPDATE"));
82
83 auto toa_tree = std::unique_ptr<TTree>(new TTree("TOA", "Time Of Arrival (Acoustic Data)"));
84
85 toa_tree->SetAutoSave(0);
86
87 JToA toa;
88
89 toa_tree->Branch("RUN", &toa.RUN);
90 toa_tree->Branch("DOMID", &toa.DOMID);
91 toa_tree->Branch("WAVEFORMID", &toa.WAVEFORMID);
92 toa_tree->Branch("DETID", &toa.DETID);
93 toa_tree->Branch("TOA_NS", &toa.TOA_NS);
94 toa_tree->Branch("SECONDS", &toa.SECONDS);
95 toa_tree->Branch("TICKS", &toa.TICKS);
96 toa_tree->Branch("QUALITYFACTOR", &toa.QUALITYFACTOR);
97 toa_tree->Branch("QUALITYNORMALISATION", &toa.QUALITYNORMALISATION);
98
100
101 const JToAshort* p = in.next();
102
103 toa.DETID = getDetector(p->DETID);
104 toa.RUN = p->RUN;
105 toa.DOMID = p->DOMID;
106 toa.WAVEFORMID = p->EMITTERID;
107 toa.TOA_NS = p->getAbsoluteToA_ns();
108 toa.SECONDS = p->getDAQFrameSeconds();
109 toa.TICKS = p->getDAQFrameTicks();
112
113 toa_tree->Fill();
114 }
115
116 toa_tree->Write();
117 }
118 catch (const exception& error) {
119 FATAL(error.what() << endl);
120 }
121}
string outputFile
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Object iteration from database.
Auxiliary class for specifying selection of database data.
virtual bool hasNext() override
Check availability of next element.
Utility class to parse command line options.
Definition JParser.hh:1698
Object writing to file.
JDetectorsHelper & getDetector()
Auxiliary function for helper object initialisation.
std::vector< JServer > getServernames()
Get list of names of available database servers.
Definition JDB.hh:108
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Time-of-arrival data from acoustic piezo sensor or hydrophone.
Definition JToA.hh:28
uint32_t SECONDS
Time of Arrival, in ns (relative to Unix epoch, 1 January 1970 00:00:00 UTC)
Definition JToA.hh:37
uint32_t DOMID
DAQ run number.
Definition JToA.hh:34
int64_t TOA_NS
Unique ID of the waveform that best described the signal around TOA_NS.
Definition JToA.hh:36
uint32_t QUALITYFACTOR
The ticks (16ns) part of the DAQ frame timestamp.
Definition JToA.hh:39
uint32_t QUALITYNORMALISATION
A measure of how good the waveform match was to the signal.
Definition JToA.hh:40
int32_t WAVEFORMID
DOM unique identifeir.
Definition JToA.hh:35
int32_t DETID
Definition JToA.hh:32
int32_t RUN
detector identifier
Definition JToA.hh:33
uint32_t TICKS
The seconds part of the DAQ frame timestamp.
Definition JToA.hh:38
static void initialise(JHelper_t &helper, const Args &...args)
Initialise.
Wrapper class for server name.
Definition JDB.hh:54
uint32_t getDAQFrameSeconds() const
get the number of seconds (since Unix epoch) of the DAQ Frame start time
Definition JToAshort.hh:52
int EMITTERID
waveform identifier
Definition JToAshort.hh:29
uint32_t getDAQFrameTicks() const
get the number of ticks (16 ns) of the DAQ Frame start time
Definition JToAshort.hh:58
static const char *const getName()
Table name.
Definition JToAshort.hh:22
std::string DETID
constraint
Definition JToAshort.hh:24
int64_t getAbsoluteToA_ns() const
return the absolute Time Of Arrival, in nanoseconds (since Unix epoch 1 January 1970 00:00:00 UTC)
Definition JToAshort.hh:40
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition JParser.hh:68
Auxiliary class for ROOT I/O of application specific meta data.
Definition JMeta.hh:72