Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JPrintAAnet.cc
Go to the documentation of this file.
1
2#include <string>
3#include <iostream>
4#include <iomanip>
5#include <cmath>
6
9
11
13#include "JSupport/JSupport.hh"
14
15#include "Jeep/JParser.hh"
16#include "Jeep/JMessage.hh"
17
18namespace {
19
20 /**
21 * Print track.
22 *
23 * \param out output stream
24 * \param prefix prefix
25 * \param trk track
26 */
27 inline void print(std::ostream& out, const std::string& prefix, const Trk& trk)
28 {
29 using namespace std;
30
31 out << prefix << ' '
32 << FIXED(7,2) << trk.pos.x << ' '
33 << FIXED(7,2) << trk.pos.y << ' '
34 << FIXED(7,2) << trk.pos.z << ' '
35 << FIXED(7,4) << trk.dir.x << ' '
36 << FIXED(7,4) << trk.dir.y << ' '
37 << FIXED(7,4) << trk.dir.z << ' '
38 << FIXED(11,1) << trk.t << ' '
39 << setw(3) << trk.status << ':';
40
41 for (const auto i : trk.rec_stages) {
42 out << ' ' << i;
43 }
44
45 out << endl;
46 }
47
48
49 /**
50 * Recursively print track with given mother identifier.
51 *
52 * \param out output stream
53 * \param prefix prefix
54 * \param evt event
55 * \param id identifier
56 */
57 inline void print(std::ostream& out, const std::string& prefix, const Evt& evt, const int id)
58 {
59 if (id != -1) {
60 for (const Trk& i : evt.trks) {
61 if (i.id == id) {
62 print(out, prefix, i);
63 print(out, " " + prefix, evt, i.mother_id);
64 break;
65 }
66 }
67 }
68 }
69}
70
71/**
72 * \file
73 *
74 * Example program to print track fit results from Evt formatted data.
75 * \author mdejong
76 */
77int main(int argc, char **argv)
78{
79 using namespace std;
80 using namespace JPP;
81
83 JLimit_t& numberOfEvents = inputFile.getLimit();
84 int debug;
85
86 try {
87
88 JParser<> zap("Example program to print track fit results from Evt formatted data.");
89
90 zap['f'] = make_field(inputFile);
91 zap['n'] = make_field(numberOfEvents) = JLimit::max();
92 zap['d'] = make_field(debug) = 2;
93
94 zap(argc, argv);
95 }
96 catch(const exception& error) {
97 FATAL(error.what() << endl);
98 }
99
100
101 while (inputFile.hasNext()) {
102
103 cout << "event " << setw(10) << inputFile.getCounter() << endl;
104
105 const Evt* evt = inputFile.next();
106
107 if (has_reconstructed_jppmuon(*evt)) {
108
109 const Trk trk = get_best_reconstructed_jppmuon(*evt);
110
111 print(cout, "", trk);
112 print(cout, "->", *evt, trk.mother_id);
113 }
114 }
115}
Definition of hit and track types and auxiliary methods for handling Monte Carlo data.
General purpose messaging.
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
int main(int argc, char **argv)
ROOT TTree parameter settings of various packages.
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.
std::ostream & print(std::ostream &out, const JTestSummary &summary, const char delimiter=' ', const bool useColors=true)
Print test summary.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition Evt.hh:21
std::vector< Trk > trks
list of reconstructed tracks (can be several because of prefits,showers, etc).
Definition Evt.hh:39
Auxiliary data structure for floating point format specification.
Definition JManip.hh:448
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
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Definition Trk.hh:15
int status
MC status code, see km3net-dataformat/definitions/trkmembers.csv for values.
Definition Trk.hh:28
int id
track identifier
Definition Trk.hh:16
Vec dir
track direction
Definition Trk.hh:18
std::vector< int > rec_stages
list of identifyers of succesfull fitting stages resulting in this track
Definition Trk.hh:26
double t
track time [ns] (when the particle is at pos )
Definition Trk.hh:19
int mother_id
MC id of the parent particle.
Definition Trk.hh:29
Vec pos
postion [m] of the track at time t
Definition Trk.hh:17
double z
Definition Vec.hh:14
double x
Definition Vec.hh:14
double y
Definition Vec.hh:14
const Trk & get_best_reconstructed_jppmuon(const Evt &evt)
Get best reconstructed muon.
bool has_reconstructed_jppmuon(const Evt &evt)
Test whether given event has a track with muon reconstruction.