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