Jpp
 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 
75  return out;
76  }
77  };
78 }
79 
80 /**
81  * Auxiliary program to print fit results;
82  */
83 int main(int argc, char **argv)
84 {
85  using namespace std;
86  using namespace JPP;
87  using namespace KM3NETDAQ;
88 
89  typedef JParallelFileScanner< JTypeList<JDAQEvent, JEvt> > JParallelFileScanner_t;
90  typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
91 
92  JParallelFileScanner_t inputFile;
93  JLimit_t& numberOfEvents = inputFile.getLimit();
95  size_t numberOfFits;
96  int debug;
97 
98  try {
99 
100  JParser<> zap("Auxiliary program to print fit results.");
101 
102  zap['f'] = make_field(inputFile);
103  zap['n'] = make_field(numberOfEvents) = JLimit::max();
105  zap['N'] = make_field(numberOfFits) = 1;
106  zap['d'] = make_field(debug) = 2;
107 
108  zap(argc, argv);
109  }
110  catch(const exception& error) {
111  FATAL(error.what() << endl);
112  }
113 
114 
115 
116  const int WIDTH = 16;
117 
118  JTreeScanner<Evt> mc(inputFile);
119 
120  JPosition3D center(0,0,0);
121 
122  try {
123  center = get<JPosition3D>(getHeader(inputFile));
124  } catch(const exception& error) {}
125 
126 
127  while (inputFile.hasNext()) {
128 
129  cout << "event: " << setw(10) << inputFile.getCounter() << endl;
130 
131  multi_pointer_type ps = inputFile.next();
132 
133  JDAQEvent* tev = ps;
134  JEvt* evt = ps;
135 
136  if (quality_sorter.is_valid()) {
137  sort(evt->begin(), evt->end(), quality_sorter);
138  }
139 
140  time_converter converter;
141 
142  cout << "trigger: " << setw(10) << tev->getCounter() << ' '
143  << tev->getTimesliceStart() << endl;
144 
145  if (mc.getEntries() != 0) {
146 
147  Evt* event = mc.getEntry(tev->getCounter());
148 
149  if (event != NULL) {
150 
151  converter = time_converter(*event, *tev);
152 
153  if (has_neutrino(*event)) {
154 
155  JTrack ta = getTrack(get_neutrino(*event));
156 
157  ta.add(center);
158 
159  cout << LEFT(WIDTH) << "neutrino" << right << ' ' << ta << endl;
160  }
161 
163 
164  track = find_if(event->mc_trks.begin(), event->mc_trks.end(), is_muon);
165 
166  if (track != event->mc_trks.end()) {
167 
168  JTrack ta = getTrack(*track);
169 
170  ta.add(center);
171 
172  cout << LEFT(WIDTH) << "muon" << right << ' ' << ta << endl;
173  }
174 
175  track = find_if(event->mc_trks.begin(), event->mc_trks.end(), is_electron);
176 
177  if (track != event->mc_trks.end()) {
178 
179  JTrack ta = getTrack(*track);
180 
181  ta.add(center);
182 
183  cout << LEFT(WIDTH) << "electron" << right << ' ' << ta << endl;
184  }
185  }
186  }
187 
188  cout << "number of fits " << setw(4) << right << evt->size() << endl;
189 
190  for (size_t i = 0; i != min(evt->size(), numberOfFits); ++i) {
191 
192  const JFit& fit = (*evt)[i];
193 
194  JTrack tb = getTrack(fit);
195 
196  tb.sub(converter.putTime());
197 
198  cout << LEFT(WIDTH) << "fit" << right << ' ' << tb << ' ' << fit.getQ() << ' ' << fit.getE() << endl;
199  cout << fit.getHistory() << endl;
200  }
201  }
202 }
bool is_electron(const Trk &track)
Test whether given track is a (anti-)electron.
Auxiliary data structure for alignment of data.
Definition: JManip.hh:230
Utility class to parse command line options.
Definition: JParser.hh:1500
JDAQUTCExtended getTimesliceStart() const
Get start of timeslice.
ROOT TTree parameter settings of various packages.
JTrack3E getTrack(const Trk &track)
Get track.
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:445
3D track with energy.
Definition: JTrack3E.hh:30
Acoustic single fit.
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
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
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.
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
int main(int argc, char *argv[])
Definition: Main.cpp:15