16 using namespace Diana;
26 fInput = GetString(
"ParametersInput",
"");
29 fDataset = GetInt(
"Dataset",-1,
false);
31 GlobalHandle<QInt> dHandle(
"Dataset");
32 GlobalData().Get(
"",&dHandle,
"");
33 fDataset = dHandle.Get();
36 fAmplitudeLabel = GetString(
"AmplitudeLabel",
"CorrectAmplitudes@Amplitude");
52 int run = header.GetRun();
59 GlobalData().Get(GetString(
"CalCoefficientsOwner",
"CalCoefficients",
false),¶mhandle,fInput);
61 if (!paramhandle.IsValid()) {
62 if(fBlackList.count(
channel))
return;
64 Error(
"Channel %d, will not be calibrated: %s",
channel,paramhandle.GetError().GetDescription().c_str());
70 if (fInput ==
"DB" && fChannels.find(
channel) == fChannels.end()) {
72 std::string sLabelstr;
73 GlobalHandle<QString> sLabel(
"StabilizationLabel");
76 GlobalData().Get(fAmplitudeLabel.GetOwner(),&sLabel,GetString(
"StabilizationLabelInput",
"CurrentReader",
false));
77 if (sLabel.IsValid()) {
78 sLabelstr = sLabel.Get();
84 Error(
"The amplitude to be calibrated (%s) is not the same on which the calibration parameters were calculated (%s). Calibrating %s anyway.",stabLabel.
fOwner.c_str(),paramhandle.
GetStabLabel().c_str(),fAmplitudeLabel.GetStringLabel().c_str());
88 GlobalHandle<QString> clabel(
"CalibrationLabel");
90 clabel.SetDataset(fDataset);
92 label.
fOwner= paramhandle.GetLabel().fOwner;
93 label.
fName= paramhandle.GetLabel().fName;
95 GlobalData().Set(&clabel,
"CurrentWriter");
103 if (!(energy >=0) && !(energy<=0))
return;
108 double *params = calParams.
fFunction.GetParameters();
109 const double *paramErrors = calParams.
fFunction.GetParErrors();
110 int nParams = calParams.
fFunction.GetNpar();
115 double *limitParams =
new double[nParams];
116 for (
int i = 0; i < nParams; i++)
117 limitParams[i] = params[i] + paramErrors[i];
118 double energyUpper = calFunction.EvalPar(&
amp, limitParams);
119 for (
int i = 0; i < nParams; i++)
120 limitParams[i] = params[i] - paramErrors[i];
121 double energyLower = calFunction.EvalPar(&
amp, limitParams);
123 ev.
Get<
QDouble>(
"EnergyUncertainty") = (energyUpper - energyLower) / 2;
#define REGISTER_MODULE(clazz)
Use calibration coefficients and stabilized amplitudes to compute energy.
void Init(Diana::QEvent &ev)
Init method.
~MApplyCalibration()
destructor
void Do(Diana::QEvent &ev)
Do method.
base types wrapped into a QObject. Currently implemented types are QInt QDouble and QFloat....
global handle for calibration parameters
const std::string & GetStabLabel() const
object containing calibration data (function, coefficients, source and residuals) and run numbers of ...
const Q & GetByLabel(const QEventLabel &label) const
Get a QObject in read mode by label.
void RequireByLabel(const QEventLabel &label) const
notify the QEvent that we need a QObject, if not found an exception is thrown
void Require(const std::string &owner, const std::string &name) const
notify the QEvent that we need a QObject, if not found an exception is thrown
void Get(const char *owner, ReadHandle< Q > &handle) const
Get a QObject Handle in read mode.
void Add(WriteHandle< Q > &handle)
Add a QObject to the event.
Label for global QObject's.
std::string fName
Object name.
std::string fOwner
Object owner.
std::string GetStringLabel() const
convert label to string
Raw event: bolometer channel, trigger positions and types.
const int & GetChannelId() const
Get ChannelId.
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...