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