Jpp  17.0.0
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 
40  for (const auto i : trk.rec_stages) {
41  out << ' ' << i;
42  }
43 
44  out << endl;
45  }
46 
47 
48  /**
49  * Recursively print track with given mother identifier.
50  *
51  * \param out output stream
52  * \param prefix prefix
53  * \param evt event
54  * \param id identifier
55  */
56  inline void print(std::ostream& out, const std::string& prefix, const Evt& evt, const int id)
57  {
58  if (id != -1) {
59  for (const Trk& i : evt.trks) {
60  if (i.id == id) {
61  print(out, prefix, i);
62  print(out, " " + prefix, evt, i.mother_id);
63  break;
64  }
65  }
66  }
67  }
68 }
69 
70 /**
71  * \file
72  *
73  * Example program to print track fit results from Evt formatted data.
74  * \author mdejong
75  */
76 int main(int argc, char **argv)
77 {
78  using namespace std;
79  using namespace JPP;
80 
81  JMultipleFileScanner<Evt> inputFile;
82  JLimit_t& numberOfEvents = inputFile.getLimit();
83  int debug;
84 
85  try {
86 
87  JParser<> zap("Example program to print track fit results from Evt formatted data.");
88 
89  zap['f'] = make_field(inputFile);
90  zap['n'] = make_field(numberOfEvents) = JLimit::max();
91  zap['d'] = make_field(debug) = 2;
92 
93  zap(argc, argv);
94  }
95  catch(const exception& error) {
96  FATAL(error.what() << endl);
97  }
98 
99 
100  while (inputFile.hasNext()) {
101 
102  cout << "event " << setw(10) << inputFile.getCounter() << endl;
103 
104  const Evt* evt = inputFile.next();
105 
106  if (has_reconstructed_jppmuon(*evt)) {
107 
108  const Trk trk = get_best_reconstructed_jppmuon(*evt);
109 
110  print(cout, "", trk);
111  print(cout, "->", *evt, trk.mother_id);
112  }
113  }
114 }
Utility class to parse command line options.
Definition: JParser.hh:1500
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:1961
Definition of hit and track types and auxiliary methods for handling Monte Carlo data.
int debug
debug level
Definition: JSirene.cc:66
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
Vec pos
postion of the track at time t [m]
Definition: Trk.hh:17
std::vector< Trk > trks
list of reconstructed tracks (can be several because of prefits,showers, etc).
Definition: Evt.hh:36
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:73
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Definition: Trk.hh:14
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:19