Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
JTriggerMonitor.cc File Reference

Auxiliary program to histogram and print trigger statistics. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "km3net-dataformat/online/JDAQ.hh"
#include "km3net-dataformat/online/JDAQTriggerMask.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JDAQ/JDAQTimesliceIO.hh"
#include "JDAQ/JDAQSummarysliceIO.hh"
#include "JTrigger/JTriggerParameters.hh"
#include "JTrigger/JTriggerBits.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JTriggerParametersSupportkit.hh"
#include "JROOT/JRootToolkit.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

void print (const TH1 &h1, std::ostream &out)
 Print histogram parameters.
 
int main (int argc, char **argv)
 

Variables

static const int WIDTH = 20
 

Detailed Description

Auxiliary program to histogram and print trigger statistics.

Author
mdejong

Definition in file JTriggerMonitor.cc.

Function Documentation

◆ print()

void print ( const TH1 & h1,
std::ostream & out )
inline

Print histogram parameters.

Parameters
h1histogram
outoutput stream

Definition at line 38 of file JTriggerMonitor.cc.

39{
40 using namespace std;
41
42 out << setw(WIDTH) << left << h1.GetName() << ' '
43 << FIXED(8,0) << h1.GetEntries() << ' '
44 << FIXED(8,2) << h1.GetMean() << ' '
45 << FIXED(8,2) << h1.GetRMS() << ' '
46 << endl;
47}
Auxiliary data structure for floating point format specification.
Definition JManip.hh:448
Auxiliary data structure for alignment of data.
Definition JManip.hh:231

◆ main()

int main ( int argc,
char ** argv )

Definition at line 56 of file JTriggerMonitor.cc.

57{
58 using namespace std;
59 using namespace JPP;
60 using namespace KM3NETDAQ;
61
62 JMultipleFileScanner<> inputFile;
63 JLimit_t& numberOfEvents = inputFile.getLimit();
64 string outputFile;
65 int qaqc;
66 int debug;
67
68 try {
69
70 JParser<> zap("Auxiliary program to histogram and print trigger statistics.");
71
72 zap['f'] = make_field(inputFile);
73 zap['o'] = make_field(outputFile) = "";
74 zap['n'] = make_field(numberOfEvents) = JLimit::max();
75 zap['Q'] = make_field(qaqc) = 0;
76 zap['d'] = make_field(debug) = 1;
77
78 zap(argc, argv);
79 }
80 catch(const exception &error) {
81 FATAL(error.what() << endl);
82 }
83
84
85 TH1D h1("Event ", NULL, 100, 0.0, 1.0e1);
86 TH1D h2("Summary ", NULL, 100, 0.0, 1.0e1);
87
88 TH1D hm("Trigger mask ", NULL, NUMBER_OF_TRIGGER_BITS, -0.5, NUMBER_OF_TRIGGER_BITS - 0.5);
89 TH1D hn("Trigger hits ", NULL, 1000, -0.5, 1000 - 0.5);
90 TH1D hs("Snapshot hits ", NULL, 1000, -0.5, 10000 - 0.5);
91 TH1D hr("PMT rate [kHz]", NULL, 100, 0.0, 50.0);
92
93
94 const JTriggerParameters parameters = getTriggerParameters(inputFile);
95
96 NOTICE(parameters << endl);
97
98
99 for (JMultipleFileScanner<JDAQEvent> input = inputFile; input.hasNext(); ) {
100
101 STATUS("entry: " << setw(10) << input.getCounter() << '\r'); DEBUG(endl);
102
103 const JDAQEvent* object = input.next();
104
105 h1.Fill((Double_t) getSizeof(*object) * 1e-6);
106
107 hn.Fill((Double_t) object->size<JDAQTriggeredHit>());
108 hs.Fill((Double_t) object->size<JDAQSnapshotHit> ());
109
110 for (unsigned int i = 0; i != NUMBER_OF_TRIGGER_BITS; ++i) {
111 if (object->hasTriggerBit(i)) {
112 hm.Fill((Double_t) i);
113 }
114 }
115
116 {
117 unsigned int n = 0;
118
119 typedef JDAQSnapshotHit JHit_t;
120
121 for (JDAQEvent::const_iterator<JHit_t> i = object->begin<JHit_t>(); i != object->end<JHit_t>(); ++i) {
122
123 if (object->getTriggerMask(*i) != 0) {
124 ++n;
125 }
126 }
127
128 if (object->size<JHit_t>() != 0 && n != object->size<JDAQTriggeredHit>()) {
129 ERROR("Number of snapshot hits with trigger mask " << n << " != " << object->size<JDAQTriggeredHit>() << endl);
130 }
131 }
132 }
133
134
135 long long int numberOfSummaryslices = 0;
136
137 for (JMultipleFileScanner<JDAQSummaryslice> input = inputFile; input.hasNext(); numberOfSummaryslices += parameters.writeSummary.prescale) {
138
139 STATUS("entry: " << setw(10) << input.getCounter() << '\r'); DEBUG(endl);
140
141 const JDAQSummaryslice* object = input.next();
142
143 h2.Fill((Double_t) getSizeof(*object) * 1e-6);
144
145 for (JDAQSummaryslice::const_iterator i = object->begin(); i != object->end(); ++i) {
146 for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
147 hr.Fill(i->getRate(pmt) * 1.0e-3);
148 }
149 }
150 }
151
152 if (debug >= JEEP::status_t) {
153 print(h1, cout);
154 print(h2, cout);
155 print(hn, cout);
156 print(hs, cout);
157 print(hr, cout);
158 }
159
160 NOTICE(endl);
161 NOTICE("Background rate estimate from snapshot hits " << setprecision(2)
162 << (hs.GetMean() - hn.GetMean()) * numberOfSummaryslices / (hr.GetEntries() * 2e-6 * parameters.TMaxEvent_ns)
163 << " [kHz]" << endl);
164 NOTICE(endl);
165
166
167 const double T = numberOfSummaryslices * 1.0e-9 * getFrameTime(); // [s]
168
169 NOTICE(setw(WIDTH) << left << "Total run duration (based on time slices) [s] " << FIXED(7,1) << T << endl);
170
171
172 for (Int_t i = 1; i <= hm.GetNbinsX(); ++i) {
173
174 const JTriggerbit_t x = (JTriggerbit_t) hm.GetBinCenter (i);
175 const Double_t y = (Double_t) hm.GetBinContent(i);
176
177 const char* const name = getTriggerName(x);
178
179 if (name != NULL || y != 0.0) {
180
181 NOTICE("Trigger"
182 << "[" << setw(2) << x << "]" << ' '
183 << setw(16) << left << (name != NULL ? name : "?") << ' '
184 << FIXED(9,0) << y);
185
186 if (numberOfSummaryslices != 0) {
187 NOTICE(FIXED(12,2) << y / T << " [Hz]");
188 }
189
190 NOTICE(endl);
191 }
192 }
193
194 NOTICE("Total "
195 << setw(4) << " " << ' '
196 << setw(16) << " " << ' '
197 << FIXED(9,0) << h1.GetEntries());
198
199 if (numberOfSummaryslices != 0) {
200 NOTICE(FIXED(12,2) << h1.GetEntries() / T << " [Hz]");
201 }
202
203 NOTICE(endl);
204
205 if (outputFile != "") {
206
207 TFile out(outputFile.c_str(), "recreate");
208
209 out << h1 << h2;
210 out << hm << hn << hs << hr;
211
212 out.Write();
213 out.Close();
214 }
215
216
217 for (Int_t i = 1; i <= hm.GetNbinsX(); ++i) {
218
219 const JTriggerbit_t x = (JTriggerbit_t) hm.GetBinCenter (i);
220 const Double_t y = (Double_t) hm.GetBinContent(i);
221
222 const char* const name = getTriggerName(x);
223
224 if (name != NULL) {
225 QAQC(' ' << FIXED(7,0) << y);
226 }
227 }
228
229 QAQC(endl);
230
231 return 0;
232}
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
Utility class to parse command line options.
Definition JParser.hh:1698
virtual bool hasNext() override
Check availability of next element.
Template const_iterator.
Definition JDAQEvent.hh:68
JTriggerCounter_t next()
Increment trigger counter.
std::ostream & print(std::ostream &out, const JTestSummary &summary, const char delimiter=' ', const bool useColors=true)
Print test summary.
@ status_t
status
Definition JMessage.hh:30
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
JTriggerParameters getTriggerParameters(const JMultipleFileScanner_t &file_list)
Get trigger parameters.
const int n
Definition JPolint.hh:791
const char * getTriggerName(JTriggerbit_t bit)
Get trigger name.
unsigned int JTriggerbit_t
Type definition of trigger bit.
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
double getFrameTime()
Get frame time duration.
Definition JDAQClock.hh:162
static const unsigned int NUMBER_OF_TRIGGER_BITS
Number of trigger bits.
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition JDAQ.hh:26
size_t getSizeof()
Definition of method to get size of data type.
Auxiliary class to set-up Hit.
Definition JSirene.hh:58
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

Variable Documentation

◆ WIDTH

const int WIDTH = 20
static

Definition at line 29 of file JTriggerMonitor.cc.