void fit_waveform07(void) { //=========Macro generated from canvas: c1/c1 //========= (Wed Dec 17 14:49:29 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 *hist07 = new TH1F("hist07","Ch=40,04,06",100,0,100); hist07->SetBinContent(1,2); hist07->SetBinContent(2,5); hist07->SetBinContent(3,4); hist07->SetBinContent(4,3); hist07->SetBinContent(5,5); hist07->SetBinContent(6,3); hist07->SetBinContent(7,4); hist07->SetBinContent(9,2); hist07->SetBinContent(10,2); hist07->SetBinContent(11,4); hist07->SetBinContent(12,4); hist07->SetBinContent(13,3); hist07->SetBinContent(14,3); hist07->SetBinContent(15,3); hist07->SetBinContent(16,4); hist07->SetBinContent(17,2); hist07->SetBinContent(18,5); hist07->SetBinContent(19,3); hist07->SetBinContent(20,1); hist07->SetBinContent(22,3); hist07->SetBinContent(23,2); hist07->SetBinContent(24,4); hist07->SetBinContent(25,3); hist07->SetBinContent(26,4); hist07->SetBinContent(27,2); hist07->SetBinContent(29,2); hist07->SetBinContent(30,1); hist07->SetBinContent(31,3); hist07->SetBinContent(32,3); hist07->SetBinContent(34,2); hist07->SetBinContent(36,6); hist07->SetBinContent(37,1); hist07->SetBinContent(38,16); hist07->SetBinContent(39,40); hist07->SetBinContent(40,49); hist07->SetBinContent(41,51); hist07->SetBinContent(42,49); hist07->SetBinContent(43,51); hist07->SetBinContent(44,49); hist07->SetBinContent(45,44); hist07->SetBinContent(46,41); hist07->SetBinContent(47,38); hist07->SetBinContent(48,34); hist07->SetBinContent(49,34); hist07->SetBinContent(50,29); hist07->SetBinContent(51,24); hist07->SetBinContent(52,24); hist07->SetBinContent(53,22); hist07->SetBinContent(54,19); hist07->SetBinContent(55,17); hist07->SetBinContent(56,16); hist07->SetBinContent(57,18); hist07->SetBinContent(58,15); hist07->SetBinContent(59,16); hist07->SetBinContent(60,16); hist07->SetBinContent(61,15); hist07->SetBinContent(62,14); hist07->SetBinContent(63,12); hist07->SetBinContent(64,15); hist07->SetBinContent(65,11); hist07->SetBinContent(66,11); hist07->SetBinContent(67,13); hist07->SetBinContent(68,10); hist07->SetBinContent(69,9); hist07->SetBinContent(70,8); hist07->SetBinContent(71,8); hist07->SetBinContent(72,4); hist07->SetBinContent(73,9); hist07->SetBinContent(74,7); hist07->SetBinContent(75,4); hist07->SetBinContent(76,4); hist07->SetBinContent(77,3); hist07->SetBinContent(78,5); hist07->SetBinContent(79,6); hist07->SetBinContent(80,8); hist07->SetBinContent(81,3); hist07->SetBinContent(82,2); hist07->SetBinContent(83,2); hist07->SetBinContent(84,3); hist07->SetBinContent(85,3); hist07->SetBinContent(86,1); hist07->SetBinContent(87,3); hist07->SetBinContent(88,2); hist07->SetBinContent(91,3); hist07->SetBinContent(92,2); hist07->SetBinContent(93,3); hist07->SetBinContent(94,4); hist07->SetBinContent(96,1); hist07->SetBinContent(97,5); hist07->SetBinContent(98,3); hist07->SetBinContent(99,1); hist07->SetBinContent(100,4); hist07->SetMaximum(84); hist07->SetEntries(1100); // hist07->SetStats(0); hist07->SetLineColor(2); hist07->GetXaxis()->SetTitle("sample (4 ns)"); hist07->GetXaxis()->SetNdivisions(505); hist07->GetXaxis()->SetLabelFont(42); hist07->GetXaxis()->SetLabelSize(0.07); hist07->GetXaxis()->SetTitleSize(0.07); hist07->GetXaxis()->SetTitleFont(42); hist07->GetYaxis()->SetTitle("ADC value"); hist07->GetYaxis()->SetNdivisions(505); hist07->GetYaxis()->SetLabelFont(42); hist07->GetYaxis()->SetLabelSize(0.07); hist07->GetYaxis()->SetTitleSize(0.07); hist07->GetYaxis()->SetTitleOffset(1.2); hist07->GetYaxis()->SetTitleFont(42); hist07->GetZaxis()->SetLabelFont(42); hist07->GetZaxis()->SetLabelSize(0.07); hist07->GetZaxis()->SetTitleSize(0.07); hist07->GetZaxis()->SetTitleFont(42); hist07->Draw(""); TPaveText *pt = new TPaveText(0,0.9018323,0.4148387,0.995,"blNDC"); pt->SetName("title"); pt->SetBorderSize(0); pt->SetFillColor(0); pt->SetFillStyle(0); pt->SetTextFont(42); TText *text = pt->AddText("Ch=40,04,06"); 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"); hist07->Fit(pulse); c1->SaveAs("fit_waveform07.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; }