Jpp 20.0.0-rc.6
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 "JLang/JStatus.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/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 73 of file dst.cc.

74{
75 using namespace std;
76 using namespace JPP;
77 using namespace KM3NETDAQ;
78
80
81 typedef JTriggeredFileScanner<JEvt, JMultipleFileScanner> JTriggeredFileScanner_t;
82 typedef JTriggeredFileScanner_t::multi_pointer_type multi_pointer_type;
83
84 JTriggeredFileScanner_t inputFile;
85 JLimit_t& numberOfEvents = inputFile.getLimit();
87 JStatus option;
88 set<int> keep;
89 int debug;
90
91 try {
92
93 JParser<> zap("Application for writing DST.");
94
95 zap['f'] = make_field(inputFile);
96 zap['o'] = make_field(outputFile);
97 zap['n'] = make_field(numberOfEvents) = JLimit::max();
98 zap['O'] = make_field(option, "bit pattern: " << endl << bits_t()) = 0xFF;
99 zap['k'] = make_field(keep, "keep results of selected applications") = JPARSER::initialised();
100 zap['d'] = make_field(debug) = 2;
101
102 zap(argc, argv);
103 }
104 catch(const exception& error) {
105 FATAL(error.what() << endl);
106 }
107
108
109 outputFile.open();
110
111 outputFile.put(JMeta(argc, argv));
112
113 for (JTriggerCounter_t counter = 0; inputFile.hasNext(); counter += 1) {
114
115 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
116
117 multi_pointer_type ps = inputFile.next();
118
119 JEvt* evt = ps;
120 JDAQEvent* tev = ps;
121 Evt* event = ps;
122
123 if (option.has(CLEAR_MC_HITS)) {
124 event->mc_hits.clear();
125 }
126
127 if (option.has(CLEAR_MC_TRKS)) {
128
129 vector<Trk>::iterator __end = partition(event->mc_trks.begin(), event->mc_trks.end(), [](const Trk& trk) { return is_initialstate(trk) || is_muonbundle(trk); });
130
131 if (has_neutrino(*event)) {
132
133 const int id = get_neutrino(*event).id;
134
135 __end = partition(__end, event->mc_trks.end(), [id](const Trk& trk) { return is_lepton(trk) && trk.mother_id == id; });
136 }
137
138 event->mc_trks.erase(__end, event->mc_trks.end());
139 }
140
141 if (option.has(CLEAR_DAQ_HITS)) {
142 *tev = JDAQEvent(tev->getDAQEventHeader());
143 }
144
145 if (option.has(CLEAR_INTERMEDIATE_FITS) ||
146 option.has(CLEAR_ALL_BUT_BEST_FITS)) {
147
148 JEvt::iterator __end = partition(evt->begin(), evt->end(), make_predicate(&JFit::getStatus, (int) COMPLETE_CHAIN, JComparison::eq()));
149
150 if (option.has(CLEAR_ALL_BUT_BEST_FITS) && evt->begin() != __end) {
151 __end = next(evt->begin());
152 }
153
154 if (!keep.empty()) {
155 for (JEvt::iterator i = evt->begin(), __q = __end; i != __q; ++i) {
156 __end = partition(__end, evt->end(), [i, keep](const JFit& fit) { return i->getHistory().match(fit.getHistory()) && keep.count(fit.getHistory().rbegin()->type) != 0; });
157 }
158 }
159
160 evt->erase(__end, evt->end());
161 }
162
163 // Set the event counter to the index of the Monte Carlo event in the output.
164
165 tev->setCounter(counter);
166
167 outputFile.put(*event);
168 outputFile.put(*tev);
169 outputFile.put(*evt);
170 }
171 STATUS(endl);
172
174
175 io >> outputFile;
176
177 outputFile.close();
178}
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:31
bool has(const int bit) const
Test PMT status.
Definition JStatus.hh:198
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