Added simulate functions(Crusher.cc, Draw2D.cc) created by K.Berta and Gy.Balazs Minor fixes and optimisation on other modules
This commit is contained in:
		
							parent
							
								
									ae3084b1fd
								
							
						
					
					
						commit
						4d0b94e145
					
				| 
						 | 
					@ -15,17 +15,17 @@ public:
 | 
				
			||||||
  BM1DProcess(); 
 | 
					  BM1DProcess(); 
 | 
				
			||||||
  ~BM1DProcess();
 | 
					  ~BM1DProcess();
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  void Run(int nSteps, int nRuns, double p0, double p1);
 | 
					  void Run(const int & nRuns, const int & nSteps, const  double & p0, const double & p1);
 | 
				
			||||||
  void Run(int nSteps, int nRuns, double p0, double mu, double sigma);
 | 
					  void Run(const int & nRuns, const int & nSteps, const  double & p0, const double & mu, const double & sigma);
 | 
				
			||||||
  void Run(int nSteps, int nRuns, double p0, double x1, double x2, double mu1, double sigma1, double mu2,  double sigma2);
 | 
					  void Run(const int & nRuns, const int & nSteps, const double & p0, const double & x1, const double & x2, const double & mu1, const double & sigma1, const double &mu2, const double & sigma2);
 | 
				
			||||||
  void Run(int nRuns, int nSteps, double p0, double x1, double x2, double mu1, double sigma1, double mu2, double sigma2, double j_mu1, double j_sigma1, double rat);
 | 
					  void Run(const int & nRuns, const int & nSteps, const double & p0, const double & x1, const double & x2, const double & mu1, const double & sigma1, const double &mu2, const double & sigma2, const double & j_mu1, const double & j_sigma1, const double  & rat);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  std::vector<Double_t> GetT(){return t;}
 | 
					  const std::vector<Double_t> & GetT(){return t;}
 | 
				
			||||||
  std::vector<Double_t> GetX(){return x;}
 | 
					  const std::vector<Double_t> & GetX(){return x;}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 private:
 | 
					 private:
 | 
				
			||||||
  TRandom* randomGenerator;
 | 
					  TRandom3* randomGenerator;
 | 
				
			||||||
  TRandom* randomGeneratorGauss;
 | 
					  TRandom3* randomGeneratorGauss;
 | 
				
			||||||
  //TF1* jump;
 | 
					  //TF1* jump;
 | 
				
			||||||
  Double_t rand1;
 | 
					  Double_t rand1;
 | 
				
			||||||
  std::vector<Double_t> t;
 | 
					  std::vector<Double_t> t;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,37 @@
 | 
				
			||||||
 | 
					#ifndef Crusher_h
 | 
				
			||||||
 | 
					#define Crusher_h 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <iostream>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "BM1DProcess.hh"
 | 
				
			||||||
 | 
					#include "Analyse.hh"
 | 
				
			||||||
 | 
					#include "Lattice.hh"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Crusher
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						public:
 | 
				
			||||||
 | 
							Crusher(std::vector<Double_t> tp, std::vector<Double_t> xp, double p0p);
 | 
				
			||||||
 | 
							Crusher(std::vector<Double_t> tp, std::vector<Double_t> xp);
 | 
				
			||||||
 | 
							~Crusher();
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							bool RunMachine(const int & nRunsm, const MuSigma & parameters);
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							const std::vector<Double_t> & GetMulT() {return multipleRunVectorT;}
 | 
				
			||||||
 | 
							const std::vector<Double_t> & GetMulX() {return multipleRunVectorX;}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
						private:
 | 
				
			||||||
 | 
							int nSteps;
 | 
				
			||||||
 | 
							double p0;
 | 
				
			||||||
 | 
							std::vector<Double_t> t;
 | 
				
			||||||
 | 
							std::vector<Double_t> x;
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							BM1DProcess *myBM1DProcess;
 | 
				
			||||||
 | 
							Analyse *myAnalyse;
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							bool Bigger(double percent);
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							std::vector<Double_t> multipleRunVectorT;
 | 
				
			||||||
 | 
							std::vector<Double_t> multipleRunVectorX;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,43 @@
 | 
				
			||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <iostream>
 | 
				
			||||||
 | 
					#include <string>
 | 
				
			||||||
 | 
					#include <fstream>
 | 
				
			||||||
 | 
					#include <cmath>
 | 
				
			||||||
 | 
					#include <vector>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "Analyse.hh"
 | 
				
			||||||
 | 
					#include "Lattice.hh"
 | 
				
			||||||
 | 
					#include "Crusher.hh"
 | 
				
			||||||
 | 
					#include "Plotter.hh"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "TH2.h"
 | 
				
			||||||
 | 
					#include "TCanvas.h"
 | 
				
			||||||
 | 
					#include "TGraph.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Draw2D
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						public:
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							Draw2D(int nop, double percent, int nRunsp, std::vector<Double_t> tp, std::vector<Double_t> xp);
 | 
				
			||||||
 | 
					        ~Draw2D();
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							void Histo2D();
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
						private:
 | 
				
			||||||
 | 
							std::vector<Double_t> t;
 | 
				
			||||||
 | 
							std::vector<Double_t> x;
 | 
				
			||||||
 | 
							int nRuns;
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							Analyse *myAnalyse;
 | 
				
			||||||
 | 
							Crusher *myCrusher;
 | 
				
			||||||
 | 
							Lattice *myLattice;
 | 
				
			||||||
 | 
							TCanvas* canvasB;
 | 
				
			||||||
 | 
							TCanvas* canvasB2;
 | 
				
			||||||
 | 
							TH2D *BM1D_histo;
 | 
				
			||||||
 | 
							TH2D *BM1D_histo2;
 | 
				
			||||||
 | 
							TGraph *gr;
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,6 @@
 | 
				
			||||||
#ifndef Lattice_h
 | 
					//#ifndef Lattice_h
 | 
				
			||||||
#define LAttice_h 1
 | 
					//#define LAttice_h 1
 | 
				
			||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <iostream>
 | 
					#include <iostream>
 | 
				
			||||||
#include <string>
 | 
					#include <string>
 | 
				
			||||||
| 
						 | 
					@ -29,15 +30,20 @@ public:
 | 
				
			||||||
	~Lattice();
 | 
						~Lattice();
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	void SetNop(Int_t num); //set the width of the lattice
 | 
						void SetNop(Int_t num); //set the width of the lattice
 | 
				
			||||||
	void SetPercent(Int_t num); //set the interval of mu, sigma
 | 
						void SetPercent(Double_t num); //set the interval of mu, sigma
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	void SetLattice(Double_t mu_est, Double_t sigma_est); //set the lattice around mu_est, sigma_est
 | 
						void SetLattice(Double_t mu_est, Double_t sigma_est); //set the lattice around mu_est, sigma_est
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	MuSigma GetMuSigma(Int_t index);
 | 
						const MuSigma & GetMuSigma(Int_t index);
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	Int_t GetLatticeSize(); //number of points in the lattice
 | 
						Int_t GetLatticeSize(); //number of points in the lattice
 | 
				
			||||||
	Int_t GetWidth(); //number of mu values
 | 
						const Int_t & GetWidth(); //number of mu values
 | 
				
			||||||
	Int_t GetHeight(); //number of sigma values
 | 
						const Int_t & GetHeight(); //number of sigma values
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						const double & GetMuMin();
 | 
				
			||||||
 | 
						const double & GetMuMax();
 | 
				
			||||||
 | 
						const double & GetSigmaMin();
 | 
				
			||||||
 | 
						const double & GetSigmaMax();
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
| 
						 | 
					@ -66,4 +72,4 @@ private:
 | 
				
			||||||
  	
 | 
					  	
 | 
				
			||||||
************************************************************************/
 | 
					************************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					//#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,7 +24,7 @@ class Plotter
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
  Plotter(bool draw);
 | 
					  Plotter(bool draw);
 | 
				
			||||||
  ~Plotter();
 | 
					  ~Plotter();
 | 
				
			||||||
  void Plot(Int_t numRuns, Int_t nSteps, std::vector<Double_t> t, std::vector<Double_t> x);
 | 
					  void Plot(Int_t numRuns, Int_t nSteps, const std::vector<Double_t> & t, const std::vector<Double_t> & x);
 | 
				
			||||||
  TMultiGraph * GetTmultiGraph();
 | 
					  TMultiGraph * GetTmultiGraph();
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  static unsigned int IDCounter;
 | 
					  static unsigned int IDCounter;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,10 +2,16 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Analyse::Analyse() : _p0(0), _mu(0), _sigma(0) {
 | 
					Analyse::Analyse() : _p0(0), _mu(0), _sigma(0) {
 | 
				
			||||||
	canvA = new TCanvas("cancA","display",800,400);	
 | 
						canvA = new TCanvas("cancA","display",800,400);	
 | 
				
			||||||
	dxhisto = new TH1D("dxhisto","dxhisto", 50, -5.0,5.0);
 | 
						//dxhisto = new TH1D("dxhisto","dxhisto", 50, -5.0,5.0); 
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Analyse::~Analyse() {;}
 | 
					Analyse::~Analyse()
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
						canvA->Clear();
 | 
				
			||||||
 | 
						canvA->Closed();
 | 
				
			||||||
 | 
						delete canvA;
 | 
				
			||||||
 | 
						delete dxhisto;
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Double_t Analyse::GetP0() { 
 | 
					Double_t Analyse::GetP0() { 
 | 
				
			||||||
| 
						 | 
					@ -96,5 +102,5 @@ void Analyse::AnalyseGaus(std::vector<Double_t> t, std::vector<Double_t> x){
 | 
				
			||||||
	std::cout << "mu = " << _mu << std::endl;
 | 
						std::cout << "mu = " << _mu << std::endl;
 | 
				
			||||||
	std::cout << "sigma = " << _sigma << std::endl; 
 | 
						std::cout << "sigma = " << _sigma << std::endl; 
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
		
 | 
						std::cout << "Analyse done" << std::endl;	
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,8 +2,11 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
BM1DProcess::BM1DProcess() 
 | 
					BM1DProcess::BM1DProcess() 
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  randomGenerator = new TRandom();
 | 
					  randomGenerator = new TRandom3();
 | 
				
			||||||
  randomGeneratorGauss = new TRandom();
 | 
					  randomGenerator -> SetSeed();
 | 
				
			||||||
 | 
					  randomGeneratorGauss = new TRandom3();
 | 
				
			||||||
 | 
					  randomGeneratorGauss -> SetSeed();
 | 
				
			||||||
 | 
					  std::cout << "seed:" << randomGeneratorGauss -> GetSeed() << std::endl;
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  //jump = new TF1("jump","gaus(0)+gaus(3)",-30,30);
 | 
					  //jump = new TF1("jump","gaus(0)+gaus(3)",-30,30);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -16,7 +19,7 @@ BM1DProcess::~BM1DProcess()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void BM1DProcess::Run(int nRuns, int nSteps, double p0, double p1)
 | 
					void BM1DProcess::Run(const int & nRuns, const int & nSteps, const  double & p0, const double & p1)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	t.clear();
 | 
						t.clear();
 | 
				
			||||||
	x.clear();
 | 
						x.clear();
 | 
				
			||||||
| 
						 | 
					@ -54,8 +57,11 @@ void BM1DProcess::Run(int nRuns, int nSteps, double p0, double p1)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void BM1DProcess::Run(int nRuns, int nSteps, double p0, double mu, double sigma)
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void BM1DProcess::Run(const int & nRuns, const int & nSteps, const  double & p0, const double & mu, const double & sigma)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						
 | 
				
			||||||
	t.clear();
 | 
						t.clear();
 | 
				
			||||||
	x.clear();
 | 
						x.clear();
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
| 
						 | 
					@ -82,9 +88,11 @@ void BM1DProcess::Run(int nRuns, int nSteps, double p0, double mu, double sigma)
 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
				}						
 | 
									}						
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
							
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void BM1DProcess::Run(int nRuns, int nSteps, double p0, double x1, double x2, double mu1, double sigma1, double mu2, double sigma2)
 | 
					void BM1DProcess::Run(const int & nRuns, const int & nSteps, const double & p0, const double & x1, const double & x2, const double & mu1, const double & sigma1, const double &mu2, const double & sigma2)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	t.clear();
 | 
						t.clear();
 | 
				
			||||||
	x.clear();
 | 
						x.clear();
 | 
				
			||||||
| 
						 | 
					@ -125,7 +133,7 @@ void BM1DProcess::Run(int nRuns, int nSteps, double p0, double x1, double x2, do
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void BM1DProcess::Run(int nRuns, int nSteps, double p0, double x1, double x2, double mu1, double sigma1, double mu2, double sigma2, double j_mu1, double j_sigma1, double rat)
 | 
					void BM1DProcess::Run(const int & nRuns, const int & nSteps, const double & p0, const double & x1, const double & x2, const double & mu1, const double & sigma1, const double &mu2, const double & sigma2, const double & j_mu1, const double & j_sigma1, const double  & rat)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	t.clear();
 | 
						t.clear();
 | 
				
			||||||
	x.clear();
 | 
						x.clear();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,92 @@
 | 
				
			||||||
 | 
					#include "Crusher.hh"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Crusher::Crusher(std::vector<Double_t> tp, std::vector<Double_t> xp, double p0p)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						nSteps = tp.size();
 | 
				
			||||||
 | 
						t = tp;
 | 
				
			||||||
 | 
						x = xp;
 | 
				
			||||||
 | 
						p0 = p0p;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						myBM1DProcess = new BM1DProcess();
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Crusher::Crusher(std::vector<Double_t> tp, std::vector<Double_t> xp)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						nSteps = tp.size();
 | 
				
			||||||
 | 
						t = tp;
 | 
				
			||||||
 | 
						x = xp;
 | 
				
			||||||
 | 
						p0 = 0.5;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						myBM1DProcess = new BM1DProcess();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Crusher::~Crusher()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						delete myBM1DProcess;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool Crusher::Bigger(double percent)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int counterBig = 0;
 | 
				
			||||||
 | 
						double limit = nSteps * percent;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						for(int i = 0; i < nSteps; i++)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							if(myBM1DProcess -> GetX()[i] < x[i]) // reference < origin
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								counterBig ++;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						if(counterBig >= limit)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return true;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						else return false;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool Crusher::RunMachine(const int & nRuns, const MuSigma & parameters)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
							int counter = 0;
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							multipleRunVectorT.clear();
 | 
				
			||||||
 | 
							multipleRunVectorX.clear();
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							for(int i = 0; i < nRuns; i++ )
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								myBM1DProcess->Run(1, nSteps, p0, parameters.mu, parameters.sigma);
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								//std::cout << "paramter mu:" << parameters.mu << "   paramter sigma:" << parameters.sigma << std::endl;
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								for(int i = 0; i < nSteps; i++)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									multipleRunVectorT.push_back(myBM1DProcess -> GetT()[i]);
 | 
				
			||||||
 | 
									multipleRunVectorX.push_back(myBM1DProcess -> GetX()[i]);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								if(Bigger(0.5))
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									counter ++;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							std::cout <<"mu:" << parameters.mu << "  sigma:" << parameters.sigma << "  in:" << counter <<std::endl; 
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							if(!(counter < (0.05 * nRuns) || (nRuns - counter) < (0.05 * nRuns)))
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								return true;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							else return false;
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,98 @@
 | 
				
			||||||
 | 
					#include "Draw2D.hh"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Draw2D::Draw2D(int nop, double percent, int nRunsp, std::vector<Double_t> tp, std::vector<Double_t> xp) //int nop, double percent, int nRunsp, std::vector<Double_t> tp, std::vector<Double_t> xp
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						t = tp;
 | 
				
			||||||
 | 
						x = xp;
 | 
				
			||||||
 | 
						nRuns = nRunsp;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						myAnalyse = new Analyse();
 | 
				
			||||||
 | 
						myAnalyse -> AnalyseGaus(t,x);
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						myCrusher = new Crusher(t,x);
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						myLattice = new Lattice();
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						myLattice -> SetNop(nop);
 | 
				
			||||||
 | 
						myLattice -> SetPercent(percent*100);
 | 
				
			||||||
 | 
						myLattice -> SetLattice(myAnalyse -> GetMu(), myAnalyse -> GetSigma());
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						canvasB = new TCanvas("draw2Dcanv", "Lattice",800,400);
 | 
				
			||||||
 | 
						canvasB -> Divide(2,1);
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						canvasB2 = new TCanvas("draw2Dcanv2", "Lattice2",800,400);
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						BM1D_histo = new TH2D("BM1D_histo", "BM1D_histo", myLattice -> GetWidth() , myLattice -> GetMuMin(), (myLattice -> GetMuMax()) , myLattice -> GetHeight() ,  myLattice -> GetSigmaMin(),  (myLattice -> GetSigmaMax()) );
 | 
				
			||||||
 | 
						BM1D_histo2 = new TH2D("BM1D_histo2", "BM1D_histo2",  myLattice -> GetWidth() , myLattice -> GetMuMin(), (myLattice -> GetMuMax()) , myLattice -> GetHeight() ,  myLattice -> GetSigmaMin(),  (myLattice -> GetSigmaMax()) );
 | 
				
			||||||
 | 
					    gr = new TGraph();
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						delete myAnalyse;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Draw2D::~Draw2D()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						canvasB->Clear();
 | 
				
			||||||
 | 
						canvasB->Closed();
 | 
				
			||||||
 | 
						delete canvasB;
 | 
				
			||||||
 | 
						delete BM1D_histo;
 | 
				
			||||||
 | 
						delete BM1D_histo2;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
						canvasB2->Clear();
 | 
				
			||||||
 | 
						canvasB2->Closed();
 | 
				
			||||||
 | 
						delete canvasB2;
 | 
				
			||||||
 | 
						delete gr;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						delete myLattice;
 | 
				
			||||||
 | 
						delete myCrusher;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Draw2D::Histo2D()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						double XbinSize = (myLattice -> GetMuMax() - myLattice -> GetMuMin())/ myLattice -> GetWidth() ;
 | 
				
			||||||
 | 
						double YbinSize =( myLattice -> GetSigmaMax() -  myLattice -> GetSigmaMin() ) / myLattice -> GetHeight();
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						double graphArrayX[myLattice -> GetLatticeSize()] = {};
 | 
				
			||||||
 | 
						double graphArrayY[myLattice -> GetLatticeSize()] = {}; 
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						std::cout << "maxSigma:" <<  myLattice -> GetSigmaMax() << std::endl;
 | 
				
			||||||
 | 
						std::cout << "maxMu:" <<   myLattice -> GetMuMax() << std::endl;
 | 
				
			||||||
 | 
						std::cout << "minSigma:" <<  myLattice -> GetSigmaMin() << std::endl;
 | 
				
			||||||
 | 
						std::cout << "minMu:" <<   myLattice -> GetMuMin() << std::endl;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						for(int i = 0; i < 	(myLattice -> GetLatticeSize()); i++) 
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								std::cout<<"progress: "<<i<<"/"<<myLattice -> GetLatticeSize()<<"point\n";
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								if(myCrusher -> RunMachine(nRuns, myLattice -> GetMuSigma(i)))
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										BM1D_histo -> Fill((i /  myLattice -> GetHeight()) * XbinSize + (XbinSize/2) + myLattice -> GetMuMin(),(i % myLattice -> GetHeight()) * YbinSize + (YbinSize/2) + myLattice -> GetSigmaMin() );
 | 
				
			||||||
 | 
										BM1D_histo2 -> Fill((i /  myLattice -> GetHeight()) * XbinSize + (XbinSize/2) + myLattice -> GetMuMin(),(i % myLattice -> GetHeight()) * YbinSize + (YbinSize/2) + myLattice -> GetSigmaMin());
 | 
				
			||||||
 | 
										
 | 
				
			||||||
 | 
										graphArrayX[i] = (i /  myLattice -> GetHeight()) * XbinSize;
 | 
				
			||||||
 | 
										graphArrayY[i] = (i % myLattice -> GetHeight()) * YbinSize;
 | 
				
			||||||
 | 
											
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
						std::cout << "RunMachine done" << std::endl;
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
						//TGraph *gr = new TGraph(myLattice -> GetLatticeSize(),graphArrayX,graphArrayY);
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						gr -> SetMarkerColor(46);	
 | 
				
			||||||
 | 
						canvasB2 -> cd();
 | 
				
			||||||
 | 
						//gr -> LineStyle()
 | 
				
			||||||
 | 
						gr -> DrawGraph(myLattice -> GetLatticeSize(),graphArrayX,graphArrayY,"AP*");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						BM1D_histo -> SetMarkerStyle(kFullCircle);
 | 
				
			||||||
 | 
						BM1D_histo-> SetMarkerStyle(21);
 | 
				
			||||||
 | 
						canvasB -> cd(1);
 | 
				
			||||||
 | 
						BM1D_histo -> Draw("PLC PMC");
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						canvasB -> cd(2);	
 | 
				
			||||||
 | 
						BM1D_histo2 -> Draw("COLZ");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						std::cout << "Histo done" << std::endl;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -12,17 +12,18 @@ void Lattice::SetNop(Int_t num){
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Lattice::SetPercent(Int_t num){
 | 
					void Lattice::SetPercent(Double_t num){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if((num > 1) && (num <= 100))
 | 
						if((num > 1) && (num <= 100))
 | 
				
			||||||
		_percent = num/100.0;
 | 
							_percent = num/100.0;
 | 
				
			||||||
	
 | 
						else{
 | 
				
			||||||
	else
 | 
							_percent = num;
 | 
				
			||||||
		std::cout << "Invalid value for percent, set to default" << std::endl;
 | 
							std::cout << "Invalid value for percent, set to default" << std::endl;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
MuSigma Lattice::GetMuSigma(Int_t index){
 | 
					const MuSigma & Lattice::GetMuSigma(Int_t index){
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	return ms_vect[index];
 | 
						return ms_vect[index];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -34,18 +35,38 @@ Int_t Lattice::GetLatticeSize(){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Int_t Lattice::GetWidth(){
 | 
					const Int_t & Lattice::GetWidth(){
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	return _width;
 | 
						return _width;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Int_t Lattice::GetHeight(){
 | 
					const Int_t & Lattice::GetHeight(){
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	return _height;
 | 
						return _height;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const double & Lattice::GetMuMin()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return ms_vect[0].mu;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const double & Lattice::GetMuMax()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return ms_vect[ _height * (_width-1)].mu;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const double & Lattice::GetSigmaMin()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return ms_vect[0].sigma;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const double & Lattice::GetSigmaMax()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return ms_vect[_height -1].sigma;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Lattice::SetLattice(Double_t mu_est, Double_t sigma_est){
 | 
					void Lattice::SetLattice(Double_t mu_est, Double_t sigma_est){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Double_t loc_sigma, loc_mu;
 | 
							Double_t loc_sigma, loc_mu;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,7 +26,7 @@ TMultiGraph * Plotter::GetTmultiGraph()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Plotter::Plot(Int_t numRuns, Int_t nSteps, std::vector<Double_t> t, std::vector<Double_t> x)
 | 
					void Plotter::Plot(Int_t numRuns, Int_t nSteps,const  std::vector<Double_t>  & t, const  std::vector<Double_t> & x)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  char str[30];
 | 
					  char str[30];
 | 
				
			||||||
  snprintf(str, 30, "BM1D Plotter canvas%d", ID);
 | 
					  snprintf(str, 30, "BM1D Plotter canvas%d", ID);
 | 
				
			||||||
| 
						 | 
					@ -45,7 +45,10 @@ void Plotter::Plot(Int_t numRuns, Int_t nSteps, std::vector<Double_t> t, std::ve
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  if(draw)
 | 
					  if(draw)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
 | 
							canv -> cd();
 | 
				
			||||||
		mg -> Draw("APL");
 | 
							mg -> Draw("APL");
 | 
				
			||||||
 | 
							std::cout << "Plotter done" << std::endl;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue