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 << setw(15) << scientific << setprecision(5);
123 for (
const auto& trk : evt.
mc_trks) {
128 << trk.mother_id <<
' '
140 for (
const auto& trk : evt.
trks) {
149 << trk.status << endl;
167 write(evt, out << fixed);
187 read(hit, in,
false);
204 const ios_base::fmtflags flags = out.flags();
206 write(hit, out << fixed);
234 template<
class T,
template<
class>
class JFileReader_t>
244 template<
template<
class>
class JFileReader_t>
246 public JFileReader_t<Head>
253 JFileReader_t<
Head>(),
263 virtual void open(
const char* file_name)
override
282 return JFileReader_t<Head>::hasNext();
301 template<
template<
class>
class JFileReader_t>
303 public JFileReader_t<Evt>
311 virtual void open(
const char* file_name)
override
317 if (this->is_open()) {
321 static_cast<istream&
>(*this) >> buffer;
462 using namespace JLANG;
468 unsigned int count = 0;
472 for (const_iterator i = this->begin(); i != this->end(); ++i) {
474 scanner.
open(i->c_str());
482 else if (header.
match(buffer))
485 THROW(
JException,
"JMultipleFileScanner<Head>::setObject(): inconsistent headers.");
493 copy(header,
object);
495 if (count != 0 && count != this->size()) {
497 THROW(
JException,
"JMultipleFileScanner<Head>::setObject(): missing header(s): " << count <<
" != " << this->size());
517 const Head* p = NULL;
519 if (!this->hasNext() || (p = this->next()) == NULL) {
563 if (!file_list.empty()) {
569 for (
size_t i = 1; i != file_list.size(); ++i) {
596 for (MultiHead::const_iterator i = p->cbegin(); i != p->cend(); ++i) {
600 multiHeader.
insert(header);
620 template<
class JFunction_t>
627 for (JMultipleFileScanner_t::const_iterator i = input.begin(); i != input.end(); ++i) {
650 for (JMultipleFileScanner_t::const_iterator i = file_list.cbegin(); i != file_list.cend(); ++i) {
655 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.
std::ostream & rewind(std::ostream &out)
Rewind character.
std::istream & operator>>(std::istream &in, Head &header)
Read header from input.
std::ostream & operator<<(std::ostream &out, const MultiHead &header)
Write multi-header to output.
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.
virtual const pointer_type & next()=0
Get next element.
virtual bool hasNext()=0
Check availability of next element.
Abstract object iterator with rewinding.
Template implementation of stream output for single data type.
Object reading from file.
virtual void open(const char *file_name) override
Open 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.
Template specialisation of JMultipleFileScanner for 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.
const Head & getHeader()
Get Monte Carlo Header.
General purpose class for object reading from a list of file names.
virtual bool hasNext() override
Check availability of next element.
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::istream & read(std::istream &in, JTestSummary &summary, const char delimiter=' ')
Read test summary.
T * open(const std::string &file_name)
Open file.
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
std::ostream & operator<<(std::ostream &out, const std::vector< int > &object)
Write std::vector<int> to output.
std::istream & operator>>(std::istream &in, std::vector< int > &object)
Read std::vector<int> from input.
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).
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.
virtual void close() override
Close device.
Auxiliary base class for list of file names.