#if !defined(__CINT__) || defined(__MAKECINT__) #include #include #include #include #include #include #endif // Dichiarazione delle funzioni Double_t exponential(Double_t *x, Double_t *par); //_____________________________________________________________ void Decay(Int_t n0 = 50000, Double_t alpha = 0.03, Double_t Delt = 1.0, Double_t ttot = 300, Int_t seed = 95689){ gRandom->SetSeed(seed); Int_t Nbins = static_cast(ttot/Delt); // numero di intervalli di tempo cout << "Numero di celle: "<SetFillColor(kOrange-4); //funzione teorica TF1 *fteo = new TF1("fteo",exponential,0.,timetot,2); fteo->SetLineColor(kRed); Double_t N0 = n0; Double_t ALPHA = alpha; fteo->SetParameters(N0,ALPHA); fteo->SetParNames("normalizzazione","coefficiente"); Double_t prob = alpha*Delt; //probabilita h1->Fill(0.,static_cast(n0)); for(Double_t time=Delt; timeRndm()Fill(time,static_cast(n0)); } //h1->Fit(fteo); TFile *file = new TFile("decay.root","recreate"); h1->Write(); fteo->Write(); h1->Draw("histo"); fteo->Draw("same"); file->ls(); } //_____________________________________________________________ Double_t exponential(Double_t *x, Double_t *par){ Double_t xx = x[0]; return par[0]*exp(-par[1]*xx); }