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

Program to extract events. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include "km3net-dataformat/definitions/reconstruction.hh"
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JDAQ/JDAQSummarysliceIO.hh"
#include "JSupport/JMeta.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JTreeScanner.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JParallelFileScanner.hh"
#include "JSupport/JMonteCarloFileSupportkit.hh"
#include "JTrigger/JTriggerParameters.hh"
#include "JReconstruction/JEvt.hh"
#include "JReconstruction/JEvtToolkit.hh"
#include "JReconstruction/JEventSelector.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Program to extract events.

Author
bjjung

Definition in file JSelectEvt.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 39 of file JSelectEvt.cc.

40 {
41  using namespace std;
42  using namespace JPP;
43  using namespace KM3NETDAQ;
44 
46 
47  typedef JParallelFileScanner< JTypeList<JDAQEvent, JEvt> > JParallelFileScanner_t;
48  typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
49 
50  JParallelFileScanner_t inputFile;
51  size_t numberOfEvents;
53  int application;
54  JEventSelector event_selector;
55  int debug;
56 
57 
58  try {
59 
60  JParser<> zap("Program to extract events.");
61 
62  zap['f'] = make_field(inputFile, "input file (output of JXXXReconstruction.sh)");
63  zap['n'] = make_field(numberOfEvents, "maximum number of selected events")
64  = std::numeric_limits<size_t>::max();
65  zap['o'] = make_field(outputFile, "output file name")
66  = "extract.root";
67  zap['A'] = make_field(application)
69  zap['L'] = make_field(event_selector)
71  zap['d'] = make_field(debug)
72  = 1;
73 
74  zap(argc, argv);
75  }
76  catch(const exception& error) {
77  FATAL(error.what() << endl);
78  }
79 
80 
81  outputFile.open();
82  outputFile.put(JMeta(argc, argv));
83 
84 
85  // Select events
86 
87  size_t N = 0;
88 
89  for (JTreeScanner<Evt> mc(inputFile); inputFile.hasNext() && N < numberOfEvents; ) {
90 
91  cout << "\revent: " << setw(8) << inputFile.getCounter() << flush;
92 
93  multi_pointer_type ps = inputFile.next();
94 
95  JDAQEvent* tev = ps;
96  JEvt* in = ps;
97  Evt* event = NULL;
98 
99  in->select(JHistory::is_event(application));
100 
101  if (in->empty()) { continue; }
102 
103  sort(in->begin(), in->end(), qualitySorter);
104 
105  if (mc.getEntries() != 0) {
106  event = mc.getEntry(tev->getCounter());
107  }
108 
109  if (!event_selector(*tev, *in, event)) {
110  continue;
111  }
112 
113  outputFile.put(*tev);
114  outputFile.put(*in);
115 
116  if (event != NULL) {
117  outputFile.put(*event);
118  }
119 
120  ++N;
121  }
122 
123 
124  // Copy header
125 
126  JHead header = getHeader(inputFile.getFilename());
127  header.createUUID(); // Ensure UUID is set
128 
129  Head head;
130  copy(header, head);
131 
132  outputFile.put(head);
133 
134 
135  // Copy rest
136 
138 
139  io >> outputFile;
140 
141  outputFile.close();
142 
143  return 0;
144 }
static const int JMUONSTART
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
General purpose class for parallel reading of objects from a single file or multiple files...
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:83
string outputFile
static const int JSHOWERENERGYPREFIT
bool qualitySorter(const JFit &first, const JFit &second)
Comparison of fit results.
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
Acoustic event fit.
Monte Carlo run header.
Definition: JHead.hh:1234
Auxiliary class for recursive type list generation.
Definition: JTypeList.hh:351
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
Auxiliary class to test history.
Definition: JHistory.hh:105
static const int JMUONGANDALF
static const int JSHOWERDIRECTIONPREFIT
static const int JSHOWERCOMPLETEFIT
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
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
Definition: JMuonPostfit.sh:40
Data structure for set of track fit results.
General purpose class for object reading from a list of file names.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:162
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] 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:46
JTriggerCounter_t getCounter() const
Get trigger counter.
static const int JMUONENERGY
int debug
debug level
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:20