Jpp  18.6.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPrintAAnet.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 #include <cmath>
6 
9 
10 #include "JAAnet/JAAnetToolkit.hh"
11 
13 #include "JSupport/JSupport.hh"
14 
15 #include "Jeep/JParser.hh"
16 #include "Jeep/JMessage.hh"
17 
18 namespace {
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  */
77 int main(int argc, char **argv)
78 {
79  using namespace std;
80  using namespace JPP;
81 
82  JMultipleFileScanner<Evt> inputFile;
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 }
Utility class to parse command line options.
Definition: JParser.hh:1711
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
double t
track time [ns] (when the particle is at pos )
Definition: Trk.hh:19
double z
Definition: Vec.hh:14
Vec dir
track direction
Definition: Trk.hh:18
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
bool has_reconstructed_jppmuon(const Evt &evt)
Test whether given event has a track with muon reconstruction.
double y
Definition: Vec.hh:14
int mother_id
MC id of the parent particle.
Definition: Trk.hh:29
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
double x
Definition: Vec.hh:14
const Trk & get_best_reconstructed_jppmuon(const Evt &evt)
Get best reconstructed muon.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
Definition of hit and track types and auxiliary methods for handling Monte Carlo data.
print
Definition: JConvertDusj.sh:44
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Scanning of objects from multiple files according a format that follows from the extension of each fi...
int id
track identifier
Definition: Trk.hh:16
int status
MC status code, see km3net-dataformat/definitions/trkmembers.csv for values.
Definition: Trk.hh:28
Vec pos
postion [m] of the track at time t
Definition: Trk.hh:17
std::vector< Trk > trks
list of reconstructed tracks (can be several because of prefits,showers, etc).
Definition: Evt.hh:39
std::vector< int > rec_stages
list of identifyers of succesfull fitting stages resulting in this track
Definition: Trk.hh:26
General purpose class for object reading from a list of file names.
Utility class to parse command line options.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:84
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Definition: Trk.hh:14
int debug
debug level
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:20