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

Online supernova processor. More...

#include <iostream>
#include <iomanip>
#include <queue>
#include <string>
#include "nlohmann/json.hpp"
#include "JDAQ/JDAQTimesliceIO.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JDAQ/JDAQSummarysliceIO.hh"
#include "JDAQ/JDAQTags.hh"
#include "JDAQ/JDAQEvaluator.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JNet/JControlHostObjectIterator.hh"
#include "JNet/JControlHost.hh"
#include "JLang/JObjectIterator.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
#include "Jeep/JProperties.hh"
#include "JROOT/JROOTClassSelector.hh"
#include "JTrigger/JDAQHitToTSelector.hh"
#include "JSupport/JSupport.hh"
#include "JMath/JRandom.hh"
#include "JSupport/JTreeScanner.hh"
#include "JSupernova.hh"
#include "JSupernovaProcessor.hh"

Go to the source code of this file.

Typedefs

using json = nlohmann::json
 

Functions

int main (int argc, char *argv[])
 

Detailed Description

Online supernova processor.

Author
mlincett,selhedri,iagoos,gvannoye

Definition in file JSupernovaProcessor.cc.

Typedef Documentation

◆ json

using json = nlohmann::json

Definition at line 38 of file JSupernovaProcessor.cc.

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 46 of file JSupernovaProcessor.cc.

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