本文整理汇总了C++中TPaveStats::SetY2NDC方法的典型用法代码示例。如果您正苦于以下问题:C++ TPaveStats::SetY2NDC方法的具体用法?C++ TPaveStats::SetY2NDC怎么用?C++ TPaveStats::SetY2NDC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPaveStats
的用法示例。
在下文中一共展示了TPaveStats::SetY2NDC方法的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: 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();
}
示例4: 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();
}
示例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: 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");
}
示例9: 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.);
}
示例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: 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);
}
}
}
}
示例14: plotSubDetResiduals
//------------------------------------------------------------------------------
void PlotAlignmentValidation::plotSubDetResiduals(bool plotNormHisto,unsigned int subDetId)
{
setNiceStyle();
gStyle->SetOptStat(11111);
gStyle->SetOptFit(0000);
TCanvas *c = new TCanvas("c", "c", 600,600);
c->SetTopMargin(0.15);
TString histoName= "";
if (plotNormHisto) {histoName= "h_NormXprime";}
else histoName= "h_Xprime_";
switch (subDetId){
case 1 : histoName+="TPBBarrel_0";break;
case 2 : histoName+="TPEendcap_1";break;
case 3 : histoName+="TPEendcap_2";break;
case 4 : histoName+="TIBBarrel_0";break;
case 5 : histoName+="TIDEndcap_1";break;
case 6 : histoName+="TIDEndcap_2";break;
case 7 : histoName+="TOBBarrel_3";break;
case 8 : histoName+="TECEndcap_4";break;
case 9 : histoName+="TECEndcap_5";break;
}
int tmpcounter = 0;
TH1 *sumHisto = 0;
for(std::vector<TkOfflineVariables*>::iterator it = sourceList.begin();
it != sourceList.end(); ++it) {
if (tmpcounter == 0 ) {
TFile *f= (*it)->getFile();
sumHisto =(TH1*) f->FindKeyAny(histoName)->ReadObj();//FindObjectAny(histoName.Data());
sumHisto->SetLineColor(tmpcounter+1);
sumHisto->SetLineStyle(tmpcounter+1);
sumHisto->GetFunction("tmp")->SetBit(TF1::kNotDraw);
sumHisto->Draw();
//get statistic box coordinate to plot all boxes one below the other
//gStyle->SetStatY(0.91);
//gStyle->SetStatW(0.15);
//gStyle->SetStatBorderSize(1);
//gStyle->SetStatH(0.10);
tmpcounter++;
} else {
sumHisto = (TH1*) (*it)->getFile()->FindObjectAny(histoName);
sumHisto->SetLineColor(tmpcounter+1);
sumHisto->SetLineStyle(tmpcounter+1);
sumHisto->GetFunction("tmp")->SetBit(TF1::kNotDraw);
//hstack->Add(sumHisto);
c->Update();
tmpcounter++;
}
TObject *statObj = sumHisto->GetListOfFunctions()->FindObject("stats");
if (statObj && statObj->InheritsFrom(TPaveStats::Class())) {
TPaveStats *stats = static_cast<TPaveStats*>(statObj);
stats->SetLineColor(tmpcounter+1);
stats->SetTextColor(tmpcounter+1);
stats->SetFillColor(10);
stats->SetX1NDC(0.91-tmpcounter*0.1);
stats->SetX2NDC(0.15);
stats->SetY1NDC(1);
stats->SetY2NDC(0.10);
sumHisto->Draw("sames");
}
}
//hstack->Draw("nostack");
char PlotName[1000];
sprintf( PlotName, "%s/%s.eps", outputDir.c_str(), histoName.Data() );
c->Print(PlotName);
//delete c;
//c=0;
}
示例15: plot
//.........这里部分代码省略.........
TFile* f = new TFile(file_name.c_str(),"READ");
TDirectory* d = (TDirectory*)f->Get(dir.c_str());
TH2D* his = (TH1*)d->Get(histo.c_str());
if ( !his ) return;
//his->Rebin2D(2,2);
if ( true ) { gPad->SetLogz(); }
if ( scale ) his->Scale( lumi / 100. );
his->SetMaximum(1.e4);
his->SetMinimum(1.e-5);
//his->SetMinimum( his->GetMinimum(1.e-12) );
// his->SetMaximum( 20000. );
// his->SetMinimum( 2.e-4 );
// his->SetMaximum( 20000. );
// his->SetMinimum( 20. );
double xmin = his->GetXaxis()->GetXmin();
double xmax = his->GetXaxis()->GetXmax();
double ymin = his->GetYaxis()->GetXmin();
double ymax = his->GetYaxis()->GetXmax();
// Reset title
std::string title = ";" + std::string(his->GetXaxis()->GetTitle()) + ";" + std::string(his->GetYaxis()->GetTitle());
his->SetTitle(title.c_str());
his->GetXaxis()->SetTitle("x_{2}");
his->GetXaxis()->SetTitleOffset(1.2);
his->GetYaxis()->SetTitle("x_{1}");
his->GetYaxis()->SetTitleOffset(1.4);
his->Draw("COLZ");
gPad->Update();
// Lumi
if (1) {
std::stringstream ss;
ss << "#int L dt = " << lumi << " pb^{-1}";
double xpos = 0.05 * (xmax-xmin)+xmin;
double ypos = 0.25 * (ymax-ymin)+ymin;
TLatex* text1 = new TLatex(xpos,ypos,ss.str().c_str());
text1->SetTextAlign(12);
text1->SetTextSize(0.035);
text1->Draw();
}
// Jet type
if (1) {
double xpos = 0.05 * (xmax-xmin)+xmin;
double ypos = 0.15 * (ymax-ymin)+ymin;
TText* text2 = new TText(xpos,ypos,type.c_str());
text2->SetTextAlign(12);
text2->SetTextSize(0.035);
text2->Draw();
}
// Sample
if (1) {
double xpos = 0.05 * (xmax-xmin)+xmin;
double ypos = 0.10 * (ymax-ymin)+ymin;
TText* text3 = new TText(xpos,ypos,sample.c_str());
text3->SetTextAlign(12);
text3->SetTextSize(0.035);
text3->Draw();
}
// Stats
gStyle->SetOptStat("i");
his->SetStats(1);
TPaveStats* stats = (TPaveStats*)his->GetListOfFunctions()->FindObject("stats");
std::string stats_pos = "br";
if ( stats ) {
stats->SetFillColor(0);
stats->SetLineColor(0);
stats->SetShadowColor(0);
if ( stats_pos == "tr" ) {
stats->SetX1NDC(0.60); stats->SetY1NDC(0.68); stats->SetX2NDC(0.83); stats->SetY2NDC(0.88);
} else if ( stats_pos == "br" ) {
stats->SetX1NDC(0.60); stats->SetY1NDC(0.18); stats->SetX2NDC(0.83); stats->SetY2NDC(0.28);
} else {
stats->SetX1NDC(0.60); stats->SetY1NDC(0.68); stats->SetX2NDC(0.83); stats->SetY2NDC(0.88);
}
}
// Scale
gStyle->SetPalette(1);
TPaletteAxis* palette = (TPaletteAxis*)his->GetListOfFunctions()->FindObject("palette");
if ( palette ) {
palette->SetY1NDC(0.2);
palette->SetY2NDC(0.8);
}
canvas->Modified();
canvas->cd();
canvas->SetSelected(canvas);
canvas->SaveAs(std::string(canvas_name+".png").c_str());
//canvas->Write();
}