#!/usr/bin/python import os,sys from ROOT import * L1 = 1E-6 #metal L2 = 30E-6 #gas fast_depol = 0.01 #gas fr = 0.25 #fraction stopping in gas fu1 = '1.00 * exp(-1.*'+str(L1)+'*x)' fu2 = str(1-fast_depol)+'* exp(-1.*'+str(L2)+'*x)' fu3 = str(1-fr)+'*'+fu1+' + '+str(fr)+'*'+fu2 f1 = TF1('f1',fu1,-1.,10000.0) f2 = TF1('f2',fu2,-1.,10000.0) f3 = TF1('f3',fu3,-1.,10000.0) f1.SetLineColor(1) f2.SetLineColor(2) f3.SetLineColor(4) c1 = TCanvas('c1','c1') f1.Draw() f2.Draw('same') f3.Draw('same') c2 = TCanvas('c2','c2') gr = TGraph() for i in range(100): t = 100*i gr.SetPoint(i,t,(1-fr)*(1.00*exp(-1.*L1*t))+fr*((1-fast_depol)*exp(-1.*L2*t))) gr.SetMarkerStyle(20) #p1_r = TF1('p1_r','pol1',1000.,10000.) #gr.Fit('p1_r','R') def my_exp(x,par): return par[0]*exp(-1*par[1]*x[0]) tf_exp = TF1('tf_exp', my_exp, 1000., 10000., 2 ) gr.Fit(tf_exp,'R','',1000.,10000.) gr.Draw("AP") au = raw_input('>')