Jpp
Functions
JDAQModuleRouter.cc File Reference
#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "TH2D.h"
#include "TProfile2D.h"
#include "JTools/JRange.hh"
#include "JDAQ/JDAQSummaryslice.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

◆ main()

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 
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 }
JDETECTOR::load
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
Definition: JDetectorToolkit.hh:456
JTOOLS::JRange< int >
JSUPPORT::JLimit_t
JLimit JLimit_t
Type definition of limit.
Definition: JLimit.hh:215
KM3NETDAQ::NUMBER_OF_PMTS
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
NOTICE
#define NOTICE(A)
Definition: JMessage.hh:64
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
debug
int debug
debug level
Definition: JSirene.cc:59
JSUPPORT::JLimit::getLimit
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
KM3NETDAQ::JDAQSummaryslice
Data summary slice.
Definition: JDAQSummaryslice.hh:31
STATUS
#define STATUS(A)
Definition: JMessage.hh:63
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
DEBUG
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
std
Definition: jaanetDictionary.h:36
KM3NETDAQ
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
outputFile
string outputFile
Definition: JDAQTimesliceSelector.cc:37