Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JPrintEvt.cc File Reference
#include <string>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include "TROOT.h"
#include "TFile.h"
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "km3net-dataformat/definitions/fitparameters.hh"
#include "km3net-dataformat/tools/time_converter.hh"
#include "JAAnet/JHead.hh"
#include "JAAnet/JHeadToolkit.hh"
#include "JAAnet/JAAnetToolkit.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JSupport/JParallelFileScanner.hh"
#include "JSupport/JTreeScanner.hh"
#include "JSupport/JMonteCarloFileSupportkit.hh"
#include "JSupport/JSupport.hh"
#include "JReconstruction/JEvt.hh"
#include "JReconstruction/JEvtToolkit.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 Auxiliary program to print fit results;. More...
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Auxiliary program to print fit results;.

Definition at line 84 of file JPrintEvt.cc.

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
JDAQUTCExtended getTimesliceStart() const
Get start of timeslice.
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
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
Acoustic event fit.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
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.
#define FATAL(A)
Definition: JMessage.hh:67
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