本文整理汇总了C++中TF1::Print方法的典型用法代码示例。如果您正苦于以下问题:C++ TF1::Print方法的具体用法?C++ TF1::Print怎么用?C++ TF1::Print使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TF1
的用法示例。
在下文中一共展示了TF1::Print方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateDataTemplates
void CreateDataTemplates(double dX,int BRN_ORDER)
{
gROOT->ForceStyle();
RooMsgService::instance().setSilentMode(kTRUE);
for(int i=0;i<2;i++) {
RooMsgService::instance().setStreamStatus(i,kFALSE);
}
double XMIN = 80;
double XMAX = 200;
const int NSEL(2);
const int NCAT[NSEL] = {4,3};
const double MVA_BND[NSEL][NCAT[0]+1] = {{-0.6,0.0,0.7,0.84,1},{-0.1,0.4,0.8,1}};
char name[1000];
TString SELECTION[NSEL] = {"NOM","VBF"};
TString SELTAG[NSEL] = {"NOM","PRK"};
TString MASS_VAR[NSEL] = {"mbbReg[1]","mbbReg[2]"};
TFile *fBKG = TFile::Open("limit_BRN5+4_dX0p1_80-200_CAT0-6/output/bkg_shapes_workspace.root");
RooWorkspace *wBkg = (RooWorkspace*)fBKG->Get("w");
RooWorkspace *w = new RooWorkspace("w","workspace");
//RooRealVar x(*(RooRealVar*)wBkg->var("mbbReg"));
TTree *tr;
TH1F *h,*hBlind;
TCanvas *canFit[5];
RooDataHist *roohist[5],*roohist_blind[5];
TFile *fTransfer = TFile::Open("limit_BRN5+4_dX0p1_80-200_CAT0-6/output/transferFunctions.root");
TF1 *transFunc;
int counter(0);
int NPAR = BRN_ORDER;
for(int isel=0;isel<NSEL;isel++) {
TFile *fDATA = TFile::Open("flat/Fit_data_sel"+SELECTION[isel]+".root");
RooRealVar *brn[8];
RooArgSet brn_params;
if (isel == 1) {
NPAR = 4;
}
for(int ib=0;ib<=NPAR;ib++) {
brn[ib] = new RooRealVar("b"+TString::Format("%d",ib)+"_sel"+SELECTION[isel],"b"+TString::Format("%d",ib)+"_sel"+SELECTION[isel],0.5,0,10.);
brn_params.add(*brn[ib]);
}
for(int icat=0;icat<NCAT[isel];icat++) {
RooRealVar x("mbbReg_"+TString::Format("CAT%d",counter),"mbbReg_"+TString::Format("CAT%d",counter),XMIN,XMAX);
sprintf(name,"fitRatio_sel%s_CAT%d",SELTAG[isel].Data(),counter);
transFunc = (TF1*)fTransfer->Get(name);
transFunc->Print();
// --- The error on the tranfer function parameters is shrinked because the correlations are ingored.
// --- Must be consistent with TransferFunctions.C
float p0 = transFunc->GetParameter(0);
float e0 = transFunc->GetParError(0);
float p1 = transFunc->GetParameter(1);
float e1 = transFunc->GetParError(1);
float p2 = transFunc->GetParameter(2);
float e2 = transFunc->GetParError(2);
RooRealVar trans_p2(TString::Format("trans_p2_CAT%d",counter),TString::Format("trans_p2_CAT%d",counter),p2);
RooRealVar trans_p1(TString::Format("trans_p1_CAT%d",counter),TString::Format("trans_p1_CAT%d",counter),p1);
RooRealVar trans_p0(TString::Format("trans_p0_CAT%d",counter),TString::Format("trans_p0_CAT%d",counter),p0);
printf("%.2f %.2f %.2f\n",p0,p1,p2);
RooGenericPdf *transfer;
if (isel == 0) {
trans_p2.setError(0.5*e2);
trans_p1.setError(0.5*e1);
trans_p0.setError(0.5*e0);
transfer = new RooGenericPdf(TString::Format("transfer_CAT%d",counter),"@2*@[email protected]",RooArgList(x,trans_p0,trans_p1));
}
else {
trans_p2.setError(0.05*e2);
trans_p1.setError(0.05*e1);
trans_p0.setError(0.05*e0);
transfer = new RooGenericPdf(TString::Format("transfer_CAT%d",counter),"@3*@0*@[email protected]*@[email protected]",RooArgList(x,trans_p0,trans_p1,trans_p2));
}
trans_p2.setConstant(kTRUE);
trans_p1.setConstant(kTRUE);
trans_p0.setConstant(kTRUE);
transfer->Print();
sprintf(name,"FitData_sel%s_CAT%d",SELECTION[isel].Data(),icat);
canFit[icat] = new TCanvas(name,name,900,600);
canFit[icat]->cd(1)->SetBottomMargin(0.4);
sprintf(name,"Hbb/events");
tr = (TTree*)fDATA->Get(name);
sprintf(name,"hMbb_%s_CAT%d",SELECTION[isel].Data(),icat);
int NBINS = (XMAX[isel][icat]-XMIN[isel][icat])/dX;
h = new TH1F(name,name,NBINS,XMIN[isel][icat],XMAX[isel][icat]);
sprintf(name,"hMbb_blind_%s_CAT%d",SELECTION[isel].Data(),icat);
hBlind = new TH1F(name,name,NBINS,XMIN[isel][icat],XMAX[isel][icat]);
sprintf(name,"mva%s>%1.2f && mva%s<=%1.2f",SELECTION[isel].Data(),MVA_BND[isel][icat],SELECTION[isel].Data(),MVA_BND[isel][icat+1]);
TCut cut(name);
sprintf(name,"mva%s>%1.2f && mva%s<=%1.2f && %s>100 && %s<150",SELECTION[isel].Data(),MVA_BND[isel][icat],SELECTION[isel].Data(),MVA_BND[isel][icat+1],MASS_VAR[isel].Data(),MASS_VAR[isel].Data());
TCut cutBlind(name);
tr->Draw(MASS_VAR[isel]+">>"+h->GetName(),cut);
tr->Draw(MASS_VAR[isel]+">>"+hBlind->GetName(),cutBlind);
sprintf(name,"yield_data_CAT%d",counter);
//.........这里部分代码省略.........
示例2: dNdEta_vs_roots_fit
//.........这里部分代码省略.........
Bool_t bw = 1; // 1: BLACK AND WHITE, 0: COLOR
Float_t msize = 1.; // MARKER SIZE
//****************************************************
TCanvas *c = new TCanvas("c","c",550,600);
// gStyle->SetTitleYSize(.060);
gStyle->SetTitleYOffset(1.4);
c->SetLogx();
// c->SetLeftMargin(0.15);
TH1F *dummy = new TH1F("dummy","dummy",100,9,10000);
dummy->SetMaximum(7.5);
dummy->SetMinimum(0);
dummy->SetXTitle("#sqrt{s} [GeV]");
dummy->SetYTitle("dN_{ch}/d#eta|_{#eta=0}");
/*
dummy->GetYaxis()->SetNdivisions(505);
dummy->GetXaxis()->SetNdivisions(505);
dummy->GetXaxis()->SetLabelSize(0.05);
dummy->GetYaxis()->SetLabelSize(0.05);
dummy->GetXaxis()->SetTitleSize(0.05);
dummy->GetYaxis()->SetTitleSize(0.05);
dummy->GetXaxis()->SetLabelOffset(0.00);
dummy->GetXaxis()->SetTitleOffset(1.0);
dummy->GetYaxis()->SetTitleOffset(0.75);
*/
dummy->GetYaxis()->CenterTitle();
dummy->GetXaxis()->CenterTitle();
dummy->Draw();
Int_t N = 100;
Int_t ip = 0;
// ---- UA5 NSD ---
TGraphErrors *gre = new TGraphErrors(N);
gre->SetName("Graph");
gre->SetTitle("Graph");
gre->SetMarkerStyle(kFullCircle);
gre->SetMarkerSize(msize);
gre->SetPoint(ip,53,1.93);
gre->SetPointError(ip,0,0.1086);
gre->SetPoint(++ip,200,2.48);
gre->SetPointError(ip,0,0.0852);
gre->SetPoint(++ip,546,3.05);
gre->SetPointError(ip,0,0.0624);
gre->SetPoint(++ip,900,3.48);
gre->SetPointError(ip,0,0.1011);
// ---- CDF NSD ----
gre->SetPoint(++ip,630,3.18);
gre->SetPointError(ip,0,0.0854);
gre->SetPoint(++ip,1800,3.95);
gre->SetPointError(ip,0,0.0845);
// ---- UA1 NSD ---
gre->SetPoint(++ip,200,2.65);
gre->SetPointError(ip,0,0.1936);
gre->SetPoint(++ip,260,2.71);
gre->SetPointError(ip,0,0.1992);
gre->SetPoint(++ip,380,2.94);
gre->SetPointError(ip,0,0.2144);
gre->SetPoint(++ip,500,3.05);
gre->SetPointError(ip,0,0.2255);
gre->SetPoint(++ip,620,3.15);
gre->SetPointError(ip,0,0.2310);
gre->SetPoint(++ip,790,3.41);
gre->SetPointError(ip,0,0.2517);
gre->SetPoint(++ip,900,3.48);
gre->SetPointError(ip,0,0.2517);
// ---- ALICE NSD ------
gre->SetPoint(++ip,900,3.51);
gre->SetPointError(ip,0,0.2135);
// ---- CMS NSD ---
gre->SetPoint(++ip,900,3.477);
gre->SetPointError(ip,0,0.0798);
gre->SetPoint(++ip,2360,4.469);
gre->SetPointError(ip,0,0.1052);
// ---- STAR NSD ----
gre->SetPoint(++ip,200,2.98);
gre->SetPointError(ip,0,0.34);
gre->Draw("p");
// fit
TF1 *func = new TF1("func","[0]+[1]*log(x^2)+[2]*(log(x^2))^2",18,100000);
// TF1 *func = new TF1("func","[0]+[1]*exp(sqrt(log(x^2)))",18,100000);
func->SetLineColor(1);
func->SetLineWidth(1.5);
//func->SetParameters(2,-0.2,0.02);
gre->Fit("func","","",18,3000);
func->Draw("same");
func->Print();
}
示例3: fit1
void fit1() {
TCanvas *c1 = new TCanvas("c1_fit1","The Fit Canvas",200,10,700,500);
c1->SetGridx();
c1->SetGridy();
c1->GetFrame()->SetFillColor(21);
c1->GetFrame()->SetBorderMode(-1);
c1->GetFrame()->SetBorderSize(5);
gBenchmark->Start("fit1");
//
// We connect the ROOT file generated in a previous tutorial
// (see <a href="fillrandom.C.nbconvert.ipynb">Filling histograms with random numbers from a function</a>)
//
TString dir = gROOT->GetTutorialsDir();
dir.Append("/fit/");
TFile *file = TFile::Open("fillrandom.root");
if (!file) {
gROOT->ProcessLine(Form(".x %s../hist/fillrandom.C",dir.Data()));
file = TFile::Open("fillrandom.root");
if (!file) return;
}
//
// The function "ls()" lists the directory contents of this file
//
file->ls();
//
// Get object "sqroot" from the file. Undefined objects are searched
// for using gROOT->FindObject("xxx"), e.g.:
// TF1 *sqroot = (TF1*) gROOT.FindObject("sqroot")
//
TF1 * sqroot = 0;
file->GetObject("sqroot",sqroot);
if (!sqroot){
Error("fit1.C","Cannot find object sqroot of type TF1\n");
return;
}
sqroot->Print();
//
// Now get and fit histogram h1f with the function sqroot
//
TH1F* h1f = 0;
file->GetObject("h1f",h1f);
if (!h1f){
Error("fit1.C","Cannot find object h1f of type TH1F\n");
return;
}
h1f->SetFillColor(45);
h1f->Fit("sqroot");
// We now annotate the picture by creating a PaveText object
// and displaying the list of commands in this macro
//
TPaveText * fitlabel = new TPaveText(0.6,0.4,0.9,0.75,"NDC");
fitlabel->SetTextAlign(12);
fitlabel->SetFillColor(42);
fitlabel->ReadFile(Form("%sfit1_C.txt",dir.Data()));
fitlabel->Draw();
c1->Update();
gBenchmark->Show("fit1");
}
示例4: DoTDeriMax1090Correction
//.........这里部分代码省略.........
FitFuncSlices->SetParameters(FitFuncGausSlices->GetParameter(0),FitFuncGausSlices->GetParameter(1),FitFuncGausSlices->GetParameter(2),10);
FitFuncSlices->SetParLimits(0,0,10000);
FitFuncSlices->SetParLimits(1,MaxValue-10,MaxValue+10);
FitFuncSlices->SetParLimits(2,0,10);
FitFuncSlices->SetParLimits(3,0,100);
hProfileY->Fit(FitFuncSlices,"RNQ");
cout <<MaxValue<<" " << FitFuncSlices->GetParameter(1) << " " << FitFuncSlices->GetParError(1) <<endl;
hSpectrumTDeriMax1090Rel_EnergyChannel_MaxPosManually->SetBinContent(binX, FitFuncSlices->GetParameter(1));
hSpectrumTDeriMax1090Rel_EnergyChannel_MaxPosManually->SetBinError(binX, FitFuncSlices->GetParError(1));
}
hSpectrumTDeriMax1090Rel_EnergyChannel_MaxPosManually->GetYaxis()->SetRangeUser(ChannelPeakPos-100,ChannelPeakPos+50);
hSpectrumTDeriMax1090Rel_EnergyChannel_MaxPosManually->GetXaxis()->SetRangeUser(-0.05,0.9);
TF1 * funcCorrConst = new TF1("funcCorrConst","pol0",-0.03,0.03);
funcCorrConst->SetLineColor(kRed);
TF1 * funcCorrPol = new TF1("funcCorrPol",PolPiecewise,-0.05,0.9,6);
funcCorrPol->SetLineColor(kBlue);
funcCorrPol->SetParameter(0,0.04);
funcCorrPol->SetParameter(1,ChannelPeakPos);
hSpectrumTDeriMax1090Rel_EnergyChannel_MaxPosManually->Fit(funcCorrConst,"R");
hSpectrumTDeriMax1090Rel_EnergyChannel_MaxPosManually->Fit(funcCorrPol,"R+");
TCanvas* can2=new TCanvas();
gPad->SetLogz();
hSpectrumTDeriMax1090Rel_EnergyChannel->Draw("colz");
funcCorrPol->DrawCopy("same");
for(int i = 7;i>0;i--)
funcCorrPol->SetParameter(i,funcCorrPol->GetParameter(i)/funcCorrPol->GetParameter(1));
funcCorrPol->Print();
char buf[20];
sprintf(buf, "funcCorrNorm_%d",ki);
funcCorrPol->Write(buf,TObject::kOverwrite);
funcCorrConst->Delete();
funcCorrPol->Delete();
//second correction via T1090 (after first)
hSpectrumT1090_EnergyChannelCorr1->GetYaxis()->SetRangeUser(ChannelRangeMin,ChannelRangeMax);
//TF1* FitFuncSlices = new TF1("FitFuncSlices","gaus(0)+pol0(3)",ChannelRangeMin,ChannelRangeMax);
//FitFuncSlices->SetParameters(1000,ChannelPeakPos-10,4,10);
//FitFuncSlices->SetParLimits(1,ChannelRangeMin,ChannelRangeMax);
//FitFuncSlices->SetParLimits(2,0,10);
//FitFuncSlices->SetParLimits(3,0,100);
//gDirectory->ls();
TH1D *hSpectrumT1090_EnergyChannelCorr1_MaxPosManually=new TH1D("hSpectrumT1090_EnergyChannelCorr1_MaxPosManually","",hSpectrumT1090_EnergyChannelCorr1->GetNbinsX(),0,1000);
//cout <<hSpectrumTDeriMax1090_EnergyChannel_MaxPos->GetEntries()<< endl;
for(int binX = hSpectrumT1090_EnergyChannelCorr1->GetXaxis()->FindBin(30);binX <= hSpectrumT1090_EnergyChannelCorr1->GetXaxis()->FindBin(500);binX++)
{
cout << "binx " << binX << endl;
TH1D *hProfileY =hSpectrumT1090_EnergyChannelCorr1->ProjectionY("_py",binX,binX);
//hProfileY->Draw();
//return 0;
double MaxValue=hProfileY->GetBinCenter(hProfileY->GetMaximumBin());
FitFuncSlices = new TF1("FitFuncSlices","gaus(0)+[3]",MaxValue-20,MaxValue+20);
FitFuncGausSlices = new TF1("FitFuncGausSlices","gaus(0)",MaxValue-20,MaxValue+20);
FitFuncGausSlices->SetParameters(hProfileY->GetBinContent(hProfileY->GetMaximumBin()),MaxValue,4);