Jpp  18.3.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JMergeEvt.cc File Reference

Application for merging Monte-Carlo files. More...

#include <uuid/uuid.h>
#include <iostream>
#include <iomanip>
#include <string>
#include "km3net-dataformat/definitions/weightlist.hh"
#include "km3net-dataformat/offline/MultiHead.hh"
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JDAQ/JDAQTimesliceIO.hh"
#include "JDAQ/JDAQSummarysliceIO.hh"
#include "JTrigger/JTriggerParameters.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
#include "JAAnet/JHead.hh"
#include "JAAnet/JMultiHead.hh"
#include "JReconstruction/JEvt.hh"
#include "JSupport/JMeta.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JEvtWeightFileScannerSet.hh"
#include "JSupport/JMonteCarloFileSupportkit.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Application for merging Monte-Carlo files.

Author
bjung

Definition in file JMergeEvt.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 41 of file JMergeEvt.cc.

42 {
43  using namespace std;
44  using namespace JPP;
45  using namespace KM3NETDAQ;
46 
48 
49 
50  JMultipleFileScanner_t inputFiles;
52 
53  int debug;
54 
55  try {
56 
57  JParser<> zap;
58 
59  zap['f'] = make_field(inputFiles);
60  zap['o'] = make_field(outputFile) = "merged.root";
61  zap['d'] = make_field(debug) = 1;
62 
63  zap(argc, argv);
64  }
65  catch(const exception& error) {
66  FATAL(error.what() << endl);
67  }
68 
69 
70  outputFile.open();
71 
72  outputFile.put(JMeta(argc, argv));
73 
74  // Create set of filescanners ordered based on header-info
75 
76  JEvtWeightFileScannerSet<> scanners(inputFiles);
77 
78  JHead commonHeader = scanners.begin()->getHeader();
79 
80  // Merge multi-headers
81 
82  JMultiHead eventHeaders = getMultiHeader(inputFiles);
83 
84  for (JEvtWeightFileScannerSet<>::iterator scanner = scanners.begin(); scanner != scanners.end(); ++scanner) {
85 
86  JHead header = scanner->getHeader();
87  header.createUUID(); // Ensure UUID is set
88 
89  commonHeader = commonHeader.getMatch(header);
90 
91  eventHeaders.merge(header);
92 
93  // Add event-weight normalisations
94 
95  while (scanner->hasNext()) {
96 
97  STATUS("Event:" << RIGHT(10) << scanner->getCounter() << '\r'); DEBUG(endl);
98 
99  const Evt* event = scanner->next();
100 
101  Evt out = *event;
102 
103  // Update event-weight normalisation
104 
105  if (out.w.size() <= WEIGHTLIST_NORMALISATION) {
106  out.w.resize(WEIGHTLIST_NORMALISATION + 1, 0.0);
107  }
108 
109  const JUUID headerUUID = (uuid_is_null(event->header_uuid) == 0 ? // is valid
110  eventHeaders.getHeaderUUID(*event) : header.UUID);
111 
112  out.w[WEIGHTLIST_NORMALISATION] = eventHeaders.getNormalisation(headerUUID);
113 
114  uuid_copy(out.header_uuid, headerUUID.uuid);
115 
116  outputFile.put(out);
117  }
118  }
119 
120  Head newHead;
121  copy(commonHeader, newHead);
122 
123  outputFile.put(newHead);
124 
125  outputFile.put(static_cast<const MultiHead&>(eventHeaders));
126 
128 
129  io >> outputFile;
130 
131  outputFile.close();
132 
133  return 0;
134 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:70
Object writing to file.
Utility class to parse command line options.
Definition: JParser.hh:1514
Auxiliary data structure to store multiple headers and bookkeep event-weight normalisations.
Definition: JMultiHead.hh:37
#define STATUS(A)
Definition: JMessage.hh:63
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
string outputFile
Monte Carlo run header.
Definition: JHead.hh:1234
uuid_t header_uuid
UUID of header containing the event-weight information.
Definition: Evt.hh:35
JUUID UUID
Definition: JHead.hh:1581
Auxiliary class for recursive type list generation.
Definition: JTypeList.hh:351
void createUUID()
Create UUID if not already set.
Definition: JHead.hh:1301
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
JMultiHead getMultiHeader(const JMultipleFileScanner_t &file_list)
Get multi-header corresponding to a given file list.
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
Definition: Head.hh:65
#define FATAL(A)
Definition: JMessage.hh:67
Auxiliary base class for list of file names.
std::vector< filescanner_type >::iterator iterator
Data structure for set of track fit results.
General purpose class for object reading from a list of file names.
Simple wrapper for UUID.
Definition: JUUID.hh:22
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:162
static const int WEIGHTLIST_NORMALISATION
Event rate normalisation.
Definition: weightlist.hh:16
const JHead & getHeader() const
Get header.
Definition: JHead.hh:1270
Auxiliary class for organising Monte Carlo file scanners associated with event weighters.
uuid_t uuid
Definition: JUUID.hh:172
int debug
debug level
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:20
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62