R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BTcutPar.cxx
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3 * Copyright (C) 2019-2025 Members of R3B Collaboration *
4 * *
5 * This software is distributed under the terms of the *
6 * GNU General Public Licence (GPL) version 3, *
7 * copied verbatim in the file "LICENSE". *
8 * *
9 * In applying this license GSI does not waive the privileges and immunities *
10 * granted to it by virtue of its status as an Intergovernmental Organization *
11 * or submit itself to any jurisdiction. *
12 ******************************************************************************/
13
14// --------------------------------------------------------------
15// ----- R3BTcutPar -----
16// ----- Created Jan 23th 2022 by J.L. Rodriguez-Sanchez -----
17// --------------------------------------------------------------
18
19#include "R3BTcutPar.h"
20#include "R3BLogger.h"
21
22#include "FairLogger.h"
23#include "FairParamList.h"
24
25#include "TArrayF.h"
26#include "TMath.h"
27
28// ----- Default constructor -----------------------------------------------
29R3BTcutPar::R3BTcutPar(const TString& cutname)
30 : TNamed(cutname, cutname)
31 , fMaxPoints(40)
32 , fCut(NULL)
33{
34}
35
36// ---- Method putParams ------------------------------------------------------
37void R3BTcutPar::putParams(FairParamList* list)
38{
39 R3BLOG(info, "called for " << fCut->GetN() << " points");
40
41 TArrayF* p = new TArrayF(2);
42 for (int n = 0; n < fCut->GetN(); n++)
43 {
44 Double_t a[2];
45 fCut->GetPoint(n, a[0], a[1]);
46
47 TString name = GetNameObj() + "Point" + n;
48 p->AddAt(a[0], 0);
49 p->AddAt(a[1], 1);
50 list->add(name, *p);
51 }
52 delete p;
53}
54
55// ---- Method getParams ------------------------------------------------------
56TCutG* R3BTcutPar::getParams(FairParamList* list)
57{
58 R3BLOG(info, "called");
59
60 TArrayF* p = new TArrayF(2);
61 for (int n = 0; n < fMaxPoints; n++)
62 {
63 TString name = GetNameObj() + "Point" + n;
64 if (list->fill(name, p))
65 {
66 if (fCut == NULL)
67 fCut = new TCutG(GetNameObj(), 1);
68 fCut->SetPoint(n, p->GetAt(0), p->GetAt(1));
69 }
70 else
71 {
72 break;
73 }
74 }
75 delete p;
76 return fCut;
77}
78
79// ---- Method print ----------------------------------------------------------
81{
82 if (fCut)
83 {
84 R3BLOG(info, "for " << fCut->GetName());
85 for (int n = 0; n < fCut->GetN(); n++)
86 {
87 Double_t a[2];
88 fCut->GetPoint(n, a[0], a[1]);
89 LOG(info) << "CutPoint" << n << ": " << a[0] << " ; " << a[1];
90 }
91 }
92 else
93 {
94 R3BLOG(warn, "Cut parameters not found");
95 }
96}
97
#define R3BLOG(severity, x)
Definition R3BLogger.h:35
ClassImp(R3BTcutPar)
void print()
Method to print values of parameters.
virtual void putParams(FairParamList *list)
Method to store all parameters using FairRuntimeDB.
TString GetNameObj()
Definition R3BTcutPar.h:46
R3BTcutPar(const TString &cutname="Cut")
Default constructor.
TCutG * getParams(FairParamList *list)
Method to retrieve all parameters using FairRuntimeDB.