Jpp 21.0.0-rc.3
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 <vector>
6#include <cmath>
7
10
12
14
16#include "JSupport/JSupport.hh"
17
18#include "Jeep/JParser.hh"
19#include "Jeep/JMessage.hh"
20
21namespace {
22
23 /**
24 * Print track.
25 *
26 * \param out output stream
27 * \param prefix prefix
28 * \param trk track
29 */
30 inline void print(std::ostream& out, const std::string& prefix, const Trk& trk)
31 {
32 using namespace std;
33
34 out << prefix << ' '
35 << setw(4) << trk.id << ' '
36 << FIXED(7,2) << trk.pos.x << ' '
37 << FIXED(7,2) << trk.pos.y << ' '
38 << FIXED(7,2) << trk.pos.z << ' '
39 << FIXED(7,4) << trk.dir.x << ' '
40 << FIXED(7,4) << trk.dir.y << ' '
41 << FIXED(7,4) << trk.dir.z << ' '
42 << FIXED(11,1) << trk.t << ' '
43 << setw(3) << trk.rec_type << ' '
44 << setw(3) << trk.status << ':';
45
46 for (const auto i : trk.rec_stages) {
47 out << ' ' << i;
48 }
49 }
50
51
52 /**
53 * Recursively print track with given mother identifier.
54 *
55 * \param out output stream
56 * \param prefix prefix
57 * \param evt event
58 * \param id identifier
59 */
60 inline void print(std::ostream& out, const std::string& prefix, const Evt& evt, const int id)
61 {
62 using namespace std;
63
64 if (id != -1) {
65 for (const Trk& i : evt.trks) {
66 if (i.id == id) {
67 out << endl;
68 print(out, prefix, i);
69 print(out, " " + prefix, evt, i.mother_id);
70 break;
71 }
72 }
73 }
74 }
75}
76
77/**
78 * \file
79 *
80 * Example program to print track fit results from Evt formatted data.
81 * \author mdejong
82 */
83int main(int argc, char **argv)
84{
85 using namespace std;
86 using namespace JPP;
87
89 JLimit_t& numberOfEvents = inputFile.getLimit();
90 vector<string> keys;
91 int debug;
92
93 try {
94
95 JParser<> zap("Example program to print track fit results from Evt formatted data.");
96
97 zap['f'] = make_field(inputFile);
98 zap['n'] = make_field(numberOfEvents) = JLimit::max();
99 zap['k'] = make_field(keys, "print optional weights: " << get_keys(getWeight)) = JPARSER::initialised();
100 zap['d'] = make_field(debug) = 2;
101
102 zap(argc, argv);
103 }
104 catch(const exception& error) {
105 FATAL(error.what() << endl);
106 }
107
108
109 while (inputFile.hasNext()) {
110
111 cout << "event " << setw(10) << inputFile.getCounter() << endl;
112
113 const Evt* evt = inputFile.next();
114
115 if (has_reconstructed_jppmuon(*evt)) {
116
117 const Trk trk = get_best_reconstructed_jppmuon(*evt);
118
119 print(cout, "", trk);
120 print(cout, "->", *evt, trk.mother_id);
121
122 for (const auto& key : keys) {
123 cout << ' ' << SCIENTIFIC(12,3) << getWeight(trk, key, 0.0);
124 }
125
126 cout << endl;
127 }
128
129 if (debug >= debug_t) {
130 for (const Trk& i : evt->trks) {
131 print(cout, "", i);
132 cout << endl;
133 }
134 }
135 }
136}
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:74
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:2107
ROOT TTree parameter settings of various packages.
Utility class to parse command line options.
Definition JParser.hh:1664
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, T __begin, T __end, const bool useColors=true, const JFormat_t &formatting=JFormat_t(18, 3, std::ios::fixed))
Print test summary.
@ debug_t
debug
Definition JMessage.hh:29
array_type< JKey_t > get_keys(const std::map< JKey_t, JValue_t, JComparator_t, JAllocator_t > &data)
Method to create array of keys of map.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
JRECONSTRUCTION::JWeight getWeight
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
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition JParser.hh:66
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 data structure for floating point format specification.
Definition JManip.hh:488
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Definition Trk.hh:15
int status
MC or reconstruction 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 identifiers of successful 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 rec_type
identifier of the fitting algorithm/chain/strategy, see km3net-dataformat/definitions/reconstruction....
Definition Trk.hh:25
int mother_id
id of the parent MC particle or of the reconstructed track at the previous stage
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.