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