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 "JDAQ/JDAQ.hh"
#include "JDAQ/JDAQEvent.hh"
#include "JDAQ/JDAQTimeslice.hh"
#include "JDAQ/JDAQSummaryslice.hh"
#include "JDAQ/JDAQTriggerMask.hh"
#include "JTrigger/JTriggerParameters.hh"
#include "JTrigger/JTriggerBits.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JSupport.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 37 of file JTriggerMonitor.cc.

38 {
39  using namespace std;
40 
41  out << setw(WIDTH) << left << h1.GetName() << ' '
42  << FIXED(8,0) << h1.GetEntries() << ' '
43  << FIXED(8,2) << h1.GetMean() << ' '
44  << FIXED(8,2) << h1.GetRMS() << ' '
45  << endl;
46 }
Auxiliary data structure for alignment of data.
Definition: JPrint.hh:248
Auxiliary data structure for floating point format specification.
Definition: JPrint.hh:461
int main ( int  argc,
char **  argv 
)

Definition at line 55 of file JTriggerMonitor.cc.

56 {
57  using namespace std;
58  using namespace KM3NETDAQ;
59  using namespace JPP;
60 
61  JMultipleFileScanner<> inputFile;
62  JLimit_t& numberOfEvents = inputFile.getLimit();
63  string outputFile;
64  JDAQClock clock;
65  int debug;
66 
67  try {
68 
69  JParser<> zap("Auxiliary program to histogram and print trigger statistics.");
70 
71  zap['f'] = make_field(inputFile);
72  zap['o'] = make_field(outputFile) = "monitor.root";
73  zap['n'] = make_field(numberOfEvents) = JLimit::max();
74  zap['c'] = make_field(clock) = JDAQClock::KM3NET, JDAQClock::PPM_DU, JDAQClock::ANTARES;
75  zap['d'] = make_field(debug) = 1;
76 
77  zap(argc, argv);
78  }
79  catch(const exception &error) {
80  FATAL(error.what() << endl);
81  }
82 
83 
84  cout.tie(&cerr);
85 
86 
87  TH1D h1("Timeslice", NULL, 100, 0.0, 1.0e3);
88  TH1D h2("Event ", NULL, 100, 0.0, 1.0e1);
89  TH1D h3("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  JTriggerParameters trigger_parameters;
98  long long int numberOfTimeslices = 0;
99  long long int numberOfSummaryslices = 0;
100 
101 
102  for (JMultipleFileScanner<JTriggerParameters> input = inputFile; input.hasNext(); ) {
103 
104  trigger_parameters = *input.next();
105 
106  NOTICE(trigger_parameters << endl);
107  }
108 
109 
110  for (JMultipleFileScanner<JDAQTimeslice> input = inputFile; input.hasNext(); ++numberOfTimeslices) {
111 
112  STATUS("entry: " << setw(10) << input.getCounter() << '\r'); DEBUG(endl);
113 
114  const JDAQTimeslice* object = input.next();
115 
116  h1.Fill((Double_t) object->getSize() * 1e-6);
117  }
118 
119 
120  for (JMultipleFileScanner<JDAQEvent> input = inputFile; input.hasNext(); ) {
121 
122  STATUS("entry: " << setw(10) << input.getCounter() << '\r'); DEBUG(endl);
123 
124  const JDAQEvent* object = input.next();
125 
126  h2.Fill((Double_t) object->getSize() * 1e-6);
127 
128  hn.Fill((Double_t) object->size<JDAQTriggeredHit>());
129  hs.Fill((Double_t) object->size<JDAQSnapshotHit> ());
130 
131  for (unsigned int i = 0; i != NUMBER_OF_TRIGGER_BITS; ++i) {
132  if (object->hasTriggerBit(i)) {
133  hm.Fill((Double_t) i);
134  }
135  }
136 
137  {
138  unsigned int n = 0;
139 
140  typedef JDAQSnapshotHit JHit_t;
141 
142  for (JDAQEvent::const_iterator<JHit_t> i = object->begin<JHit_t>(); i != object->end<JHit_t>(); ++i) {
143 
144  if (object->getTriggerMask(*i) != 0) {
145  ++n;
146  }
147  }
148 
149  if (object->size<JHit_t>() != 0 && n != object->size<JDAQTriggeredHit>()) {
150  ERROR("Number of snapshot hits with trigger mask " << n << " != " << object->size<JDAQTriggeredHit>() << endl);
151  }
152  }
153  }
154 
155 
156  for (JMultipleFileScanner<JDAQSummaryslice> input = inputFile; input.hasNext(); ++numberOfSummaryslices) {
157 
158  STATUS("entry: " << setw(10) << input.getCounter() << '\r'); DEBUG(endl);
159 
160  const JDAQSummaryslice* object = input.next();
161 
162  h3.Fill((Double_t) object->getSize() * 1e-6);
163 
164  for (JDAQSummaryslice::const_iterator i = object->begin(); i != object->end(); ++i) {
165  for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
166  hr.Fill(i->getRate(pmt) * 1.0e-3);
167  }
168  }
169  }
170 
171 
172  if (debug >= JEEP::status_t) {
173  print(h1, cout);
174  print(h2, cout);
175  print(h3, cout);
176  print(hn, cout);
177  print(hs, cout);
178  print(hr, cout);
179  }
180 
181  NOTICE(endl);
182  NOTICE("Background rate estimate from snapshot hits " << setprecision(2)
183  << (hs.GetMean() - hn.GetMean()) * numberOfSummaryslices / (hr.GetEntries() * 2e-6 * trigger_parameters.TMaxEvent_ns)
184  << " [kHz]" << endl);
185  NOTICE(endl);
186 
187  long long int numberOfSlices = 0;
188 
189 
190  if (numberOfSlices == 0) numberOfSlices = numberOfTimeslices * trigger_parameters.writeTimeslices.prescale;
191  if (numberOfSlices == 0) numberOfSlices = numberOfSummaryslices * trigger_parameters.writeSummary .prescale;
192 
193 
194  const double T = numberOfSlices * 1.0e-9 * getFrameTime(); // [s]
195 
196  NOTICE(setw(WIDTH) << left << "Total run duration (based on time slices) [s] " << FIXED(7,1) << T << endl);
197 
198 
199  for (Int_t i = 1; i <= hm.GetNbinsX(); ++i) {
200 
201  const Double_t x = hm.GetBinCenter (i);
202  const Double_t y = hm.GetBinContent(i);
203 
204  if (y != 0.0) {
205 
206  NOTICE("Trigger"
207  << "[" << setw(2) << (int) x << "]" << ' '
208  << setw(16) << left << getTriggerName(x) << ' '
209  << FIXED(7,0) << y);
210 
211  if (numberOfSlices != 0) {
212  NOTICE(FIXED(7,2) << y / T << " [Hz]");
213  }
214 
215  NOTICE(endl);
216  }
217  }
218 
219  NOTICE("Total "
220  << setw(4) << " " << ' '
221  << setw(16) << " " << ' '
222  << FIXED(7,0) << h2.GetEntries());
223 
224  if (numberOfSlices != 0) {
225  NOTICE(FIXED(7,2) << h2.GetEntries() / T << " [Hz]");
226  }
227 
228  NOTICE(endl);
229 
230  TFile out(outputFile.c_str(), "recreate");
231 
232  out << h1 << h2 << h3;
233  out << hm << hn << hs << hr;
234 
235  out.Write();
236  out.Close();
237 }
Auxiliary data structure for alignment of data.
Definition: JPrint.hh:248
Utility class to parse command line options.
Definition: JParser.hh:1410
#define KM3NET
Definition: JDAQ.hh:20
DAQ key hit.
Definition: JDAQKeyHit.hh:24
Data structure for all trigger parameters.
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:61
Template const_iterator.
Definition: JDAQEvent.hh:69
#define ANTARES
Definition: JDAQ.hh:21
Auxiliary data structure for floating point format specification.
Definition: JPrint.hh:461
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:229
JLimit JLimit_t
Type definition of limit.
Definition: JLimit.hh:214
virtual int getSize() const
Get size of object.
Definition: JDAQEvent.hh:304
const_iterator< T > end() const
Get end of data.
void print(const TH1 &h1, std::ostream &out)
Print histogram parameters.
status
Definition: JMessage.hh:28
const_iterator< T > begin() const
Get begin of data.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
double getFrameTime()
Get frame time duration.
Definition: JDAQClock.hh:162
virtual int getSize() const
Get size of object.
#define NOTICE(A)
Definition: JMessage.hh:62
#define ERROR(A)
Definition: JMessage.hh:64
Data time slice.
Auxiliary class to set DAQ system clock parameters.
Definition: JDAQClock.hh:27
int debug
debug level
Definition: JSirene.cc:59
#define FATAL(A)
Definition: JMessage.hh:65
virtual int getSize() const
Get size of object.
const char * getTriggerName(JTriggerbit_t bit)
Get trigger name.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:72
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26
JTriggerCounter_t next()
Increment trigger counter.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:60

Variable Documentation

const int WIDTH = 20
static

Definition at line 28 of file JTriggerMonitor.cc.