Jpp
18.0.1-rc.1
the software that should make you happy
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
software
JAAnet
JDK.cc
Go to the documentation of this file.
1
2
#include <string>
3
#include <iostream>
4
#include <iomanip>
5
#include <cmath>
6
7
#include "
km3net-dataformat/offline/Head.hh
"
8
#include "
km3net-dataformat/offline/MultiHead.hh
"
9
#include "
km3net-dataformat/offline/Evt.hh
"
10
#include "
km3net-dataformat/online/JDAQClock.hh
"
11
12
#include "
JSupport/JMultipleFileScanner.hh
"
13
#include "
JSupport/JFileRecorder.hh
"
14
#include "
JSupport/JMonteCarloFileSupportkit.hh
"
15
#include "
JSupport/JSupport.hh
"
16
#include "
JSupport/JMeta.hh
"
17
18
#include "
JAAnet/JAAnetToolkit.hh
"
19
20
#include "
Jeep/JParser.hh
"
21
#include "
Jeep/JMessage.hh
"
22
23
24
/**
25
* \file
26
*
27
* Example program to filter out-of-time hits in Evt data.
28
* \author mdejong
29
*/
30
int
main
(
int
argc,
char
**argv)
31
{
32
using namespace
std;
33
using namespace
JPP;
34
using namespace
KM3NETDAQ;
35
36
JMultipleFileScanner<Evt>
inputFile;
37
JFileRecorder <JTYPELIST<JAAnetTypes_t, JMetaTypes_t>::typelist
>
outputFile
;
38
JLimit_t
& numberOfEvents = inputFile.
getLimit
();
39
double
T_ns;
40
int
debug
;
41
42
try
{
43
44
JParser<>
zap(
"Example program to filter out-of-time hits in Evt data."
);
45
46
zap[
'f'
] =
make_field
(inputFile);
47
zap[
'o'
] =
make_field
(
outputFile
);
48
zap[
'n'
] =
make_field
(numberOfEvents) = JLimit::max();
49
zap[
'T'
] =
make_field
(T_ns) =
getFrameTime
();
50
zap[
'd'
] =
make_field
(
debug
) = 2;
51
52
zap(argc, argv);
53
}
54
catch
(
const
exception& error) {
55
FATAL
(error.what() << endl);
56
}
57
58
outputFile
.open();
59
60
if
(!
outputFile
.is_open()) {
61
FATAL
(
"Error opening file "
<<
outputFile
<< endl);
62
}
63
64
outputFile
.put(
JMeta
(argc, argv));
65
outputFile
.put(
getHeader
(inputFile));
66
67
while
(inputFile.hasNext()) {
68
69
STATUS
(
"event: "
<< setw(10) << inputFile.getCounter() <<
'\r'
);
DEBUG
(endl);
70
71
Evt
* evt = inputFile.next();
72
73
double
t0 = numeric_limits<double>::max();
74
75
for
(
vector<Hit>::iterator
hit = evt->
mc_hits
.begin(); hit != evt->
mc_hits
.end(); ++hit) {
76
if
(
getTime
(*hit) < t0) {
77
t0 =
getTime
(*hit);
78
}
79
}
80
81
vector<Hit>::iterator
__end = evt->
mc_hits
.end();
82
83
for
(
vector<Hit>::iterator
hit = evt->
mc_hits
.begin(); hit != __end; ) {
84
if
(
getTime
(*hit) <= t0 + T_ns)
85
++hit;
86
else
87
iter_swap(hit, --__end);
88
}
89
90
evt->
mc_hits
.erase(__end, evt->
mc_hits
.end());
91
92
outputFile
.put(*evt);
93
}
94
STATUS
(endl);
95
96
JMultipleFileScanner<JTYPELIST<JMetaTypes_t, MultiHead>::typelist
> io(inputFile);
97
98
io >>
outputFile
;
99
100
outputFile
.close();
101
}
JSUPPORT::JMeta
Auxiliary class for ROOT I/O of application specific meta data.
Definition:
JMeta.hh:70
JSUPPORT::JFileRecorder
Object writing to file.
Definition:
JFileRecorder.hh:42
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1514
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
JSupport.hh
ROOT TTree parameter settings of various packages.
STATUS
#define STATUS(A)
Definition:
JMessage.hh:63
JFileRecorder.hh
Recording of objects on file according a format that follows from the file name extension.
JAANET::getTime
double getTime(const Hit &hit)
Get true time of hit.
Definition:
JAAnetToolkit.hh:93
outputFile
string outputFile
Definition:
JDAQTimesliceSelector.cc:37
std::vector
Definition:
JSTDTypes.hh:12
JSUPPORT::getHeader
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
Definition:
JMonteCarloFileSupportkit.hh:534
JSUPPORT::JLimit
Auxiliary class for defining the range of iterations of objects.
Definition:
JLimit.hh:41
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1989
MultiHead.hh
KM3NETDAQ::getFrameTime
double getFrameTime()
Get frame time duration.
Definition:
JDAQClock.hh:162
JMeta.hh
ROOT I/O of application specific meta data.
JAAnetToolkit.hh
Definition of hit and track types and auxiliary methods for handling Monte Carlo data.
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JMultipleFileScanner.hh
Scanning of objects from multiple files according a format that follows from the extension of each fi...
JMonteCarloFileSupportkit.hh
Evt.hh
JSUPPORT::JMultipleFileScanner
General purpose class for object reading from a list of file names.
Definition:
JMultipleFileScanner.hh:199
JParser.hh
Utility class to parse command line options.
Evt::mc_hits
std::vector< Hit > mc_hits
MC: list of MC truth hits.
Definition:
Evt.hh:48
JSUPPORT::JLimit::getLimit
const JLimit & getLimit() const
Get limit.
Definition:
JLimit.hh:84
Head.hh
JDAQClock.hh
debug
int debug
debug level
Definition:
archive-put-wiki-detectors.sh:92
Evt
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition:
Evt.hh:20
DEBUG
#define DEBUG(A)
Message macros.
Definition:
JMessage.hh:62
Generated by
1.8.5