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

Example program to monitor event duration. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "JTools/JRange.hh"
#include "JROOT/JRootToolkit.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JDAQHitRouter.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JSupport.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to monitor event duration.

Author
mdejong

Definition in file JMermaid.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 32 of file JMermaid.cc.

33{
34 using namespace std;
35 using namespace JPP;
36 using namespace KM3NETDAQ;
37
39 JLimit_t& numberOfEvents = inputFile.getLimit();
40 string outputFile;
41 string detectorFile;
42 double T_ns;
43 int qaqc;
44 int debug;
45
46 try {
47
48 JParser<> zap("Example program to monitor event duration.");
49
50 zap['f'] = make_field(inputFile);
51 zap['o'] = make_field(outputFile) = "mermaid.root";
52 zap['a'] = make_field(detectorFile);
53 zap['n'] = make_field(numberOfEvents) = JLimit::max();
54 zap['T'] = make_field(T_ns, "Time limit for event duration [ns]") = 10.0e3;
55 zap['Q'] = make_field(qaqc) = 0;
56 zap['d'] = make_field(debug) = 2;
57
58 zap(argc, argv);
59 }
60 catch(const exception& error) {
61 FATAL(error.what() << endl);
62 }
63
64
66
67 try {
68 load(detectorFile, detector);
69 }
70 catch(const JException& error) {
71 FATAL(error);
72 }
73
74 const JDAQHitRouter router(detector);
75
76 TH1D h1("h1", NULL, 100, 0.0, 10.0e3);
77
78 size_t N = 0;
79
80 while (inputFile.hasNext()) {
81
82 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
83
84 JDAQEvent* event = inputFile.next();
85
87
88 for (JDAQEvent::const_iterator<JDAQTriggeredHit> hit = event->begin<JDAQTriggeredHit>(); hit != event->end<JDAQTriggeredHit>(); ++hit) {
89 tx.include(getTime(*hit, router.getPMT(*hit)));
90 }
91
92 h1.Fill(tx.getLength());
93
94 if (tx.getLength() >= T_ns) {
95 N += 1;
96 }
97 }
98 STATUS(endl);
99
100 TFile out(outputFile.c_str(), "recreate");
101
102 out << h1;
103
104 out.Write();
105 out.Close();
106
107 NOTICE("Number of event with duration beyond " << FIXED(9,0) << T_ns << " [ns] " << N << endl);
108
109 QAQC(N << endl);
110
111 return 0;
112}
string outputFile
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define STATUS(A)
Definition JMessage.hh:63
#define QAQC(A)
QA/QC output macro.
Definition JMessage.hh:100
int qaqc
QA/QC file descriptor.
#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
Simple wrapper around JModuleRouter class for direct addressing of PMT data in detector data structur...
Detector data structure.
Definition JDetector.hh:96
General exception.
Definition JException.hh:24
Utility class to parse command line options.
Definition JParser.hh:1698
General purpose class for object reading from a list of file names.
virtual bool hasNext() override
Check availability of next element.
counter_type getCounter() const
Get counter.
virtual const pointer_type & next() override
Get next element.
T getLength() const
Get length (difference between upper and lower limit).
Definition JRange.hh:289
static JRange< double, std::less< double > > DEFAULT_RANGE()
Definition JRange.hh:555
range_type & include(argument_type x)
Include given value to range.
Definition JRange.hh:397
Template const_iterator.
Definition JDAQEvent.hh:68
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).
const char * getTime()
Get current local time conform ISO-8601 standard.
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
Auxiliary data structure for floating point format specification.
Definition JManip.hh:448
Detector file.
Definition JHead.hh:227
Auxiliary class for defining the range of iterations of objects.
Definition JLimit.hh:45
static counter_type max()
Get maximum counter value.
Definition JLimit.hh:128