Diana Software
calibration_parameters.C
Go to the documentation of this file.
1 void Write() {
2  using namespace Diana;
4  dm.SetOwner("calibration_parameters");
5 
7  TF1 f("pol2","[0]+[1]*x+[2]*x*x");
8  f.SetParameter(0,0);
9  f.SetParameter(1,1.5);
10  f.SetParameter(2,0.3);
11  calpar.fFunction = f;
12  calpar.fSource = "Th";
13 
14  QCalibrationResiduals res2615;
15  QCalibrationResiduals res911;
16  QCalibrationResiduals res511;
17 
18  res2615.PeakEnergy = 2614.533;
19  res2615.Residual = 0.5;
20  res2615.ErrorResidual = 0.1;
21  calpar.fResiduals.push_back(res2615);
22 
23  res911.PeakEnergy = 911.5;
24  res911.Residual = 0.5;
25  res911.ErrorResidual = 0.1;
26  calpar.fResiduals.push_back(res911);
27 
28  res511.PeakEnergy = 511.0;
29  res511.Residual = 0.5;
30  res511.ErrorResidual = 0.1;
31  calpar.fResiduals.push_back(res511);
32 
33  QCalibrationParametersHandle paramhandle(1,6034);
34  paramhandle.Set(calpar);
35  cout<<calpar<<endl;
36 
37  dm.Set(&paramhandle,"calibration_parameters.root");
38 }
39 
40 void Read(const char* input) {
41  using namespace Diana;
43  dm.SetOwner("calibration_parameters");
44  QCalibrationParametersHandle paramhandle(1,6034);
45  dm.Get("calibration_parameters",&paramhandle,input);
46 
47 
48  if(!paramhandle.IsValid()) {
49  cout<<paramhandle.GetError()<<endl;
50  return;
51  }
52  const QCalibrationParameters& params = paramhandle.Get();
53  cout<<params<<endl;
54 }
QGlobalDataManager dm
void Read(const char *input)
void Write()
global handle for calibration parameters
object containing calibration data (function, coefficients, source and residuals) and run numbers of ...
std::vector< QCalibrationResiduals > fResiduals
single calibration residual: energy[keV], residual [keV], error on residual [keV]
Object to manage I/O (DB, file, or memory) of diana global quantities.
void SetOwner(const std::string &owner)
set the module that is accessing this object
QError Set(GlobalHandle< Q > *gh, const std::string &outSource, bool printError=true) const
Set a QObject using a GlobalHandle.
QError Get(const std::string &owner, GlobalHandle< Q > *gh, const std::string &inSource, bool printError=true) const
Get an object using a global handle.
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...