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