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

Auxiliary program to update the PMT status (bad channel) in the detector file based on the small ToT fraction computation (i.e. More...

#include <string>
#include <iostream>
#include <vector>
#include "JCalibrate/JParameters.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.hh"
#include "JDetector/JPMTIdentifier.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JMeta.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (const int argc, const char *const argv[])
 

Detailed Description

Auxiliary program to update the PMT status (bad channel) in the detector file based on the small ToT fraction computation (i.e.

the noise to signal ratio).

Author
acreusot

Definition in file JFindBadChannels.cc.

Function Documentation

int main ( const int  argc,
const char *const  argv[] 
)

Definition at line 26 of file JFindBadChannels.cc.

27 {
28  using namespace std;
29  using namespace JPP;
30 
31  string detectorFile;
32  string inputFile;
33  double stfCut;
34  int debug;
35  bool overwriteDetector;
36 
37  try {
38  JParser<> zap("Auxiliary program to find the bad channels (PMTs) according to the small ToT fraction (i.e. the noise to signal ratio).");
39  zap['a'] = make_field(detectorFile, "detector file");
40  zap['f'] = make_field(inputFile, "output file of JIntegrateToT");
41  zap['t'] = make_field(stfCut, "small ToT fraction cut-off") = 0.5;
42  zap['d'] = make_field(debug) = 1;
43  zap['A'] = make_field(overwriteDetector, "overwrite detector file with bad channel boolean.");
44  zap(argc, argv);
45  }
46  catch(const exception& error) {
47  FATAL(error.what() << endl);
48  }
49 
50  // Load detector file and update it to latest version
52  try {
53  load(detectorFile, detector);
54  }
55  catch(const JException& error) {
56  FATAL(error);
57  }
58  detector.comment.add(JMeta(argc,argv));
59  if (detector.setToLatestVersion()) {
60  NOTICE("Set detector version to " << detector.getVersion() << endl);
61  }
62  const JModuleRouter moduleRouter(detector);
63 
64  // read PMT ToT parameters from the data file
65  ifstream istr(inputFile.c_str());
66  vector<JParameters> vParameters;
67  for (JParameters curPar; istr >> curPar;) {
68  DEBUG("Computing small ToT fraction for DOM" << curPar.domId << " - PMT " << curPar.pmtId << endl);
69  vParameters.push_back(curPar);
70  }
71  istr.close();
72 
73  // find and store the bad channels
74  if (overwriteDetector) {
75  for (vector<JParameters>::const_iterator par = vParameters.begin(); par != vParameters.end(); ++par) {
76  if (moduleRouter.hasModule(par->domId)) {
77  // if the histogram is empty (HRV or PMT off) then ratio is set to 1
78  const double ratio = par->signal ? par->noise/par->signal : 1;
79  const bool status = ratio > stfCut ? true : false;
80 
81  const JModuleAddress& address = moduleRouter.getAddress(par->domId);
82 
83  detector.getModule(address).getPMT(par->pmtId).setStatus(status);
84 
85  if (status == true) {
86  NOTICE("bad channel: pmt " << par->pmtId << ", dom "
87  << par->domId << " with a STF of " << ratio << endl);
88  }
89  }
90  }
91  NOTICE("Store calibration data on file " << detectorFile << endl);
92  store(detectorFile, detector);
93  }
94 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:70
Utility class to parse command line options.
Definition: JParser.hh:1500
General exception.
Definition: JException.hh:23
Detector data structure.
Definition: JDetector.hh:80
Router for direct addressing of module data in detector data structure.
Detector file.
Definition: JHead.hh:196
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
#define NOTICE(A)
Definition: JMessage.hh:64
Address of module in detector data structure.
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.
do set_variable DETECTOR_TXT $WORKDIR detector
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62