Jpp 19.3.0-rc.4
the software that should make you happy
Loading...
Searching...
No Matches
JSupernovaProcessor.cc
Go to the documentation of this file.
1#include <iostream>
2#include <iomanip>
3#include <queue>
4#include <string>
5
6#include "nlohmann/json.hpp"
7
9#include "JDAQ/JDAQEventIO.hh"
11#include "JDAQ/JDAQTags.hh"
12#include "JDAQ/JDAQEvaluator.hh"
13
16
18#include "JNet/JControlHost.hh"
19
21
22#include "Jeep/JParser.hh"
23#include "Jeep/JMessage.hh"
24#include "Jeep/JProperties.hh"
25
27
29
30#include "JSupport/JSupport.hh"
31#include "JMath/JRandom.hh"
33
34#include "JSupernova.hh"
35
37
38using json = nlohmann::json;
39
40/**
41 * \file
42 *
43 * Online supernova processor
44 * \author mlincett,selhedri,iagoos,gvannoye
45 */
46int main(int argc, char* argv[]) {
47 using namespace std;
48 using namespace JPP;
49 using namespace KM3NETDAQ;
50
51 string inputLigier;
52 string ligierFireDrill;
53 string inputFileName;
54 string outputLigier;
55 JTag outputTag, tagFireDrill;
56 string outputFileName;
57 int nEntries;
58 int debug;
59
60 string detectorFile;
61 string domDetectorFile;
62
63 JTimeval timeout_us = JTimeval(1e6); // timeout for input [us]
64 int numberOfTimeouts = 1e3; // number of timeouts before stop
65 int queueLength = 100; // number of timeslices of trigger queue
66 int windowLength = 5; // number of timeslices of trigger sliding window
67
68 int TMax_ns = 10; // coincidence time window [ns]
69 int preTriggerThreshold = 4; // muon veto multiplicity threshold
70 JDAQHitToTSelector totSelector_ns = JDAQHitToTSelector(4, 255); // hit selector
71 double TVeto_ns = 1000; // muon veto time interval [ns]
72 JRange<int> M = JRange<int>(6, 10); // multiplicity range for SN coincidence level
73 JRange<int> M_BDT = JRange<int>(6, 10); // multiplicity range for SN coincidence level (with BDT)
74
75 string summaryFile = ""; // summary output file
76 int statPrintInterval_s = 30; // statistics & file print interval [s]
77
78 try {
79
80 JProperties properties;
81 string properties_description = "\n";
82
83 properties.setEndOfLine(";");
84
85 properties.insert(gmake_property(timeout_us));
86 properties_description.append("\ttimeout_us: timeout for input [us]\n");
87 properties.insert(gmake_property(numberOfTimeouts));
88 properties_description.append("\tnumberOfTimeouts: number of timeouts before stop\n");
89 properties.insert(gmake_property(queueLength));
90 properties_description.append("\tqueueLength: number of timeslices of trigger queue\n");
91 properties.insert(gmake_property(windowLength));
92 properties_description.append("\twindowLength: number of timeslices of trigger sliding window\n");
93
94 properties.insert(gmake_property(TMax_ns));
95 properties_description.append("\tTMax_ns: coincidence time window [ns]\n");
96 properties.insert(gmake_property(preTriggerThreshold));
97 properties_description.append("\tpreTriggerThreshold: muon veto multiplicity threshold\n");
98 properties.insert(gmake_property(totSelector_ns));
99 properties_description.append("\ttotSelector_ns: hit selector\n");
100 properties.insert(gmake_property(TVeto_ns));
101 properties_description.append("\tTVeto_ns: muon veto time interval [ns]\n");
102 properties.insert(gmake_property(M));
103 properties_description.append("\tM: multiplicity range for SN coincidence level\n");
104 properties.insert(gmake_property(M_BDT));
105 properties_description.append("\tM_BDT: multiplicity range for SN coincidence level (with BDT)\n");
106
107 properties.insert(gmake_property(summaryFile));
108 properties_description.append("\tsummaryFile: summary output file\n");
109 properties.insert(gmake_property(statPrintInterval_s));
110 properties_description.append("\tstatPrintInterval_s: statistics & file print interval [s]");
111
112 JParser<> zap("Supernova realtime processor");
113
114 zap['H'] = make_field(inputLigier, "Input Ligier server") = "";
115 zap['l'] = make_field(ligierFireDrill, "Ligier server for the fire drill") = "";
116 zap['g'] = make_field(tagFireDrill, "Ligier tag for the fire drill") = JTag("FDRILL");
117 zap['f'] = make_field(inputFileName) = "";
118 zap['L'] = make_field(outputLigier, "Output Ligier server") = "";
119 zap['T'] = make_field(outputTag, "Output tag for the json messages") = JTag();
120 zap['o'] = make_field(outputFileName, "Output json file name (no output to Ligier)") = "";
121 zap['n'] = make_field(nEntries, "Number of entries to write") = -1;
122 zap['a'] = make_field(detectorFile);
123 zap['b'] = make_field(domDetectorFile) = "";
124 zap['d'] = make_field(debug) = 1;
125 zap['@'] = make_field(properties, properties_description) = JPARSER::initialised();
126
127 zap(argc, argv);
128
129 }
130
131 catch(const exception &error) {
132 FATAL(error.what() << endl);
133 }
134
135 if (queueLength <= windowLength) {
136 FATAL("Length of the trigger window must be smaller than the queue.");
137 }
138
139
141
142 using namespace JSUPERNOVA;
143
144 // -------------------------------
145 // load detector and build routers
146 // -------------------------------
147
149 JDetector domDetector;
150
151 try {
152 load(detectorFile, detector);
153 }
154 catch(const JException& error) {
155 FATAL(error);
156 }
157
158 try {
159 load(domDetectorFile, domDetector);
160 }
161 catch(const JException& error) {
162 domDetector = JDetector();
163 }
164
165 const JDAQHitRouter hitRouter(detector);
166
167 const JModuleRouter& moduleRouter = hitRouter;
168
169 const int DETID = detector.getID();
170
171 const int detectorSize = detector.size();
172
173 JSNFilterM F_M1(M, 1);
174
175 // -------------------------------
176 // initialize processing queue
177 // -------------------------------
178
179 typedef JTriggerSN trigger_type;
180
181 typedef priority_queue<trigger_type, vector<trigger_type>, greater<trigger_type> > queue_type;
182
183 typedef deque<trigger_type> window_type;
184
185
186
187 typedef map<int, map<int, double> > rates_type; // (frameindex, DOMID) -> DOM rate [kHz]
188 typedef map<int, int> npmt_type ; // (frameindex) -> # active PMTs
189 typedef map<int, JVetoSet> veto_type ; // (frameindex) -> vetoes
190
191 queue_type trgQueue;
192 window_type trgWindow;
193 rates_type rates;
194 npmt_type pmts;
195 veto_type veto;
197
198 JTriggerSNStats stats(detectorSize);
199
200 long int counter_live_ts = 0;
201 long int counter_lost_ts = 0;
202
203 double frameTime_s = getFrameTime() / 1.0e9;
204
205 // Initialize output file name and number of entries for testing
206 ofstream outputFile;
207 int nWrittenEntries = 0;
208 if (outputFileName != ""){
209 outputFile.open(outputFileName);
210 }
211
212 // -------------------------------
213 // main processing
214 // -------------------------------
215
216 try {
217
218 // setup input
219
221 typedef JDAQSummaryslice summary_type;
222 typedef JDAQEvent event_type;
223
227
228 if (inputFileName != "") {
229 in = new JTreeScanner<data_type, JDAQEvaluator>(inputFileName);
230 sm = new JTreeScanner<summary_type, JDAQEvaluator>(inputFileName);
231 ev = new JTreeScanner<event_type, JDAQEvaluator>(inputFileName);
232
233 }
234 else if (inputLigier != "") {
235 in = new JControlHostObjectIterator<data_type>(inputLigier, timeout_us, true);
236
237 // timeout for the asynchronous reading of summary and event data
238 // needs to be smaller than the timeslice duration
239 const double asyncTimeout_us = 1000.0;
240
241 sm = new JControlHostObjectIterator<summary_type>(inputLigier, asyncTimeout_us, true);
242 ev = new JControlHostObjectIterator<event_type>(inputLigier, asyncTimeout_us, true);
243 }
244 else { FATAL("Need either a root file or a ligier as input!" << endl); }
245
246 JControlHost* out = NULL;
247 if (outputLigier != "") {
248 out = new JControlHost(outputLigier);
249 }
250
251 JControlHost fireDrill(ligierFireDrill);
252
253 if (ligierFireDrill != "") {
254 JSubscriptionList buffer;
255 buffer.add(JSubscriptionAll(tagFireDrill));
256
257 fireDrill.MyId("JGetMessage");
258 fireDrill.Subscribe(buffer);
259 fireDrill.SendMeAlways();
260 }
261
262 ofstream outputFile;
263 if (outputFileName != "") {
264 outputFile.open(outputFileName);
265 }
266
267 // setup state
268
269 int RUN = 0;
270 int timesliceSize = 0;
271
272 // Fire drill variables
273 int startedFireDrill = false;
274 vector<char> fireDrillFile;
275 JPrefix prefix;
276 ifstream fireDrillData;
277 int fireDrillTimeslice = 0;
278 double fireDrillOffsetTime, timeFireDrill, MultFireDrill, RFireDrill, CThetaFireDrill, TotalToTFireDrill, DeltaTFireDrill;
279 int timeSinceLastFireDrill = 10000;
280
281 for (int i = 0; i != numberOfTimeouts; ) {
282
283 if (in->hasNext()) {
284
285 data_type* timeslice = in->next();
286
287 DEBUG(timeslice->getDAQHeader() << endl);
288
289 timesliceSize = timeslice->size();
290
291 // --------------------------------
292 // run number initialise and update
293 // --------------------------------
294
295 const int r = timeslice->getRunNumber();
296
297 if (r != RUN) {
298
299 if (RUN != 0) {
300
301 NOTICE("RUN CHANGE" << endl);
302
303 while (trgQueue.size() > 0) { trgQueue.pop(); }
304
305 trgWindow.clear();
306
307 rates.clear();
308
309 pmts.clear();
310
311 veto.clear();
312
313 }
314
315 RUN = r;
316
317 }
318
319 // ------------------------------
320 // process pending summary slices
321 // ------------------------------
322
323 while ( sm->hasNext() ) {
324
325 JDAQSummaryslice* summary = sm->next();
326
327 DEBUG("SUM " << summary->getDAQHeader() << endl);
328
329 int frame_index = summary->getFrameIndex();
330
331 for (JDAQSummaryslice::const_iterator summary_frame = summary->begin();
332 summary_frame != summary->end();
333 ++summary_frame) {
334
335 int DOMID = summary_frame->getModuleID();
336
337 for (int ipmt = 0 ; ipmt < NUMBER_OF_PMTS ; ipmt++) {
338 rates[frame_index][DOMID] += summary_frame->getRate(ipmt, 1.0/1000);
339 }
340
341 doms[frame_index].push_back(DOMID);
342
343 pmts[frame_index] += summary_frame->countActiveChannels();
344 }
345
346 }
347
348 while ( ev->hasNext() ) {
349
350 JDAQEvent* event = ev->next();
351
352 DEBUG("EVT " << event->getDAQHeader() << endl);
353
354 int frame_index = event->getFrameIndex();
355
356 veto[frame_index].push_back(JVeto(*event, hitRouter));
357
358 }
359
360 // -----------------
361 // process timeslice
362 // -----------------
363
364 JDataSN preTrigger(TMax_ns, preTriggerThreshold);
365
366 preTrigger(timeslice, moduleRouter, totSelector_ns, domDetector);
367
368 JTriggerSN trigger(TVeto_ns);
369
370 trigger(preTrigger);
371
372 JTriggerSN trigger_final(TVeto_ns);
373 trigger_final.frameIndex = trigger.frameIndex;
374 trigger_final.timeUTC = trigger.timeUTC;
375
376 //----------------
377 // Inject fake CCSN candidates (fire drill)
378 //----------------
379
380 if (!startedFireDrill){
381
382 timeSinceLastFireDrill += 0.1;
383
384 // Get input file name for simulated CCSN signal
385 int drill = fireDrill.CheckHead(prefix);
386 if (drill){
387 fireDrillFile.resize(prefix.getSize());
388 fireDrill.GetFullData(fireDrillFile.data(), fireDrillFile.size());
389 }
390
391 // Determines whether to start fire drill and set
392 // Enforce 100s wait time between fire drills to make sure the triggers do not pile up
393 if (fireDrillFile.size()>0 && timeSinceLastFireDrill > 100) {
394 startedFireDrill = true;
395 fireDrillOffsetTime = 0.05; // seconds
396 fireDrillTimeslice = 0;
397 string fireDrillFileName(fireDrillFile.begin()+1, fireDrillFile.end()-1);
398 fireDrillData.open(fireDrillFileName.c_str());
399 timeFireDrill = -100;
400 } else {
401 trigger_final = trigger;
402 }
403 }
404
405 // Read simulated signal and inject it into data
406 if (startedFireDrill) {
407
408 double tmin = 0.1*fireDrillTimeslice;
409 double tmax = tmin + 0.1;
410
411 if (fireDrillTimeslice == 0) { // At start of injection, read first event in signal file
412 fireDrillData >> timeFireDrill >> MultFireDrill >> CThetaFireDrill >> RFireDrill >> TotalToTFireDrill >> DeltaTFireDrill;
413 timeFireDrill += fireDrillOffsetTime;
414 }
415
416 // Read first event in timeslice (in real data)
417 auto sn_it = trigger.begin();
418 double event_time = (sn_it==trigger.end()) ? 100 : sn_it->getPeak().time/1.0e9; // If no data in timeslice set event time to large value
419
420 // Iterate over signal file (text file)
421 while (fireDrillData && timeFireDrill < tmax) {
422
423 // Add data until we reach the time of the simulated event
424 while(event_time < timeFireDrill-tmin && sn_it != trigger.end()) {
425 trigger_final.push_back(*sn_it);
426 sn_it++;
427 if (sn_it != trigger.end()) event_time = sn_it->getPeak().time/1.0e9;
428 }
429
430 if (sn_it > trigger.begin() && event_time > timeFireDrill-tmin) sn_it -= 1; // Offset back one unit
431
432 // Inject signal event
433 if (timeFireDrill >= tmin && timeFireDrill < tmax) {
434
435 // Get random DOM ID
436 int frame_number = timeslice->getFrameIndex();
437 int dom_id = doms[frame_number][(int) getRandom(0,(int)doms[frame_number].size())];
438 // Build JCoincidenceSN object, put it in a JClusterSN, add to the trigger
439 JCoincidenceSN sn((timeFireDrill-tmin)*1e9, (int) MultFireDrill, dom_id, 0, CThetaFireDrill, RFireDrill, DeltaTFireDrill, TotalToTFireDrill, -1, true);// the last argument "true" means the event is flagged as fake
440 JClusterSN sncluster;
441 sncluster.push_back(sn); // Neglect accidental coincidences with background events
442 trigger_final.push_back(sncluster); // Add SN cluster to trigger
443
444 }
445
446 // Read new event
447 fireDrillData >> timeFireDrill >> MultFireDrill >> CThetaFireDrill >> RFireDrill >> TotalToTFireDrill >> DeltaTFireDrill;
448 timeFireDrill += fireDrillOffsetTime;
449
450 }
451
452 // Pad with what remains of noise in timeslice
453 while(sn_it != trigger.end()) {
454 trigger_final.push_back(*sn_it);
455 sn_it++;
456 }
457
458 fireDrillTimeslice++; // Increment the timeslice counter
459
460 // If no signal left in file, fire drill injection is finished
461 if (!fireDrillData){
462 startedFireDrill = false;
463 fireDrillFile.clear();
464 timeSinceLastFireDrill = 0;
465 fireDrillData.close();
466 }
467
468 }
469
470 trgQueue.push(trigger_final);
471
472 //----------------
473 // compute trigger
474 //----------------
475
476 if ( trgQueue.size() >= (unsigned) queueLength ) {
477
478 while ( trgWindow.size() <= (unsigned) windowLength ) {
479
480 trigger_type pending = trgQueue.top();
481
482 if ( trgWindow.size() == 0 || pending > trgWindow.back() ) {
483
484 trgWindow.push_back( pending );
485
486 counter_live_ts++;
487
488 }
489 else {
490 // latecoming (out of order) timeslice
491 counter_lost_ts++;
492 }
493
494 trgQueue.pop();
495
496 }
497 }
498 else {
499 NOTICE("Filling trigger queue: " << trgQueue.size() << "/" << queueLength << '\r');
500 }
501 }
502
503 else if ( inputFileName != "" ) {
504 // if we are reading from a file and we don't have timeslices anymore, we are at the end of the file
505 // we can push the content of the queue to the trigger window to process it
506 if ( trgQueue.size() > 0 ) {
507 while ( trgQueue.size() > 0 ) {
508 trgWindow.push_back(trgQueue.top());
509 trgQueue.pop();
510 }
511 }
512 else if ( trgWindow.size() < (unsigned) windowLength ) {
513 i = numberOfTimeouts;
514 }
515 }
516 else {
517 NOTICE("timeout " << setw(3) << i << endl);
518
519 ++i;
520 }
521
522 if (trgWindow.size() >= (unsigned) windowLength) {
523
524 // build triggered modules with both data and simulated signal
525
526 vector<double> observables;
527 vector<int> multiplicities;
528
529 int trg_cc_counts = 0;
530 int trg_cc_modules = 0;
531 set<int> cc_modules;
532
533 int trg_ev_counts = 0;
534 int trg_ev_modules = 0;
535 set<int> ev_modules;
536
537 // build triggered modules with only data
538
539 vector<double> observables_nofakes;
540 vector<int> multiplicities_nofakes;
541
542 int trg_cc_counts_nofakes = 0;
543 int trg_cc_modules_nofakes = 0;
544 set<int> cc_modules_nofakes;
545
546 int trg_ev_counts_nofakes = 0;
547 int trg_ev_modules_nofakes = 0;
548 set<int> ev_modules_nofakes;
549
550 // loop over the trigger window and count the triggers
551 for (int its = 0; its < windowLength; its++) {
552
553 const int frame_index = trgWindow[its].frameIndex;
554
555 JVetoSet vetoSet;
556 if (veto.count(frame_index)) {
557 vetoSet = veto.at(frame_index);
558 }
559
560 JSNFilterMV F_MV(M, vetoSet);
561 JSNFilterMV F_MV_BDT(M_BDT, vetoSet);
562
563 set<int> cc_vec = trgWindow[its].getModules(F_M1);
564 set<int> ev_vec = trgWindow[its].getModules(F_MV);
565
566 // Get cluster and event counts without the simulated CCSN signal
567 set<int> cc_vec_nofakes;
568 set<int> ev_vec_nofakes;
569
570 for (auto &trg: trgWindow[its]){
571 if (F_M1(trg)){
572 if (!trg.getPeak().fake) trg_cc_counts_nofakes++;
573 for (auto &snc: trg){
574 if (!snc.fake){
575 cc_vec_nofakes.insert(snc.moduleID);
576 }
577 }
578 }
579 if (F_MV(trg)){
580 if (!trg.getPeak().fake) trg_ev_counts_nofakes++;
581 for (auto &snc: trg){
582 if (!snc.fake){
583 ev_vec_nofakes.insert(snc.moduleID);
584 }
585 }
586 }
587 }
588
589 cc_modules.insert(cc_vec.begin(), cc_vec.end());
590 ev_modules.insert(ev_vec.begin(), ev_vec.end());
591
592 cc_modules_nofakes.insert(cc_vec_nofakes.begin(), cc_vec_nofakes.end());
593 ev_modules_nofakes.insert(ev_vec_nofakes.begin(), ev_vec_nofakes.end());
594
595 trg_cc_counts += count_if(trgWindow[its].begin(), trgWindow[its].end(), F_M1);
596 trg_ev_counts += count_if(trgWindow[its].begin(), trgWindow[its].end(), F_MV);
597
598 // Write table of observables
599 for (auto &trg: trgWindow[its]){
600 auto sn_candidate = trg.getPeak();
601 if (F_MV_BDT(sn_candidate)){
602 multiplicities.push_back(sn_candidate.multiplicity);
603 observables.push_back(sn_candidate.total_ToT);
604 observables.push_back(sn_candidate.deltaT);
605 observables.push_back(sn_candidate.mean_dir_norm);
606 observables.push_back(sn_candidate.mean_dir_ctheta);
607
608 if (!sn_candidate.fake){
609 multiplicities_nofakes.push_back(sn_candidate.multiplicity);
610 observables_nofakes.push_back(sn_candidate.total_ToT);
611 observables_nofakes.push_back(sn_candidate.deltaT);
612 observables_nofakes.push_back(sn_candidate.mean_dir_norm);
613 observables_nofakes.push_back(sn_candidate.mean_dir_ctheta);
614 }
615 }
616 }
617 }
618
619 trg_cc_modules = cc_modules.size();
620 trg_ev_modules = ev_modules.size();
621
622 trg_cc_modules_nofakes = cc_modules_nofakes.size();
623 trg_ev_modules_nofakes = ev_modules_nofakes.size();
624
625 // trigger window slide of one element
626
627 int currentFrame = trgWindow[0].frameIndex;
628 JDAQUTCExtended currentTime = trgWindow[0].timeUTC;
629
630 trgWindow.pop_front();
631
632 // calculate trigger
633
634 ++stats[trg_cc_counts];
635
636 // calculate active modules
637
638 int activeModules = -1;
639 double detectorRate = 0.0;
640
641 if (!rates.empty() &&
642 rates.count(currentFrame)) {
643
644 activeModules = 0;
645
646 for (map<int, double>::const_iterator p = rates.at(currentFrame).begin();
647 p != rates.at(currentFrame).end(); p++ ) {
648
649 detectorRate += p->second;
650
651 activeModules += (p->second > 0);
652
653 }
654 } else {
655
656 activeModules = timesliceSize;
657
658 }
659
660 // build summary message
661
662 json jd;
663 string daq_time = to_string(currentTime);
664
665 // Output with only data (even in case of a signal injection)
666 jd[detid_name] = DETID;
667 jd[active_doms_name] = activeModules;
668 jd[detector_rate_name] = int(detectorRate / 1000.0);
669 jd[run_number_name] = RUN;
670 jd[frame_index_name] = currentFrame;
671 jd[daq_time_name] = daq_time;
672 jd[trigger_name][cc_name][c_name] = trg_cc_counts_nofakes;
673 jd[trigger_name][cc_name][m_name] = trg_cc_modules_nofakes;
674 jd[trigger_name][ev_name][c_name] = trg_ev_counts_nofakes;
675 jd[trigger_name][ev_name][m_name] = trg_ev_modules_nofakes;
676 jd[active_pmts_name] = pmts[currentFrame];
677 jd[observables_name] = observables_nofakes;
678 jd[multiplicities_name] = multiplicities_nofakes;
679
680 string msg = jd.dump();
681
682 DEBUG(msg << endl);
683
684 // If a simulated signal has been injected, write the corresponding output
685 // DET ID is set to a negative value to distinguish it from the real output
686 string msg2 = "";
687 if (multiplicities.size() != multiplicities_nofakes.size()){
688 jd[detid_name] = -DETID;
689 jd[active_doms_name] = activeModules;
690 jd[detector_rate_name] = int(detectorRate / 1000.0);
691 jd[run_number_name] = RUN;
692 jd[frame_index_name] = currentFrame;
693 jd[daq_time_name] = daq_time;
694 jd[trigger_name][cc_name][c_name] = trg_cc_counts;
695 jd[trigger_name][cc_name][m_name] = trg_cc_modules;
696 jd[trigger_name][ev_name][c_name] = trg_ev_counts;
697 jd[trigger_name][ev_name][m_name] = trg_ev_modules;
698 jd[active_pmts_name] = pmts[currentFrame];
699 jd[observables_name] = observables;
700 jd[multiplicities_name] = multiplicities;
701
702 msg2 = jd.dump();
703
704 DEBUG(msg2 << endl);
705 }
706
707 if (outputFileName != ""){
708 if (nWrittenEntries < nEntries || nEntries == -1) {
709 // write summary information to output file (first nEntries)
710 outputFile << msg << endl;
711 nWrittenEntries++;
712 }
713 else {
714 // When entries written, close output file and exit loop
715 outputFile.close();
716 break;
717 }
718 }
719 else {
720 // send summary information to output ligier
721
722 if (out != NULL) {
723 if (msg2 != "") out->PutFullString(outputTag, msg2);
724 out->PutFullString(outputTag, msg);
725 }
726 }
727
728 // print stats
729
730 if ( (counter_live_ts % ((int)(statPrintInterval_s / frameTime_s)) == 0 ) ) {
731
732 double livetime = counter_live_ts * frameTime_s;
733
734 stats.setLiveTime(livetime);
735
736 NOTICE(endl);
737 NOTICE(stats.toString());
738 NOTICE("=> discarded out-of-order timeslices = " << counter_lost_ts << endl);
739
740 if (summaryFile != "") {
741 ofstream of(summaryFile.c_str());
742 of << stats.toSummaryFile();
743 of.close();
744 }
745
746 }
747 }
748 }
749 }
750
751 catch(const JSocketException& error) {
752 ERROR(error.what() << endl);
753 }
754
755 if (outputFileName != "") { outputFile.close(); }
756
757}
Fixed parameters and ControlHost tags for KM3NeT DAQ.
string outputFile
Data structure for detector geometry and calibration.
Definition of random value generator.
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define NOTICE(A)
Definition JMessage.hh:64
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Utility class to parse parameter values.
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
int main(int argc, char *argv[])
nlohmann::json json
static const std::string active_pmts_name
static const std::string cc_name
static const std::string daq_time_name
static const std::string detid_name
static const std::string c_name
static const std::string m_name
static const std::string run_number_name
static const std::string observables_name
static const std::string detector_rate_name
static const std::string ev_name
static const std::string trigger_name
static const std::string active_doms_name
static const std::string frame_index_name
static const std::string multiplicities_name
ROOT TTree parameter settings of various packages.
Simple wrapper around JModuleRouter class for direct addressing of PMT data in detector data structur...
Detector data structure.
Definition JDetector.hh:96
Router for direct addressing of module data in detector data structure.
Utility class to parse parameter values.
void setEndOfLine(const std::string &eol)
Set end of line characters.
General exception.
Definition JException.hh:24
Interface of object iteration for a single data type.
virtual bool hasNext()=0
Check availability of next element.
virtual const pointer_type & next()=0
Get next element.
Exception for socket.
Auxiliary class for time values.
Definition JTimeval.hh:29
Object iteration through ControlHost.
ControlHost class.
int MyId(const std::string &nick_name)
Identify.
int PutFullString(const JTag &tag, const std::string &buffer)
Send string.
int CheckHead(JPrefix &prefix, JTimeval timeout=JTimeval::min())
Check for header, without waiting.
int GetFullData(void *buffer, long long int length)
Receive data.
int SendMeAlways()
Tell server to send messages forever.
int Subscribe(const JSubscription &subscription)
Subscribe to single tag.
ControlHost prefix.
Definition JPrefix.hh:33
int getSize() const
Get size.
Definition JPrefix.hh:62
Subscription list.
JSubscriptionList & add(const JSubscription &subscription)
Add subscription.
ControlHost tag.
Definition JTag.hh:38
Utility class to parse command line options.
Definition JParser.hh:1698
Auxiliary class to manage a cluster of coincidences.
Auxiliary class to store reduced information of a coincidence on an optical module This class allows ...
Definition JSupernova.hh:52
Auxiliary class to build the supernova trigger dataset.
SN filter based on veto window.
SN filter based on multiplicity selection optional suppression of multi-module coincidences WARNING: ...
SN trigger statistics, the information is stored in the form of a count as a function of the trigger ...
string toString()
put statistics into printable form outputs trigger level - rate - error
void setLiveTime(const double lt)
string toSummaryFile()
put statistics into printable form outputs trigger level - rate - error
Auxiliary class to apply the supernova trigger to SN data.
JDAQUTCExtended timeUTC
Auxiliary class to manage a set of vetoes.
Auxiliary class to define a veto time window on a set of optical modules.
Template definition for direct access of elements in ROOT TChain.
Range of values.
Definition JRange.hh:42
int getFrameIndex() const
Get frame index.
const JDAQHeader & getDAQHeader() const
Get DAQ header.
Definition JDAQHeader.hh:49
Data structure for UTC time.
uint32_t dom_id(frame_idx_t idx)
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
@ debug_t
debug
Definition JMessage.hh:29
std::string to_string(const T &value)
Convert value to string.
T getRandom()
Get random value.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
std::vector< event_type > data_type
Definition JPerth.cc:81
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
double getFrameTime()
Get frame time duration.
Definition JDAQClock.hh:162
void setDAQLongprint(const bool option)
Set DAQ print option.
Definition JDAQPrint.hh:28
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition JDAQ.hh:26
Detector file.
Definition JHead.hh:227
Normalisation of MUPAGE events.
Definition JHead.hh:835
Data structure for measured coincidence rates of all pairs of PMTs in optical module.
Definition JFitK40.hh:103
Auxiliary class for all subscription.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition JParser.hh:68
Auxiliary class to select DAQ hits based on time-over-treshold value.
Timeslice data structure for SN data.