Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JDAQModuleRouter.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 
6 #include "TROOT.h"
7 #include "TFile.h"
8 #include "TH1D.h"
9 #include "TH2D.h"
10 #include "TProfile2D.h"
11 
12 #include "JTools/JRange.hh"
13 
14 #include "JDAQ/JDAQSummaryslice.hh"
15 #include "JDetector/JDetector.hh"
18 
20 #include "JSupport/JSupport.hh"
21 
22 #include "Jeep/JParser.hh"
23 #include "Jeep/JMessage.hh"
24 
25 
26 /**
27  * \file
28  *
29  * Example program to histogram string and floor rates.
30  * \author mdejong
31  */
32 int main(int argc, char **argv)
33 {
34  using namespace std;
35  using namespace JPP;
36  using namespace KM3NETDAQ;
37 
38  JMultipleFileScanner<JDAQSummaryslice> inputFile;
39  JLimit_t& numberOfEvents = inputFile.getLimit();
40  string outputFile;
41  string detectorFile;
42  int debug;
43 
44  try {
45 
46  JParser<> zap("Example program to histogram string and floor rates.");
47 
48  zap['f'] = make_field(inputFile);
49  zap['o'] = make_field(outputFile) = "router.root";
50  zap['a'] = make_field(detectorFile);
51  zap['n'] = make_field(numberOfEvents) = JLimit::max();
52  zap['d'] = make_field(debug) = 2;
53 
54  zap(argc, argv);
55  }
56  catch(const exception& error) {
57  FATAL(error.what() << endl);
58  }
59 
60 
61  cout.tie(&cerr);
62 
63 
64  JDetector detector;
65 
66  try {
67  load(detectorFile, detector);
68  }
69  catch(const JException& error) {
70  FATAL(error);
71  }
72 
73  const JModuleRouter router(detector);
74 
75 
76  typedef JTOOLS::JRange<int> JRange_t;
77 
78  const JRange_t string(detector.begin(), detector.end(), &JModule::getString);
79  const JRange_t floor (detector.begin(), detector.end(), &JModule::getFloor);
80 
81  NOTICE("String " << string.getLowerLimit() << " - " << string.getUpperLimit() << endl);
82  NOTICE("Floor " << floor .getLowerLimit() << " - " << floor .getUpperLimit() << endl);
83 
84 
85  TFile out(outputFile.c_str(), "recreate");
86 
87  TProfile2D h2("h2", NULL,
88  string.getLength() + 1,
89  string.getLowerLimit() - 0.5,
90  string.getUpperLimit() + 0.5,
91  floor.getLength() + 1,
92  floor.getLowerLimit() - 0.5,
93  floor.getUpperLimit() + 0.5);
94 
95 
96  while (inputFile.hasNext()) {
97 
98  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
99 
100  JDAQSummaryslice* summary = inputFile.next();
101 
102  for (JDAQSummaryslice::const_iterator frame = summary->begin(); frame != summary->end(); ++frame) {
103 
104  const JModule& module = router.getModule(frame->getModuleID());
105 
106  for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
107  if (!frame->testHighRateVeto(pmt) && !frame->testFIFOStatus(pmt)) {
108  h2.Fill((double) module.getString(), (double) module.getFloor(), frame->getRate(pmt) * 1.0e-3); // [kHz]
109  }
110  }
111  }
112  }
113  STATUS(endl);
114 
115  out.Write();
116  out.Close();
117 }
Utility class to parse command line options.
Definition: JParser.hh:1410
#define STATUS(A)
Definition: JMessage.hh:61
string outputFile
Data structure for detector geometry and calibration.
JLimit JLimit_t
Type definition of limit.
Definition: JLimit.hh:214
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
#define NOTICE(A)
Definition: JMessage.hh:62
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
int debug
debug level
Definition: JSirene.cc:59
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:65
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Direct access to module in detector data structure.
Auxiliary class to define a range between two values.
Utility class to parse command line options.
ROOT TTree parameter settings.
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
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:60
int main(int argc, char *argv[])
Definition: Main.cpp:15