R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BTsplinePar.cxx
Go to the documentation of this file.
1
2/******************************************************************************
3 * Copyright (C) 2022 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
4 * Copyright (C) 2022-2026 Members of R3B Collaboration *
5 * *
6 * This software is distributed under the terms of the *
7 * GNU General Public Licence (GPL) version 3, *
8 * copied verbatim in the file "LICENSE". *
9 * *
10 * In applying this license GSI does not waive the privileges and immunities *
11 * granted to it by virtue of its status as an Intergovernmental Organization *
12 * or submit itself to any jurisdiction. *
13 ******************************************************************************/
14
15// --------------------------------------------------------------
16// ----- R3BTsplinePar -----
17// ----- Created Jan 23th 2022 by J.L. Rodriguez-Sanchez -----
18// --------------------------------------------------------------
19
20#include "R3BTsplinePar.h"
21#include "R3BLogger.h"
22
23#include <FairParamList.h>
24
25#include <Rtypes.h>
26#include <TArrayF.h>
27#include <TF1.h>
28
29// ----- Default constructor -----------------------------------------------
30R3BTsplinePar::R3BTsplinePar(const TString& name)
31 : TNamed(name, name)
32 , fSpline(NULL)
33 , fMaxPoints(4000) // 100
34 , fxmin(-100.50)
35 , fxmax(1030)
36{
37 // fSpline = new TSpline3();
38}
39
40// ---- Method putParams ------------------------------------------------------
41void R3BTsplinePar::putParams(FairParamList* list)
42{
43 R3BLOG(info, "called for " << fSpline->GetNp() << " points");
44
45 TArrayF* p = new TArrayF(5);
46 // TArrayF* q = new TArrayF(3);
47 for (int n = 0; n < fSpline->GetNp(); n++)
48 {
49 Double_t a[2];
50 Double_t b[6];
51 fSpline->GetKnot(n, a[0], a[1]);
52 fSpline->GetCoeff(n, b[0], b[1], b[2], b[3], b[4]);
53 TString name = GetNameObj() + "Point" + n;
54 p->AddAt(a[0], 0);
55 p->AddAt(a[1], 1);
56 p->AddAt(b[2], 2);
57 p->AddAt(b[3], 3);
58 p->AddAt(b[4], 4);
59 list->add(name, *p);
60 /*TString namecoeff = GetNameObj() + "PointCoeff" + n;
61 q->AddAt(b[0], 0);
62 q->AddAt(b[1], 1);
63 q->AddAt(b[2], 2);
64 list->add(namecoeff, *q);*/
65 }
66 delete p;
67}
68
69// ---- Method getParams ------------------------------------------------------
70TSpline3* R3BTsplinePar::getParams(FairParamList* list)
71{
72 R3BLOG(info, "called");
73 // if (fSpline == NULL)
74 fSpline = new TSpline3("spline_func", fxmin, fxmax, (TF1*)0, fMaxPoints);
75 TArrayF* p = new TArrayF(5);
76 // TArrayF* q = new TArrayF(3);
77 for (int n = 0; n < fMaxPoints; n++)
78 {
79 TString name = GetNameObj() + "Point" + n;
80 // TString namecoeff = GetNameObj() + "PointCoeff" + n;
81 if (list->fill(name, p))
82 {
83 fSpline->SetPoint(n, p->GetAt(0), p->GetAt(1));
84 fSpline->SetPointCoeff(n, p->GetAt(2), p->GetAt(3), p->GetAt(4));
85 }
86 else
87 {
88 break;
89 }
90 }
91 delete p;
92 // std::cout << "Np spline = " << fSpline->GetNp() << std::endl;
93 return fSpline;
94}
95
96// ---- Method print ----------------------------------------------------------
98{
99 if (fSpline)
100 {
101 R3BLOG(info, "for " << fSpline->GetName());
102
103 for (int n = 0; n < fSpline->GetNp(); n++)
104 {
105 Double_t a[2];
106 Double_t b[6];
107 fSpline->GetKnot(n, a[0], a[1]);
108 fSpline->GetCoeff(n, b[0], b[1], b[2], b[3], b[4]);
109 LOG(info) << "CutPoint" << n << ": " << a[0] << " ; " << a[1];
110 LOG(info) << "CutPoint" << n << ": " << b[0] << " ; " << b[1] << " ; " << b[2];
111 }
112 }
113 else
114 {
115 R3BLOG(warn, "Spline parameters not found");
116 }
117}
118
#define R3BLOG(severity, x)
Definition R3BLogger.h:33
ClassImp(R3B::Neuland::Cal2HitPar)
TSpline3 * getParams(FairParamList *list)
Method to retrieve all parameters using FairRuntimeDB.
virtual void putParams(FairParamList *list)
Method to store all parameters using FairRuntimeDB.
R3BTsplinePar(const TString &name="Spline")
Default constructor.
TString GetNameObj()
Accessor functions.
void print()
Method to print values of parameters.
TSpline3 * fSpline