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

Program to create input data for HV-tuning. More...

#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
#include "JSupport/JMeta.hh"
#include "JSupport/JSingleFileScanner.hh"
#include "dbclient/KM3NeTDBClient.h"
#include "JDB/JDB.hh"
#include "JDB/JDBToolkit.hh"
#include "JDB/JDBincludes.hh"
#include "JDB/JSelector.hh"
#include "JDB/JSelectorSupportkit.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JCalibrate/JFitToT.hh"
#include "JCalibrate/JHVInterpolator.hh"
#include "JROOT/JManager.hh"
#include "TFile.h"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Program to create input data for HV-tuning.

Author
bjung

Definition in file JGetInputTuneHV.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 34 of file JGetInputTuneHV.cc.

35 {
36  using namespace std;
37  using namespace JPP;
38 
39  JServer server;
40  string usr;
41  string pwd;
42  string cookie;
43 
44  map<int, string> inputFiles;
45  string detectorFile;
46  string outputFile;
47 
48  int debug;
49 
50  try {
51 
52  JParser<> zap("Program to create input data for HV-tuning.");
53 
54  zap['s'] = make_field(server) = getServernames();
55  zap['u'] = make_field(usr) = "";
56  zap['!'] = make_field(pwd) = "";
57  zap['C'] = make_field(cookie) = "";
58  zap['f'] = make_field(inputFiles, "map of run numbers to file names (i.e. to the output of JFitToT)");
59  zap['a'] = make_field(detectorFile, "detector file");
60  zap['o'] = make_field(outputFile, "output file");
61  zap['d'] = make_field(debug, "debug") = 1;
62 
63  zap(argc, argv);
64  }
65  catch(const exception &error) {
66  FATAL(error.what() << endl);
67  }
68 
69 
71 
72  JManager<string, TMultiGraph> manager(new TMultiGraph(), "%.HVxG");
73 
74  try {
75 
76  load(detectorFile, detector);
77 
78  JDB::reset(usr, pwd, cookie);
79 
80  // Extract gain and high-voltage data
81 
82  for (map<int, string>::const_iterator fileIt = inputFiles.cbegin(); fileIt != inputFiles.cend(); ++fileIt) {
83 
84  const int runNr = fileIt->first;
85 
86  NOTICE("Extracting Gain-/HV-data for run " << runNr << endl);
87 
88  {
89  TFile fitData(fileIt->second.c_str(), "READ");
90 
92  ResultSet& rs = getResultSet(getTable<JPMTHVRunSettings>(), selector);
93 
94  for (JPMTHVRunSettings table; rs >> table; ) {
95 
96  const int domID = detector.getModule(JLocation(table.DUID, table.FLOORID)).getID();
97  const string pmtID = MAKE_STRING(right << domID << '.' << FILL(2,'0') << table.CABLEPOS);
98 
99  const TH1* h1 = (TH1*) fitData.Get(MAKE_CSTRING(pmtID << FITTOT_SUFFIX));
100  const TF1* f1 = (h1 != NULL ? h1->GetFunction(FITTOT_FNAME.c_str()) : NULL);
101 
102  JHVInterpolator interpolator(*(manager[pmtID]));
103 
104  if (f1 != NULL) {
105 
106  const int Ngain = f1->GetParNumber(FITTOT_GAIN_PARNAME);
107 
108  const double gain = f1->GetParameter(Ngain);
109  const double gainError = f1->GetParError (Ngain);
110 
111  interpolator.AddPoint(table.HV_VALUE, gain, gainError);
112  }
113  }
114 
115  rs.Close();
116  }
117  }
118 
119  } catch (const exception& error) {
120 
121  FATAL(error.what() << endl);
122  }
123 
124 
125  // Write output
126 
127  TFile out(outputFile.c_str(), "RECREATE");
128 
129  putObject(out, JMeta(argc, argv));
130 
131  for (map<int, string>::const_iterator i = inputFiles.cbegin(); i != inputFiles.cend(); ++i) {
132  for (JSingleFileScanner<JMeta> in(i->second); in.hasNext(); ) {
133  putObject(out, *in.next());
134  }
135  }
136 
137  out << manager;
138 
139  out.Close();
140 }
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:1517
Detector data structure.
Definition: JDetector.hh:89
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:136
Auxiliary class for specifying selection of database data.
string outputFile
JDetectorsHelper & getDetector()
Auxiliary function for helper object initialisation.
Definition: JDBToolkit.hh:378
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:127
static const std::string FITTOT_SUFFIX
Definition: JFitToT.hh:36
const JPolynome f1(1.0, 2.0, 3.0)
Function.
static const char * FITTOT_GAIN_PARNAME
Definition: JFitToT.hh:39
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys...
Definition: JManager.hh:43
Detector file.
Definition: JHead.hh:226
Logical location of module.
Definition: JLocation.hh:37
Auxiliary data structure to store high-voltage versus gain data and interpolate the nominal high-volt...
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1993
#define NOTICE(A)
Definition: JMessage.hh:64
bool putObject(TDirectory &dir, const TObject &object)
Write object to ROOT directory.
Auxiliary data structure for sequence of same character.
Definition: JManip.hh:328
#define FATAL(A)
Definition: JMessage.hh:67
then $JPP_DIR examples JDetector JToT o $OUTPUT_FILE n N $NPE P gain
Definition: JToT.sh:47
void reset(T &value)
Reset value.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition: JDB.hh:431
std::vector< JServer > getServernames()
Get list of names of available database servers.
Definition: JDB.hh:101
Wrapper class for server name.
Definition: JDB.hh:45
Object reading from a list of files.
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 JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
Template definition for getting table specific selector.
static const std::string FITTOT_FNAME
Definition: JFitToT.hh:37
int debug
debug level