KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVCalibrator.h
1#ifndef __KV_CALIBRATOR__
2#define __KV_CALIBRATOR__
3
4#include "KVBase.h"
5#include "TRef.h"
6#include "KVDetector.h"
7#include "TF1.h"
8#include "KVValueRange.h"
9
56
99class KVCalibrator: public KVBase {
100
110
111protected:
113 {
116 fCalibFunc = f;
117 }
119 {
120 return fCalibFunc;
121 }
123 {
128
129 int status;
130 Double_t res = ProtectedGetX(fCalibFunc, x, status); // fCalibFunc->GetX(x);
131 fInversionFail = (status != 0);
132 return res;
133 }
134 bool in_range(double X, double Xmin, double Xmax)
135 {
137 return (X >= Xmin) && (X <= Xmax);
138 }
140public:
142 : KVBase("Calibrator", "KVCalibrator"), fDetector(nullptr), fCalibFunc(nullptr), fReady(kFALSE), fUseInverseFunction(kFALSE), fInputMin(99), fInputMax(-1), fInversionFail(kFALSE) {}
143 KVCalibrator(const TString& formula, const TString& type)
144 : KVBase("Calibrator", type), fDetector(nullptr), fCalibFunc(new TF1("KVCalibrator::fCalibFunc", formula)), fReady(kFALSE), fUseInverseFunction(kFALSE), fInputMin(99), fInputMax(-1), fInversionFail(kFALSE)
145 {
147 }
149 {
151 }
152
154 {
156 return (fCalibFunc ? fCalibFunc->GetNpar() : 0);
157 }
158 void SetParameter(int i, Double_t par_val) const
159 {
160 if (fCalibFunc) fCalibFunc->SetParameter(i, par_val);
161 }
163 {
164 return (fCalibFunc ? fCalibFunc->GetParameter(i) : 0);
165 }
166 void SetStatus(Bool_t ready)
167 {
168 fReady = ready;
169 if (ready)
172 }
174 {
175 return fReady;
176 }
177 virtual void Print(Option_t* opt = "") const;
178 virtual void Reset()
179 {
180 for (Int_t i = 0; i < GetNumberParams(); i++) {
181 SetParameter(i, 0.0);
182 }
184 }
185 virtual Double_t Compute(Double_t x, const KVNameValueList&) const
186 {
188
190 }
191 virtual Double_t Invert(Double_t x, const KVNameValueList&) const
192 {
194
196 }
198 {
200 return Compute(x, par);
201 }
203 {
209
210 return kTRUE;
211 }
212
213 static KVCalibrator* MakeCalibrator(const Char_t* type);
214
215 virtual void SetOptions(const KVNameValueList&);
216 void SetInputSignalType(const TString& type)
217 {
219 }
220 void SetOutputSignalType(const TString& type)
221 {
223 }
225 {
226 return fInputSignal;
227 }
229 {
230 return fOutputSignal;
231 }
233 {
234 fDetector = d;
235 }
237 {
238 return fDetector;
239 }
240
242 {
246 }
248 {
251 return fUseInverseFunction;
252 }
254 {
257 return fInversionFail;
258 }
259
260 TGraph* GetGraphOfCalibration(int npts, KVValueRange<double> input_range, const KVNameValueList& par = "");
261
262 ClassDef(KVCalibrator, 2)//Base class for calibration of detectors
263};
264
265#endif
int Int_t
#define SafeDelete(p)
#define d(i)
#define f(i)
bool Bool_t
char Char_t
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
const char Option_t
#define ClassDef(name, id)
#define X(type, name)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Base class for KaliVeda framework.
Definition KVBase.h:142
Double_t ProtectedGetX(const TF1 *func, Double_t val, int &status, Double_t xmin=0.0, Double_t xmax=0.0) const
Definition KVBase.cpp:1691
Base class for all detector calibrations.
Double_t operator()(Double_t x, const KVNameValueList &par="")
void adjust_range_of_inverse_calibration()
void SetCalibFunction(TF1 *f)
TF1 * GetCalibFunction() const
void SetUseInverseFunction(Bool_t yes=kTRUE)
KVDetector * GetDetector() const
virtual Double_t Invert(Double_t x, const KVNameValueList &) const
Bool_t fReady
= kTRUE if calibration formula & parameters have been set up
Bool_t GetStatus() const
Bool_t fInversionFail
problem inverting calibration function
Int_t GetNumberParams() const
Double_t fInputMin
required minimum input signal for inverse calibration
virtual ~KVCalibrator()
virtual void Reset()
virtual Bool_t IsAvailableFor(const KVNameValueList &) const
virtual void SetOptions(const KVNameValueList &)
void SetParameter(int i, Double_t par_val) const
Double_t do_inversion(Double_t x) const
virtual Double_t Compute(Double_t x, const KVNameValueList &) const
void SetStatus(Bool_t ready)
TGraph * GetGraphOfCalibration(int npts, KVValueRange< double > input_range, const KVNameValueList &par="")
TF1 * fCalibFunc
calibration function
Double_t GetParameter(int i) const
virtual void Print(Option_t *opt="") const
Print a description of the calibration object, including a list of its parameters.
Double_t fInputMax
required maximum input signal for inverse calibration
KVCalibrator(const TString &formula, const TString &type)
TString GetInputSignalType() const
TString fOutputSignal
type of output calibrated signal
void SetOutputSignalType(const TString &type)
void SetDetector(KVDetector *d)
void SetInputSignalType(const TString &type)
TString GetOutputSignalType() const
KVDetector * fDetector
associated detector
Bool_t fUseInverseFunction
true if inverse i.e. TF1::GetX should be used for Compute()
TString fInputSignal
type of signal used as input
Bool_t InversionFailure() const
Bool_t IsUseInverseFunction() const
static KVCalibrator * MakeCalibrator(const Char_t *type)
bool in_range(double X, double Xmin, double Xmax)
Base class for detector geometry description.
Definition KVDetector.h:160
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
Range of values specified by minimum, maximum.
virtual Double_t GetParameter(const TString &name) const
virtual Int_t GetNpar() const
virtual Double_t Eval(Double_t x, Double_t y=0, Double_t z=0, Double_t t=0) const
virtual void SetParameter(const TString &name, Double_t value)
Double_t x[n]