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

Example program to interpolate input high-voltage-gain data. More...

#include <string>
#include <vector>
#include <istream>
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
#include "JROOT/JManager.hh"
#include "JGizmo/JRootObjectID.hh"
#include "JSupport/JMeta.hh"
#include "JDetector/JCalibration.hh"
#include "JCalibrate/JFitToT.hh"
#include "JCalibrate/JHVInterpolator.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to interpolate input high-voltage-gain data.

Author
bjjung

Definition in file JHVInterpolator.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 28 of file JHVInterpolator.cc.

29 {
30  using namespace std;
31  using namespace JPP;
32 
34 
35  typedef map<double, pair<double, double>> map_t;
36  typedef JRange<double> JRange_t;
37 
38  map_t input;
39  JRootObjectID output;
40 
41  double minDistanceHV = 2 * 3.14;
42  JRange_t rangeHV = JRange_t(-1500 + 1e-2,
43  -80 - 1e-2);
44  JRange_t rangeGain = JRange_t(FITTOT_GAIN_MIN + 1e-2,
45  FITTOT_GAIN_MAX - 1e-2);
46  double targetGain = NOMINAL_GAIN;
47 
48  int debug;
49 
50  try {
51 
52  JParser<> zap("Example program to interpolate high-voltage versus gain ASCII data.");
53 
54  JProperties properties;
55 
56  properties.insert(gmake_property(minDistanceHV));
57  properties.insert(gmake_property(rangeHV));
58  properties.insert(gmake_property(rangeGain));
59  properties.insert(gmake_property(targetGain));
60 
61  zap['f'] = make_field(input);
62  zap['o'] = make_field(output) = JPARSER::initialised();
63  zap['@'] = make_field(properties) = JPARSER::initialised();
64  zap['d'] = make_field(debug) = 2;
65 
66  zap(argc, argv);
67  }
68  catch (const exception& error) {
69  FATAL(error.what() << endl);
70  }
71 
72  JHVInterpolator::setMinHVDistance(minDistanceHV);
73  JHVInterpolator::setHVRange (rangeHV);
74  JHVInterpolator::setGainRange (rangeGain);
75 
76  TMultiGraph graph (output.getObjectName(), NULL);
77  JHVInterpolator interpolator(graph);
78 
79  NOTICE(RIGHT(35) << "High-Voltage [V]" << RIGHT(31) << "gain [-]" << endl);
80 
81  for (map_t::const_iterator i = input.cbegin(); i != input.cend(); ++i) {
82 
83  const double HV = i->first;
84  const double gain = i->second.first;
85  const double gainError = i->second.second;
86 
87  NOTICE(FIXED(35,2) << HV << FIXED(22,2) << gain << " +/- " << FIXED(3,2) << gainError << endl);
88 
89  interpolator.AddPoint(HV, gain, gainError);
90  }
91 
92  TFile file(output.getFilename().c_str(), "RECREATE");
93 
94  putObject(file, JMeta(argc, argv));
95 
96  graph.Write();
97 
98  file.Close();
99 
100  NOTICE(FILL(100,'-') << " Interpolated high-voltage" << setfill(' ') << endl);
101 
102  try {
103 
104  interpolator.interpolateHV(targetGain);
105 
106  const double targetHV = interpolator.getHV ();
107  const double targetHVError = interpolator.getHVError();
108 
109  NOTICE(FIXED(35,2) << right << -targetHV << " +/- " <<
110  FIXED(8, 2) << left << targetHVError <<
111  FIXED(9, 2) << right << targetGain << endl);
112  }
113  catch (const exception& error) {
114  FATAL(error.what() << endl);
115  }
116 }
Utility class to parse command line options.
Definition: JParser.hh:1514
then usage $script[< detector identifier >< run range >]< QA/QCfile > nExample script to produce data quality plots nWhen a detector identifier and run range are data are downloaded from the database nand subsequently stored in the given QA QC file
Definition: JDataQuality.sh:19
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
static const double FITTOT_GAIN_MAX
Default maximal gain.
Definition: JFitToT.hh:44
static const double FITTOT_GAIN_MIN
Default minimal gain.
Definition: JFitToT.hh:43
Utility class to parse parameter values.
Definition: JProperties.hh:497
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:83
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
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:1989
#define NOTICE(A)
Definition: JMessage.hh:64
bool putObject(TDirectory &dir, const TObject &object)
Write object to ROOT directory.
const double NOMINAL_GAIN
Specification for normalized gain corresponding to a one photo-electron pulse.
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
int debug
debug level