Jpp
 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/offline/io_ascii.hh"
#include "km3net-dataformat/definitions/fitparameters.hh"
#include "JAAnet/JHead.hh"
#include "JAAnet/JHeadToolkit.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JTrigger/JTimeConverter.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 83 of file JPrintEvt.cc.

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  JTimeConverter 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 = JTimeConverter(*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: JPrint.hh:267
Utility class to parse command line options.
Definition: JParser.hh:1493
JDAQUTCExtended getTimesliceStart() const
Get start of timeslice.
JTrack3E getTrack(const Trk &track)
Get track.
double putTime() const
Get Monte Carlo minus DAQ/trigger hit time.
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.
Definition: JEvtToolkit.hh:262
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:63
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
Data structure for track fit results.
Definition: JEvt.hh:32
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
Muon trajectory.
int debug
debug level
Definition: JSirene.cc:61
Reconstruction type dependent comparison of track quality.
#define FATAL(A)
Definition: JMessage.hh:67
double getQ() const
Get quality.
Definition: JEvt.hh:152
Data structure for set of track fit results.
Definition: JEvt.hh:294
Auxiliary class to convert DAQ/trigger hit time to/from Monte Carlo hit time.
Data structure for position in three dimensions.
Definition: JPosition3D.hh:35
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
const Trk & get_neutrino(const Evt &evt)
Get incoming neutrino.
const JHistory & getHistory() const
Get history.
Definition: JHistory.hh:228
JTriggerCounter_t getCounter() const
Get trigger counter.
double getE() const
Get energy.
Definition: JEvt.hh:154
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:19