本文整理汇总了C++中TPaveStats::SetX1NDC方法的典型用法代码示例。如果您正苦于以下问题:C++ TPaveStats::SetX1NDC方法的具体用法?C++ TPaveStats::SetX1NDC怎么用?C++ TPaveStats::SetX1NDC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPaveStats
的用法示例。
在下文中一共展示了TPaveStats::SetX1NDC方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ColourStatsBoxes
//________________________________________________________
void GFHistManager::ColourStatsBoxes(GFHistArray *hists) const
{
// colours stats boxes like hists' line colors and moves the next to each other
if (!hists) return;
Double_t x1 = fStatsX1, x2 = fStatsX2, y1 = fStatsY1, y2 = fStatsY2;
for (Int_t iH = 0; iH < hists->GetEntriesFast(); ++iH) {
TH1 *h = hists->At(iH);
if (!h) continue;
TObject *statObj = h->GetListOfFunctions()->FindObject("stats");
if (statObj && statObj->InheritsFrom(TPaveStats::Class())) {
TPaveStats *stats = static_cast<TPaveStats*>(statObj);
stats->SetLineColor(hists->At(iH)->GetLineColor());
stats->SetTextColor(hists->At(iH)->GetLineColor());
stats->SetX1NDC(x1);
stats->SetX2NDC(x2);
stats->SetY1NDC(y1);
stats->SetY2NDC(y2);
y2 = y1 - 0.005; // shift down 2
y1 = y2 - (fStatsY2 - fStatsY1); // shift down 1
if (y1 < 0.) {
y1 = fStatsY1; y2 = fStatsY2; // restart y-positions
x2 = x1 - 0.005; // shift left 2
x1 = x2 - (fStatsX2 - fStatsX1); // shift left 1
if (x1 < 0.) { // give up, start again:
x1 = fStatsX1, x2 = fStatsX2, y1 = fStatsY1, y2 = fStatsY2;
}
}
} else if (gStyle->GetOptStat() != 0) { // failure in case changed in list via TExec....
this->Warning("ColourStatsBoxes", "No stats found for %s", hists->At(iH)->GetName());
}
}
}
示例2: resizeStatBox
// Resize any histograms (they all inherit from h1) stat box. Uses NDC coordinates (e.g. 0.65, 0.5)
bool resizeStatBox( TCanvas *c1, TH1* h1, float x1, float y1, float x2=-1, float y2=-1,
TString newname = "", int color = -1, TString oldname = "", int iDebug = 0 )
{
if( !c1 || !h1 ) {cerr<<"Null pointer given to resizeStatBox!"<<endl; return 0;}
c1->Update();
if( oldname.Length() <= 0 ) oldname = "stats";
if( iDebug > 20 ) print_list_of_functions( *h1 );
TPaveStats *stats = (TPaveStats*) h1->FindObject( oldname );
if( iDebug ) cout<<"Found old name (\""<<oldname<<"\"? "<<( stats != 0 )<<endl;
if( (!stats) && newname.Length() > 0 ){ // maybe it was already renamed
stats = (TPaveStats*) h1->FindObject( newname );
if( iDebug ) cout<<"Found new name (\""<<newname<<"\"? "<<(stats != 0)<<endl;
}
if( !stats ) {cerr<<"Can't find stat box"<<endl; return 0;}
stats->SetX1NDC( x1 );
stats->SetY1NDC( y1 );
if( x2 >= 0 ) stats->SetX2NDC( x2 );
if( y2 >= 0 ) stats->SetY2NDC( y2 );
if( newname.Length() > 0 ) {
stats->SetName( newname );
if( iDebug ) cout<<"SetName to "<<newname<<endl;
}
if( color != -1 ) stats->SetTextColor (color);
stats->Draw(); // maybe, just maybe, this will finally make them appear every time, even with draw "same"
return 1;
}
示例3: repositionStatbox
void repositionStatbox(std::string name)
{
// Reposition and resize statbox
TH2F *h = (TH2F*)gDirectory->GetList()->FindObject(name.c_str());
TPaveStats *st = (TPaveStats*)h->GetListOfFunctions()->FindObject("stats");
st->SetX1NDC(0.63);
st->SetY1NDC(0.72);
st->SetX2NDC(0.99);
st->SetY2NDC(0.99);
st->Draw();
}
示例4: SetStatPad
void SetStatPad(TH1* hst,float x1,float x2,float y1,float y2)
{
TPaveStats* pad = GetStatPad(hst);
if (!pad) return;
pad->SetX1NDC( x1 );
pad->SetX2NDC( x2 );
pad->SetY1NDC( y1 );
pad->SetY2NDC( y2 );
//
gPad->Modified();
}
示例5: relocateStatBox
// ---------------------------------------------------------------------------------------------
// The SLAC version
bool relocateStatBox (float x1, float y1, float x2=-1, float y2=-1, TString newname = "")
{
TPaveStats *st = (TPaveStats*)gPad->GetPrimitive("stats");
if (0 == st) {cerr<<"Can't find stat box in pad"<<endl; return 0;}
if (newname.Length() > 0) st->SetName(newname);
st->SetX1NDC(x1);
if (x2 != -1) st->SetX2NDC(x2);
st->SetY1NDC(y1);
if (y2 != -1) st->SetY2NDC(y2);
st->Draw();
return 1;
}
示例6: drawStatBox
// überladen: Statbox-Größen manuell eingeben
void drawStatBox(int& step, TH1D* histo, int color = -1, double statboxHeight = 0.1, double statboxSpacing = 0.15){
TPaveStats* statBox = dynamic_cast<TPaveStats*>( histo->GetListOfFunctions()->FindObject("stats") );
if(color == -1) color = step+1;
statBox->SetX1NDC(0.80);
statBox->SetX2NDC(0.99);
statBox->SetY2NDC(0.95-step*statboxSpacing);
statBox->SetY1NDC(0.95-step*statboxSpacing-statboxHeight);
statBox->SetTextColor(color);
statBox->Draw();
step++;
}
示例7: SetStPadPos
TPaveStats* SetStPadPos(TH1* hst,float x1,float x2,float y1,float y2, Int_t stl, Int_t col)
{
TPaveStats* pad = GetStPad(hst);
if (!pad) return 0;
pad->SetX1NDC( x1 );
pad->SetX2NDC( x2 );
pad->SetY1NDC( y1 );
pad->SetY2NDC( y2 );
if (stl>=0) pad->SetFillStyle(stl);
if (col>=0) pad->SetTextColor(col);
pad->SetFillColor(0);
//
gPad->Modified();
return pad;
}
示例8: plotPair
//==========================================
//==========================================
void plotPair(TH1F *h1,TH1F *h0 ) {
h1->Draw();
// edit fonts/sizes
TAxis *ax =h1->GetYaxis();
float ss=ax->GetTitleSize();
//printf("ss=%f\n",ss);
ax->SetTitleSize(2*ss);
ax->SetTitleOffset(0.5);
ax =h1->GetXaxis();
ax->SetTitleSize(1.5*ss);
ax->SetLabelSize(1.5*ss);
ax->SetTitleOffset(0.7);
// edit fonts/sizes DONE
gPad->Update();
//scale hint1 to the pad coordinates
Float_t rightmax = 1.1*h0->GetMaximum();
Float_t scale = gPad->GetUymax()/rightmax;
h0->Scale(scale);
h0->Draw("same");
//draw an axis on the right side
TGaxis *axis = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),
gPad->GetUxmax(), gPad->GetUymax(),0,rightmax,510,"-R");
int col=h0->GetLineColor();
axis->SetLineColor(col);
axis->SetTextColor(col);
axis->SetLabelColor(col);
axis ->SetTitle("LCP yield");
axis->SetTitleSize(2*ss);
axis->SetTitleOffset(.5);
axis->Draw();
TPaveStats *st =( TPaveStats *)gPad->GetPrimitive("stats");
st->SetX1NDC(0.35);
st->SetX2NDC(0.5);
st->SetY1NDC(0.7);
st->SetY2NDC(1.);
}
示例9: n_photons
void n_photons(){
gStyle->SetOptStat(2210);
TString filename = TString("/Users/scook/code/MuSIC/simulation/") +
TString("MuSIC_5_detector_sim/MuSIC5/output/output_from_hep_batch/") +
TString("optical_processes.root");
TFile* file = new TFile(filename.Data(), "READ");
TTree* mppc = (TTree*) file->Get("mppc");
TH1F* hist = new TH1F("h", "Number of detected photons", 1000, 0, 1000);
hist->GetXaxis()->SetTitle("Number of photons");
hist->GetYaxis()->SetTitle("Count");
n_photons_t branch;
mppc->SetBranchAddress("mppc_x", branch.x);
mppc->SetBranchAddress("mppc_y", branch.y);
mppc->SetBranchAddress("mppc_z", branch.z);
mppc->SetBranchAddress("mppc_hits", &branch.nhits);
for(int entry = 0; entry < mppc->GetEntries(); ++entry) {
mppc->GetEntry(entry);
int count = 0;
for(Int_t hit = 0; hit < branch.nhits; ++hit) {
bool correct_z = 3635.0 < branch.z[hit] && branch.z[hit] < 3640.0;
bool correct_y = 97.0 < branch.y[hit] && branch.y[hit] < 102.0;
if(correct_z && correct_y) {
++count;
}
}
if (count > 0) hist->Fill(count);
}
TCanvas* can = new TCanvas("c1","c1",1436,856);
can->SetLogx();
can->SetLogy();
hist->Draw();
can->Update();
TPaveStats* stats = (TPaveStats*) hist->FindObject("stats");
stats->SetX1NDC(0.65);
stats->SetX2NDC(0.90);
stats->SetY1NDC(0.70);
stats->SetY2NDC(0.90);
can->Update();
can->SaveAs("n_photons.png");
can->SaveAs("n_photons.svg");
}
示例10: main
int main(int argc, char** argv){
if(argc!=2){
std::cerr << "### Usage like ... \n ./gaus2d 10000(imax)" << std::endl ;
return EXIT_FAILURE ;
}
else{/* DO NOT ANYTHING */}
TApplication app( "app", &argc, argv );
double x ;
double y ;
int imax = atoi(argv[1]) ;
TString title("2D Gaussian") ;
TString titleimax(argv[1]) ;
title += titleimax ;
TCanvas *c1 = new TCanvas("c1", "c1", 600, 600) ;
gStyle->SetOptStat("enRM") ;
c1->SetTicks(1,1) ;
c1->SetGrid(1,1) ;
c1->SetRightMargin(0.15) ;
TH2D *hist = new TH2D("hist",title,100, -5., 5., 100, -5., 5.) ;
TF2 *gausfunc = new TF2("gausfunc","[0]*TMath::Exp( - TMath::Sqrt( TMath::Power((x-[1])/[2],2)/2. + TMath::Power((y-[3])/[4],2)/2. ))", -5., 5., -5., 5.) ;
gausfunc->SetParameters(1., 0., 0.5, 0., 0.5) ;
gausfunc->SetNpx(300) ;
gausfunc->SetNpy(300) ;
gRandom->SetSeed(unsigned(time(NULL))) ;
for(int i =0 ; i< imax ; i++){
gausfunc->GetRandom2(x,y) ;
hist->Fill(x,y) ;
}
hist->Draw("colz") ;
gPad->Update();
TPaveStats *st = (TPaveStats*)hist->FindObject("stats") ;
st->SetX1NDC(0.60) ;
st->SetX2NDC(0.85) ;
st->SetY1NDC(0.70) ;
st->SetY2NDC(0.90) ;
c1->SaveAs("gaus2dc1.eps") ;
app.Run() ;
delete c1 ;
delete hist ;
delete gausfunc ;
return EXIT_SUCCESS ;
}
示例11: MakeNiceStatBox
void MakeNiceStatBox(TH1* histo){
TObject *statObj;
TPaveStats *stats;
statObj = histo->GetListOfFunctions()->FindObject("stats");
stats= static_cast<TPaveStats*>(statObj);
stats->SetFillColor(10);
stats->SetLineWidth(1);
stats->SetShadowColor(0);
stats->SetTextFont(42);
stats->SetTextSize(0.05);
//stats->SetLineColor(LineColors);
//stats->SetTextColor(LineColors);
stats->SetX1NDC(0.615);
stats->SetY1NDC(0.747);
stats->SetX2NDC(0.979);
stats->SetY2NDC(0.986);
}
示例12: drawHits
pqPoint HitCollection::drawHits(bool fit, bool draw, bool rz) {
unsigned int hits_n = hitCollection.size();
TGraph hits_h(hits_n);
hits_h.SetTitle("Hits");
for (unsigned int hit_i = 0; hit_i < hits_n; hit_i++) {
hits_h.SetPoint(hit_i, hitCollection[hit_i].x, hitCollection[hit_i].y);
}
TCanvas c("c", "c", 600, 600);
hits_h.GetXaxis()->SetLimits(-1.1*zmax, 1.1*zmax);
hits_h.GetYaxis()->SetRangeUser(0., 1.1*rmax);
hits_h.GetXaxis()->SetTitle("x[cm]");
hits_h.GetYaxis()->SetTitle("y[cm]");
hits_h.Draw("A*");
pqPoint pqpoint;
if (fit) {
gStyle->SetOptFit(10001);
string pol1("[1]*x + [0]");
if (rz) pol1 = "1./[1]*x - [0]/[1]";
TF1 * fitfun = new TF1("fitfun", pol1.c_str());
fitfun->SetParNames("q","p");
fitfun->SetParameters(1., 1.);
hits_h.Fit(fitfun, draw ? "" : "q");
c.Update();
pqpoint.p = fitfun->GetParameter("p");
// pqpoint.p = atan(fun->GetParameter("p"));
pqpoint.q = fitfun->GetParameter("q");
pqpoint.w = 1.;
}
else pqpoint.w = -1.;
TPaveStats *st = (TPaveStats*)hits_h.FindObject("stats");
st->SetY1NDC(0.72);
st->SetY2NDC(0.87);
st->SetX1NDC(0.13);
st->SetX2NDC(0.28);
if (draw) c.Print(Form("figs/hits_%s.pdf", name.c_str()));
return pqpoint;
}
示例13: makeInvMassHistosNoBGKK
//.........这里部分代码省略.........
TF1 *fit = new TF1(Form("fitPTbin%d00particle%d", nfile*2+1, i), FitFunRelBW, 0.68, 1.05, 5);
//TF1 *fit = new TF1(Form("fitPTbin%d00particle%d", nfile*2+1, i), "gaus(0)", 0.86, 0.92);
fit->SetParNames("BW Area", "Mass", "Width", "PT", "Temp");
fit->SetParameters(TMath::Power(10.0, (float)(nfile)/1.7), 0.89, 0.1, 0.5, 0.130);
//fit->SetParNames("BW Area", "Mass", "Width");
//fit->SetParameters(100, 0.89, 0.0474);
//fit->SetParLimits(0, -10, 1.5e9);
Float_t max = histos[i]->GetXaxis()->GetBinCenter(histos[i]->GetMaximumBin());
//if(max < 0.91 && max > 0.892){
// fit->SetParLimits(1, max-0.001, max+0.001);
//}else{
fit->SetParLimits(1, 0.82, 0.98);
//}
//fit->SetParLimits(2, 0.005, 0.15);
fit->FixParameter(2, 0.042);
fit->FixParameter(3, meanPT);
//fit->SetParLimits(4, 0.05, 0.2);
fit->FixParameter(4, 0.100001);
fit->SetLineColor(2);
printf("%s\n", fit->GetName());
histos[i]->Fit(Form("fitPTbin%d00particle%d", nfile*2+1, i), "BRIM", "SAME");
TVirtualFitter *fitter = TVirtualFitter::GetFitter();
histos[i]->SetStats(1);
histos[i]->Draw();
gPad->Update();
pad->Update();
st = (TPaveStats*)histos[i]->FindObject("stats");
st->SetX1NDC(0.524);
st->SetY1NDC(0.680);
st->SetX2NDC(0.884);
st->SetY2NDC(0.876);
//fit->Draw("SAME");
//histos[i]->Draw();
gPad->Update();
pad->Update();
printf("\n");
diffHistos[i] = (TH1D*)histos[i]->Clone(Form("diffPTbin%d00particl%d", nfile*2+1, i));
diffHistos[i]->Add(fit, -1);
diffCanvas[i]->cd(nfile+1);
diffHistos[i]->Draw("HIST E");
diffHistos[i]->Write();
//counting bins
Float_t integral = histos[i]->Integral(1, 500)*500.0;
//integrals << integral <<" \n";
histos[i]->Write();
fit->Write();
//Do mass and width vs. pT plots just for K*0
if(i==PARTICLE_NUM){
mass = fit->GetParameter(1);
massError = fit->GetParError(1);
collWidth = fit->GetParameter(2);
collWidthError = fit->GetParError(2);
width = Gamma(mass, collWidth);
kstar0mass->SetBinContent(nfile+1, mass);
kstar0mass->SetBinError(nfile+1, massError);
示例14: produceTF
//.........这里部分代码省略.........
funcGaus->FixParameter(12,1.0);
funcGaus->SetParameter(0,1.0);
funcGaus->SetParameter(1,mean);
funcGaus->SetParameter(2,sigma);
if( hName[i] == "dBJetPz" ) funcGaus->SetParameter(0,0.6);
if( hName[i] == "dBJetE" ) funcGaus->SetParameter(0,0.6);
funcGaus->SetParameter(3,0.3);
funcGaus->SetParameter(4,mean);
funcGaus->SetParameter(5,sigma*2.);
if( hName[i] == "dBJetPz" ) funcGaus->SetParameter(3,0.15);
if( hName[i] == "dBJetE" ) funcGaus->SetParameter(3,0.3);
if( hName[i] == "dBJetE" ) funcGaus->SetParameter(5,sigma*4);
if( hName[i] == "dBJetPy" ) funcGaus->SetParameter(3,0.2);
funcGaus->SetParameter(6,1.);
funcGaus->SetParameter(7,mean);
funcGaus->SetParameter(8,sigma/2.);
if( hName[i] == "dBJetPz" ) funcGaus->SetParameter(8,sigma/3.);
funcGaus->SetParameter(9,0.5);
funcGaus->SetParameter(10,mean);
funcGaus->SetParameter(11,sigma);
h[i]->Fit(funcGausName.c_str(),"QR");
TF1 *fit = h[i]->GetFunction(funcGausName.c_str());
fit->SetLineColor(1);
if( hName[i] == "dBJetE" )
{
c1->Update();
TPaveStats *st = (TPaveStats*)h[i]->FindObject("stats");
st->SetX1NDC(0.20);
st->SetX2NDC(0.47);
}
fit->Draw("same");
fit->SetParameter(12,1./fit->GetMaximum());
fit->Write();
}
if( hName[i] == "dElecPx" || hName[i] == "dElecPy" || hName[i] == "dElecPz" || hName[i] == "dElecE" )
{
double mean = 0.;
double sigma = 1.;
std::string funcGausName = hName[i]+"_Fit";
TF1 *funcGaus = new TF1(funcGausName.c_str(),"[9]*(gaus(0)+gaus(3)+gaus(6))",h[i]->GetXaxis()->GetBinLowEdge(1),
h[i]->GetXaxis()->GetBinUpEdge(h[i]->GetXaxis()->GetNbins()));
funcGaus->FixParameter(9,1.0);
funcGaus->SetParameter(0,1);
funcGaus->SetParameter(1,mean);
funcGaus->SetParameter(2,sigma);
if( hName[i] == "dElecPz" ) funcGaus->SetParameter(0,0.8);
funcGaus->SetParameter(3,0.3);
funcGaus->SetParameter(4,mean);
funcGaus->SetParameter(5,sigma*2.);
if( hName[i] == "dElecPz" ) funcGaus->SetParameter(3,0.15);
if( hName[i] == "dElecE" ) funcGaus->SetParameter(3,0.1);
funcGaus->SetParameter(6,1.);
示例15: DrawAllHistos
//.........这里部分代码省略.........
TDirectory *stardir = gDirectory;
TObject *thesourcedir;
TIter nextdir(stardir->GetListOfKeys());
while((thesourcedir=nextdir())){
TString dirName = thesourcedir->GetName();
stardir->cd(dirName);
TDirectory *current_sourcedir = gDirectory;
TH1::AddDirectory(kFALSE);
std::cout << "*************************" <<std::endl;
std::cout << "Reading Directory: " << dirName <<std::endl;
TObject *obj;
TIter next(current_sourcedir->GetListOfKeys());
while ((obj=next())) {
TString objName =obj->GetName();
if(objName.Contains("pfx")) continue;
if (objName.Contains("h2") && !objName.Contains("pfx")) {
//std::cout << "Reading: " << obj->GetName() <<std::endl;
TH2F* h2 = (TH2F*)file->Get(dirName+"/"+objName);
h2->SetName(objName+dirName);
h2vec.push_back(h2);
TCanvas *c = new TCanvas(h2->GetName(),h2->GetName(),800,600);
c->cd();
gPad->SetTopMargin(0.08);
gPad->SetRightMargin(0.15);
h2->SetStats(kFALSE);
h2->Draw("colz");
c->Draw();
c->cd();
TProfile *hpfx_tmp = (TProfile*) h2->ProfileX("_pfx",1,-1,"o");
hpfx_tmp->SetStats(kFALSE);
//hpfx_tmp->SetMarkerColor(kBlack);
hpfx_tmp->SetMarkerColor(kRed);
hpfx_tmp->SetMarkerSize(1.2);
hpfx_tmp->SetMarkerStyle(20);
hpfx_tmp->Draw("psame");
c->Draw();
cmsPrel(60.,sa,sb, isMC);
TString canvName = h2->GetName();
c->cd()->SetLogz();
c->SaveAs(canvName+"."+format);
} else {
TH1F* h1 = (TH1F*)file->Get(dirName+"/"+objName);
h1->SetName(objName+dirName);
h1vec.push_back(h1);
TCanvas *c = new TCanvas(h1->GetName(),h1->GetName(),600,600);
c->cd()->SetLogy();
h1->SetMarkerColor(kBlack);
h1->SetMarkerStyle(20);
h1->SetLineWidth(1.5);
h1->SetFillColor(393);
//h1->SetFillStyle(3005);
h1->Draw("hist");
h1->Draw("e1same");
c->Draw();
TObject *statObj;
TPaveStats *stats;
statObj = h1->GetListOfFunctions()->FindObject("stats");
stats= static_cast<TPaveStats*>(statObj);
stats->SetFillColor(10);
stats->SetLineWidth(1);
stats->SetShadowColor(0);
stats->SetTextFont(42);
stats->SetTextSize(0.025);
//stats->SetLineColor(LineColors);
//stats->SetTextColor(LineColors);
stats->SetX1NDC(0.75);
stats->SetY1NDC(0.72);
stats->SetX2NDC(0.97);
stats->SetY2NDC(0.92);
stats->Draw("same");
cmsPrel(60.,sa,sb,isMC);
TString canvName = h1->GetName();
c->SaveAs(canvName+"."+format);
}
}
}
}