Jpp  15.0.5
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JDAQModuleRouter.cc File Reference

Example program to histogram string and floor rates. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "TH2D.h"
#include "TProfile2D.h"
#include "JTools/JHashCollection.hh"
#include "JDAQ/JDAQSummarysliceIO.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JSupport.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to histogram string and floor rates.

Author
mdejong

Definition in file JDAQModuleRouter.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 32 of file JDAQModuleRouter.cc.

33 {
34  using namespace std;
35  using namespace JPP;
36  using namespace KM3NETDAQ;
37 
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 
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::JHashCollection<int> JHashCollection_t;
77 
78  const JHashCollection_t string(make_array(detector.begin(), detector.end(), &JModule::getString));
79  const JHashCollection_t floor (make_array(detector.begin(), detector.end(), &JModule::getFloor));
80 
81  TFile out(outputFile.c_str(), "recreate");
82 
83  TProfile2D h2("h2", NULL,
84  string.size(), -0.5, string.size() - 0.5,
85  floor .size(), -0.5, floor .size() - 0.5);
86 
87  for (Int_t i = 1; i <= h2.GetXaxis()->GetNbins(); ++i) {
88  h2.GetXaxis()->SetBinLabel(i, MAKE_CSTRING(string.at(i-1)));
89  }
90  for (Int_t i = 1; i <= h2.GetYaxis()->GetNbins(); ++i) {
91  h2.GetYaxis()->SetBinLabel(i, MAKE_CSTRING(floor .at(i-1)));
92  }
93 
94  while (inputFile.hasNext()) {
95 
96  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
97 
98  const JDAQSummaryslice* summary = inputFile.next();
99 
100  for (JDAQSummaryslice::const_iterator frame = summary->begin(); frame != summary->end(); ++frame) {
101 
102  if (router.hasModule(frame->getModuleID())) {
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) string.getIndex(module.getString()),
109  (double) floor .getIndex(module.getFloor()),
110  frame->getRate(pmt) * 1.0e-3); // [kHz]
111  }
112  }
113  } else {
114  FATAL("JModuleRouter trying to access non existing identifier: " << frame->getModuleID());
115  }
116  }
117  }
118  STATUS(endl);
119 
120  out.Write();
121  out.Close();
122 }
Utility class to parse command line options.
Definition: JParser.hh:1500
General exception.
Definition: JException.hh:23
int getFloor() const
Get floor number.
Definition: JLocation.hh:145
Data structure for a composite optical module.
Definition: JModule.hh:68
#define STATUS(A)
Definition: JMessage.hh:63
Detector data structure.
Definition: JDetector.hh:89
Router for direct addressing of module data in detector data structure.
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:151
string outputFile
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Detector file.
Definition: JHead.hh:196
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
const array_type< JValue_t > & make_array(const JValue_t(&array)[N])
Method to create array of values.
Definition: JVectorize.hh:54
int getIndex()
Get index for user I/O manipulation.
Definition: JManip.hh:26
int debug
debug level
Definition: JSirene.cc:63
#define FATAL(A)
Definition: JMessage.hh:67
int getString() const
Get string number.
Definition: JLocation.hh:134
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
do set_variable DETECTOR_TXT $WORKDIR detector
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26