Added new window for Analyse

This commit is contained in:
Reka Korei 2017-10-31 16:00:35 +01:00
parent c78b2b6b9f
commit 30e1f549d1
2 changed files with 11 additions and 15 deletions

View File

@ -10,6 +10,7 @@
#include "TH1.h" #include "TH1.h"
#include "TF1.h" #include "TF1.h"
#include "TMath.h" #include "TMath.h"
#include "TCanvas.h"
class Analyse{ class Analyse{
@ -28,6 +29,7 @@ private:
Double_t _p0; Double_t _p0;
Double_t _mu; Double_t _mu;
Double_t _sigma; Double_t _sigma;
TCanvas* canvA;
}; };

View File

@ -1,6 +1,8 @@
#include "Analyse.hh" #include "Analyse.hh"
Analyse::Analyse() : _p0(0), _mu(0), _sigma(0) {} Analyse::Analyse() : _p0(0), _mu(0), _sigma(0) {
canvA = new TCanvas("cancA","display",800,400);
}
Analyse::~Analyse() {;} Analyse::~Analyse() {;}
@ -26,7 +28,7 @@ void Analyse::AnalyseGaus(std::vector<Double_t> t, std::vector<Double_t> x){
Double_t dx = 0.0; Double_t dx = 0.0;
Double_t q = 10000; Double_t q = 100000000;
Double_t max = std::numeric_limits<int>::min(); Double_t max = std::numeric_limits<int>::min();
Double_t min = std::numeric_limits<int>::max(); Double_t min = std::numeric_limits<int>::max();
@ -41,12 +43,8 @@ void Analyse::AnalyseGaus(std::vector<Double_t> t, std::vector<Double_t> x){
if(TMath::Abs(x[i]-x[i-1]) < dx) _p0 += 1.0; if(TMath::Abs(x[i]-x[i-1]) < dx) _p0 += 1.0;
} }
//std::cout << "t.size " << t.size() << std::endl;
_p0 /= (Double_t)t.size(); _p0 /= (Double_t)t.size();
//std::cout << "p0 = " << _p0 << std::endl;
std::vector<Double_t> deltax; std::vector<Double_t> deltax;
@ -61,8 +59,6 @@ void Analyse::AnalyseGaus(std::vector<Double_t> t, std::vector<Double_t> x){
} }
//std::cout << deltax[i-1] << std::endl;
} }
@ -76,20 +72,18 @@ void Analyse::AnalyseGaus(std::vector<Double_t> t, std::vector<Double_t> x){
} }
Int_t nbin = (max-min)/0.1; Int_t nbin = (max-min)/0.1;
//std::cout << nbin << std::endl;
TH1D* dxhisto = new TH1D("dxhisto","dxhisto", nbin, min+0.1*min,max+0.1*max); TH1D* dxhisto = new TH1D("dxhisto","dxhisto", nbin, min+0.1*min,max+0.1*max);
for (int i = 0; i < deltax.size(); i++) dxhisto->Fill(deltax[i]); for (int i = 0; i < deltax.size(); i++) dxhisto->Fill(deltax[i]);
canvA->cd();
dxhisto->Fit("gaus"); dxhisto->Fit("gaus");
dxhisto->Draw(); dxhisto->Draw();
//std::cout << dxhisto->GetFunction("gaus")->GetParameter(1) <<std::endl;
_mu = dxhisto->GetFunction("gaus")->GetParameter(1); _mu = dxhisto->GetFunction("gaus")->GetParameter(1);
_sigma = dxhisto->GetFunction("gaus")->GetParameter(2); _sigma = dxhisto->GetFunction("gaus")->GetParameter(2);