Jpp  18.3.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JMonitorSinglesRates.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 "TH2D.h"
9 
10 #include "JROOT/JManager.hh"
11 
13 #include "JDAQ/JDAQTimesliceIO.hh"
17 
18 #include "JTools/JRange.hh"
19 
21 #include "JSupport/JSupport.hh"
22 #include "Jeep/JParser.hh"
23 #include "Jeep/JMessage.hh"
24 
25 /**
26  * \file
27  *
28  * Monitoring of PMT time over threshold distributions.
29  * \author mkarel
30  */
31 int main(int argc, char **argv)
32 {
33  using namespace std;
34  using namespace JPP;
35  using namespace KM3NETDAQ;
36 
38  string outputFile;
39  int debug;
40 
41  try {
42 
43  JParser<> zap("Monitoring of PMT time over threshold distributions.");
44 
45  zap['f'] = make_field(inputFile);
46  zap['o'] = make_field(outputFile) = "monitor.root";
47  zap['d'] = make_field(debug) = 1;
48  zap(argc, argv);
49  }
50  catch(const exception &error) {
51  FATAL(error.what() << endl);
52  }
53 
54 
55  using namespace KM3NETDAQ;
56 
57  const double factor = 1.0/1000 ;
58  const int Nbins = 90 ; // reasonable range for singles rates from 0-20 kHz
59 
60  JManager<int, TH2D> SinglesRatedistr(new TH2D("%.2S", NULL, NUMBER_OF_PMTS, -0.5, NUMBER_OF_PMTS-0.5, Nbins, JDAQRate::getData(factor))) ;
61 
62  while (inputFile.hasNext()) {
63 
64  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
65 
66  JDAQSummaryslice* summary = inputFile.next() ;
67 
68  for (KM3NETDAQ::JDAQSummaryslice::const_iterator summary_frame = summary->begin(); summary_frame != summary->end(); ++summary_frame) {
69 
70  int DOMID = summary_frame->getModuleID() ;
71  TH2D* h_i = SinglesRatedistr[DOMID] ;
72 
73  for (int ipmt = 0 ; ipmt<NUMBER_OF_PMTS ; ipmt++) {
74  h_i->Fill(ipmt, summary_frame->getRate(ipmt, factor), summary_frame->getWeight(ipmt, factor));
75  }
76 
77  }
78 
79  }
80  STATUS(endl);
81 
82  // Store histogram(s).
83  TFile out(outputFile.c_str(), "recreate");
84  SinglesRatedistr.Write(out) ;
85  out.Write();
86  out.Close();
87 
88 }
Utility class to parse command line options.
Definition: JParser.hh:1514
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
#define STATUS(A)
Definition: JMessage.hh:63
Dynamic ROOT object management.
string outputFile
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys...
Definition: JManager.hh:43
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
void Write(TDirectory &out, const bool wm=false)
Write objects to file.
Definition: JManager.hh:295
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...
Direct access to module in detector data structure.
Auxiliary class to define a range between two values.
Utility class to parse command line options.
KM3NeT DAQ constants, bit handling, etc.
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