void fit_waveform04(void) { //=========Macro generated from canvas: c1/c1 //========= (Wed Dec 17 14:48:47 2014) by ROOT version5.34/19 TCanvas *c1 = new TCanvas("c1", "c1",1505,246,779,672); gROOT->Reset(); //TTree *Bfield = (TTree *) gROOT->FindObject("Bfield"); gStyle->SetPalette(1,0); gStyle->SetOptStat(kTRUE); gStyle->SetOptFit(kTRUE); gStyle->SetOptFit(1111); gStyle->SetPadRightMargin(0.15); gStyle->SetPadLeftMargin(0.15); gStyle->SetPadBottomMargin(0.15); gStyle->SetFillColor(0); // c1->Range(-21.79487,-16.8,106.4103,95.2); c1->SetFillColor(0); c1->SetBorderMode(0); c1->SetBorderSize(2); c1->SetLeftMargin(0.17); c1->SetRightMargin(0.05); c1->SetBottomMargin(0.15); c1->SetFrameBorderMode(0); c1->SetFrameBorderMode(0); TH1F *hist04 = new TH1F("hist04","Ch=38,10,14",100,0,100); hist04->SetBinContent(1,1); hist04->SetBinContent(2,3); hist04->SetBinContent(3,2); hist04->SetBinContent(4,4); hist04->SetBinContent(5,2); hist04->SetBinContent(6,2); hist04->SetBinContent(7,3); hist04->SetBinContent(8,2); hist04->SetBinContent(9,2); hist04->SetBinContent(11,2); hist04->SetBinContent(12,2); hist04->SetBinContent(13,2); hist04->SetBinContent(14,2); hist04->SetBinContent(15,2); hist04->SetBinContent(16,3); hist04->SetBinContent(17,3); hist04->SetBinContent(18,2); hist04->SetBinContent(19,3); hist04->SetBinContent(20,1); hist04->SetBinContent(22,1); hist04->SetBinContent(23,2); hist04->SetBinContent(24,2); hist04->SetBinContent(25,1); hist04->SetBinContent(26,4); hist04->SetBinContent(27,2); hist04->SetBinContent(28,2); hist04->SetBinContent(29,2); hist04->SetBinContent(30,1); hist04->SetBinContent(31,2); hist04->SetBinContent(32,2); hist04->SetBinContent(33,1); hist04->SetBinContent(34,1); hist04->SetBinContent(35,2); hist04->SetBinContent(36,10); hist04->SetBinContent(37,27); hist04->SetBinContent(38,32); hist04->SetBinContent(39,33); hist04->SetBinContent(40,33); hist04->SetBinContent(41,29); hist04->SetBinContent(42,25); hist04->SetBinContent(43,25); hist04->SetBinContent(44,24); hist04->SetBinContent(45,21); hist04->SetBinContent(46,19); hist04->SetBinContent(47,17); hist04->SetBinContent(48,14); hist04->SetBinContent(49,16); hist04->SetBinContent(50,12); hist04->SetBinContent(51,14); hist04->SetBinContent(52,12); hist04->SetBinContent(53,11); hist04->SetBinContent(54,9); hist04->SetBinContent(55,11); hist04->SetBinContent(56,10); hist04->SetBinContent(57,7); hist04->SetBinContent(58,7); hist04->SetBinContent(59,8); hist04->SetBinContent(60,6); hist04->SetBinContent(61,5); hist04->SetBinContent(62,8); hist04->SetBinContent(63,7); hist04->SetBinContent(64,5); hist04->SetBinContent(65,3); hist04->SetBinContent(66,2); hist04->SetBinContent(67,3); hist04->SetBinContent(68,2); hist04->SetBinContent(69,7); hist04->SetBinContent(70,2); hist04->SetBinContent(71,6); hist04->SetBinContent(72,4); hist04->SetBinContent(73,4); hist04->SetBinContent(74,1); hist04->SetBinContent(75,3); hist04->SetBinContent(76,4); hist04->SetBinContent(78,2); hist04->SetBinContent(79,2); hist04->SetBinContent(80,2); hist04->SetBinContent(81,1); hist04->SetBinContent(82,2); hist04->SetBinContent(83,3); hist04->SetBinContent(84,1); hist04->SetBinContent(85,1); hist04->SetBinContent(87,1); hist04->SetBinContent(88,2); hist04->SetBinContent(89,1); hist04->SetBinContent(90,1); hist04->SetBinContent(91,1); hist04->SetBinContent(95,2); hist04->SetBinContent(96,3); hist04->SetBinContent(97,4); hist04->SetBinContent(98,3); hist04->SetBinContent(99,2); hist04->SetBinContent(100,2); hist04->SetMaximum(84); hist04->SetEntries(1100); // hist04->SetStats(0); hist04->SetLineColor(2); hist04->GetXaxis()->SetTitle("sample (4 ns)"); hist04->GetXaxis()->SetNdivisions(505); hist04->GetXaxis()->SetLabelFont(42); hist04->GetXaxis()->SetLabelSize(0.07); hist04->GetXaxis()->SetTitleSize(0.07); hist04->GetXaxis()->SetTitleFont(42); hist04->GetYaxis()->SetTitle("ADC value"); hist04->GetYaxis()->SetNdivisions(505); hist04->GetYaxis()->SetLabelFont(42); hist04->GetYaxis()->SetLabelSize(0.07); hist04->GetYaxis()->SetTitleSize(0.07); hist04->GetYaxis()->SetTitleOffset(1.2); hist04->GetYaxis()->SetTitleFont(42); hist04->GetZaxis()->SetLabelFont(42); hist04->GetZaxis()->SetLabelSize(0.07); hist04->GetZaxis()->SetTitleSize(0.07); hist04->GetZaxis()->SetTitleFont(42); hist04->Draw(""); TPaveText *pt = new TPaveText(0,0.9018323,0.416129,0.995,"blNDC"); pt->SetName("title"); pt->SetBorderSize(0); pt->SetFillColor(0); pt->SetFillStyle(0); pt->SetTextFont(42); TText *text = pt->AddText("Ch=38,10,14"); pt->Draw(); c1->Modified(); c1->cd(); c1->SetSelected(c1); // define pulse function Double_t xmin=0; Double_t xmax=100; TF1 *pulse = new TF1("pulse_func",pulse_func,xmin,xmax,5); Double_t mu=1/8.; // unis of 1/x Double_t sigma=5; // units of x Double_t gain=500; Double_t t0=40; Double_t pedestal=2; pulse->SetParameters(mu,sigma,gain,t0,pedestal); pulse->SetParNames("mu","sigma","gain","t0","pedestal"); // pulse->FixParameter(0,0.0787); // pulse->FixParameter(1,0.865); hist04->Fit(pulse); c1->SaveAs("fit_waveform04.pdf"); } Double_t pulse_func (Double_t *x, Double_t *par) { Double_t mu=par[0]; Double_t sigma=par[1]; Double_t gain=par[2]; Double_t t0=par[3]; Double_t pedestal=par[4]; Double_t x1=x[0]-t0; char string[256]; Double_t func; Double_t amplitude; if (x1 < -20) { func = pedestal; } else if { Double_t arg = (mu*sigma*sigma-x1)/(sqrt(2)*sigma); Double_t arg2 = -mu*x1 +(mu*sigma)*(mu*sigma)/2; amplitude = (mu/2)* exp(arg2) * TMath::Erfc(arg); func = gain * amplitude + pedestal; } /*sprintf (string,"x1=%f amplitude=%f mu=%f sigma=%f t0=%f pedestal=%f, func=%f\n",x1,amplitude,mu,sigma,pedestal,func); printf ("string=%s",string);*/ return func; }