Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
JDK.cc File Reference

Example program to filter out-of-time hits in Evt data. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <cmath>
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/MultiHead.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "km3net-dataformat/online/JDAQClock.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JMonteCarloFileSupportkit.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JMeta.hh"
#include "JAAnet/JAAnetToolkit.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to filter out-of-time hits in Evt data.

Author
mdejong

Definition in file JDK.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 30 of file JDK.cc.

31{
32 using namespace std;
33 using namespace JPP;
34 using namespace KM3NETDAQ;
35
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 long long int number_of_hits[] = { 0, 0 };
68
69 while (inputFile.hasNext()) {
70
71 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
72
73 Evt* evt = inputFile.next();
74
75 number_of_hits[0] += evt->mc_hits.size();
76
77 double t0 = numeric_limits<double>::max();
78
79 for (vector<Hit>::iterator hit = evt->mc_hits.begin(); hit != evt->mc_hits.end(); ++hit) {
80 if (getTime(*hit) < t0) {
81 t0 = getTime(*hit);
82 }
83 }
84
85 vector<Hit>::iterator __end = evt->mc_hits.end();
86
87 for (vector<Hit>::iterator hit = evt->mc_hits.begin(); hit != __end; ) {
88 if (getTime(*hit) <= t0 + T_ns)
89 ++hit;
90 else
91 iter_swap(hit, --__end);
92 }
93
94 number_of_hits[1] += distance(__end, evt->mc_hits.end());
95
96 evt->mc_hits.erase(__end, evt->mc_hits.end());
97
98 outputFile.put(*evt);
99 }
100 STATUS(endl);
101
102 cout << "Number of hits processed/removed " << number_of_hits[0] << "/" << number_of_hits[1] << endl;
103
105
106 io >> outputFile;
107
108 outputFile.close();
109}
string outputFile
#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
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Utility class to parse command line options.
Definition JParser.hh:1698
General purpose class for object reading from a list of file names.
virtual bool hasNext() override
Check availability of next element.
counter_type getCounter() const
Get counter.
virtual const pointer_type & next() override
Get next element.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
const char * getTime()
Get current local time conform ISO-8601 standard.
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
double getFrameTime()
Get frame time duration.
Definition JDAQClock.hh:162
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition Evt.hh:21
std::vector< Hit > mc_hits
MC: list of MC truth hits.
Definition Evt.hh:48
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 for ROOT I/O of application specific meta data.
Definition JMeta.hh:72