Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions | Variables
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. More...
 
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

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 alignment of data.
Definition: JManip.hh:230
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:445
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  cout.tie(&cerr);
86 
87 
88  TH1D h1("Event ", NULL, 100, 0.0, 1.0e1);
89  TH1D h2("Summary ", NULL, 100, 0.0, 1.0e1);
90 
91  TH1D hm("Trigger mask ", NULL, NUMBER_OF_TRIGGER_BITS, -0.5, NUMBER_OF_TRIGGER_BITS - 0.5);
92  TH1D hn("Trigger hits ", NULL, 1000, -0.5, 1000 - 0.5);
93  TH1D hs("Snapshot hits ", NULL, 1000, -0.5, 10000 - 0.5);
94  TH1D hr("PMT rate [kHz]", NULL, 100, 0.0, 50.0);
95 
96 
97  const JTriggerParameters trigger_parameters = getTriggerParameters(inputFile);
98 
99  NOTICE(trigger_parameters << endl);
100 
101 
102  for (JMultipleFileScanner<JDAQEvent> input = inputFile; input.hasNext(); ) {
103 
104  STATUS("entry: " << setw(10) << input.getCounter() << '\r'); DEBUG(endl);
105 
106  const JDAQEvent* object = input.next();
107 
108  h1.Fill((Double_t) getSizeof(*object) * 1e-6);
109 
110  hn.Fill((Double_t) object->size<JDAQTriggeredHit>());
111  hs.Fill((Double_t) object->size<JDAQSnapshotHit> ());
112 
113  for (unsigned int i = 0; i != NUMBER_OF_TRIGGER_BITS; ++i) {
114  if (object->hasTriggerBit(i)) {
115  hm.Fill((Double_t) i);
116  }
117  }
118 
119  {
120  unsigned int n = 0;
121 
122  typedef JDAQSnapshotHit JHit_t;
123 
124  for (JDAQEvent::const_iterator<JHit_t> i = object->begin<JHit_t>(); i != object->end<JHit_t>(); ++i) {
125 
126  if (object->getTriggerMask(*i) != 0) {
127  ++n;
128  }
129  }
130 
131  if (object->size<JHit_t>() != 0 && n != object->size<JDAQTriggeredHit>()) {
132  ERROR("Number of snapshot hits with trigger mask " << n << " != " << object->size<JDAQTriggeredHit>() << endl);
133  }
134  }
135  }
136 
137 
138  long long int numberOfSummaryslices = 0;
139 
140  for (JMultipleFileScanner<JDAQSummaryslice> input = inputFile; input.hasNext(); ++numberOfSummaryslices) {
141 
142  STATUS("entry: " << setw(10) << input.getCounter() << '\r'); DEBUG(endl);
143 
144  const JDAQSummaryslice* object = input.next();
145 
146  h2.Fill((Double_t) getSizeof(*object) * 1e-6);
147 
148  for (JDAQSummaryslice::const_iterator i = object->begin(); i != object->end(); ++i) {
149  for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
150  hr.Fill(i->getRate(pmt) * 1.0e-3);
151  }
152  }
153  }
154 
155 
156  if (debug >= JEEP::status_t) {
157  print(h1, cout);
158  print(h2, cout);
159  print(hn, cout);
160  print(hs, cout);
161  print(hr, cout);
162  }
163 
164  NOTICE(endl);
165  NOTICE("Background rate estimate from snapshot hits " << setprecision(2)
166  << (hs.GetMean() - hn.GetMean()) * numberOfSummaryslices / (hr.GetEntries() * 2e-6 * trigger_parameters.TMaxEvent_ns)
167  << " [kHz]" << endl);
168  NOTICE(endl);
169 
170 
171  const double T = numberOfSummaryslices * 1.0e-9 * getFrameTime(); // [s]
172 
173  NOTICE(setw(WIDTH) << left << "Total run duration (based on time slices) [s] " << FIXED(7,1) << T << endl);
174 
175 
176  for (Int_t i = 1; i <= hm.GetNbinsX(); ++i) {
177 
178  const JTriggerbit_t x = (JTriggerbit_t) hm.GetBinCenter (i);
179  const Double_t y = (Double_t) hm.GetBinContent(i);
180 
181  const char* const name = getTriggerName(x);
182 
183  if (name != NULL || y != 0.0) {
184 
185  NOTICE("Trigger"
186  << "[" << setw(2) << x << "]" << ' '
187  << setw(16) << left << (name != NULL ? name : "?") << ' '
188  << FIXED(7,0) << y);
189 
190  if (numberOfSummaryslices != 0) {
191  NOTICE(FIXED(7,2) << y / T << " [Hz]");
192  }
193 
194  NOTICE(endl);
195  }
196  }
197 
198  NOTICE("Total "
199  << setw(4) << " " << ' '
200  << setw(16) << " " << ' '
201  << FIXED(7,0) << h1.GetEntries());
202 
203  if (numberOfSummaryslices != 0) {
204  NOTICE(FIXED(7,2) << h1.GetEntries() / T << " [Hz]");
205  }
206 
207  NOTICE(endl);
208 
209  if (outputFile != "") {
210 
211  TFile out(outputFile.c_str(), "recreate");
212 
213  out << h1 << h2;
214  out << hm << hn << hs << hr;
215 
216  out.Write();
217  out.Close();
218  }
219 
220 
221  for (Int_t i = 1; i <= hm.GetNbinsX(); ++i) {
222 
223  const JTriggerbit_t x = (JTriggerbit_t) hm.GetBinCenter (i);
224  const Double_t y = (Double_t) hm.GetBinContent(i);
225 
226  const char* const name = getTriggerName(x);
227 
228  if (name != NULL) {
229  QAQC(' ' << FIXED(7,0) << y);
230  }
231  }
232 
233  QAQC(endl);
234 
235  return 0;
236 }
Auxiliary class to set-up Hit.
Definition: JHit_t.hh:25
Auxiliary data structure for alignment of data.
Definition: JManip.hh:230
Utility class to parse command line options.
Definition: JParser.hh:1500
DAQ key hit.
Definition: JDAQKeyHit.hh:19
bool hasTriggerBit(const unsigned int bit) const
Check trigger bit.
static const unsigned int NUMBER_OF_TRIGGER_BITS
Number of trigger bits.
#define STATUS(A)
Definition: JMessage.hh:63
Template const_iterator.
Definition: JDAQEvent.hh:68
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:445
string outputFile
unsigned int size() const
Get number of hits.
static JTriggerMask_t getTriggerMask(const JDAQTriggeredHit &hit)
Get trigger mask of given hit.
Definition: JDAQEvent.hh:228
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
const_iterator< T > end() const
Get end of data.
status
Definition: JMessage.hh:30
virtual bool hasNext() override
Check availability of next element.
const_iterator< T > begin() const
Get begin of data.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
double getFrameTime()
Get frame time duration.
Definition: JDAQClock.hh:162
do set_variable OUTPUT_DIRECTORY $WORKDIR T
#define NOTICE(A)
Definition: JMessage.hh:64
#define ERROR(A)
Definition: JMessage.hh:66
int debug
debug level
Definition: JSirene.cc:63
print
Definition: JConvertDusj.sh:44
#define FATAL(A)
Definition: JMessage.hh:67
then echo n User name
Definition: JCookie.sh:45
const char * getTriggerName(JTriggerbit_t bit)
Get trigger name.
#define QAQC(A)
QA/QC output macro.
Definition: JMessage.hh:100
alias put_queue eval echo n
Definition: qlib.csh:19
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26
size_t getSizeof(const JDAQEvent &object)
Get size of object.
Definition: JDAQEventIO.hh:26
int qaqc
QA/QC file descriptor.
JTriggerParameters getTriggerParameters(const JMultipleFileScanner_t &file_list)
Get trigger parameters.
JTriggerCounter_t next()
Increment trigger counter.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
unsigned int JTriggerbit_t
Type definition of trigger bit.

Variable Documentation

const int WIDTH = 20
static

Definition at line 29 of file JTriggerMonitor.cc.