Jpp 20.0.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
dst.cc File Reference

Application for writing DST. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <set>
#include <algorithm>
#include "TROOT.h"
#include "TFile.h"
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/MultiHead.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "km3net-dataformat/online/JDAQEvent.hh"
#include "km3net-dataformat/definitions/reconstruction.hh"
#include "JReconstruction/JEvt.hh"
#include "JReconstruction/JEvtToolkit.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JAAnet/JAAnetToolkit.hh"
#include "JSupport/JTriggeredFileScanner.hh"
#include "JSupport/JMonteCarloFileSupportkit.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JMeta.hh"
#include "Jeep/JStatus.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Macros

#define PRINT_BIT(OUT, A)
 

Functions

int main (int argc, char **argv)
 

Detailed Description

Application for writing DST.

Author
mdejong

Definition in file dst.cc.

Macro Definition Documentation

◆ PRINT_BIT

#define PRINT_BIT ( OUT,
A )
Value:
OUT << (int) A << " -> " << #A << std::endl;

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 72 of file dst.cc.

73{
74 using namespace std;
75 using namespace JPP;
76 using namespace KM3NETDAQ;
77
79
80 typedef JTriggeredFileScanner<JEvt, JMultipleFileScanner> JTriggeredFileScanner_t;
81 typedef JTriggeredFileScanner_t::multi_pointer_type multi_pointer_type;
82
83 JTriggeredFileScanner_t inputFile;
84 JLimit_t& numberOfEvents = inputFile.getLimit();
86 JStatus option;
87 set<int> keep;
88 int debug;
89
90 try {
91
92 JParser<> zap("Application for writing DST.");
93
94 zap['f'] = make_field(inputFile);
95 zap['o'] = make_field(outputFile);
96 zap['n'] = make_field(numberOfEvents) = JLimit::max();
97 zap['O'] = make_field(option, "bit pattern: " << endl << bits_t()) = 0xFF;
98 zap['k'] = make_field(keep, "keep results of selected applications") = JPARSER::initialised();
99 zap['d'] = make_field(debug) = 2;
100
101 zap(argc, argv);
102 }
103 catch(const exception& error) {
104 FATAL(error.what() << endl);
105 }
106
107
108 outputFile.open();
109
110 outputFile.put(JMeta(argc, argv));
111
112 for (JTriggerCounter_t counter = 0; inputFile.hasNext(); counter += 1) {
113
114 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
115
116 multi_pointer_type ps = inputFile.next();
117
118 JEvt* evt = ps;
119 JDAQEvent* tev = ps;
120 Evt* event = ps;
121
122 if (option.has(CLEAR_MC_HITS)) {
123 event->mc_hits.clear();
124 }
125
126 if (option.has(CLEAR_MC_TRKS)) {
127
128 vector<Trk>::iterator __end = partition(event->mc_trks.begin(), event->mc_trks.end(), [](const Trk& trk) { return is_initialstate(trk) || is_muonbundle(trk); });
129
130 if (has_neutrino(*event)) {
131
132 const int id = get_neutrino(*event).id;
133
134 __end = partition(__end, event->mc_trks.end(), [id](const Trk& trk) { return is_lepton(trk) && trk.mother_id == id; });
135 }
136
137 event->mc_trks.erase(__end, event->mc_trks.end());
138 }
139
140 if (option.has(CLEAR_DAQ_HITS)) {
141 *tev = JDAQEvent(tev->getDAQEventHeader());
142 }
143
144 if (option.has(CLEAR_INTERMEDIATE_FITS) ||
145 option.has(CLEAR_ALL_BUT_BEST_FITS)) {
146
147 JEvt::iterator __end = partition(evt->begin(), evt->end(), make_predicate(&JFit::getStatus, (int) COMPLETE_CHAIN, JComparison::eq()));
148
149 if (option.has(CLEAR_ALL_BUT_BEST_FITS) && evt->begin() != __end) {
150 __end = next(evt->begin());
151 }
152
153 if (!keep.empty()) {
154 for (JEvt::iterator i = evt->begin(), __q = __end; i != __q; ++i) {
155 __end = partition(__end, evt->end(), [i, keep](const JFit& fit) { return i->getHistory().match(fit.getHistory()) && keep.count(fit.getHistory().rbegin()->type) != 0; });
156 }
157 }
158
159 evt->erase(__end, evt->end());
160 }
161
162 // Set the event counter to the index of the Monte Carlo event in the output.
163
164 tev->setCounter(counter);
165
166 outputFile.put(*event);
167 outputFile.put(*tev);
168 outputFile.put(*evt);
169 }
170 STATUS(endl);
171
173
174 io >> outputFile;
175
176 outputFile.close();
177}
string outputFile
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define STATUS(A)
Definition JMessage.hh:63
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
int getStatus() const
Get status of the fit; negative values should refer to a bad fit.
Utility class to parse command line options.
Definition JParser.hh:1698
Object writing to file.
General purpose class for object reading from a list of file names.
const JDAQEventHeader & getDAQEventHeader() const
Get DAQ event header.
void setCounter(const JTriggerCounter_t counter)
Set trigger counter.
bool has_neutrino(const Evt &evt)
Test whether given event has an incoming neutrino.
const Trk & get_neutrino(const Evt &evt)
Get incoming neutrino.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
unsigned long long int JTriggerCounter_t
Type definition of trigger counter.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition Evt.hh:21
Acoustic event fit.
Acoustic single fit.
Auxiliary class for handling status.
Definition JStatus.hh:39
bool has(const int bit) const
Test PMT status.
Definition JStatus.hh:120
Type list.
Definition JTypeList.hh:23
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition JParser.hh:68
Auxiliary class for defining the range of iterations of objects.
Definition JLimit.hh:45
const JLimit & getLimit() const
Get limit.
Definition JLimit.hh:84
static counter_type max()
Get maximum counter value.
Definition JLimit.hh:128
Auxiliary class for ROOT I/O of application specific meta data.
Definition JMeta.hh:72
Auxiliary class to synchronously read DAQ events and Monte Carlo events (and optionally other events)...
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Definition Trk.hh:15
int id
track identifier
Definition Trk.hh:16