GetHist function added

This commit is contained in:
Reka Korei 2017-11-02 12:53:04 +01:00
parent 0d5f9974ad
commit 2cb63ce971
2 changed files with 15 additions and 4 deletions

View File

@ -12,6 +12,12 @@
#include "TMath.h"
#include "TCanvas.h"
//////////////////////////////////////////////////
// //
// Estimate p0, mu, sigma for one particle //
// //
//////////////////////////////////////////////////
class Analyse{
@ -22,6 +28,7 @@ public:
Double_t GetP0();
Double_t GetMu();
Double_t GetSigma();
TH1D* GetHist();
void AnalyseGaus(std::vector<Double_t> t, std::vector<Double_t> x);
@ -30,6 +37,7 @@ private:
Double_t _mu;
Double_t _sigma;
TCanvas* canvA;
TH1D* dxhisto;
};

View File

@ -2,6 +2,7 @@
Analyse::Analyse() : _p0(0), _mu(0), _sigma(0) {
canvA = new TCanvas("cancA","display",800,400);
dxhisto = new TH1D("dxhisto","dxhisto", 50, -5.0,5.0);
}
Analyse::~Analyse() {;}
@ -23,6 +24,10 @@ Double_t Analyse::GetSigma(){
return _sigma;
}
TH1D* Analyse::GetHist(){
return dxhisto;
}
void Analyse::AnalyseGaus(std::vector<Double_t> t, std::vector<Double_t> x){
@ -74,15 +79,13 @@ void Analyse::AnalyseGaus(std::vector<Double_t> t, std::vector<Double_t> x){
Int_t nbin = (max-min)/0.1;
TH1D* dxhisto = new TH1D("dxhisto","dxhisto", nbin, min+0.1*min,max+0.1*max);
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]);
canvA->cd();
dxhisto->Fit("gaus");
canvA->cd();
dxhisto->Draw();
_mu = dxhisto->GetFunction("gaus")->GetParameter(1);