Jpp  18.6.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Namespaces | Functions
JMonteCarloFileSupportkit.hh File Reference
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/MultiHead.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "km3net-dataformat/offline/io_ascii.hh"
#include "JLang/JASCIIFileReader.hh"
#include "JLang/JGZFileReader.hh"
#include "JLang/JStreamObjectOutput.hh"
#include "JLang/JAbstractObjectIterator.hh"
#include "JLang/JObjectOutput.hh"
#include "JLang/JException.hh"
#include "JLang/JManip.hh"
#include "JAAnet/JHead.hh"
#include "JAAnet/JMultiHead.hh"
#include "JAAnet/JHeadToolkit.hh"
#include "JAAnet/JAAnetToolkit.hh"
#include "JSupport/JMonteCarloFileReader.hh"
#include "JSupport/JMonteCarloFileWriter.hh"
#include "JSupport/JMultipleFileScanner.hh"

Go to the source code of this file.

Classes

class  JSUPPORT::JMonteCarloFileReader< T, JFileReader_t >
 Template definition of Monte Carlo object reader. More...
 
class  JSUPPORT::JMonteCarloFileReader< Head, JFileReader_t >
 Template specialisation of JMonteCarloFileReader for Head. More...
 
class  JSUPPORT::JMonteCarloFileReader< Evt, JFileReader_t >
 Template specialisation of JMonteCarloFileReader for Event. More...
 
class  JSUPPORT::JMonteCarloASCIIFileReader< Head >
 Template implementation of Monte Carlo object reader for ASCII formatted file (i.e. '.evt') More...
 
class  JSUPPORT::JMonteCarloASCIIFileReader< Evt >
 Template implementation of Monte Carlo object reader for ASCII formatted file (i.e. '.evt') More...
 
class  JSUPPORT::JMonteCarloGZFileReader< Head >
 Template implementation of Monte Carlo object reader for gzipped ASCII formatted file (i.e. '.gz') More...
 
class  JSUPPORT::JMonteCarloGZFileReader< Evt >
 Template implementation of Monte Carlo object reader for gzipped ASCII formatted file (i.e. '.gz') More...
 
class  JSUPPORT::JMonteCarloStreamObjectOutput< Head >
 Template specialisation of JMonteCarloStreamObjectOutput for Head. More...
 
class  JSUPPORT::JMonteCarloStreamObjectOutput< Evt >
 Template specialisation of JMonteCarloStreamObjectOutput for Evt. More...
 
class  JSUPPORT::JMultipleFileScanner< Head >
 Template specialisation of JMultipleFileScanner for Monte Carlo header. More...
 

Namespaces

 JSUPPORT
 Support classes and methods for experiment specific I/O.
 
 JPP
 This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 

Functions

std::istream & operator>> (std::istream &in, Head &header)
 Read header from input. More...
 
std::ostream & operator<< (std::ostream &out, const MultiHead &header)
 Write multi-header to output. More...
 
std::istream & operator>> (std::istream &in, Evt &evt)
 Read event from input. More...
 
std::ostream & operator<< (std::ostream &out, const Evt &evt)
 Write event to output. More...
 
std::istream & operator>> (std::istream &in, Hit &hit)
 Read hit from input. More...
 
std::ostream & operator<< (std::ostream &out, const Hit &hit)
 Write hit to output. More...
 
Head JSUPPORT::getHeader (const JMultipleFileScanner_t &file_list)
 Get Monte Carlo header. More...
 
JMultiHead JSUPPORT::getMultiHeader (const JMultipleFileScanner_t &file_list)
 Get multi-header corresponding to a given file list. More...
 
template<class JFunction_t >
JMultipleFileScanner_t JSUPPORT::getAAnetFiles (const JMultipleFileScanner_t &input, JFunction_t test)
 Get list of files compatible with geven header. More...
 

Function Documentation

std::istream& operator>> ( std::istream &  in,
Head header 
)
inline

Read header from input.

Author
mdejong
Parameters
ininput stream
headerheader
Returns
input stream

Definition at line 39 of file JMonteCarloFileSupportkit.hh.

40 {
41  header.clear();
42 
43  read(header, in);
44 
45  return in;
46 }
std::istream & read(std::istream &in, JTestSummary &summary, const char delimiter= ' ')
Read test summary.
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
std::ostream& operator<< ( std::ostream &  out,
const MultiHead header 
)
inline

Write multi-header to output.

Parameters
outoutput stream
headerheader
Returns
output stream

Definition at line 75 of file JMonteCarloFileSupportkit.hh.

76 {
77  for (MultiHead::const_iterator i = header.begin(); i != header.end(); ++i) {
78  write(*i, out);
79  }
80 
81  return out;
82 }
bool write(const Vec &v, std::ostream &os)
Write a Vec(tor) to a stream.
Definition: io_ascii.hh:155
std::istream& operator>> ( std::istream &  in,
Evt evt 
)
inline

Read event from input.

Parameters
ininput stream
evtevent
Returns
input stream

Definition at line 92 of file JMonteCarloFileSupportkit.hh.

93 {
94  evt = Evt();
95 
96  read(evt, in, false);
97 
98  return in;
99 }
std::istream & read(std::istream &in, JTestSummary &summary, const char delimiter= ' ')
Read test summary.
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:20
std::ostream& operator<< ( std::ostream &  out,
const Evt evt 
)
inline

Write event to output.

Parameters
outoutput stream
evtevent
Returns
output stream

Definition at line 109 of file JMonteCarloFileSupportkit.hh.

110 {
111  using namespace std;
112  using namespace JPP;
113 
114  const ios_base::fmtflags flags = out.flags();
115 
116  out << setw(15) << scientific << setprecision(5);
117 
118  if (getLongprint(out)) {
119 
120  out << mc_keys::start_event_t << ' ' << evt.mc_id << ' ' << 1 << endl;
121 
122  for (const auto& trk : evt.mc_trks) {
123 
124  const int motherType = (trk.mother_id >= 0 && trk.mother_id < (int) evt.mc_trks.size() ?
125  evt.mc_trks[trk.mother_id].type : 0);
126 
127  out << mc_keys::track_in_t << ' '
128  << trk.id << ' '
129  << trk.type << ' '
130  << trk.mother_id << ' '
131  << motherType << ' '
132  << trk.pos << ' '
133  << trk.dir << ' '
134  << trk.len << ' '
135  << trk.E << ' '
136  << trk.t << ' '
137  << trk.status << ' '
138  << is_initialstate(trk)
139  << is_finalstate (trk)
140  << endl;
141  }
142 
143  for (const auto& trk : evt.trks) {
144 
145  out << mc_keys::track_fit_t << ' '
146  << trk.id << ' '
147  << trk.pos << ' '
148  << trk.dir << ' '
149  << trk.len << ' '
150  << trk.E << ' '
151  << trk.t << endl;
152  }
153 
154  for (const auto& hit : evt.mc_hits) { write (hit, out, mc_keys::hit_t); }
155  for (const auto& hit : evt.hits) { write (hit, out, mc_keys::hit_raw_t); }
156 
157  out << mc_keys::weights_t; for (const auto& w : evt.w) { out << ' ' << w;} out << endl;
158  out << mc_keys::w2list_t; for (const auto& w : evt.w2list) { out << ' ' << w;} out << endl;
159  out << mc_keys::w3list_t; for (const auto& w : evt.w3list) { out << ' ' << w;} out << endl;
160 
161  out << mc_keys::eventtime_t << ' '
162  << evt.mc_event_time.GetSec() << ' '
163  << evt.mc_event_time.GetNanoSec() / 16 << endl;
164 
165  out << mc_keys::end_event_t << endl;
166 
167  } else {
168 
169  write(evt, out << fixed);
170  }
171 
172  out.flags(flags);
173 
174  return out;
175 }
data_type w[N+1][M+1]
Definition: JPolint.hh:867
const char *const w2list_t
Definition: io_ascii.hh:34
const char *const weights_t
Definition: io_ascii.hh:33
const char *const w3list_t
Definition: io_ascii.hh:35
std::vector< double > w
MC: Weights w[0]=w1, w[1]=w2, w[2]=w3 (see e.g. Tag list or km3net-dataformat/definitions) ...
Definition: Evt.hh:42
const char *const track_fit_t
Definition: io_ascii.hh:28
bool is_finalstate(const Trk &track)
Test whether given track corresponds to a final state particle.
const char *const eventtime_t
Definition: io_ascii.hh:37
int mc_id
identifier of the MC event (as found in ascii or antcc file).
Definition: Evt.hh:24
TTimeStamp mc_event_time
MC: true generation time (UTC) of the event, (default: 01 Jan 1970 00:00:00)
Definition: Evt.hh:46
bool getLongprint(std::ostream &out)
Get long print option.
Definition: JManip.hh:121
bool is_initialstate(const Trk &track)
Test whether given track corresponds to an initial state particle.
const char *const track_in_t
Definition: io_ascii.hh:26
std::vector< Trk > trks
list of reconstructed tracks (can be several because of prefits,showers, etc).
Definition: Evt.hh:39
bool write(const Vec &v, std::ostream &os)
Write a Vec(tor) to a stream.
Definition: io_ascii.hh:155
std::vector< Hit > mc_hits
MC: list of MC truth hits.
Definition: Evt.hh:48
const char *const hit_t
Definition: io_ascii.hh:24
const char *const end_event_t
Definition: io_ascii.hh:40
std::vector< Hit > hits
list of hits
Definition: Evt.hh:38
const char *const hit_raw_t
Definition: io_ascii.hh:25
const char *const start_event_t
Definition: io_ascii.hh:23
std::vector< double > w2list
MC: factors that make up w[1]=w2 (see e.g. Tag list or km3net-dataformat/definitions) ...
Definition: Evt.hh:43
std::vector< Trk > mc_trks
MC: list of MC truth tracks.
Definition: Evt.hh:49
std::vector< double > w3list
MC: atmospheric flux information.
Definition: Evt.hh:44
std::istream& operator>> ( std::istream &  in,
Hit hit 
)
inline

Read hit from input.

Parameters
ininput stream
hithit
Returns
input stream

Definition at line 185 of file JMonteCarloFileSupportkit.hh.

186 {
187  hit = Hit();
188 
189  read(hit, in, false);
190 
191  return in;
192 }
std::istream & read(std::istream &in, JTestSummary &summary, const char delimiter= ' ')
Read test summary.
Definition: Hit.hh:8
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
std::ostream& operator<< ( std::ostream &  out,
const Hit hit 
)
inline

Write hit to output.

Parameters
outoutput stream
hithit
Returns
output stream

Definition at line 202 of file JMonteCarloFileSupportkit.hh.

203 {
204  using namespace std;
205 
206  const ios_base::fmtflags flags = out.flags();
207 
208  write(hit, out << fixed);
209 
210  out.flags(flags);
211 
212  return out;
213 }
bool write(const Vec &v, std::ostream &os)
Write a Vec(tor) to a stream.
Definition: io_ascii.hh:155