Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
CorrFitMapKstarRstar.cxx
1/*
2 * CorrFitMap1D.cxx
3 *
4 * Created on: 18 paź 2021
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9#include "CorrFitMapKstarRstar.h"
10
11#include "Cout.h"
12#include "DividedHisto.h"
13#include "Splines.h"
14
15namespace Hal {
16 CorrFitMapKstarRstar::CorrFitMapKstarRstar(TString name) :
17 fHisto2d(nullptr), fSplined(nullptr), fFrameScale(1), fFrame(Femto::EKinematics::kPRF) {
18 SetName(name);
19 }
20
21 CorrFitMapKstarRstar::CorrFitMapKstarRstar(const TH2D& h, Femto::EKinematics kin) :
22 fSplined(nullptr), fFrameScale(1), fFrame(kin) {
23 fHisto2d = (TH2D*) h.Clone();
24 fHisto2d->SetDirectory(nullptr);
25 }
26
27 CorrFitMapKstarRstar::CorrFitMapKstarRstar(const CorrFitMapKstarRstar& other) :
28 Object(other), fHisto2d(nullptr), fSplined(nullptr), fFrameScale(other.fFrameScale), fFrame(other.fFrame) {
29 if (other.fHisto2d) fHisto2d = (TH2D*) other.fHisto2d->Clone();
30 // if (other.fSplined) fSplined = (Spline2D*) other.fSplined->Clone();
31 }
32
33 Double_t CorrFitMapKstarRstar::Eval(Double_t q, Double_t R) const {
34 q = q * fFrameScale;
35 return fSplined->Eval(q, R);
36 }
37
38 CorrFitMapKstarRstar::CorrFitMapKstarRstar(TString name,
39 Int_t binsKstar,
40 Double_t minKstar,
41 Double_t maxKstar,
42 Int_t binsR,
43 Double_t minR,
44 Double_t maxR,
45 Femto::EKinematics kin) :
46 fSplined(nullptr), fFrameScale(1.0), fFrame(kin) {
47 fHisto2d = new TH2D("CFMap", "CFMap", binsKstar, minKstar, maxKstar, binsR, minR, maxR);
48 SetName(name);
49 }
50
51 void CorrFitMapKstarRstar::Recalc(TString extrOpt) {
52 if (fSplined != nullptr) {
53 Cout::Text("Splinned already exist in CorrFitMap1D::BuildSpline");
54 delete fSplined;
55 fSplined = nullptr;
56 }
57 fSplined = new Spline2D(fHisto2d, extrOpt);
58 fSplined->Refit();
59 }
60
61 void CorrFitMapKstarRstar::SetFrameScale(Femto::EKinematics kin) {
62 if (kin == fFrame) fFrameScale = 1.0;
63 if (kin == Femto::EKinematics::kLCMS && fFrame == Femto::EKinematics::kPRF) { fFrameScale = 0.5; }
64 if (kin == Femto::EKinematics::kPRF && fFrame == Femto::EKinematics::kLCMS) { fFrameScale = 2.0; }
65 }
66
67 Double_t CorrFitMapKstarRstar::EvalNumError(Double_t q, Double_t R) const {
68 q = q * fFrameScale;
69 return fSplined->GetError(q, R) * 1.5;
70 }
71
72 CorrFitMapKstarRstar::~CorrFitMapKstarRstar() {
73 if (fHisto2d) delete fHisto2d;
74 if (fSplined) delete fSplined;
75 }
76
77 CorrFitMapKstarRstar& CorrFitMapKstarRstar::operator=(const CorrFitMapKstarRstar& other) {
78 if (this == &other) return *this;
79 TNamed::operator=(other);
80 if (fHisto2d) delete fHisto2d;
81 if (fSplined) delete fSplined;
82 fHisto2d = nullptr;
83 fSplined = nullptr;
84 if (other.fHisto2d) { fHisto2d = (TH2D*) other.fHisto2d->Clone(); }
85 if (other.fSplined) { fSplined = (Spline2D*) fSplined->Clone(); }
86 fFrame = other.fFrame;
87 fFrameScale = other.fFrameScale;
88 return *this;
89 }
90
91 void CorrFitMapKstarRstar::Add(const Object* pack) {
93 if (fHisto2d) fHisto2d->Add(other->fHisto2d);
94 }
95
96 //===============================================================================
97 CorrFitMapKstarRstarDiv::CorrFitMapKstarRstarDiv(TString name) : CorrFitMapKstarRstar(name), fHistoDiv2d(nullptr) {}
98
99 CorrFitMapKstarRstarDiv::CorrFitMapKstarRstarDiv(const CorrFitMapKstarRstarDiv& other) : CorrFitMapKstarRstar(other) {
100 fHistoDiv2d = (DividedHisto2D*) other.fHistoDiv2d->Clone();
101 }
102
103 CorrFitMapKstarRstarDiv::CorrFitMapKstarRstarDiv(const DividedHisto2D& other, Femto::EKinematics kin) : CorrFitMapKstarRstar() {
104 fFrame = kin;
105 fHistoDiv2d = (DividedHisto2D*) other.Clone();
106 fHisto2d = (TH2D*) fHistoDiv2d->GetHist(kFALSE);
107 }
108
109 CorrFitMapKstarRstarDiv& CorrFitMapKstarRstarDiv::operator=(const CorrFitMapKstarRstarDiv& other) {
110 if (this == &other) return *this;
111 CorrFitMapKstarRstar::operator=(other);
112 if (fHistoDiv2d) {
113 delete fHistoDiv2d;
114 fHistoDiv2d = nullptr;
115 }
116 fHistoDiv2d = (DividedHisto2D*) other.fHistoDiv2d->Clone();
117 return *this;
118 }
119
123 fHistoDiv2d->Add(other->fHistoDiv2d);
124 }
125
126 void CorrFitMapKstarRstarDiv::Recalc(TString opt) {
127 if (fHisto2d) delete fHisto2d;
128 if (fSplined) delete fSplined;
129 fSplined = nullptr;
130 fHisto2d = (TH2D*) fHistoDiv2d->GetHist(kFALSE);
131 CorrFitMapKstarRstar::Recalc(opt);
132 }
133
134 CorrFitMapKstarRstarDiv::~CorrFitMapKstarRstarDiv() {
135 if (fHistoDiv2d) delete fHistoDiv2d;
136 }
137} // namespace Hal
virtual void Add(const Object *pack)
virtual void Add(const Object *pack)
TH1 * GetHist(Bool_t normalized=kTRUE) const
virtual void Add(const Object *h)
virtual void Add(const Object *pack)
Definition Object.cxx:24