diff --git a/BM1D.cc b/BM1D.cc index 441770a..a4f6cbb 100644 --- a/BM1D.cc +++ b/BM1D.cc @@ -2,6 +2,7 @@ #include "BM1DProcess.hh" #include "Plotter.hh" #include "TApplication.h" +#include "Analyse.hh" using namespace std; @@ -71,6 +72,13 @@ int main(int argc, char* argv[]) Plotter* myPlotter = new Plotter(vis==1); myPlotter->Plot(nRuns, nSteps, myBM1DProcess->GetT(), myBM1DProcess->GetX()); + + Analyse *myAnalyse = new Analyse(); + + switch(random_type){ + case 'g' : + myAnalyse->AnalyseGaus(myBM1DProcess->GetT(),myBM1DProcess->GetX()); + } App.Run(); return 0; diff --git a/include/Analyse.hh b/include/Analyse.hh new file mode 100644 index 0000000..1ebfd99 --- /dev/null +++ b/include/Analyse.hh @@ -0,0 +1,34 @@ +#ifndef Analyse_h +#define Analyse_h 1 + +#include +#include +#include +#include +#include + +#include "TH1.h" +#include "TF1.h" +#include "TMath.h" + + +class Analyse{ + +public: + Analyse(); + ~Analyse(); + + Double_t GetP0(); + Double_t GetMu(); + Double_t GetSigma(); + + void AnalyseGaus(std::vector t, std::vector x); + +private: + Double_t _p0; + Double_t _mu; + Double_t _sigma; + +}; + +#endif diff --git a/src/Analyse.cc b/src/Analyse.cc new file mode 100644 index 0000000..b2dc6ac --- /dev/null +++ b/src/Analyse.cc @@ -0,0 +1,103 @@ +#include "Analyse.hh" + +Analyse::Analyse() : _p0(0), _mu(0), _sigma(0) {} + +Analyse::~Analyse() {;} + + +Double_t Analyse::GetP0() { + + return _p0; + } + + +Double_t Analyse::GetMu(){ + + return _mu; + } + + +Double_t Analyse::GetSigma(){ + + return _sigma; + } + +void Analyse::AnalyseGaus(std::vector t, std::vector x){ + + + Double_t dx = 0.0; + Double_t q = 10000; + Double_t max = std::numeric_limits::min(); + Double_t min = std::numeric_limits::max(); + + for (int i = 1; i < t.size(); i++) dx += TMath::Abs(x[i]-x[i-1]); + + dx/=t.size(); + dx/=q; + + + for (int i = 1; i < t.size(); i++){ + + 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(); + + //std::cout << "p0 = " << _p0 << std::endl; + + + std::vector deltax; + + + deltax.push_back(x[0]); + + for (int i = 1; i < t.size(); i++) { + + if(TMath::Abs(x[i]-x[i-1]) > dx){ + + deltax.push_back(x[i]-x[i-1]); + + } + + + //std::cout << deltax[i-1] << std::endl; + } + + + for (int i = 0; i < deltax.size(); i++){ + + Double_t loc_dx = deltax[i]; + + max = (loc_dx > max) ? loc_dx : max; + min = (loc_dx < min) ? loc_dx : min; + + } + + + 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); + + for (int i = 0; i < deltax.size(); i++) dxhisto->Fill(deltax[i]); + + dxhisto->Fit("gaus"); + + dxhisto->Draw(); + + + //std::cout << dxhisto->GetFunction("gaus")->GetParameter(1) <GetFunction("gaus")->GetParameter(1); + _sigma = dxhisto->GetFunction("gaus")->GetParameter(2); + + + std::cout << "p0 = " << _p0 << std::endl; + std::cout << "mu = " << _mu << std::endl; + std::cout << "sigma = " << _sigma << std::endl; + + +}