1 #ifndef __JSUPPORT__JMONTECARLOFILESUPPORTKIT__
2 #define __JSUPPORT__JMONTECARLOFILESUPPORTKIT__
77 for (MultiHead::const_iterator
i = header.begin();
i != header.end(); ++
i) {
114 const ios_base::fmtflags flags = out.flags();
116 out << setw(15) << scientific << setprecision(5);
122 for (
const auto& trk : evt.
mc_trks) {
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);
130 << trk.mother_id <<
' '
143 for (
const auto& trk : evt.
trks) {
152 << trk.status << endl;
170 write(evt, out << fixed);
190 read(hit, in,
false);
207 const ios_base::fmtflags flags = out.flags();
209 write(hit, out << fixed);
217 namespace JSUPPORT {}
218 namespace JPP {
using namespace JSUPPORT; }
236 template<
class T,
template<
class>
class JFileReader_t>
246 template<
template<
class>
class JFileReader_t>
248 public JFileReader_t<Head>
255 JFileReader_t<
Head>(),
265 virtual void open(
const char* file_name)
override
284 return JFileReader_t<Head>::hasNext();
303 template<
template<
class>
class JFileReader_t>
305 public JFileReader_t<Evt>
313 virtual void open(
const char* file_name)
override
319 if (this->is_open()) {
323 static_cast<istream&
>(*this) >> buffer;
464 using namespace JLANG;
470 unsigned int count = 0;
474 for (const_iterator
i = this->begin();
i != this->end(); ++
i) {
476 scanner.
open(
i->c_str());
478 if (scanner.hasNext()) {
480 const JHead buffer = *scanner.next();
484 else if (header.match(buffer))
487 THROW(
JException,
"JMultipleFileScanner<Head>::setObject(): inconsistent headers.");
495 copy(header,
object);
499 THROW(
JException,
"JMultipleFileScanner<Head>::setObject(): missing header(s): " <<
count <<
" != " << this->size());
519 const Head* p = NULL;
521 if (!this->hasNext() || (p = this->next()) == NULL) {
565 if (!file_list.empty()) {
571 for (
size_t i = 1;
i != file_list.size(); ++
i) {
598 for (MultiHead::const_iterator
i = p->cbegin();
i != p->cend(); ++
i) {
602 multiHeader.insert(header);
622 template<
class JFunction_t>
629 for (JMultipleFileScanner_t::const_iterator
i = input.begin();
i != input.end(); ++
i) {
JMultipleFileScanner(const JMultipleFileScanner_t &file_list)
Copy constructor.
Object reading from ASCII file.
virtual void rewind() override
Rewind.
virtual bool hasNext() override
Check availability of next element.
const char *const w2list_t
std::istream & operator>>(std::istream &in, std::vector< int > &object)
Read std::vector<int> from input.
std::istream & read(std::istream &in, JTestSummary &summary, const char delimiter= ' ')
Read test summary.
const char *const weights_t
Auxiliary data structure to store multiple headers and bookkeep event-weight normalisations.
Head getCommonHeader(const JMultipleFileScanner_t &file_list)
Get common Monte Carlo header.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
const char *const w3list_t
then usage $script< input file >[option] nPossible options count
std::vector< double > w
MC: Weights w[0]=w1, w[1]=w2, w[2]=w3 (see e.g. Tag list or km3net-dataformat/definitions) ...
JMonteCarloFileReader()
Default constructor.
JMonteCarloStreamObjectOutput(std::ostream &out)
Constructor.
const char *const track_fit_t
Template definition of Monte Carlo object reader for gzipped ASCII formatted file (i...
static bool merge
Allow merging of files w/o header.
T * open(const std::string &file_name)
Open file.
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
bool is_finalstate(const Trk &track)
Test whether given track corresponds to a final state particle.
Template definition of Monte Carlo object reader for ASCII formatted file (i.e. '.evt')
std::ostream & rewind(std::ostream &out)
Rewind character.
virtual void open(const char *file_name) override
Open file.
JMonteCarloStreamObjectOutput(std::ostream &out)
Constructor.
const char *const eventtime_t
Exception for null pointer operation.
void createUUID()
Create UUID if not already set.
int mc_id
identifier of the MC event (as found in ascii or antcc file).
JMultiHead getMultiHeader(const JMultipleFileScanner_t &file_list)
Get multi-header corresponding to a given file list.
JHead getMatch(const JHead &header) const
Get matching fields.
TTimeStamp mc_event_time
MC: true generation time (UTC) of the event, (default: 01 Jan 1970 00:00:00)
bool getLongprint(std::ostream &out)
Get long print option.
const Head & getHeader()
Get Monte Carlo Header.
virtual bool setObject(Head &object) override
Set object.
JMultipleFileScanner()
Default constructor.
virtual void open(const char *file_name) override
Open file.
JHead & add(const JHead &header)
Addition of headers.
bool is_initialstate(const Trk &track)
Test whether given track corresponds to an initial state particle.
Template specialisation of JMultipleFileScanner for Monte Carlo header.
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
Scanning of objects from multiple files according a format that follows from the extension of each fi...
const char *const track_in_t
Template definition of Monte Carlo object reader.
Auxiliary base class for list of file names.
std::istream & operator>>(std::istream &in, JAANET::JHead &header)
Read header from input.
std::ostream & operator<<(std::ostream &out, const std::vector< int > &object)
Write std::vector<int> to output.
std::vector< Trk > trks
list of reconstructed tracks (can be several because of prefits,showers, etc).
General purpose class for object reading from a list of file names.
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
bool write(const Vec &v, std::ostream &os)
Write a Vec(tor) to a stream.
std::vector< Hit > mc_hits
MC: list of MC truth hits.
Object reading from gzipped file.
Template implementation of stream output for single data type.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Object reading from file.
virtual void open(const char *file_name) override
Open file.
JMultipleFileScanner_t getAAnetFiles(const JMultipleFileScanner_t &input, JFunction_t test)
Get list of files compatible with geven header.
Abstract object iterator with rewinding.
const char *const end_event_t
std::vector< Hit > hits
list of hits
const char *const hit_raw_t
const char *const start_event_t
std::vector< double > w2list
MC: factors that make up w[1]=w2 (see e.g. Tag list or km3net-dataformat/definitions) ...
std::vector< Trk > mc_trks
MC: list of MC truth tracks.
std::vector< double > w3list
MC: atmospheric flux information.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Template definition of Monte Carlo stream output for single data type.