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