Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPrintEvt.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 #include <algorithm>
6 
7 #include "TROOT.h"
8 #include "TFile.h"
9 
14 
15 #include "JAAnet/JHead.hh"
16 #include "JAAnet/JHeadToolkit.hh"
17 #include "JAAnet/JAAnetToolkit.hh"
18 
19 #include "JDAQ/JDAQEventIO.hh"
20 
22 #include "JSupport/JTreeScanner.hh"
24 #include "JSupport/JSupport.hh"
25 
26 #include "JReconstruction/JEvt.hh"
28 
29 #include "Jeep/JPrint.hh"
30 #include "Jeep/JParser.hh"
31 #include "Jeep/JMessage.hh"
32 
33 
34 /**
35  * \author mdejong
36  */
37 
38 namespace {
39 
40  /**
41  * Auxiliary data structure for formatted printing.
42  */
43  struct JTrack :
45  {
46  /**
47  * Constructor.
48  *
49  * \param track track
50  */
51  JTrack(const JTrack3E& track) :
52  JGEOMETRY3D::JTrack3E(track)
53  {}
54 
55 
56  /**
57  * Print track.
58  *
59  * \param out output stream
60  * \param track track
61  * \return output stream
62  */
63  friend inline std::ostream& operator<<(std::ostream& out, const JTrack& track)
64  {
65  using namespace JPP;
66 
67  out << FIXED(8,2) << track.getX() << ' '
68  << FIXED(8,2) << track.getY() << ' '
69  << FIXED(8,2) << track.getZ() << ' '
70  << FIXED(7,3) << track.getDX() << ' '
71  << FIXED(7,3) << track.getDY() << ' '
72  << FIXED(7,3) << track.getDZ() << ' '
73  << FIXED(8,1) << track.getT() << ' '
74  << SCIENTIFIC(12,3) << track.getE();
75 
76  return out;
77  }
78  };
79 }
80 
81 /**
82  * Auxiliary program to print fit results;
83  */
84 int main(int argc, char **argv)
85 {
86  using namespace std;
87  using namespace JPP;
88  using namespace KM3NETDAQ;
89 
90  typedef JParallelFileScanner< JTypeList<JDAQEvent, JEvt> > JParallelFileScanner_t;
91  typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
92 
93  JParallelFileScanner_t inputFile;
94  JLimit_t& numberOfEvents = inputFile.getLimit();
96  size_t numberOfFits;
97  int debug;
98 
99  try {
100 
101  JParser<> zap("Auxiliary program to print fit results.");
102 
103  zap['f'] = make_field(inputFile);
104  zap['n'] = make_field(numberOfEvents) = JLimit::max();
106  zap['N'] = make_field(numberOfFits) = 1;
107  zap['d'] = make_field(debug) = 2;
108 
109  zap(argc, argv);
110  }
111  catch(const exception& error) {
112  FATAL(error.what() << endl);
113  }
114 
115 
116 
117  const int WIDTH = 16;
118 
119  JTreeScanner<Evt> mc(inputFile);
120 
121  JPosition3D center(0,0,0);
122 
123  try {
124  center = get<JPosition3D>(getHeader(inputFile));
125  } catch(const exception& error) {}
126 
127 
128  while (inputFile.hasNext()) {
129 
130  cout << "event: " << setw(10) << inputFile.getCounter() << endl;
131 
132  multi_pointer_type ps = inputFile.next();
133 
134  JDAQEvent* tev = ps;
135  JEvt* evt = ps;
136 
137  if (quality_sorter.is_valid()) {
138  sort(evt->begin(), evt->end(), quality_sorter);
139  }
140 
141  time_converter converter;
142 
143  cout << "trigger: " << setw(10) << tev->getCounter() << ' '
144  << tev->getTimesliceStart() << endl;
145 
146  if (mc.getEntries() != 0) {
147 
148  Evt* event = mc.getEntry(tev->getCounter());
149 
150  if (event != NULL) {
151 
152  converter = time_converter(*event, *tev);
153 
154  if (has_neutrino(*event)) {
155 
156  JTrack ta = getTrack(get_neutrino(*event));
157 
158  ta.add(center);
159 
160  cout << LEFT(WIDTH) << "neutrino" << right << ' ' << ta << endl;
161  }
162 
163 
164  for (vector<Trk>::const_iterator i = event->mc_trks.begin(); i != event->mc_trks.end(); ++i) {
165 
166  JTrack ta = getTrack(*i);
167 
168  ta.add(center);
169 
170  cout << LEFT(WIDTH) << (is_muon (*i) ? "muon" :
171  is_electron(*i) ? "electron" :
172  is_hadron (*i) ? "hadron" : "other") << right << ' ' << ta << endl;
173  }
174  }
175  }
176 
177  cout << "number of fits " << setw(4) << right << evt->size() << endl;
178 
179  for (size_t i = 0; i != min(evt->size(), numberOfFits); ++i) {
180 
181  const JFit& fit = (*evt)[i];
182 
183  JTrack tb = getTrack(fit);
184 
185  tb.sub(converter.putTime());
186 
187  cout << LEFT(WIDTH) << "fit" << right << ' '
188  << tb << ' '
189  << FIXED(7,2) << fit.getQ() << ' '
190  << SCIENTIFIC(12,3) << fit.getW(JENERGY_MINIMAL_ENERGY,0.0) << ' '
191  << SCIENTIFIC(12,3) << fit.getW(JENERGY_MAXIMAL_ENERGY,0.0) << endl;
192 
193  cout << fit.getHistory() << endl;
194  }
195  }
196 }
bool is_electron(const Trk &track)
Test whether given track is a (anti-)electron.
Auxiliary data structure for alignment of data.
Definition: JManip.hh:231
Utility class to parse command line options.
Definition: JParser.hh:1500
int main(int argc, char *argv[])
Definition: Main.cc:15
JDAQUTCExtended getTimesliceStart() const
Get start of timeslice.
ROOT TTree parameter settings of various packages.
JTrack3E getTrack(const Trk &track)
Get track.
static const int JENERGY_MAXIMAL_ENERGY
maximal energy [GeV] from JEnergy.cc
bool has_neutrino(const Evt &evt)
Test whether given event has an incoming neutrino.
bool is_muon(const Trk &track)
Test whether given track is a (anti-)muon.
General purpose sorter of fit results.
General purpose class for parallel reading of objects from a single file or multiple files...
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:66
Auxiliary class to convert DAQ hit time to/from Monte Carlo hit time.
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
3D track with energy.
Definition: JTrack3E.hh:30
Acoustic single fit.
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
static const int JENERGY_MINIMAL_ENERGY
minimal energy [GeV] from JEnergy.cc
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
I/O formatting auxiliaries.
Acoustic event fit.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
double getE(const double z) const
Get muon energy at given position.
Parallel scanning of objects from a single file or multiple files according a format that follows fro...
Definition of hit and track types and auxiliary methods for handling Monte Carlo data.
double putTime() const
Get Monte Carlo time minus DAQ/trigger time.
Muon trajectory.
int debug
debug level
Definition: JSirene.cc:63
Reconstruction type dependent comparison of track quality.
General purpose messaging.
Auxiliary include file for time conversion between DAQ/trigger hit and Monte Carlo hit...
#define FATAL(A)
Definition: JMessage.hh:67
Utility class to parse command line options.
std::ostream & operator<<(std::ostream &stream, const CLBCommonHeader &header)
Data structure for position in three dimensions.
Definition: JPosition3D.hh:36
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
const Trk & get_neutrino(const Evt &evt)
Get incoming neutrino.
bool is_hadron(const Trk &track)
Test whether given track is a hadron.
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:484
JTriggerCounter_t getCounter() const
Get trigger counter.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:19