Jpp  17.2.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JDAQSummaryslice.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 #include <limits>
6 
7 #include "TROOT.h"
8 #include "TFile.h"
9 #include "TH1D.h"
10 #include "TH2D.h"
11 #include "TProfile.h"
12 
16 
18 #include "JSupport/JSupport.hh"
19 
20 #include "Jeep/JParser.hh"
21 #include "Jeep/JMessage.hh"
22 
23 
24 /**
25  * \file
26  *
27  * Example program to histogram KM3NETDAQ::JDAQSummaryslice.
28  * \author mdejong
29  */
30 int main(int argc, char **argv)
31 {
32  using namespace std;
33  using namespace JPP;
34  using namespace KM3NETDAQ;
35 
37  JLimit_t& numberOfEvents = inputFile.getLimit();
38  string outputFile;
39  bool correct;
40  int debug;
41 
42  try {
43 
44  JParser<> zap("Example program to histogram summary data.");
45 
46  zap['f'] = make_field(inputFile);
47  zap['o'] = make_field(outputFile) = "summaryslice.root";
48  zap['n'] = make_field(numberOfEvents) = JLimit::max();
49  zap['c'] = make_field(correct);
50  zap['d'] = make_field(debug) = 2;
51 
52  zap(argc, argv);
53  }
54  catch(const exception& error) {
55  FATAL(error.what() << endl);
56  }
57 
58 
59  const double factor = 1.0e-3; // [kHz]
60 
61  cout.tie(&cerr);
62 
63  TFile out(outputFile.c_str(), "recreate");
64 
65  TH1D h0("h0", NULL, JDAQRate::getN(), JDAQRate::getData(factor));
66  TProfile h1("h1", NULL, 32,-0.5, 31.5);
67  TProfile h2("h2", NULL, 32,-0.5, 31.5);
68 
69  TH2D hu("hu", NULL, 201, -0.5, +200.5, 201, -0.5, +200.5);
70 
71  TH2D hv("hv", NULL, 51, -0.5, +50.5, 200, 0.0, 50.0);
72  TH2D hw("hw", NULL, 51, -0.5, +50.5, 200, 0.0, 50.0);
73 
74  TH2D hx("hx", NULL, NUMBER_OF_PMTS, -0.5, NUMBER_OF_PMTS - 0.5, 200, 0.0, 50.0);
75  TH2D hy("hy", NULL, NUMBER_OF_PMTS, -0.5, NUMBER_OF_PMTS - 0.5, 200, 0.0, 50.0);
76 
77 
78  while (inputFile.hasNext()) {
79 
80  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
81 
82  JDAQSummaryslice* summaryslice = inputFile.next();
83 
84  DEBUG("Summary: "
85  << setw(8) << inputFile.getCounter() << ' '
86  << setw(8) << summaryslice->getRunNumber() << ' '
87  << setw(8) << summaryslice->getFrameIndex() << ' '
88  << setw(6) << summaryslice->size() << endl);
89 
90  const JDetectorAddressMap& demo = getDetectorAddressMap(summaryslice->getDetectorID());
91 
92  for (JDAQSummaryslice::const_iterator frame = summaryslice->begin(); frame != summaryslice->end(); ++frame) {
93 
94  const JModuleAddressMap& memo = demo.get(frame->getModuleID());
95 
96  int N[2] = { 0 };
97  double R[2] = { 0.0 };
98 
99  int lower[2] = { 0 };
100  int upper[2] = { 0 };
101 
102  for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
103 
104  const int index = (!frame->testHighRateVeto(pmt) && !frame->testFIFOStatus(pmt) ? 0 : 1);
105 
106  N[index] += 1;
107  R[index] += correct ? getRate(*frame, pmt, factor) : frame->getRate(pmt, factor);
108 
109  if (memo.getAddressTranslator(pmt).ring <= 'D')
110  lower[index] += 1;
111  else
112  upper[index] += 1;
113 
114  h0.Fill(correct ? getRate(*frame, pmt, factor) : frame->getRate(pmt, factor), frame->getWeight(pmt, factor));
115 
116  h1.Fill((Double_t) pmt, (frame->testHighRateVeto(pmt) ? 1.0 : 0.0));
117  h2.Fill((Double_t) pmt, (frame->testFIFOStatus (pmt) ? 1.0 : 0.0));
118  }
119 
120  hu.Fill((double) frame->getUDPMaximalSequenceNumber(),
121  (double) frame->getUDPNumberOfReceivedPackets());
122 
123  if (N[0] != 0) { hv.Fill((double) frame->getUDPMaximalSequenceNumber(), R[0] / N[0]); }
124  if (N[1] != 0) { hw.Fill((double) frame->getUDPMaximalSequenceNumber(), R[1] / N[1]); }
125 
126  if (N[0] != 0) {
127 
128  hx.Fill((double) N[1], R[0] / N[0]);
129 
130  if (lower[0] != 0 && upper[0] != 0) {
131  hy.Fill((double) N[1], R[0] / N[0]);
132  }
133  }
134 
135  const bool status = (frame->getUDPNumberOfReceivedPackets() == frame->getUDPMaximalSequenceNumber() + 1 &&
136  frame->hasUDPTrailer());
137 
138  h1.Fill((Double_t) 31, (frame->testWhiteRabbitStatus() ? 1.0 : 0.0));
139  h2.Fill((Double_t) 31, (status ? 1.0 : 0.0));
140  }
141  }
142  STATUS(endl);
143 
144  out.Write();
145  out.Close();
146 }
Utility class to parse command line options.
Definition: JParser.hh:1517
int main(int argc, char *argv[])
Definition: Main.cc:15
double getN(const JRange< T > &range, const double R)
Get expected number of occurrences due to given rate within specified interval.
Definition: JRange.hh:713
ROOT TTree parameter settings of various packages.
int getDetectorID() const
Get detector identifier.
#define STATUS(A)
Definition: JMessage.hh:63
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
Lookup table for PMT addresses in detector.
string outputFile
int getRunNumber() const
Get run number.
int getFrameIndex() const
Get frame index.
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Lookup table for PMT addresses in optical module.
Detector specific mapping between logical positions and readout channels of PMTs in optical modules...
double getRate(const JDAQSummaryFrame &frame, const int pmt, const double factor=1.0)
Get corrected rate of PMT.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1993
char ring
ring number [&#39;A&#39;,&#39;F&#39;]
JDetectorAddressMap & getDetectorAddressMap()
Get detector address map.
then usage $script[distance] fi case set_variable R
Definition: JDrawLED.sh:43
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Scanning of objects from multiple files according a format that follows from the extension of each fi...
const JPMTAddressTranslator & getAddressTranslator(const int tdc) const
Get PMT address translator.
Utility class to parse command line options.
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
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62