68{
72
76
79 JLimit_t& numberOfEvents = inputFile.getLimit();
80 string detectorFile;
81 JCalibration_t calibrationFile;
82 double Tmax_s;
85 size_t numberOfFits;
87
88 try {
89
90 JParser<> zap(
"Auxiliary program to convert fit results to Evt format.\
91 \nThe option -L corresponds to the name of a shared library \
92 \nand function so to rearrange the order of fit results.");
93
104
105 zap(argc, argv);
106 }
107 catch(const exception& error) {
108 FATAL(error.what() << endl);
109 }
110
111 if (detectorFile == "" && !calibrationFile.empty()) {
112 FATAL(
"Missing detector file." << endl);
113 }
114
116 typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
117
119
120 if (detectorFile != "") {
121 try {
123 }
126 }
127 }
128
129 unique_ptr<JDynamics> dynamics;
130
131 if (!calibrationFile.empty()) {
132
133 try {
134
136
137 dynamics->load(calibrationFile);
138 }
139 catch(const exception& error) {
141 }
142 }
143
144
147
148
150
152
153 try {
155 } catch(const exception& error) {}
156
158
159
160
162
163 buffer.DAQ.livetime_s =
getLivetime(inputFile.begin(), inputFile.end());
165
166 copy(buffer, header);
167 }
168
169 if (detectorFile != "") {
170
173
174 copy(buffer, header);
175 }
176
177
179
180
182
185
187
189
190 STATUS(
"Processing: " << *i << endl);
191
192 JParallelFileScanner_t in(*i);
194
195 in.setLimit(inputFile.getLimit());
196
198
199 int mc_run_id = 0;
200
201 try {
202
204
206 mc_run_id = head.start_run.run_id;
207
208 } catch(const exception& error) {}
209
210
211 while (in.hasNext()) {
212
213 STATUS(
"event: " << setw(10) << in.getCounter() <<
'\r');
DEBUG(endl);
214
215 multi_pointer_type ps = in.next();
216
219
220 if (dynamics) {
221 dynamics->update(*tev);
222 }
223
224 JFIT::JEvt::iterator __end = evt->end();
225
226 if (numberOfFits > 0) {
227 advance(__end = evt->begin(), min(numberOfFits, evt->size()));
228 }
229
231 partial_sort(evt->begin(), __end, evt->end(),
qualitySorter);
232 }
233
235
236 if (mc.getEntries() != 0) {
237
239
240 if (event != NULL) {
241
242 out = *event;
243
246 }
247
249 i->pos += offset;
250 }
251 }
252 }
253
255
256 if (!pmt_router->empty()) {
257
259
260 if (pmt_router.hasPMT(i->pmt_id)) {
261
262 const JPMTAddress address = pmt_router.getAddress(i->pmt_id);
264 const JPMT& pmt = pmt_router.getPMT(address);
265
266 i->dom_id =
id.
getID();
267 i->channel_id = id.getPMTAddress();
270
271 } else {
272
273 miss_pmt[i->pmt_id] += 1;
274 }
275 }
276 }
277
278 if (!mod_router->empty()) {
279
281
282 if (mod_router.hasModule(i->dom_id)) {
283
285
288
289 const JPMT& pmt = mod_router.getPMT(
id);
290
292
294
295 i->pmt_id = pmt.
getID();
298 i->t = hit.getT();
299 i->tot = hit.getToT();
300 i->a = cpu.getNPE(i->tot);
301
302 } else {
303
304 miss_mod[i->dom_id] += 1;
305 }
306 }
307 }
308
309 copy(evt->cbegin(), __end, out);
310
311 out.
id = ++number_of_events;
312
314 }
315 }
316
318
319 for (
const auto& i : miss_pmt) {
ERROR(
"Misses PMT " << setw(8) << i.first <<
' ' << setw(8) << i.second << endl); }
320 for (
const auto& i : miss_mod) {
ERROR(
"Misses module " << setw(8) << i.first <<
' ' << setw(8) << i.second << endl); }
321
323
325
327}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
JAANET::calibration calibration
const JCalibration & getCalibration() const
Get calibration.
Router for direct addressing of module data in detector data structure.
Address of PMT in detector data structure.
Auxiliary class for map of PMT parameters.
const JPMTParameters & getPMTParameters(const JPMTIdentifier &id) const
Get PMT parameters.
Data structure for PMT parameters.
bool slewing
time slewing of analogue signal
Router for direct addressing of PMT data in detector data structure.
Data structure for PMT geometry, calibration and status.
Data structure for set of track fit results.
int getID() const
Get identifier.
Utility class to parse command line options.
General purpose class for object reading from a list of file names.
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.
static void setSlewing(const bool slewing)
Set slewing option.
JTriggerCounter_t getCounter() const
Get trigger counter.
JDirection3D getDirection(const Vec &dir)
Get direction.
void copy(const Head &from, JHead &to)
Copy header from from to to.
JPosition3D getPosition(const Vec &pos)
Get position.
Vec getOffset(const JHead &header)
Get offset.
std::istream & read(std::istream &in, JTestSummary &summary)
Read test summary.
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).
bool qualitySorter(const JFit &first, const JFit &second)
Comparison of fit results.
counter_type advance(counter_type &counter, const counter_type value, const counter_type limit=std::numeric_limits< counter_type >::max())
Advance counter.
Long64_t counter_type
Type definition for counter.
double getLivetime(const std::string &file_name)
Get data taking live time.
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
const char * getTime()
Get current local time conform ISO-8601 standard.
KM3NeT DAQ data structures and auxiliaries.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
std::vector< Hit > hits
list of hits
int mc_run_id
MC run identifier.
std::vector< Hit > mc_hits
MC: list of MC truth hits.
std::vector< Trk > mc_trks
MC: list of MC truth tracks.
int id
offline event identifier
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
static const std::string dynamical()
PMT analogue signal processor.
Dynamic detector calibration.
Auxiliary class for recursive type list generation.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
General purpose sorter of fit results.
Auxiliary class for defining the range of iterations of objects.
static counter_type max()
Get maximum counter value.
The Vec class is a straightforward 3-d vector, which also works in pyroot.