9#include "Fluctuation1D.h"
33 fM[0] = fM[1] = fM[2] = fM[3] = fM[4] = fM[5] = fM[6] = 0;
34 fMErr[0] = fMErr[1] = fMErr[2] = fMErr[3] = fMErr[4] = fMErr[5] = fMErr[6] = 0;
37 void Fluctuation1D::Calc(TH1D* h) {
38 fN = fM[0] = fM[1] = fM[2] = fM[3] = fM[4] = fM[5] = fM[6] = 0.0;
39 Double_t entries = h->GetEntries();
41 for (
int i = 1; i <= h->GetNbinsX(); i++) {
42 Double_t pN = ((Double_t) h->GetBinContent(i));
43 Double_t N = (Double_t) h->GetBinCenter(i);
47 for (
int i = 1; i <= h->GetNbinsX(); i++) {
48 Double_t pN = ((Double_t) h->GetBinContent(i));
49 Double_t N = (Double_t) h->GetBinCenter(i);
50 for (
int j = 1; j <= 6; j++) {
51 fM[j] += TMath::Power(N - fN, j) * pN;
54 for (
int j = 1; j <= 6; j++) {
55 fM[j] = fM[j] / entries;
80 void Fluctuation1D::CalcError(TH1D* h) {
81 TH1D* hh = (TH1D*) h->Clone(
"temp_boostrap");
83 Double_t* mean =
new Double_t[fNSample];
84 Double_t* omega =
new Double_t[fNSample];
85 Double_t* sigma =
new Double_t[fNSample];
86 Double_t* kappa =
new Double_t[fNSample];
87 Double_t** central_moment =
new Double_t*[5];
88 for (
int i = 0; i < 5; i++) {
89 central_moment[i] =
new Double_t[fNSample];
91 for (
int i = 0; i < fNSample; i++) {
93 for (
int j = 0; j < h->GetEntries(); j++) {
94 hh->Fill(h->GetRandom());
101 for (
int j = 2; j < 7; j++)
104 fOmegaError = GetRMS(omega, fNSample);
105 fSigmaError = GetRMS(sigma, fNSample);
106 fKappaError = GetRMS(kappa, fNSample);
107 fNError = GetRMS(mean, fNSample);
108 for (
int i = 2; i < 7; i++) {
109 fMErr[i] = GetRMS(central_moment[i - 2], fNSample);
111 for (
int i = 0; i < 5; i++) {
112 delete[] central_moment[i];
114 delete[] central_moment;
124 if (h->InheritsFrom(
"TH2")) {
125 Cout::PrintInfo(
"Cannot call Fluctuation1D(TH2D*)", EInfo::kLowWarning);
128 fHistogram = (TH1D*) h->Clone();
133 if (opt.EqualTo(
"x") || opt.EqualTo(
"pos")) {
134 fHistogram = h->ProjectionX(Form(
"%s_pos", h->GetName()));
135 }
else if (opt.EqualTo(
"y") || opt.EqualTo(
"neg")) {
136 fHistogram = h->ProjectionY(Form(
"%s_neg", h->GetName()));
137 }
else if (opt.EqualTo(
"sum") || opt.EqualTo(
"+")) {
138 fHistogram = CalcProfile(h, 1);
140 fHistogram = CalcProfile(h, 0);
146 TString path = Form(
"%s/fluct_%i", dir.Data(), no);
147 gSystem->MakeDirectory(path);
148 TString filename = Form(
"%s/fluct.html", path.Data());
151 HtmlRow row1(
"",
"dark_blue",
"");
155 HtmlRow row2(
"",
"dark_blue",
"");
159 HtmlRow row3(
"",
"dark_blue",
"");
163 file.AddContent(table);
165 HtmlRow row4(
"",
"dark_blue",
"");
169 file.AddContent(table2);
170 TCanvas* c1 =
new TCanvas();
171 fHistogram->DrawClone();
177 c1->SaveAs(Form(
"%s//fluct.root", path.Data()));
179 TString file_name = Form(
"%s/fluct.root", path.Data());
182 return HtmlCore::GetUrl(Form(
"fluct_%i/fluct.html", no), this->ClassName());
186 if (pack->InheritsFrom(
"Hal::Fluctuation1D")) {
188 fHistogram->Add(other->fHistogram);
191 Cout::PrintInfo(Form(
"Cannot ddd %s to %s", pack->ClassName(), this->ClassName()), EInfo::kLowWarning);
198 TIter iterator(collection);
200 fHistogram->Add(pack->fHistogram);
207 Double_t Fluctuation1D::GetRMS(Double_t* array, Int_t size)
const {
208 Double_t average = 0;
210 for (
int i = 0; i < size; i++) {
213 average = average / n;
215 for (
int i = 0; i < size; i++) {
216 Double_t dx = array[i] - average;
219 return TMath::Sqrt(rms / n);
222 TH1D* Fluctuation1D::CalcProfile(TH2D* h, Int_t opt) {
223 Double_t min_pos = h->GetXaxis()->GetBinLowEdge(1);
224 Double_t max_pos = h->GetXaxis()->GetBinUpEdge(h->GetXaxis()->GetNbins());
225 Double_t min_neg = h->GetYaxis()->GetBinLowEdge(1);
226 Double_t max_neg = h->GetYaxis()->GetBinUpEdge(h->GetYaxis()->GetNbins());
229 min = min_pos - max_neg;
230 max = max_pos - min_neg;
232 min = min_pos + min_neg;
233 max = max_pos + max_neg;
235 min = TMath::Floor(min) - 0.5;
236 max = TMath::Ceil(max) + 0.5;
238 TH1D* temp =
new TH1D(
"profile",
"profile", (max - min), min, max);
239 for (
int j = 1; j <= h->GetNbinsX(); j++) {
240 Double_t y = h->GetYaxis()->GetBinCenter(j);
241 if (opt == 0) y = -y;
242 for (
int i = 1; i <= h->GetNbinsY(); i++) {
243 Double_t x = h->GetXaxis()->GetBinCenter(i);
244 Double_t n = h->GetBinContent(i, j);
245 temp->Fill(x + y, n);
253 CalcError(fHistogram);
256 void Fluctuation1D::Browse(TBrowser* b) {
258 TVirtualPad* c1 = gPad;
264 void Fluctuation1D::Draw(Option_t* opt) {
265 TString option = opt;
266 if (option ==
"all") {
267 fHistogram->SetStats(kFALSE);
279 void Fluctuation1D::GetFrom2D(TH1D* , TString ) {}
281 void Fluctuation1D::Print(Option_t* )
const {
282 std::cout <<
"Fluctuation1D " << std::endl;
287 for (
int i = 2; i < 7; i++) {
290 std::cout <<
"**********************" << std::endl;
293 Fluctuation1D::~Fluctuation1D() {
294 if (fHistogram)
delete fHistogram;
static void PrintInfo(TString text, Hal::EInfo status)
Double_t GetOmegaError() const
Double_t GetKappaSigma() const
virtual TString HTMLExtract(Int_t no, TString dir="") const
Double_t GetMeanError() const
virtual Long64_t Merge(TCollection *collection)
Double_t GetKappaSigmaError() const
Double_t GetSSigmaError() const
virtual void Add(const Object *pack)
Double_t GetSSigma() const
Double_t GetCentralMomentError(Int_t i) const
Double_t GetCentralMoment(Int_t i) const
Double_t GetOmega() const
static TString GetUrl(TString adress, TString text)
static TString GetJsDiv(TString root_file, TString object_name, TString draw_opt="colz", TString draw_div_name="drawing")
virtual void AddContent(const HtmlObject &obj)
virtual void AddContent(const HtmlObject &obj)