Jpp - 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  cout.tie(&cerr);
55 
56  using namespace KM3NETDAQ;
57 
58  const double factor = 1.0/1000 ;
59  const int Nbins = 90 ; // reasonable range for singles rates from 0-20 kHz
60 
61  JManager<int, TH2D> SinglesRatedistr(new TH2D("%.2S", NULL, NUMBER_OF_PMTS, -0.5, NUMBER_OF_PMTS-0.5, Nbins, JDAQRate::getData(factor))) ;
62 
63  while (inputFile.hasNext()) {
64 
65  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
66 
67  JDAQSummaryslice* summary = inputFile.next() ;
68 
69  for (KM3NETDAQ::JDAQSummaryslice::const_iterator summary_frame = summary->begin(); summary_frame != summary->end(); ++summary_frame) {
70 
71  int DOMID = summary_frame->getModuleID() ;
72  TH2D* h_i = SinglesRatedistr[DOMID] ;
73 
74  for (int ipmt = 0 ; ipmt<NUMBER_OF_PMTS ; ipmt++) {
75  h_i->Fill(ipmt, summary_frame->getRate(ipmt, factor), summary_frame->getWeight(ipmt, factor));
76  }
77 
78  }
79 
80  }
81  STATUS(endl);
82 
83  // Store histogram(s).
84  TFile out(outputFile.c_str(), "recreate");
85  SinglesRatedistr.Write(out) ;
86  out.Write();
87  out.Close();
88 
89 }
Utility class to parse command line options.
Definition: JParser.hh:1500
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:1961
void Write(TDirectory &out, const bool wm=false)
Write objects to file.
Definition: JManager.hh:295
int debug
debug level
Definition: JSirene.cc:63
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.
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
KM3NeT DAQ constants, bit handling, etc.
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26