Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JReconstruction/JDAQFilter.cc
Go to the documentation of this file.
1
2#include <string>
3#include <iostream>
4#include <iomanip>
5#include <set>
6#include <map>
7
10
14
15#include "JDAQ/JDAQEventIO.hh"
17
18#include "JSupport/JMeta.hh"
19#include "JSupport/JSupport.hh"
24
26
30
31#include "Jeep/JParser.hh"
32#include "Jeep/JMessage.hh"
33
34
35/**
36 * \file
37 *
38 * Example program to select events based on hits in strings.
39 * \author mdejong
40 */
41int main(int argc, char **argv)
42{
43 using namespace std;
44 using namespace JPP;
45 using namespace KM3NETDAQ;
46
47 typedef map<int, int> map_type;
48
50
51 typedef JParallelFileScanner< JTypeList<JDAQEvent, JEvt> > JParallelFileScanner_t;
52 typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
53
54 JParallelFileScanner_t inputFile;
55 size_t numberOfEvents;
57 string detectorFile;
58 map_type selector;
59 int debug;
60
61 try {
62
63 JParser<> zap("Example program to select events based on hits in strings.");
64
65 zap['f'] = make_field(inputFile, "input file (output of JXXXReconstruction.sh)");
66 zap['n'] = make_field(numberOfEvents, "maximum number of selected events")
67 = std::numeric_limits<size_t>::max();
68 zap['o'] = make_field(outputFile, "output file name")
69 = "extract.root";
70 zap['a'] = make_field(detectorFile, "detector file.");
71 zap['S'] = make_field(selector, "selection: pairs of <string number> <minimum number of triggered hits>");
72 zap['d'] = make_field(debug) = 2;
73
74 zap['a'] = JPARSER::initialised();
75 zap['S'] = JPARSER::initialised();
76
77 zap(argc, argv);
78 }
79 catch(const exception& error) {
80 FATAL(error.what() << endl);
81 }
82
83
85
86 if (detectorFile != "") {
87
88 try {
89 load(detectorFile, detector);
90 }
91 catch(const JException& error) {
92 FATAL(error);
93 }
94
95 } else if (!selector.empty()) {
96
97 FATAL("Missing detector file.");
98 }
99
100 const JDAQHitRouter router(detector);
101
102
103 map<int, set<int> > buffer;
104
105 outputFile.open();
106
107 outputFile.put(JMeta(argc, argv));
108
109 for (JTreeScanner<Evt> mc(inputFile); inputFile.hasNext(); ) {
110
111 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
112
113 multi_pointer_type ps = inputFile.next();
114
115 JDAQEvent* tev = ps;
116 JEvt* in = ps;
117 Evt* event = NULL;
118
119 if (in->empty()) { continue; }
120
121 if (mc.getEntries() != 0) {
122 event = mc.getEntry(tev->getCounter());
123 }
124
125 bool status = selector.empty();
126
127 if (!status) {
128
129 map_type response;
130
131 typedef JDAQTriggeredHit JHit_t;
132
133 for (JDAQEvent::const_iterator<JHit_t> hit = tev->begin<JHit_t>(); hit != tev->end<JHit_t>(); ++hit) {
134
135 const JPMTChannel& channel = router.getPMTChannel(*hit);
136
137 response[channel.getString()] += 1;
138 }
139
140 for (map_type::const_iterator i = selector.begin(); i != selector.end() && !status; ++i) {
141 status = response[i->first] >= i->second;
142 }
143 }
144
145 if (status) {
146
147 if (event != NULL) {
148 outputFile.put(*event);
149 }
150 outputFile.put(*tev);
151 outputFile.put(*in);
152
153 buffer[tev->getRunNumber()].insert(tev->getFrameIndex());
154 }
155 }
156 STATUS(endl);
157
158
159 for (JMultipleFileScanner<JDAQSummaryslice> in(inputFile); in.hasNext(); ) {
160
161 STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl);
162
163 JDAQSummaryslice* summary = in.next();
164
165 if (buffer[summary->getRunNumber()].count(summary->getFrameIndex())) {
166 outputFile.put(*summary);
167 }
168 }
169 STATUS(endl);
170
171
173
174 io >> outputFile;
175
176 outputFile.close();
177}
Direct access to PMT data in detector data structure for DAQ hits.
string outputFile
Data structure for detector geometry and calibration.
Recording of objects on file according a format that follows from the file name extension.
General purpose messaging.
#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
ROOT I/O of application specific meta data.
Parallel scanning of objects from a single file or multiple files according a format that follows fro...
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
int main(int argc, char **argv)
ROOT TTree parameter settings of various packages.
Simple wrapper around JModuleRouter class for direct addressing of PMT data in detector data structur...
JPMTChannel getPMTChannel(const JDAQKeyHit &hit) const
Get PMT channel.
Detector data structure.
Definition JDetector.hh:96
int getString() const
Get string number.
Definition JLocation.hh:135
Auxiliary class to uniquely identify PMT readout channel.
Data structure for set of track fit results.
General exception.
Definition JException.hh:24
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.
virtual bool hasNext() override
Check availability of next element.
General purpose class for parallel reading of objects from a single file or multiple files.
Template definition for direct access of elements in ROOT TChain.
int getRunNumber() const
Get run number.
int getFrameIndex() const
Get frame index.
Template const_iterator.
Definition JDAQEvent.hh:68
const_iterator< T > end() const
Get end of data.
const_iterator< T > begin() const
Get begin of data.
JTriggerCounter_t getCounter() const
Get trigger counter.
char response[100000]
Definition elog.cc:330
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
std::map< int, range_type > map_type
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition Evt.hh:21
Detector file.
Definition JHead.hh:227
Acoustic event fit.
Auxiliary class for recursive type list generation.
Definition JTypeList.hh:351
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition JParser.hh:68
Auxiliary class to set-up Hit.
Definition JSirene.hh:58
Auxiliary class for ROOT I/O of application specific meta data.
Definition JMeta.hh:72