Jpp  master_rocky-37-gf0c5bc59d
the software that should make you happy
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

◆ main()

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 }
#define NOTICE(A)
Definition: JMessage.hh:64
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2142
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
Utility class to parse parameter values.
Definition: JProperties.hh:501
Auxiliary class to handle file name, ROOT directory and object name.
TString getObjectName() const
Get object name.
const std::string & getFilename() const
Get file name.
Utility class to parse command line options.
Definition: JParser.hh:1698
static const double FITTOT_GAIN_MAX
Default maximal gain.
Definition: JFitToT.hh:45
static const double FITTOT_GAIN_MIN
Default minimal gain.
Definition: JFitToT.hh:44
const double NOMINAL_GAIN
Specification for normalized gain corresponding to a one photo-electron pulse.
@ RIGHT
Definition: JTwosome.hh:18
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
bool putObject(TDirectory &dir, const TObject &object)
Write object to ROOT directory.
Definition: JSTDTypes.hh:14
Auxiliary data structure for sequence of same character.
Definition: JManip.hh:330
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:448
Type definition of range.
Definition: JHead.hh:43
Auxiliary data structure to store high-voltage versus gain data and interpolate the nominal high-volt...
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:68
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:72