1#ifndef __JSUPPORT__JMONTECARLOFILESUPPORTKIT__
2#define __JSUPPORT__JMONTECARLOFILESUPPORTKIT__
78 for (MultiHead::const_iterator i = header.begin(); i != header.end(); ++i) {
115 const ios_base::fmtflags flags = out.flags();
117 out << scientific << setprecision(5);
123 for (
const auto& trk : evt.
mc_trks) {
126 << setw( 3) << trk.id <<
' '
127 << setw(10) << trk.type <<
' '
128 << setw( 3) << trk.mother_id <<
' '
129 <<
FIXED(12,3) << trk.pos.x <<
' '
130 <<
FIXED(12,3) << trk.pos.y <<
' '
131 <<
FIXED(12,3) << trk.pos.z <<
' '
132 <<
FIXED( 7,4) << trk.dir.x <<
' '
133 <<
FIXED( 7,4) << trk.dir.y <<
' '
134 <<
FIXED( 7,4) << trk.dir.z <<
' '
135 <<
FIXED( 7,1) << trk.len <<
' '
138 << setw( 4) << trk.status <<
' '
144 for (
const auto& trk : evt.
trks) {
147 << setw(3) << trk.id <<
' '
148 <<
FIXED(12,3) << trk.pos.x <<
' '
149 <<
FIXED(12,3) << trk.pos.y <<
' '
150 <<
FIXED(12,3) << trk.pos.z <<
' '
151 <<
FIXED( 7,4) << trk.dir.x <<
' '
152 <<
FIXED( 7,4) << trk.dir.y <<
' '
153 <<
FIXED( 7,4) << trk.dir.z <<
' '
154 <<
FIXED( 7,1) << trk.len <<
' '
156 <<
FIXED(10,1) << trk.t <<
' '
157 << setw(3) << trk.status << endl;
175 write(evt, out << fixed);
195 read(hit, in,
false);
212 const ios_base::fmtflags flags = out.flags();
214 write(hit, out << fixed);
242 template<
class T,
template<
class>
class JFileReader_t>
252 template<
template<
class>
class JFileReader_t>
254 public JFileReader_t<Head>
261 JFileReader_t<
Head>(),
271 virtual void open(
const char* file_name)
override
273 JFileReader_t<Head>::open(file_name);
290 return JFileReader_t<Head>::hasNext();
309 template<
template<
class>
class JFileReader_t>
311 public JFileReader_t<Evt>
319 virtual void open(
const char* file_name)
override
323 JFileReader_t<Evt>::open(file_name);
325 if (this->is_open()) {
329 static_cast<istream&
>(*this) >> buffer;
470 using namespace JLANG;
476 unsigned int count = 0;
480 for (const_iterator i = this->begin(); i != this->end(); ++i) {
490 else if (header.
match(buffer))
493 THROW(
JException,
"JMultipleFileScanner<Head>::setObject(): inconsistent headers.");
501 copy(header,
object);
503 if (count != 0 && count != this->size()) {
505 THROW(
JException,
"JMultipleFileScanner<Head>::setObject(): missing header(s): " << count <<
" != " << this->size());
525 const Head* p = NULL;
527 if (!this->
hasNext() || (p = this->
next()) == NULL) {
571 if (!file_list.empty()) {
577 for (
size_t i = 1; i != file_list.size(); ++i) {
604 for (MultiHead::const_iterator i = p->cbegin(); i != p->cend(); ++i) {
608 multiHeader.
insert(header);
628 template<
class JFunction_t>
635 for (JMultipleFileScanner_t::const_iterator i = input.begin(); i != input.end(); ++i) {
658 for (JMultipleFileScanner_t::const_iterator i = file_list.cbegin(); i != file_list.cend(); ++i) {
663 categories.insert(cats.begin(), cats.end());
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
bool getLongprint(std::ostream &out)
Get long print option.
Scanning of objects from multiple files according a format that follows from the extension of each fi...
JHead & add(const JHead &header)
Addition of headers.
void createUUID()
Create UUID if not already set.
JHead getMatch(const JHead &header) const
Get matching fields.
bool match(const JHead &header) const
Test match of headers.
Object reading from ASCII file.
Object reading from gzipped file.
Exception for null pointer operation.
Abstract object iterator with rewinding.
Template implementation of stream output for single data type.
Object reading from file.
Template definition of Monte Carlo object reader for ASCII formatted file (i.e. '....
virtual void open(const char *file_name) override
Open file.
virtual bool hasNext() override
Check availability of next element.
virtual void open(const char *file_name) override
Open file.
JMonteCarloFileReader()
Default constructor.
Template definition of Monte Carlo object reader.
Template definition of Monte Carlo object reader for gzipped ASCII formatted file (i....
JMonteCarloStreamObjectOutput(std::ostream &out)
Constructor.
JMonteCarloStreamObjectOutput(std::ostream &out)
Constructor.
Template definition of Monte Carlo stream output for single data type.
const Head & getHeader()
Get Monte Carlo Header.
JMultipleFileScanner()
Default constructor.
JMultipleFileScanner(const JMultipleFileScanner_t &file_list)
Copy constructor.
virtual bool setObject(Head &object) override
Set object.
static bool merge
Allow merging of files w/o header.
virtual void rewind() override
Rewind.
General purpose class for object reading from a list of file names.
virtual void rewind() override
Rewind.
virtual bool hasNext() override
Check availability of next element.
virtual const pointer_type & next() override
Get next element.
JFileScanner< T > scanner
bool write(const Vec &v, std::ostream &os)
Write a Vec(tor) to a stream.
bool is_finalstate(const Trk &track)
Test whether given track corresponds to a final state particle.
bool is_initialstate(const Trk &track)
Test whether given track corresponds to an initial state particle.
void copy(const Head &from, JHead &to)
Copy header from from to to.
std::ostream & operator<<(std::ostream &out, const morphology_type &object)
Write morphology to output stream.
std::istream & operator>>(std::istream &in, morphology_type &object)
Read morphology from input stream.
std::istream & read(std::istream &in, JTestSummary &summary)
Read test summary.
Auxiliary classes and methods for language specific functionality.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Support classes and methods for experiment specific I/O.
JMultiHead getMultiHeader(const JMultipleFileScanner_t &file_list)
Get multi-header corresponding to a given file list.
JMultipleFileScanner_t getAAnetFiles(const JMultipleFileScanner_t &input, JFunction_t test)
Get list of files compatible with geven header.
Head getCommonHeader(const JMultipleFileScanner_t &file_list)
Get common Monte Carlo header.
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
JAANET::JEvtCategorySet getCategories(const JMultipleFileScanner_t &file_list)
Get the unique event categories corresponding to a given list of MC files.
const char *const w3list_t
const char *const weights_t
const char *const eventtime_t
const char *const track_in_t
const char *const start_event_t
const char *const end_event_t
const char *const track_fit_t
const char *const w2list_t
const char *const hit_raw_t
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
std::vector< double > w
MC: Weights w[0]=w1, w[1]=w2, w[2]=w3 (see e.g. Tag list or km3net-dataformat/definitions)
int mc_id
identifier of the MC event (as found in ascii or antcc file).
std::vector< Hit > hits
list of hits
std::vector< Hit > mc_hits
MC: list of MC truth hits.
std::vector< Trk > mc_trks
MC: list of MC truth tracks.
TTimeStamp mc_event_time
MC: true generation time (UTC) of the event, (default: 01 Jan 1970 00:00:00)
std::vector< double > w3list
MC: atmospheric flux information.
std::vector< double > w2list
MC: factors that make up w[1]=w2 (see e.g. Tag list or km3net-dataformat/definitions)
std::vector< Trk > trks
list of reconstructed tracks (can be several because of prefits,showers, etc).
Auxiliary data structure for floating point format specification.
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
Helper class for event categories.
Container for a set of event categories.
Auxiliary data structure to store multiple headers and bookkeep event-weight normalisations.
bool insert(const JHead &header)
Insert the given header.
void merge(const JHead &header)
Merge the given header into this object.
Auxiliary base class for list of file names.
Auxiliary data structure for floating point format specification.