1 #include "GainVoltPmtParameters.h"
4 int GainVoltPmtParameters::ioMode=2;
9 double GainVoltPmtParameters::_defaultB = 10.71;
11 GainVoltPmtParameters::GainVoltPmtParameters()
14 GainVoltPmtParameters::GainVoltPmtParameters(
double refVoltage,
double gains[5])
16 set(refVoltage,gains);
19 GainVoltPmtParameters::GainVoltPmtParameters(
int n,
double volts[],
double gains[])
27 GainVoltPmtParameters::~GainVoltPmtParameters()
45 throw runtime_error(
"GainVoltPmtParameters::set(double,int,double[]) - F - invalid reference voltage");
46 _data[refVolt-100] = gains[0];
47 _data[refVolt- 50] = gains[1];
48 _data[refVolt ] = gains[2];
49 _data[refVolt- 50] = gains[3];
50 _data[refVolt+100] = gains[4];
60 throw runtime_error(
"GainVoltPmtParameters::set() - F - invalid number of points");
64 _data[volts[i]] = gains[i];
72 map<double,double>::const_iterator i;
75 if (i->first<200 || i->second<1)
87 _a =
_fit.getCoefficient();
92 cout <<
"GainVoltPmtParameters::fit() - Default Parameters used for " << *
this<<endl;
100 os <<
object._id <<
"\t";
101 if (
object.ioMode&1) os <<
object._a <<
"\t" <<
object._b<<
"\t";
104 map<double,double>::const_iterator i;
107 os <<
object.getNPoints()<<
"\t";
108 for (i=
object._data.begin();i!=
object._data.end();i++) os << i->first <<
"\t" << i->second<<
"\t";
112 i=
object._data.begin(); i++;i++;
113 os << i->first <<
"\t";
114 for (i=
object._data.begin();i!=
object._data.end();i++) os << i->second <<
"\t";
137 for (
int i=0;i<n;i++)
147 is >> gain;
object._data[refVolt-100] = gain;
148 is >> gain;
object._data[refVolt- 50] = gain;
149 is >> gain;
object._data[refVolt ] = gain;
150 is >> gain;
object._data[refVolt+ 50] = gain;
151 is >> gain;
object._data[refVolt+100] = gain;
155 cout <<
"no data input "<<endl;
175 throw runtime_error(
"GainVoltPmtParameters::getGain(double) - F - given voltage<0");
176 return exp(
_a+
_b*::log(voltage));
182 if (gain<=0)
return 0;
183 return exp(::log(gain)/
_b-
_a);
202 <<
"Voltage(V) Gain(Relative)"<<endl
203 <<
"============================="<<endl;
204 map<double,double>::const_iterator i;
207 cout << i->first <<
"\t" << i->second<<endl;
209 cout <<
"============================="<<endl
210 <<
" a : " <<
_a<< endl
211 <<
" b : " <<
_b<< endl;
223 _defaultB = exponent;
static void setDefaults(double multCoefficient, double exponent)
double _a
multiplicative coefficient
double getExponent() const
Get exponent of the power law.
map< double, double > _data
HV/Gain data.
int getNPoints() const
Get the number of data points available and used for this PMT.
double getGain(double voltage) const
Get the gain obtained if the given voltage is applied.
PowerLawFit< double > _fit
Transient Fit Object.
PmtIdentifier & getPmtIdentifier()
Get the PMT identifier.
void set(double refVolt, double gains[5])
Set the voltages and gains.
void print()
Print the information of this PMT.
bool isValid() const
Determine whether the input data are valid.
double getMultConstant() const
Get multiplicative constant.
double getVoltage(double gain) const
Get the voltage need to obtain the given relative gain.