Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Macros | Functions
JPrintEvt.cc File Reference
#include <string>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#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 "JLang/JVectorize.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Macros

#define MAKE_ENTRY(A)   std::make_pair(#A, A)
 

Functions

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

Macro Definition Documentation

#define MAKE_ENTRY (   A)    std::make_pair(#A, A)

Function Documentation

int main ( int  argc,
char **  argv 
)

Auxiliary program to print fit results;.

Definition at line 151 of file JPrintEvt.cc.

152 {
153  using namespace std;
154  using namespace JPP;
155  using namespace KM3NETDAQ;
156 
157  typedef JParallelFileScanner< JTypeList<JDAQEvent, JEvt> > JParallelFileScanner_t;
158  typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
159 
160  JParallelFileScanner_t inputFile;
161  JLimit_t& numberOfEvents = inputFile.getLimit();
163  size_t numberOfFits;
164  vector<string> keys;
165  int debug;
166 
167  try {
168 
169  JParser<> zap("Auxiliary program to print fit results.");
170 
171  zap['f'] = make_field(inputFile);
172  zap['n'] = make_field(numberOfEvents) = JLimit::max();
174  zap['N'] = make_field(numberOfFits) = 1;
175  zap['k'] = make_field(keys, MAKE_STRING("print optional weights: " << get_keys(getWeight))) = JPARSER::initialised();
176  zap['d'] = make_field(debug) = 2;
177 
178  zap(argc, argv);
179  }
180  catch(const exception& error) {
181  FATAL(error.what() << endl);
182  }
183 
184 
185 
186  const int WIDTH = 16;
187 
188  JTreeScanner<Evt> mc(inputFile);
189 
190  JPosition3D center(0,0,0);
191 
192  try {
193  center = get<JPosition3D>(getHeader(inputFile));
194  } catch(const exception& error) {}
195 
196 
197  while (inputFile.hasNext()) {
198 
199  cout << "event: " << setw(10) << inputFile.getCounter() << endl;
200 
201  multi_pointer_type ps = inputFile.next();
202 
203  JDAQEvent* tev = ps;
204  JEvt* evt = ps;
205 
206  if (quality_sorter.is_valid()) {
207  sort(evt->begin(), evt->end(), quality_sorter);
208  }
209 
210  time_converter converter;
211 
212  cout << "trigger: " << setw(10) << tev->getCounter() << ' '
213  << tev->getTimesliceStart() << endl;
214 
215  if (mc.getEntries() != 0) {
216 
217  Evt* event = mc.getEntry(tev->getCounter());
218 
219  if (event != NULL) {
220 
221  converter = time_converter(*event, *tev);
222 
223  if (has_neutrino(*event)) {
224 
225  JTrack ta = getTrack(get_neutrino(*event));
226 
227  ta.add(center);
228 
229  cout << LEFT(WIDTH) << "neutrino" << right << ' ' << ta << endl;
230  }
231 
232 
233  for (vector<Trk>::const_iterator i = event->mc_trks.begin(); i != event->mc_trks.end(); ++i) {
234 
235  JTrack ta = getTrack(*i);
236 
237  ta.add(center);
238 
239  cout << LEFT(WIDTH) << (is_muon (*i) ? "muon" :
240  is_electron(*i) ? "electron" :
241  is_hadron (*i) ? "hadron" : "other") << right << ' ' << ta << endl;
242  }
243  }
244  }
245 
246  cout << "number of fits " << setw(4) << right << evt->size() << endl;
247 
248  for (size_t i = 0; i != min(evt->size(), numberOfFits); ++i) {
249 
250  const JFit& fit = (*evt)[i];
251 
252  JTrack tb = getTrack(fit);
253 
254  tb.sub(converter.putTime());
255 
256  cout << LEFT(WIDTH) << "fit" << right << ' '
257  << tb << ' '
258  << FIXED(7,2) << fit.getQ();
259 
260  for (const auto& key : keys) {
261  cout << ' ' << SCIENTIFIC(12,3) << getWeight(fit, key, 0.0);
262  }
263 
264  cout << endl;
265  cout << fit.getHistory() << endl;
266  }
267  }
268 }
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.
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.
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:142
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
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.
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.
Definition: JVectorize.hh:139
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:19