本文整理汇总了C++中TPad::GetWh方法的典型用法代码示例。如果您正苦于以下问题:C++ TPad::GetWh方法的具体用法?C++ TPad::GetWh怎么用?C++ TPad::GetWh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPad
的用法示例。
在下文中一共展示了TPad::GetWh方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_res
//.........这里部分代码省略.........
aRname.precision(2);
nRname.precision(2);
chiname.precision(5);
if (do_fit) {
muname << fixed << "#mu = " << gfit->GetParameter(1) << " #pm " << gfit->GetParError(1);
signame << fixed << "#sigma = " << gfit->GetParameter(2) << " #pm " << gfit->GetParError(2);
musigname << fixed << "#sigma/#mu = " << gfit->GetParameter(2)/gfit->GetParameter(1) << " #pm " <<
gfit->GetParameter(2)/gfit->GetParameter(1) * sqrt( Power(gfit->GetParError(1),2)/Power(gfit->GetParameter(1),2) + Power(gfit->GetParError(2),2)/Power(gfit->GetParameter(2),2) );
//aLname << fixed << "a_{L} = " << gfit->GetParameter(3) << " #pm " << gfit->GetParError(3);
//nLname << fixed << "n_{L} = " << gfit->GetParameter(4) << " #pm " << gfit->GetParError(4);
//aRname << fixed << "a_{R} = " << gfit->GetParameter(5) << " #pm " << gfit->GetParError(5);
//nRname << fixed << "n_{R} = " << gfit->GetParameter(6) << " #pm " << gfit->GetParError(6);
chiname << fixed << "#chi^{2}/ndf = " << gfit->GetChisquare()/gfit->GetNDF();
}
else {
muname << fixed << "Mean = " << m << " #pm " << me;
signame << fixed << "RMS = " << s << " #pm " << se;
musigname << fixed << "RMS/Mean = " << s/m << " #pm " << s/m*sqrt((me*me)/(m*m)+(se*se)/(s*s));
}
Nname << "N = " << N;
//plotting
if (do_show){
can = new TCanvas((oname.str()).c_str(),(oname.str()).c_str(),700,500);
can->cd();
pad = new TPad("graph","",0,0,1,1);
pad->SetMargin(0.12,0.05,0.15,0.05);
pad->Draw();
pad->cd();
//formatting
h_res->SetStats(kTRUE);
gStyle->SetOptStat("mr");
h_res->GetYaxis()->SetTitleSize(32/(pad->GetWh()*pad->GetAbsHNDC()));
h_res->GetYaxis()->SetLabelSize(28/(pad->GetWh()*pad->GetAbsHNDC()));
h_res->GetXaxis()->SetTitleSize(32/(pad->GetWh()*pad->GetAbsHNDC()));
h_res->GetXaxis()->SetLabelSize(28/(pad->GetWh()*pad->GetAbsHNDC()));
h_res->GetYaxis()->SetTickLength(12/(pad->GetWh()*pad->GetAbsHNDC()));
h_res->GetXaxis()->SetTickLength(12/(pad->GetWh()*pad->GetAbsHNDC()));
//plot histo and fit
h_res->Draw("hist");
if(do_fit) gfit->Draw("same");
//determine placing of legend and paves - par pave goes on side with more space
Double_t xmin;
if (m/((h_res->GetXaxis()->GetXmax() + h_res->GetXaxis()->GetXmin())/2) < 1) xmin = 0.65;
else xmin = 0.2;
if(do_fit) { //legend
leg = new TLegend(xmin,0.78,xmin+0.2,0.88);
leg->AddEntry(h_res,"Standalone");
leg->AddEntry(gfit,"Fit");
leg->SetFillColor(0);
leg->SetBorderSize(0);
leg->SetTextSize(0.05);
leg->SetTextFont(42);
leg->Draw("same");
can->Update();
/*
//left line
Double_t bndL = gfit->GetParameter(1) - gfit->GetParameter(2)*gfit->GetParameter(3);
aLline = new TLine(bndL,pad->GetUymin(),bndL,pad->GetUymax());
aLline->SetLineStyle(2);
aLline->SetLineWidth(3);
示例2: TSpectrum
//--------------------------------------
//function to calculate sampling factors
std::pair<Double_t,Double_t> g4_sample(int snum, Double_t energy, bool do_pion, bool do_show, bool do_print=false, bool set_val=true){
Sample* sp = sample_map[snum];
if(!sp) { std::cout << "Sample " << snum << " is not loaded." << std::endl; return std::pair<Double_t,Double_t>(0.,0.); }
//select correct file
std::string fpre = sp->fpre;
if(do_pion) fpre += "_pion";
else fpre += "_elec";
//make filenames
std::stringstream drawname, fname, piname;
fname << sp->dir << "/" << fpre << "_" << energy << "gev_10k.root";
if(do_pion) piname << "#pi^{-} " << energy << " GeV";
else piname << "e^{-} " << energy << " GeV";
//open file and tree
TFile* _file;
_file = TFile::Open((fname.str()).c_str());
TTree* totalTree = (TTree*)_file->Get("Total");
//get histo from tree (no display)
//define mip as sam_ecal*ecal < 1 gev = 1000 mev (for pions in HCAL)
if(sp->det==Hcal) drawname << "(hcal+" << sp->zeroWt << "*zero)/1000>>hsam(200)";
else drawname << "(ecal)/1000>>hsam(200)";
totalTree->Draw((drawname.str()).c_str(),"","hist goff");
TH1F* hsam = (TH1F*)gDirectory->Get("hsam");
//use parameters from histo to start fit
TSpectrum* spec = new TSpectrum(5);
spec->Search(hsam,5,"nodraw goff");
Float_t* xpos = spec->GetPositionX();
Float_t* ypos = spec->GetPositionY();
Double_t m = xpos[0];
Double_t me = hsam->GetMeanError();
Double_t N = hsam->GetEntries();
std::stringstream s_mean;
s_mean.precision(3);
Double_t f = energy/m;
Double_t f_err = energy*(me/(m*m));
s_mean << f << " #pm " << f_err;
TPolyMarker* pm = new TPolyMarker(1, xpos, ypos);
hsam->GetListOfFunctions()->Add(pm);
pm->SetMarkerStyle(23);
pm->SetMarkerColor(kRed);
pm->SetMarkerSize(1.3);
std::cout.precision(6);
std::cout << "f_" << (do_pion ? "pion" : "elec") << " = " << f << " +/- " << f_err << std::endl;
//plotting and printing
if (do_show){
TCanvas* can = new TCanvas("sample","sample",700,500);
can->cd();
TPad* pad = new TPad("graph","",0,0,1,1);
pad->SetMargin(0.12,0.05,0.15,0.05);
pad->Draw();
pad->cd();
//formatting
hsam->SetTitle("");
hsam->GetXaxis()->SetTitle("Energy [GeV]");
//hsam->SetStats(kTRUE);
//gStyle->SetOptStat("mr");
hsam->SetLineWidth(2);
hsam->SetLineColor(kBlack);
hsam->GetYaxis()->SetTitleSize(32/(pad->GetWh()*pad->GetAbsHNDC()));
hsam->GetYaxis()->SetLabelSize(28/(pad->GetWh()*pad->GetAbsHNDC()));
hsam->GetXaxis()->SetTitleSize(32/(pad->GetWh()*pad->GetAbsHNDC()));
hsam->GetXaxis()->SetLabelSize(28/(pad->GetWh()*pad->GetAbsHNDC()));
hsam->GetYaxis()->SetTickLength(12/(pad->GetWh()*pad->GetAbsHNDC()));
hsam->GetXaxis()->SetTickLength(12/(pad->GetWh()*pad->GetAbsHNDC()));
hsam->Draw();
std::stringstream Nname;
Nname << "N = " << N;
//determine placing of pave
Double_t xmin;
if (m/((hsam->GetXaxis()->GetXmax() + hsam->GetXaxis()->GetXmin())/2) < 1) xmin = 0.65;
else xmin = 0.2;
//legend
TPaveText *pave = new TPaveText(xmin,0.65,xmin+0.2,0.85,"NDC");
pave->AddText((piname.str()).c_str());
pave->AddText((Nname.str()).c_str());
pave->AddText("Peak sampling factor:");
pave->AddText((s_mean.str()).c_str());
pave->SetFillColor(0);
pave->SetBorderSize(0);
pave->SetTextFont(42);
pave->SetTextSize(0.05);
pave->Draw("same");
if(do_print) {
//.........这里部分代码省略.........