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