diff --git a/Lectures_my/EMPP/2016/Lecture4/Exercises/Markov2/Makefile b/Lectures_my/EMPP/2016/Lecture4/Exercises/Markov2/Makefile new file mode 100644 index 0000000..33f601a --- /dev/null +++ b/Lectures_my/EMPP/2016/Lecture4/Exercises/Markov2/Makefile @@ -0,0 +1,65 @@ +#---------------------------------------------------------------------- +# Przyklad linkowania bibliotek systemu ROOT z wlasnym programem +#---------------------------------------------------------------------- +.SUFFIXES: .o .c .cxx .cpp .C .f .l .s .sh .h .a +#====================================================================== +# Biblioteki ROOTa dla linkera +# 1) Jawnie: +## Sciezka to systemu ROOT - nalezy ja ustawic odpowiednio +#RPATH = /usr/local/root/ +#RLIB= -L$(RPATH)lib -lCore -lCint -lHist -lGraf -lGraf3d -lGpad -lTree \ +# -lRint -lPostscript -lMatrix -lPhysics -lm -ldl -lpthread -rdynamic +# 2) Niejawnie, przy uzyciu root-config +RLIB= `root-config --libs` +#====================================================================== +# Nazwa biezacego katalogu +DIRNAME = ./ +#====================================================================== +# Nazwa rdzeniowa modulu programu +NAME1 = mark1 +NAME2 = mark2 +#NAME2 = generatory +# Pliki objectowe (po kompilacji) +#OBJT1 = $(NAME1).o +OBJT2 = $(NAME2).o +# Pliki wykonawcze (po linkowaniu) +#EXEC1 = $(NAME1).x +EXEC1 = $(NAME2).x +# Nazwa i opcje kompilatora +CXX = g++ +# 1) Jawnie +#CXXFLAGS = -O -Wall -pthread -I$(RPATH)include +# 2) Przy uzyciu root-config +CXXFLAGS = -O -Wall `root-config --cflags` +# Nazwa i opcje linkera +LD = $(CXX) +LDFLAGS = `root-config --ldflags` +#============================================================================== +# Kompilacja dla modulow z plikami naglowkowymi +%.o: %.cxx %.h + $(CXX) $(CXXFLAGS) -c $< +# Kompilacja dla modulow bez plikow naglowkowych +%.o: %.cxx + $(CXX) $(CXXFLAGS) -c $< +#============================================================================== +.PHONY: all run clean tar +all: ${EXEC1} +#============================================================================== +# Linkowanie +${EXEC1}: ${OBJT1} ${OBJT2} + $(LD) -o $@ $(LDFLAGS) $^ $(RLIB) +#============================================================================== +# Uruchamianie +run: ${EXEC1} + ./${EXEC1} +#============================================================================== +clean: + (rm -f *.o *.a *~ *.exe *.x core lmap *.dvi *.aux *.log a.out) +#============================================================================== +tar: clean + (cd ../; tar -cvzf $(DIRNAME).tar.gz $(DIRNAME) ) +#============================================================================== +# Wszelkie akcje jakie należy podjąć aby program zaprezentował swoje działanie: +test: run + @echo 'Test run finished' +#============================================================================== diff --git a/Lectures_my/EMPP/2016/Lecture4/Exercises/Markov2/mark2.cc b/Lectures_my/EMPP/2016/Lecture4/Exercises/Markov2/mark2.cc new file mode 100644 index 0000000..93ac0f5 --- /dev/null +++ b/Lectures_my/EMPP/2016/Lecture4/Exercises/Markov2/mark2.cc @@ -0,0 +1,81 @@ +#include "TF1.h" +#include "TCanvas.h" +#include "TApplication.h" +#include "TH3D.h" +#include "TH2D.h" +#include "TRandom.h" +#include "TRandom3.h" +#include "TMath.h" +#include +#include +#include +#include "TStyle.h" + +#include + + +using namespace std; + +void solution(double &x,double &y,double &z,int traj, TRandom *gen) +{ + //double p[3]={0.9,0.8,0.7}; + double p[3]={0.3,0.3,0.6}; + double hPrim[3][3]={{0.3,0.5,0.9},{0.3,0.6,0.9},{0.6,0.7,0.9}}; + //double hPrim[3][3]={{0.9,1,1},{0.8,0.8,1},{0.7,0.7,0.7}}; + + double a[3]={1.5, -1.,0.7}; + double wynik[3]={0.,0.,0.}; + double ran; + double q[3]={1./3.,1./3.,1./3.}; + int i,ik; + int n; + ik=0; + for(int j=0;jRndm(); + if(ran<=q[0]){n=0;} + if(ran>q[0] && ranq[0]+q[1]){n=2;} + i=n+1; + while(i!=0) + { + ran=gen->Rndm(); + //if(n==2){cout<ran){ik=i; i=0;} + else + { + for(int m=2;m>=0;--m) + { + if(hPrim[i-1][m]SetOptFit(1); + gStyle->SetTitleFillColor(0); + gStyle->SetStatColor(0); + double x,y,z; + TRandom *gen=new TRandom3(); + solution(x,y,z, NTOYS,gen); + cout<