1 #ifndef __JCALIBRATE_JHVINTERPOLATOR__
2 #define __JCALIBRATE_JHVINTERPOLATOR__
12 #include "TGraphErrors.h"
13 #include "TMultiGraph.h"
14 #include "TAttMarker.h"
22 namespace JCALIBRATE {
47 TGraphErrors* g0 =
new TGraphErrors();
50 g0->SetLineColor (kRed);
51 g0->SetMarkerColor(kRed);
52 g0->SetMarkerStyle(kFullDotSmall);
57 TGraphErrors*
g1 =
new TGraphErrors();
60 g1->SetMarkerStyle(kFullDotSmall);
78 const Int_t
N = g1->GetN();
80 g1->SetPoint (N, fabs(HV), gain);
81 g1->SetPointError(N, 0.0, gainError);
93 void SetPoint(Int_t i, Double_t HV, Double_t
gain, Double_t gainError)
97 g1->SetPoint (i, fabs(HV), gain);
98 g1->SetPointError(i, 0.0, gainError);
122 const bool checkHV(
const double HV1,
const double HV2)
const
124 return (fabs(HV1 - HV2) >
dHVmin);
153 if ((i >= 0 && i < g1->GetN()) &&
154 (j >= 0 && i < g1->GetN())) {
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)));
177 if ((i >= 0 && i < g1->GetN()) &&
178 (j >= 0 && j < g1->GetN())) {
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);
205 if (g1->GetN() < 2 || !
checkGain(gainTarget)) {
214 for (Int_t
k = 2;
k < g1->GetN(); ++
k) {
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);
220 if (dGain_k < dGain_j) {
233 const double logHV0 =
log(fabs(g1->GetPointX(i)));
234 const double logHV1 =
log(fabs(g1->GetPointX(j)));
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);
241 const double dlogG0 =
log(gainTarget) - logG0;
242 const double dlogG1 =
log(gainTarget) - logG1;
244 const double slope = (logG1 - logG0) / (logHV1 - logHV0);
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));
250 const double distance = fabs((
log(HVnom) - logHV0) / (logHV0 - logHV1));
251 static const double maxDist = 2.0;
253 if (
checkHV(-HVnom) && distance < maxDist) {
257 g0->SetPoint (0, HVnom, gainTarget);
258 g0->SetPointError(0, eHVnom, 0.0);
278 if (g0->GetN() > 0) {
280 return g0->GetPointX(0);
284 THROW(
JNoValue,
"JHVInterpolator::getHV(): Missing HV inter-/extrapolation point. Please call JHVInterpolator::interpolateHV() first.");
299 if (g0->GetN() > 0) {
301 return g0->GetErrorX(0);
305 THROW(
JNoValue,
"JHVInterpolator::getHVError(): Missing HV inter-/extrpolation point. Please call JHVInterpolator::interpolateHV() first.");
317 TList* list =
data->GetListOfGraphs();
323 }
else if (list == NULL) {
341 TList* list =
data->GetListOfGraphs();
347 }
else if (list == NULL) {
void SetPoint(Int_t i, Double_t HV, Double_t gain, Double_t gainError)
Set point with index i.
then fatal No hydrophone data file $HYDROPHONE_TXT fi sort gr k
static const char * HVINTERPOLATOR_RESULT
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
static const double FITTOT_GAIN_MAX
Default maximal gain.
static const double FITTOT_GAIN_MIN
Default minimal gain.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
static void setGainRange(const JRange< double > range)
Set valid gain range.
static const std::string HVINTERPOLATOR_SUFFIX
static JRange< double > hvRange
Allowed high-voltage range [V].
static void setHVRange(const JRange< double > range)
Set valid gain range.
static JRange< double > gainRange
Allowed gain range.
const bool checkHV(const double HV) const
Checks whether high-voltage is within range.
TMultiGraph * data
HV-versus-gain data.
TGraphErrors * getData() const
Get graph with the input data for the interpolation.
Exception for missing value.
static void setMinHVDistance(const double minDist)
Set minimal separation distance for high-voltage.
Exception for null pointer operation.
const bool checkGain(const double gain) const
Checks if gain is within range.
Auxiliary data structure to store high-voltage versus gain data and interpolate the nominal high-volt...
double getHV() const
Get interpolated high-voltage.
double getHVError() const
Get error estimate on interpolated high-voltage.
static const char * HVINTERPOLATOR_DATA
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
then $JPP_DIR examples JDetector JToT o $OUTPUT_FILE n N $NPE P gain
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
Auxiliary class to define a range between two values.
static double dHVmin
Minimal high-voltage difference between two points [V].
JHVInterpolator(TMultiGraph &object)
Constructor.
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...
Exception for accessing a value in a collection that is outside of its range.
then cat $TRIPOD_INITIAL<< EOF1 256877.5 4743716.7-2438.42 256815.5 4743395.0-2435.53 257096.2 4743636.0-2439.5EOFfiif[[!-f $DETECTOR]];then JEditDetector-a $DETECTOR_INITIAL-s"-1 addz -6.9"-o $DETECTOR--!eval`JPrintDetector-a $DETECTOR-O SUMMARY`for STRING in ${STRINGS[*]};do set_variable MODULE`getModule-a $DETECTOR-L"$STRING 0"`JEditDetector-a $DETECTOR-M"$MODULE setz -2.9"-o $DETECTOR--!donefiif[[!-f $TRIPOD]];then cp-p $TRIPOD_INITIAL $TRIPODfiJAcoustics.sh $DETECTOR_IDcat > acoustics_trigger_parameters txt<< EOFQ=0.0;TMax_s=0.020;numberOfHits=90;EOFJAcousticsEventBuilder.sh $DETECTOR $RUNS[*]INPUT_FILES=(`ls KM3NeT_ ${(l:8::0::0:) DETECTOR_ID}_0 *${^RUNS}_event.root`) cd $WORKDIRif[!$HOMEDIR-ef $WORKDIR];then cp-p $HOMEDIR/$DETECTOR $WORKDIR cp-p $HOMEDIR/${^ACOUSTICS_KEYS}.txt $WORKDIR cp-p $HOMEDIR/${^INPUT_FILES}$WORKDIRfisource $JPP_DIR/examples/JAcoustics/acoustics-fit-toolkit.shtimer_startinitialise stage_b 1 0 100.0e-6 10.0 0.002 0.1 0 > &stage log
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
const bool checkHV(const double HV1, const double HV2) const
Checks whether two high-voltage values are different.
void AddPoint(Double_t HV, Double_t gain, Double_t gainError)
Add point to diagram.
TGraphErrors * getResult() const
Get graph with the interpolation result.
bool interpolateHV(const double gainTarget)
Inter-/Extrapolate the high-voltage value corresponding to the target gain value. ...
Double_t g1(const Double_t x)
Function.