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

Auxiliary program to calculate the noise to signal ratio in the ToT distribution. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JPMTParametersMap.hh"
#include "JDetector/JDetectorCalibration.hh"
#include "JSupport/JMeta.hh"
#include "JCalibrate/JCalibrateToT.hh"
#include "JCalibrate/JParameters.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
#include "JROOT/JManager.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to calculate the noise to signal ratio in the ToT distribution.

Author
acreusot

Definition in file JIntegrateToT.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 37 of file JIntegrateToT.cc.

38 {
39  using namespace std;
40  using namespace JPP;
41  using namespace KM3NETDAQ;
42 
43  typedef JRange<double> JRange_t;
44  string inputFile;
45  string outputFile;
46  string detectorFile;
47  JRange_t fitRange;
48  string regexp;
49  int runNb;
50  int debug;
51 
52  try {
53 
54  JParser<> zap("Auxiliary program to integrate time-over-threshold distributions.");
55 
56  zap['f'] = make_field(inputFile, "input file (output from JCalibrateToT).");
57  zap['o'] = make_field(outputFile, "output file.") = "results.txt";
58  zap['a'] = make_field(detectorFile, "detector file.");
59  zap['x'] = make_field(fitRange, "ROOT integration range for noise.") = JRange_t(0.0, 8.0);
60  zap['R'] = make_field(regexp, "regular expression for histogram name.") = MAKE_CSTRING(WILDCARD << _2SToT);
61  zap['r'] = make_field(runNb, "current run number");
62  zap['d'] = make_field(debug, "debug.") = 1;
63 
64  zap(argc, argv);
65  }
66  catch(const exception &error) {
67  FATAL(error.what() << endl);
68  }
69 
70 
71  //----------------------------------------------------------
72  // load detector file
73  //----------------------------------------------------------
74 
76  try {
77  load(detectorFile, detector);
78  }
79  catch(const JException& error) {
80  FATAL(error);
81  }
82  const JModuleRouter moduleRouter(detector);
83 
84  TFile* in = TFile::Open(inputFile.c_str(), "exist");
85  if (in == NULL || !in->IsOpen()) {
86  FATAL("File: " << inputFile << " not opened." << endl);
87  }
88  ofstream ostr(outputFile.c_str(), ios::out|ios::app);
89 
90  for (JDetector::iterator module = detector.begin(); module != detector.end(); ++module) {
91  DEBUG("Module " << module->getID() << endl);
92  TH2D* h2s = (TH2D*) in->Get(replace(regexp, WILDCARD, MAKE_STRING(module->getID())).c_str());
93  if (h2s == NULL) {
94  WARNING("No histogram " << module->getID() << "; skip calculation." << endl);
95  continue;
96  }
97 
98  for (int ix = 1; ix <= h2s->GetXaxis()->GetNbins(); ++ix) {
99  double noise = 0;
100  double signal = 0;
101  const int domId = module->getID();
102  const JPMTIdentifier id(domId, ix - 1);
103  const string name = MAKE_STRING(id.getPMTAddress());
104  for (int iy = h2s->GetNbinsY(); iy >= 1; --iy) {
105  const double y = h2s->GetBinContent(ix, iy);
106  signal += y;
107  if ((iy >= fitRange.getLowerLimit()) && (iy <= fitRange.getUpperLimit())) noise += y;
108  }
109  const double ratio = (signal != 0? noise/signal : 0);
110  const JModule dom = moduleRouter.getModule(domId);
111  //JPMT pmt = dom.getPMT(ix - 1);
112  const JParameters curPar(runNb, domId, ix - 1, -1, noise, signal, ratio > 0.5);
113  ostr << curPar << endl;
114  }
115  }
116  ostr.close();
117 }
Utility class to parse command line options.
Definition: JParser.hh:1500
General exception.
Definition: JException.hh:23
#define WARNING(A)
Definition: JMessage.hh:65
TString replace(const TString &target, const TRegexp &regexp, const T &replacement)
Replace regular expression in input by given replacement.
Definition: JPrintResult.cc:63
Data structure for a composite optical module.
Definition: JModule.hh:66
Detector data structure.
Definition: JDetector.hh:81
Router for direct addressing of module data in detector data structure.
Auxiliary class for PMT parameters including threshold.
Definition: JParameters.hh:21
then echo Enter input within $TIMEOUT_S seconds echo n User name
Definition: JCookie.sh:42
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:151
string outputFile
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:142
Detector file.
Definition: JHead.hh:196
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:63
#define FATAL(A)
Definition: JMessage.hh:67
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
static const char *const _2SToT
Histogram naming.
do set_variable DETECTOR_TXT $WORKDIR detector
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:40