Jpp test-rotations-old-57-g407471f53
the software that should make you happy
Loading...
Searching...
No Matches
JPrintEvt.cc
Go to the documentation of this file.
1
2#include <string>
3#include <iostream>
4#include <iomanip>
5#include <algorithm>
6#include <vector>
7#include <map>
8#include <set>
9
10#include "TROOT.h"
11#include "TFile.h"
12
17
18#include "JAAnet/JHead.hh"
21
22#include "JDAQ/JDAQEventIO.hh"
23
27#include "JSupport/JSupport.hh"
28
31
32#include "JLang/JVectorize.hh"
33
34#include "Jeep/JPrint.hh"
35#include "Jeep/JParser.hh"
36#include "Jeep/JMessage.hh"
37
38
39/**
40 * \author mdejong
41 */
42
43namespace {
44
45 /**
46 * Auxiliary data structure for formatted printing.
47 */
48 struct JTrack :
50 {
51 /**
52 * Constructor.
53 *
54 * \param track track
55 */
56 JTrack(const JTrack3E& track) :
57 JGEOMETRY3D::JTrack3E(track)
58 {}
59
60
61 /**
62 * Print track.
63 *
64 * \param out output stream
65 * \param track track
66 * \return output stream
67 */
68 friend inline std::ostream& operator<<(std::ostream& out, const JTrack& track)
69 {
70 using namespace JPP;
71
72 out << FIXED(8,2) << track.getX() << ' '
73 << FIXED(8,2) << track.getY() << ' '
74 << FIXED(8,2) << track.getZ() << ' '
75 << FIXED(7,4) << track.getDX() << ' '
76 << FIXED(7,4) << track.getDY() << ' '
77 << FIXED(7,4) << track.getDZ() << ' '
78 << FIXED(10,1) << track.getT() << ' '
79 << SCIENTIFIC(12,3) << track.getE();
80
81 return out;
82 }
83 };
84
85 static const char* const MONTECARLO = "MonteCarlo";
86 static const char* const HISTORY = "history";
87}
88
89/**
90 * Auxiliary program to print fit results;
91 */
92int main(int argc, char **argv)
93{
94 using namespace std;
95 using namespace JPP;
96 using namespace KM3NETDAQ;
97
98 typedef JParallelFileScanner< JTypeList<JDAQEvent, JEvt> > JParallelFileScanner_t;
99 typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
100
101 JParallelFileScanner_t inputFile;
102 JLimit_t& numberOfEvents = inputFile.getLimit();
104 size_t numberOfFits;
105 vector<string> keys;
106 set <string> option;
107 int debug;
108
109 try {
110
111 JParser<> zap("Auxiliary program to print fit results.");
112
113 zap['f'] = make_field(inputFile);
114 zap['n'] = make_field(numberOfEvents) = JLimit::max();
116 zap['N'] = make_field(numberOfFits) = 1;
117 zap['k'] = make_field(keys, "print optional weights: " << get_keys(getWeight)) = JPARSER::initialised();
118 zap['+'] = make_field(option, "print optional data: " << MONTECARLO << ", " << HISTORY) = JPARSER::initialised();
119 zap['d'] = make_field(debug) = 2;
120
121 zap(argc, argv);
122 }
123 catch(const exception& error) {
124 FATAL(error.what() << endl);
125 }
126
127
128 const int WIDTH = 16;
129
130 JTreeScanner<Evt> mc(inputFile);
131
132 Vec offset(0,0,0);
133
134 try {
135 offset = getOffset(getHeader(inputFile));
136 } catch(const exception& error) {}
137
138
139 while (inputFile.hasNext()) {
140
141 cout << "event: " << setw(10) << inputFile.getCounter() << endl;
142
143 multi_pointer_type ps = inputFile.next();
144
145 JDAQEvent* tev = ps;
146 JEvt* evt = ps;
147
148 if (quality_sorter.is_valid()) {
149 sort(evt->begin(), evt->end(), quality_sorter);
150 }
151
152 time_converter converter;
153
154 cout << "trigger: " << setw(10) << tev->getCounter() << ' '
155 << tev->getTimesliceStart() << endl;
156
157 if (mc.getEntries() != 0) {
158
159 Evt* event = mc.getEntry(tev->getCounter());
160
161 if (event != NULL) {
162
163 converter = time_converter(*event, *tev);
164
165 if (option.count(MONTECARLO) != 0) {
166
167 if (has_neutrino(*event)) {
168
169 JTrack ta = getTrack(get_neutrino(*event));
170
171 ta.add(getPosition(offset));
172
173 cout << LEFT(WIDTH) << "neutrino" << right << ' ' << ta << endl;
174 }
175
176
177 for (vector<Trk>::const_iterator i = event->mc_trks.begin(); i != event->mc_trks.end(); ++i) {
178
179 JTrack ta = getTrack(*i);
180
181 ta.add(getPosition(offset));
182
183 cout << LEFT(WIDTH) << (is_muon (*i) ? "muon" :
184 is_electron(*i) ? "electron" :
185 is_hadron (*i) ? "hadron" : "other") << right << ' ' << ta << endl;
186 }
187 }
188 }
189 }
190
191 cout << "number of fits " << setw(4) << right << evt->size() << endl;
192
193 for (size_t i = 0; i != min(evt->size(), numberOfFits); ++i) {
194
195 const JFit& fit = (*evt)[i];
196
197 JTrack tb = getTrack(fit);
198
199 tb.sub(converter.putTime());
200
201 cout << LEFT(WIDTH) << "fit" << right << ' '
202 << tb << ' '
203 << FIXED(7,2) << fit.getQ() << ' '
204 << setw(2) << fit.getHistory().size() << '/' << fit.getStatus();
205
206 for (const auto& key : keys) {
207 cout << ' ' << SCIENTIFIC(12,3) << getWeight(fit, key, 0.0);
208 }
209
210 cout << endl;
211
212 for (size_t row = 0; row != fit.getDimensionOfErrorMatrix(); ++row) {
213 for (size_t col = 0; col <= row; ++col) {
214 cout << ' ' << SCIENTIFIC(12,3) << fit.getV(row,col);
215 }
216 cout << endl;
217 }
218
219 if (option.count(HISTORY) != 0) {
220 cout << fit.getHistory() << endl;
221 }
222 }
223 }
224}
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:72
Parallel scanning of objects from a single file or multiple files according a format that follows fro...
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
int main(int argc, char **argv)
Auxiliary program to print fit results;.
Definition JPrintEvt.cc:92
I/O formatting auxiliaries.
ROOT TTree parameter settings of various packages.
Auxiliary methods to convert data members or return values of member methods of a set of objects to a...
3D track with energy.
Definition JTrack3E.hh:32
Utility class to parse command line options.
Definition JParser.hh:1698
General purpose class for parallel reading of objects from a single file or multiple files.
Template definition for direct access of elements in ROOT TChain.
JDAQUTCExtended getTimesliceStart() const
Get start of timeslice.
JTriggerCounter_t getCounter() const
Get trigger counter.
Auxiliary class to convert DAQ hit time to/from Monte Carlo hit time.
double putTime() const
Get Monte Carlo time minus DAQ/trigger time.
JTrack3E getTrack(const Trk &track)
Get track.
bool is_electron(const Trk &track)
Test whether given track is a (anti-)electron.
bool has_neutrino(const Evt &evt)
Test whether given event has an incoming neutrino.
JPosition3D getPosition(const Vec &pos)
Get position.
bool is_muon(const Trk &track)
Test whether given track is a (anti-)muon.
Vec getOffset(const JHead &header)
Get offset.
const Trk & get_neutrino(const Evt &evt)
Get incoming neutrino.
bool is_hadron(const Trk &track)
Test whether given track is a hadron.
Auxiliary classes and methods for 3D geometrical objects and operations.
Definition JAngle3D.hh:19
@ LEFT
Definition JTwosome.hh:18
const 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
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
JWriter & operator<<(JWriter &out, const JDAQChronometer &chronometer)
Write DAQ chronometer to output.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition Evt.hh:21
Auxiliary data structure for floating point format specification.
Definition JManip.hh:448
Acoustic event fit.
Acoustic single fit.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition JParser.hh:68
General purpose sorter of fit results.
Auxiliary class for defining the range of iterations of objects.
Definition JLimit.hh:45
const JLimit & getLimit() const
Get limit.
Definition JLimit.hh:84
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 Vec class is a straightforward 3-d vector, which also works in pyroot.
Definition Vec.hh:13
Auxiliary data structure for alignment of data.
Definition JManip.hh:231
Reconstruction type dependent comparison of track quality.
Auxiliary include file for time conversion between DAQ/trigger hit and Monte Carlo hit.