Jpp  18.4.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | List of all members
JCALIBRATE::JHVInterpolator Struct Reference

Auxiliary data structure to store high-voltage versus gain data and interpolate the nominal high-voltage. More...

#include <JHVInterpolator.hh>

Public Member Functions

 JHVInterpolator (TMultiGraph &object)
 Constructor. More...
 
void AddPoint (Double_t HV, Double_t gain, Double_t gainError)
 Add point to diagram. More...
 
void SetPoint (Int_t i, Double_t HV, Double_t gain, Double_t gainError)
 Set point with index i. More...
 
const bool checkHV (const double HV) const
 Checks whether high-voltage is within range. More...
 
const bool checkHV (const double HV1, const double HV2) const
 Checks whether two high-voltage values are different. More...
 
const bool checkGain (const double gain) const
 Checks if gain is within range. More...
 
const bool areIncreasing (const Int_t i, const Int_t j) const
 Checks whether the gains of two points are strictly increasing as function of their absolute high-voltage. More...
 
const bool areValid (const Int_t i, const Int_t j) const
 Checks whether two points are valid for inter-/extrapolation. More...
 
bool interpolateHV (const double gainTarget)
 Inter-/Extrapolate the high-voltage value corresponding to the target gain value. More...
 
double getHV () const
 Get interpolated high-voltage. More...
 
double getHVError () const
 Get error estimate on interpolated high-voltage. More...
 
TGraphErrors * getData () const
 Get graph with the input data for the interpolation. More...
 
TGraphErrors * getResult () const
 Get graph with the interpolation result. More...
 

Static Public Member Functions

static void setMinHVDistance (const double minDist)
 Set minimal separation distance for high-voltage. More...
 
static void setHVRange (const JRange< double > range)
 Set valid gain range. More...
 
static void setGainRange (const JRange< double > range)
 Set valid gain range. More...
 

Private Attributes

TMultiGraph * data
 HV-versus-gain data. More...
 

Static Private Attributes

static double dHVmin = 2 * 3.14
 Minimal high-voltage difference between two points [V]. More...
 
static JRange< double > hvRange = JRange<double>(-1500, -80)
 Allowed high-voltage range [V]. More...
 
static JRange< double > gainRange
 Allowed gain range. More...
 

Detailed Description

Auxiliary data structure to store high-voltage versus gain data and interpolate the nominal high-voltage.

Definition at line 37 of file JHVInterpolator.hh.

Constructor & Destructor Documentation

JCALIBRATE::JHVInterpolator::JHVInterpolator ( TMultiGraph &  object)
inline

Constructor.

Parameters
objectTMultiGraph object

Definition at line 44 of file JHVInterpolator.hh.

44  :
45  data(&object)
46  {
47  TGraphErrors* g0 = new TGraphErrors();
48 
49  g0->SetName(HVINTERPOLATOR_RESULT);
50  g0->SetLineColor (kRed);
51  g0->SetMarkerColor(kRed);
52  g0->SetMarkerStyle(kFullDotSmall);
53  g0->Set(0);
54 
55  data->Add(g0);
56 
57  TGraphErrors* g1 = new TGraphErrors();
58 
59  g1->SetName(HVINTERPOLATOR_DATA);
60  g1->SetMarkerStyle(kFullDotSmall);
61  g1->Set(0);
62 
63  data->Add(g1);
64  }
static const char * HVINTERPOLATOR_RESULT
TMultiGraph * data
HV-versus-gain data.
static const char * HVINTERPOLATOR_DATA
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25

Member Function Documentation

void JCALIBRATE::JHVInterpolator::AddPoint ( Double_t  HV,
Double_t  gain,
Double_t  gainError 
)
inline

Add point to diagram.

Parameters
HVhigh-voltage [V]
gaingain value
gainErrorerror on gain value

Definition at line 74 of file JHVInterpolator.hh.

75  {
76  TGraphErrors* g1 = getData();
77 
78  const Int_t N = g1->GetN();
79 
80  g1->SetPoint (N, fabs(HV), gain);
81  g1->SetPointError(N, 0.0, gainError);
82  }
TGraphErrors * getData() const
Get graph with the input data for the interpolation.
then $JPP_DIR examples JDetector JToT o $OUTPUT_FILE n N $NPE P gain
Definition: JToT.sh:47
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
Definition: JMuonPostfit.sh:40
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25
void JCALIBRATE::JHVInterpolator::SetPoint ( Int_t  i,
Double_t  HV,
Double_t  gain,
Double_t  gainError 
)
inline

Set point with index i.

Parameters
iindex of point
HVhigh-voltage [V]
gaingain value
gainErrorerror on gain value

Definition at line 93 of file JHVInterpolator.hh.

94  {
95  TGraphErrors* g1 = getData();
96 
97  g1->SetPoint (i, fabs(HV), gain);
98  g1->SetPointError(i, 0.0, gainError);
99  }
TGraphErrors * getData() const
Get graph with the input data for the interpolation.
then $JPP_DIR examples JDetector JToT o $OUTPUT_FILE n N $NPE P gain
Definition: JToT.sh:47
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25
const bool JCALIBRATE::JHVInterpolator::checkHV ( const double  HV) const
inline

Checks whether high-voltage is within range.

Parameters
HVhigh-voltage [V]
Returns
true if high-voltage is within range; else false

Definition at line 108 of file JHVInterpolator.hh.

109  {
110  return (HV > hvRange.getLowerLimit() &&
111  HV < hvRange.getUpperLimit());
112  }
T getLowerLimit() const
Get lower limit.
Definition: JRange.hh:202
static JRange< double > hvRange
Allowed high-voltage range [V].
T getUpperLimit() const
Get upper limit.
Definition: JRange.hh:213
const bool JCALIBRATE::JHVInterpolator::checkHV ( const double  HV1,
const double  HV2 
) const
inline

Checks whether two high-voltage values are different.

Parameters
HV1first high-voltage [V]
HV2second high-voltage [V]
Returns
true if absolute difference is greater than minimal required difference; else false

Definition at line 122 of file JHVInterpolator.hh.

123  {
124  return (fabs(HV1 - HV2) > dHVmin);
125  }
static double dHVmin
Minimal high-voltage difference between two points [V].
const bool JCALIBRATE::JHVInterpolator::checkGain ( const double  gain) const
inline

Checks if gain is within range.

Parameters
gaingain value
Returns
true if gain within allowed range; else false

Definition at line 134 of file JHVInterpolator.hh.

135  {
136  return (gain > gainRange.getLowerLimit() &&
138  }
T getLowerLimit() const
Get lower limit.
Definition: JRange.hh:202
static JRange< double > gainRange
Allowed gain range.
T getUpperLimit() const
Get upper limit.
Definition: JRange.hh:213
then $JPP_DIR examples JDetector JToT o $OUTPUT_FILE n N $NPE P gain
Definition: JToT.sh:47
const bool JCALIBRATE::JHVInterpolator::areIncreasing ( const Int_t  i,
const Int_t  j 
) const
inline

Checks whether the gains of two points are strictly increasing as function of their absolute high-voltage.

Parameters
iindex of first point
jindex of second point
Returns
true if gains of given points are strictly increasing
as function of the absolute high-voltage; else false

Definition at line 149 of file JHVInterpolator.hh.

150  {
151  TGraphErrors* g1 = getData();
152 
153  if ((i >= 0 && i < g1->GetN()) &&
154  (j >= 0 && i < g1->GetN())) {
155 
156  return ((g1->GetPointX(i) > g1->GetPointX(j) && g1->GetPointY(i) > g1->GetPointY(j)) ||
157  (g1->GetPointX(i) < g1->GetPointX(j) && g1->GetPointY(i) < g1->GetPointY(j)));
158 
159  } else {
160 
161  return false;
162  }
163  }
TGraphErrors * getData() const
Get graph with the input data for the interpolation.
int j
Definition: JPolint.hh:792
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25
const bool JCALIBRATE::JHVInterpolator::areValid ( const Int_t  i,
const Int_t  j 
) const
inline

Checks whether two points are valid for inter-/extrapolation.

Parameters
iindex of first point
jindex of second point
Returns
true if valid for inter-/extrapolation; else false

Definition at line 173 of file JHVInterpolator.hh.

174  {
175  TGraphErrors* g1 = getData();
176 
177  if ((i >= 0 && i < g1->GetN()) &&
178  (j >= 0 && j < g1->GetN())) {
179 
180  const double HV_i = -fabs(g1->GetPointX(i));
181  const double HV_j = -fabs(g1->GetPointX(j));
182  const double gain_i = g1->GetPointY(i);
183  const double gain_j = g1->GetPointY(j);
184 
185  return (areIncreasing( i, j) && checkHV(HV_i) && checkGain(gain_i) &&
186  checkHV (HV_i, HV_j) && checkHV(HV_j) && checkGain(gain_j));
187 
188  } else {
189 
190  return false;
191  }
192  }
const bool checkHV(const double HV) const
Checks whether high-voltage is within range.
TGraphErrors * getData() const
Get graph with the input data for the interpolation.
const bool checkGain(const double gain) const
Checks if gain is within range.
const bool areIncreasing(const Int_t i, const Int_t j) const
Checks whether the gains of two points are strictly increasing as function of their absolute high-vol...
int j
Definition: JPolint.hh:792
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25
bool JCALIBRATE::JHVInterpolator::interpolateHV ( const double  gainTarget)
inline

Inter-/Extrapolate the high-voltage value corresponding to the target gain value.

Parameters
gainTargettarget gain value for inter-/extrapolation
Returns
true if inter-/extrapolation successful; else false

Definition at line 201 of file JHVInterpolator.hh.

202  {
203  TGraphErrors* g1 = getData();
204 
205  if (g1->GetN() < 2 || !checkGain(gainTarget)) {
206  return false;
207  }
208 
209  // Search for valid inter-/extrapolation points
210 
211  Int_t i = 0;
212  Int_t j = 1;
213 
214  for (Int_t k = 2; k < g1->GetN(); ++k) {
215 
216  const double dGain_i = fabs(g1->GetPointY(i) - gainTarget);
217  const double dGain_j = fabs(g1->GetPointY(j) - gainTarget);
218  const double dGain_k = fabs(g1->GetPointY(k) - gainTarget);
219 
220  if (dGain_k < dGain_j) {
221  i = (areValid(j,k) ? j : i);
222  j = k;
223  } else if ((dGain_k < dGain_i || !areValid(i,j)) && areValid(j,k)) {
224  i = j;
225  j = k;
226  }
227  }
228 
229  // Inter-/Extrapolate high-voltage corresponding to given gain
230 
231  if (areValid(i, j)) {
232 
233  const double logHV0 = log(fabs(g1->GetPointX(i)));
234  const double logHV1 = log(fabs(g1->GetPointX(j)));
235 
236  const double logG0 = log(g1->GetPointY(i));
237  const double logG1 = log(g1->GetPointY(j));
238  const double elogG0 = g1->GetErrorY(i) / g1->GetPointY(i);
239  const double elogG1 = g1->GetErrorY(j) / g1->GetPointY(j);
240 
241  const double dlogG0 = log(gainTarget) - logG0;
242  const double dlogG1 = log(gainTarget) - logG1;
243 
244  const double slope = (logG1 - logG0) / (logHV1 - logHV0);
245 
246  const double HVnom = exp(dlogG0 / slope + logHV0);
247  const double eHVnom = HVnom * sqrt(dlogG1 * dlogG1 * elogG0 * elogG0 +
248  dlogG0 * dlogG0 * elogG1 * elogG1) / fabs(slope * (logG1 - logG0));
249 
250  const double distance = fabs((log(HVnom) - logHV0) / (logHV0 - logHV1));
251  static const double maxDist = 2.0;
252 
253  if (checkHV(-HVnom) && distance < maxDist) {
254 
255  TGraphErrors* g0 = getResult();
256 
257  g0->SetPoint (0, HVnom, gainTarget);
258  g0->SetPointError(0, eHVnom, 0.0);
259 
260  return true;
261  }
262  }
263 
264  return false;
265  }
then fatal No hydrophone data file $HYDROPHONE_TXT fi sort gr k
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
then set_variable DIR else fatal Wrong number of arguments fi for INPUT_FILE in ls rt $DIR stage * log
const bool checkHV(const double HV) const
Checks whether high-voltage is within range.
TGraphErrors * getData() const
Get graph with the input data for the interpolation.
const bool checkGain(const double gain) const
Checks if gain is within range.
int j
Definition: JPolint.hh:792
const bool areValid(const Int_t i, const Int_t j) const
Checks whether two points are valid for inter-/extrapolation.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable STRING $argv[2] set_array QUANTILES set_variable FORMULA *[0] exp(-0.5 *(x-[1])*(x-[1])/([2]*[2]))" set_variable MODULE `getModule -a $DETECTOR -L "$STRING 0"` source JAcousticsToolkit.sh typeset -A TRIPODS get_tripods $WORKDIR/tripod.txt TRIPODS XMEAN
TGraphErrors * getResult() const
Get graph with the interpolation result.
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25
double JCALIBRATE::JHVInterpolator::getHV ( ) const
inline

Get interpolated high-voltage.

Returns
inter-/extrapolated high-voltage
corresponding to target gain value [V]

Definition at line 274 of file JHVInterpolator.hh.

275  {
276  TGraphErrors* g0 = getResult();
277 
278  if (g0->GetN() > 0) {
279 
280  return g0->GetPointX(0);
281 
282  } else {
283 
284  THROW(JNoValue, "JHVInterpolator::getHV(): Missing HV inter-/extrapolation point. Please call JHVInterpolator::interpolateHV() first.");
285  }
286  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
TGraphErrors * getResult() const
Get graph with the interpolation result.
double JCALIBRATE::JHVInterpolator::getHVError ( ) const
inline

Get error estimate on interpolated high-voltage.

Returns
error on inter-/extrapolated high-voltage
corresponding to the target gain value [V]

Definition at line 295 of file JHVInterpolator.hh.

296  {
297  TGraphErrors* g0 = getResult();
298 
299  if (g0->GetN() > 0) {
300 
301  return g0->GetErrorX(0);
302 
303  } else {
304 
305  THROW(JNoValue, "JHVInterpolator::getHVError(): Missing HV inter-/extrpolation point. Please call JHVInterpolator::interpolateHV() first.");
306  }
307  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
TGraphErrors * getResult() const
Get graph with the interpolation result.
TGraphErrors* JCALIBRATE::JHVInterpolator::getData ( ) const
inline

Get graph with the input data for the interpolation.

Returns
pointer to graph with input data

Definition at line 315 of file JHVInterpolator.hh.

316  {
317  TList* list = data->GetListOfGraphs();
318 
319  if (list != NULL && list->FindObject(HVINTERPOLATOR_DATA) != NULL) {
320 
321  return (TGraphErrors*)list->FindObject(HVINTERPOLATOR_DATA);
322 
323  } else if (list == NULL) {
324 
325  THROW(JNullPointerException, "JHVInterpolator()::getData(): Emtpy list of graphs.");
326 
327  } else {
328 
329  THROW(JNullPointerException, "JHVInterpolator()::getData(): No " << HVINTERPOLATOR_DATA << " graph.");
330  }
331  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
TMultiGraph * data
HV-versus-gain data.
static const char * HVINTERPOLATOR_DATA
TGraphErrors* JCALIBRATE::JHVInterpolator::getResult ( ) const
inline

Get graph with the interpolation result.

Returns
pointer to graph with the interpolation result

Definition at line 339 of file JHVInterpolator.hh.

340  {
341  TList* list = data->GetListOfGraphs();
342 
343  if (list != NULL && list->FindObject(HVINTERPOLATOR_RESULT) != NULL) {
344 
345  return (TGraphErrors*)list->FindObject(HVINTERPOLATOR_RESULT);
346 
347  } else if (list == NULL) {
348 
349  THROW(JNullPointerException, "JHVInterpolator::getResult(): Empty list of graphs.");
350 
351  } else {
352 
353  THROW(JNullPointerException, "JHVInterpolator::getResult(): No " << HVINTERPOLATOR_RESULT << " graph.");
354  }
355  }
static const char * HVINTERPOLATOR_RESULT
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
TMultiGraph * data
HV-versus-gain data.
static void JCALIBRATE::JHVInterpolator::setMinHVDistance ( const double  minDist)
inlinestatic

Set minimal separation distance for high-voltage.

Parameters
minDistminimal separation distance for high-voltage

Definition at line 363 of file JHVInterpolator.hh.

364  {
365  dHVmin = minDist;
366  }
static double dHVmin
Minimal high-voltage difference between two points [V].
static void JCALIBRATE::JHVInterpolator::setHVRange ( const JRange< double >  range)
inlinestatic

Set valid gain range.

Parameters
rangevalid high-voltage range [V]

Definition at line 374 of file JHVInterpolator.hh.

375  {
376  hvRange = range;
377  }
static JRange< double > hvRange
Allowed high-voltage range [V].
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
static void JCALIBRATE::JHVInterpolator::setGainRange ( const JRange< double >  range)
inlinestatic

Set valid gain range.

Parameters
rangevalid gain range

Definition at line 385 of file JHVInterpolator.hh.

386  {
387  gainRange = range;
388  }
static JRange< double > gainRange
Allowed gain range.
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $

Member Data Documentation

TMultiGraph* JCALIBRATE::JHVInterpolator::data
private

HV-versus-gain data.

Definition at line 393 of file JHVInterpolator.hh.

double JCALIBRATE::JHVInterpolator::dHVmin = 2 * 3.14
staticprivate

Minimal high-voltage difference between two points [V].

Default values.

Definition at line 395 of file JHVInterpolator.hh.

JRange< double > JCALIBRATE::JHVInterpolator::hvRange = JRange<double>(-1500, -80)
staticprivate

Allowed high-voltage range [V].

Definition at line 396 of file JHVInterpolator.hh.

JRange< double > JCALIBRATE::JHVInterpolator::gainRange
staticprivate
Initial value:
= JRange<double>(FITTOT_GAIN_MIN,

Allowed gain range.

Definition at line 397 of file JHVInterpolator.hh.


The documentation for this struct was generated from the following file: