本文整理汇总了C++中TPaletteAxis::SetX2NDC方法的典型用法代码示例。如果您正苦于以下问题:C++ TPaletteAxis::SetX2NDC方法的具体用法?C++ TPaletteAxis::SetX2NDC怎么用?C++ TPaletteAxis::SetX2NDC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPaletteAxis
的用法示例。
在下文中一共展示了TPaletteAxis::SetX2NDC方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wfd_raw_fill_reset
void wfd_raw_fill_reset(const int run_nr = 0)
{
int i;
char name[256];
const int n_crates = WFD_NUMBER_OF_CRATES;
TH2D *h2[n_crates];
//=========================================================
// *** initialize style ***
//=========================================================
init();
gStyle->SetOptStat(11);
//=========================================================
// *** open canvas ***
//=========================================================
TCanvas *c1 = new TCanvas("c1","c1",0,0,800,1000);
c1->Draw();
c1->cd();
c1->Divide(2,3,0.001,0.001,10);
//=========================================================
// *** receive and plot histograms ***
//=========================================================
for (i=0; i<n_crates; i++) {
sprintf(name,"WFDrawFillHasResetBlock%s",wfd_crate_name[i]);
h2[i] = (TH2D*) get_hist(name, run_nr);
if ( !h2[i] ) continue;
int ipad = i+1;
c1->cd(ipad);
h2[i]->Draw("ColZ");
c1->GetPad(ipad)->Update();
h2[i]->SetXTitle("fill counter");
h2[i]->SetYTitle("(slot-1)*4 + chan.");
h2[i]->GetXaxis()->SetRangeUser(0.0,2000.0);
TPaletteAxis *palette = (TPaletteAxis*)h2[i]->GetListOfFunctions()->FindObject("palette");
if ( palette ) {
palette->SetX2NDC( palette->GetX1NDC()+0.01 );
palette->Draw();
}
}
c1->SaveAs("../png/wfd_raw_fill_reset.png");
}
示例2: MovePaletteHorizontally
TPaletteAxis* MovePaletteHorizontally(TH1 *histo, Double_t step) {
TPaletteAxis *palette = (TPaletteAxis*)histo->GetListOfFunctions()->FindObject("palette");
if (palette) {
palette->SetX1NDC(palette->GetX1NDC()-step);
palette->SetX2NDC(palette->GetX2NDC()-step);
palette->GetAxis()->SetLabelOffset(0.01);
} else {
std::cout << "Palette not found!" << std::endl;
}
return palette;
}
示例3: repositionPalette
void repositionPalette(std::string name)
{
// Reposition and resize palette
TH2F *h = (TH2F*)gDirectory->GetList()->FindObject(name.c_str());
TPaletteAxis *pal;
pal = (TPaletteAxis*)h->FindObject("palette");
pal->SetX1NDC(0.83);
pal->SetY1NDC(0.14);
pal->SetX2NDC(0.88);
pal->SetY2NDC(0.60);
pal->SetLabelSize(.04);
}
示例4: repositionPalette
void repositionPalette(std::string name)
{
// Reposition and resize palette
TH2F *h = (TH2F*)gDirectory->GetList()->FindObject(name.c_str());
TPaletteAxis *pal;
pal = (TPaletteAxis*)h->FindObject("palette");
if (0==pal)
{
cout << "Palette not found - cannot reposition it" << endl;
return;
}
pal->SetX1NDC(0.83);
pal->SetY1NDC(0.14);
pal->SetX2NDC(0.88);
pal->SetY2NDC(0.60);
pal->SetLabelSize(.04);
cout << "Repo" << endl;
}
示例5: PlotRakeBunch
//.........这里部分代码省略.........
TLine lPmean(hP1X1->GetXaxis()->GetXmin(),ymean,hP1X1->GetXaxis()->GetXmax(),ymean);
lPmean.SetLineColor(kGray+2);
lPmean.SetLineStyle(2);
lPmean.Draw();
hP1X1->GetYaxis()->SetNdivisions(503);
hP1X1->GetZaxis()->SetNdivisions(503);
hP1X1->GetZaxis()->SetRangeUser(0.001*hP1X1->GetMaximum(),hP1X1->GetMaximum());
hP1X1->GetZaxis()->SetLabelSize(0.05);
hP1X1->GetZaxis()->SetTitleSize(0.04);
hP1X1->GetZaxis()->SetTitleFont(42);
hP1X1->Draw("colzsame");
// hP1X1->SetContour(20);
// hP1X1->Draw("contzsame");
// hP1X1prof->SetMarkerStyle(1);
// hP1X1prof->SetLineWidth(2);
// hP1X1prof->Draw("zsame");
//hP1->Draw("C");
gPad->Update();
TPaletteAxis *palette = (TPaletteAxis*)hP1X1->GetListOfFunctions()->FindObject("palette");
if(palette) {
Float_t y1 = gPad->GetBottomMargin();
Float_t y2 = 1 - gPad->GetTopMargin();
Float_t x1 = 1 - gPad->GetRightMargin();
palette->SetY2NDC(y2 - 0.04);
palette->SetY1NDC(y1 + 0.04);
palette->SetX1NDC(x1 + 0.01);
palette->SetX2NDC(x1 + 0.04);
palette->SetLabelFont(42);
palette->SetLabelSize(0.08);
//palette->SetLabelOffset(0.005/vfactor);
palette->SetTitleSize(0.10);
// palette->SetTitleOffset(9999.0*vfactor);
palette->SetTitleOffset(0.6);
palette->SetBorderSize(2);
palette->SetLineColor(1);
}
textTime->Draw();
textInfo->Draw();
// textCharge->Draw();
textMom->Draw();
gPad->RedrawAxis();
// Bottom plot -----------------------------------------
C->cd();
pad[0]->Draw();
pad[0]->cd();
hFrame[0]->GetYaxis()->SetRangeUser(0.0,1.1*yMax);
hFrame[0]->Draw();
示例6: PlotChargeFieldFocus2D
//.........这里部分代码省略.........
if(hDen2D[1]) {
exElec->Draw();
hDen2D[1]->Draw("colz same");
}
if(opt.Contains("1dline")) {
lineYzero->Draw();
lineYdown->Draw();
lineYup->Draw();
}
if(zStartPlasma>xmin && zStartPlasma<xmax)
lineStartPlasma->Draw();
if(zStartNeutral>xmin && zStartNeutral<xmax)
lineStartNeutral->Draw();
if(zEndNeutral>xmin && zEndNeutral<xmax)
lineEndNeutral->Draw();
pad[0]->Update();
TPaletteAxis *palette = NULL;
for(Int_t i=0;i<Nspecies;i++) {
if(!hDen2D[i]) continue;
palette = (TPaletteAxis*) hDen2D[i]->GetListOfFunctions()->FindObject("palette");
if(!palette) continue;
Float_t y1 = gPad->GetBottomMargin();
Float_t y2 = 1 - gPad->GetTopMargin();
Float_t x1 = gPad->GetLeftMargin();
Float_t x2 = 1 - gPad->GetRightMargin();
palette->SetY2NDC( (i+1)*(y2-y1)/Nspecies + y1);
palette->SetY1NDC( i*(y2-y1)/Nspecies + y1);
palette->SetX1NDC(x2 + 0.005);
palette->SetX2NDC(x2 + 0.03);
palette->SetTitleOffset(0.65);
palette->SetTitleSize(0.07);
palette->SetLabelSize(0.065);
palette->SetBorderSize(2);
palette->SetLineColor(1);
}
// 1D charge density plots:
Float_t yaxismin = pad[0]->GetUymin();
Float_t yaxismax = pad[0]->GetUymin() + 0.33*(pad[0]->GetUymax() - pad[0]->GetUymin()) - 0.00;
// Float_t denmin = (0.1001) * density;
Float_t denmin = gMin;
Float_t denmax = gMax;
if(opt.Contains("logz")) {
denmin = TMath::Log10(denmin);
denmax = TMath::Log10(denmax);
}
for(Int_t i=0;i<Nspecies;i++) {
if(!hDen1D[i]) continue;
Float_t slope = (yaxismax - yaxismin)/(denmax - denmin);
for(Int_t j=0;j<hDen1D[i]->GetNbinsX();j++) {
Float_t content = hDen1D[i]->GetBinContent(j+1);
if(opt.Contains("logz")) content = TMath::Log10(content);
if(content<denmin)
hDen1D[i]->SetBinContent(j+1,yaxismin);
示例7: PlotRakeInjection
//.........这里部分代码省略.........
if(k==0) {
hFrame[k]->GetXaxis()->SetLabelSize(0.10);
hFrame[k]->GetXaxis()->SetLabelOffset(0.02);
hFrame[k]->GetXaxis()->SetTitleSize(0.14);
hFrame[k]->GetXaxis()->SetTitleOffset(1.0);
} else {
hFrame[k]->GetXaxis()->SetLabelSize(0.0);
hFrame[k]->GetXaxis()->SetTitleSize(0.0);
}
hFrame[k]->Draw("axis");
exPlasma->Draw();
// Sum of histograms!
hDen2D[k][0]->Add(hDen2D[k][1]);
// hDen2D[k][0]->GetZaxis()->SetRangeUser(Min[1],Max[1]);
hDen2D[k][0]->Draw("colz same");
pad[k]->Update();
TPaletteAxis *palette = (TPaletteAxis*)hDen2D[k][0]->GetListOfFunctions()->FindObject("palette");
Float_t y1 = pad[k]->GetBottomMargin();
Float_t y2 = 1 - pad[k]->GetTopMargin();
Float_t x1 = pad[k]->GetLeftMargin();
Float_t x2 = 1 - pad[k]->GetRightMargin();
palette->SetY2NDC(y2 - 1*(y2-y1)/2.0 - 0.00);
palette->SetY1NDC(y1 + 0*(y2-y1)/2.0 + 0.00);
palette->SetX1NDC(x2 + 0.005);
palette->SetX2NDC(x2 + 0.03);
palette->SetLabelFont(42);
palette->SetLabelSize(0.03/vfactor);
palette->SetLabelOffset(-0.004);
palette->SetTitleSize(0.03/vfactor);
palette->SetTitleOffset(9999.0*vfactor);
palette->SetBorderSize(2);
palette->SetLineColor(1);
exHot->Draw();
hDen2D[k][2]->Draw("colz same");
pad[k]->Update();
palette = (TPaletteAxis*)hDen2D[k][2]->GetListOfFunctions()->FindObject("palette");
palette->SetY2NDC(y2 - 0*(y2-y1)/2.0 - 0.00);
palette->SetY1NDC(y1 + 1*(y2-y1)/2.0 + 0.00);
palette->SetX1NDC(x2 + 0.005);
palette->SetX2NDC(x2 + 0.03);
palette->SetLabelFont(42);
palette->SetLabelSize(0.03/vfactor);
palette->SetLabelOffset(-0.004);
palette->SetTitleSize(0.03/vfactor);
palette->SetTitleOffset(9999.0*vfactor);
palette->SetBorderSize(2);
palette->SetLineColor(1);
示例8: makeEfficiency_74X_setBr
//.........这里部分代码省略.........
}
}
}// end of event loop
cout << "hGenPt integral = " << hGenPt->Integral() << endl;
cout << "hRecoPt integral = " << hRecoPt->Integral() << endl;
cout << "hGenRap integral = " << hGenRap->Integral() << endl;
cout << "hRecoRap integral = " << hRecoRap->Integral() << endl;
cout << "hGenLxy integral = " << hGenLxy->Integral() << endl;
cout << "hRecoLxy integral = " << hRecoLxy->Integral() << endl;
//calculate efficiency
hEffPtY->Divide(hRecoPtY,hGenPtY,1,1,"b");
hEffPt->Divide(hRecoPt,hGenPt,1,1,"b");
hEffRap->Divide(hRecoRap,hGenRap,1,1,"b");
hEffLxy->Divide(hRecoLxy,hGenLxy,1,1,"b");
//Legend
TLegend *legUR = new TLegend(0.56,0.68,0.90,0.90,NULL,"brNDC");
TLegend *legUL = new TLegend(0.17,0.68,0.51,0.90,NULL,"brNDC");
TLegend *legBM = new TLegend(0.40,0.20,0.75,0.35,NULL,"brNDC");
TLegend *legBR = new TLegend(0.56,0.20,0.90,0.42,NULL,"brNDC");
SetLegendStyle(legUR);
SetLegendStyle(legUL);
SetLegendStyle(legBM);
SetLegendStyle(legBR);
TCanvas *c1 = new TCanvas("c1","c1",600,600);
//draw 2D Pt-y
TPaletteAxis* pal;
hEffPtY->SetMinimum(0.0);
hEffPtY->SetMaximum(1.0);
if (isPair) hEffPtY->GetXaxis()->SetTitle("y");
else hEffPtY->GetXaxis()->SetTitle("#eta");
hEffPtY->GetXaxis()->CenterTitle();
hEffPtY->GetYaxis()->SetTitle("p_{T} (GeV)");
hEffPtY->Draw("colz");
c1->Update();
pal = (TPaletteAxis*)hEffPtY->GetListOfFunctions()->FindObject("palette");
pal->SetX2NDC(0.92);
c1->Modified();
c1->Update();
c1->SaveAs(Form("%s/EffPtY_isPtCut%d_doWeight%d_isEmbedded%d_%s_%s_%s.pdf",strDir.c_str(),(int)isPtCut,(int)doWeight,(int)isEmbedded,strPrompt.c_str(),strEmbd.c_str(),strPair.c_str()));
c1->Clear();
//draw EffPt
SetHistStyle(hEffPt,3,0);
hEffPt->SetMinimum(0.0);
hEffPt->SetMaximum(1.0);
if (isPair) hEffPt->GetXaxis()->SetTitle("Pair p_{T} (GeV)");
else hEffPt->GetXaxis()->SetTitle("Trk p_{T} (GeV)");
hEffPt->GetYaxis()->SetTitle("Efficiency");
hEffPt->Draw("pe");
c1->SaveAs(Form("%s/EffPt_isPtCut%d_doWeight%d_isEmbedded%d_%s_%s_%s.pdf",strDir.c_str(),(int)isPtCut,(int)doWeight,(int)isEmbedded,strPrompt.c_str(),strEmbd.c_str(),strPair.c_str()));
c1->Clear();
//draw EffRap
SetHistStyle(hEffRap,3,0);
hEffRap->SetMinimum(0.0);
hEffRap->SetMaximum(1.0);
if (isPair) hEffRap->GetXaxis()->SetTitle("y");
else hEffRap->GetXaxis()->SetTitle("#eta");
hEffRap->GetXaxis()->CenterTitle();
hEffRap->GetYaxis()->SetTitle("Efficiency");
hEffRap->Draw("pe");
c1->SaveAs(Form("%s/EffRap_isPtCut%d_doWeight%d_isEmbedded%d_%s_%s_%s.pdf",strDir.c_str(),(int)isPtCut,(int)doWeight,(int)isEmbedded,strPrompt.c_str(),strEmbd.c_str(),strPair.c_str()));
c1->Clear();
//draw EffLxy
SetHistStyle(hEffLxy,3,0);
hEffLxy->SetMinimum(0.0);
hEffLxy->SetMaximum(1.0);
hEffLxy->GetXaxis()->SetTitle("Lxy");
hEffLxy->GetYaxis()->SetTitle("Efficiency");
hEffLxy->Draw("pe");
c1->SaveAs(Form("%s/EffLxy_isPtCut%d_doWeight%d_isEmbedded%d_%s_%s_%s.pdf",strDir.c_str(),(int)isPtCut,(int)doWeight,(int)isEmbedded,strPrompt.c_str(),strEmbd.c_str(),strPair.c_str()));
c1->Clear();
//save as a root file
TFile* outFile = new TFile(Form("%s/Eff_isPtCut%d_doWeight%d_isEmbedded%d_%s_%s_%s.root",strDir.c_str(),(int)isPtCut,(int)doWeight,(int)isEmbedded,strPrompt.c_str(),strEmbd.c_str(),strPair.c_str()),"RECREATE");
outFile->cd();
hGenPtY->Write();
hRecoPtY->Write();
hEffPtY->Write();
hGenPt->Write();
hGenRap->Write();
hGenLxy->Write();
hRecoPt->Write();
hRecoRap->Write();
hRecoLxy->Write();
hEffPt->Write();
hEffRap->Write();
hEffLxy->Write();
outFile->Close();
return;
}
示例9: PlotEvolutionsWIII
//.........这里部分代码省略.........
if(mask & 0x1) {
pad[ip]->Draw();
pad[ip]->cd();
if(opt.Contains("logz")) {
pad[ip]->SetLogz(1);
} else {
pad[ip]->SetLogz(0);
}
hFrame[ip]->Draw("col");
// hDen1DvsTime->GetZaxis()->SetNdivisions(503);
hDen1DvsTime->GetZaxis()->SetTitleFont(fonttype);
Float_t xFactor = pad[0]->GetAbsWNDC()/pad[ip]->GetAbsWNDC();
Float_t yFactor = pad[0]->GetAbsHNDC()/pad[ip]->GetAbsHNDC();
hDen1DvsTime->GetZaxis()->SetTickLength(xFactor*tylength/yFactor);
exElec->Draw();
hDen1DvsTime->Draw("colz same");
pad[ip]->Update();
y1 = pad[ip]->GetBottomMargin();
y2 = 1 - pad[ip]->GetTopMargin();
x1 = pad[ip]->GetLeftMargin();
x2 = 1 - pad[ip]->GetRightMargin();
palette = (TPaletteAxis*) hDen1DvsTime->GetListOfFunctions()->FindObject("palette");
if(palette) {
palette->SetY2NDC(y2 - gap);
palette->SetY1NDC(y1 + gap);
palette->SetX1NDC(x2 + 0.005);
palette->SetX2NDC(x2 + 0.03);
palette->SetTitleOffset(tzoffset);
palette->SetTitleSize(tzsize);
palette->SetLabelFont(fonttype);
palette->SetLabelSize(lzsize);
palette->SetLabelOffset(lyoffset);
palette->SetBorderSize(2);
palette->SetLineColor(1);
}
pad[ip]->RedrawAxis();
ip--;
C->cd(0);
}
if(mask & 0x2) {
pad[ip]->Draw();
pad[ip]->cd();
if(opt.Contains("logz")) {
pad[ip]->SetLogz(1);
} else {
pad[ip]->SetLogz(0);
}
hFrame[ip]->Draw("col");
// hRmsvsTime->GetZaxis()->SetNdivisions(503);
hRmsvsTime->GetZaxis()->SetTitleFont(fonttype);
Float_t xFactor = pad[0]->GetAbsWNDC()/pad[ip]->GetAbsWNDC();
Float_t yFactor = pad[0]->GetAbsHNDC()/pad[ip]->GetAbsHNDC();
示例10: draw_2D_eff_fine
void draw_2D_eff_fine(int MrapNpt=89, int isPA = 1, int accCutType =2, bool isPrompt = false, bool useZvtxWeight=false, bool useSF=false, TString szDir="dir_eff")
{
gROOT->Macro("../Style2D.C");
TString szBinning;
if (MrapNpt==89) {szBinning = "8rap9pt"; }
else if (MrapNpt==83) { szBinning = "8rap3pt"; }
else if (MrapNpt==63) { szBinning = "6rap3pt"; }
else if (MrapNpt==62) { szBinning = "6rap2pt"; }
else {cout << "select among MrapNpt = 89, 83, 63, or 62"<< endl; return; }
TString szPA;
if (isPA==0) szPA="pp";
else if (isPA==1) szPA="Pbp";
else if (isPA==2) szPA="pPb";
else {cout << "select among isPA = 0, 1, or 2 (pp, Pbp or pPb) "<< endl; return; }
TString szAccCut;
if (accCutType==1) szAccCut="oldcut";
else if (accCutType==2) szAccCut="newcut";
else {cout << "select among accCutType = 1 or 2"<< endl; return; }
TString szPrompt;
if (isPrompt) szPrompt = "PR";
else szPrompt = "NP";
const TString szFinal = Form("%s_%s_%s_%s",szBinning.Data(),szPA.Data(),szPrompt.Data(),szAccCut.Data());
std::cout << "szFinal: " << szFinal << std::endl;
TFile * f2D = new TFile(Form("EffAna_%s_Zvtx%d_SF%d.root",szFinal.Data(),(int)useZvtxWeight,(int)useSF));
// --- read-in 2D hist
TH2D* h2D_Den = (TH2D*)f2D->Get("h2D_Den_pt_y_fine");
TH2D* h2D_Num = (TH2D*)f2D->Get("h2D_Num_pt_y_fine");
TH2D* h2D_Eff = (TH2D*)f2D->Get("h2D_Eff_pt_y_fine");
//latex box for beam, rapidity, pT info
TLatex* latex = new TLatex();
latex->SetNDC();
latex->SetTextAlign(12);
latex->SetTextSize(0.04);
//////////////////////////////////////////////////////////////////
// --- Draw histograms
TCanvas* c1 = new TCanvas("c1","c1",700,600);
TPaletteAxis* pal;
c1->cd();
h2D_Den->GetXaxis()->SetTitle("y_{lab}");
h2D_Den->GetXaxis()->CenterTitle();
h2D_Den->GetYaxis()->SetTitle("p_{T} (GeV/c)");
h2D_Den->Draw("colz");
c1->Update();
pal = (TPaletteAxis*)h2D_Den->GetListOfFunctions()->FindObject("palette");
pal->SetX2NDC(0.92);
c1->Modified();
c1->Update();
c1->SaveAs(Form("%s/h2D_Den_%s_fine.pdf",szDir.Data(),szFinal.Data()));
h2D_Num->GetXaxis()->SetTitle("y_{lab}");
h2D_Num->GetXaxis()->CenterTitle();
h2D_Num->GetYaxis()->SetTitle("p_{T} (GeV/c)");
h2D_Num->Draw("colz");
c1->Update();
pal = (TPaletteAxis*)h2D_Num->GetListOfFunctions()->FindObject("palette");
pal->SetX2NDC(0.92);
c1->Modified();
c1->Update();
c1->SaveAs(Form("%s/h2D_Num_%s_fine.pdf",szDir.Data(),szFinal.Data()));
h2D_Eff->GetXaxis()->SetTitle("y_{lab}");
h2D_Eff->GetXaxis()->CenterTitle();
h2D_Eff->GetYaxis()->SetTitle("p_{T} (GeV/c)");
h2D_Eff->SetMaximum(1.);
h2D_Eff->Draw("colz");
c1->Update();
pal = (TPaletteAxis*)h2D_Eff->GetListOfFunctions()->FindObject("palette");
pal->SetX2NDC(0.92);
c1->Modified();
c1->Update();
c1->SaveAs(Form("%s/h2D_Eff_%s_fine.pdf",szDir.Data(),szFinal.Data()));
return;
}
示例11: PlotPotential2D
//.........这里部分代码省略.........
lineYdown->Draw();
lineYup->Draw();
}
if(opt.Contains("sline")) {
if(zStartPlasma>xmin && zStartPlasma<xmax)
lineStartPlasma->Draw();
if(zStartNeutral>xmin && zStartNeutral<xmax)
lineStartNeutral->Draw();
if(zEndNeutral>xmin && zEndNeutral<xmax)
lineEndNeutral->Draw();
}
// lineYdown->Draw();
// lineYup->Draw();
// Palettes re-arrangement
pad[0]->Update();
Float_t y1 = pad[0]->GetBottomMargin();
Float_t y2 = 1 - pad[0]->GetTopMargin();
Float_t x1 = pad[0]->GetLeftMargin();
Float_t x2 = 1 - pad[0]->GetRightMargin();
TPaletteAxis *palette = NULL;
if(Nspecies>=3) {
if(hDen2D[2]) {
palette = (TPaletteAxis*)hDen2D[2]->GetListOfFunctions()->FindObject("palette");
}
}
if(palette) {
palette->SetY2NDC(y2 - 0.00);
palette->SetY1NDC(0.66*(y1+y2) + 0.00);
palette->SetX1NDC(x2 + 0.005);
palette->SetX2NDC(x2 + 0.03);
// palette->SetTitleFont(42);
// palette->SetTitleOffset(0.85);
palette->SetTitleOffset(999.9);
palette->SetTitleSize(0.075);
palette->SetLabelFont(42);
palette->SetLabelSize(0.075);
palette->SetLabelOffset(0.001);
palette->SetBorderSize(2);
palette->SetLineColor(1);
}
palette = (TPaletteAxis*)hDen2D[0]->GetListOfFunctions()->FindObject("palette");
if(palette) {
palette->SetY2NDC(0.66*(y1+y2) - 0.00);
palette->SetY1NDC(0.33*(y1+y2) + 0.00);
palette->SetX1NDC(x2 + 0.005);
palette->SetX2NDC(x2 + 0.03);
// palette->SetTitleFont(42);
palette->SetTitleOffset(0.80);
palette->SetTitleSize(0.075);
palette->SetLabelFont(42);
palette->SetLabelSize(0.075);
palette->SetLabelOffset(0.001);
palette->SetBorderSize(2);
palette->SetLineColor(1);
}
palette = (TPaletteAxis*)hDen2D[1]->GetListOfFunctions()->FindObject("palette");
if(palette) {
palette->SetY2NDC(0.33*(y1+y2) - 0.00);
palette->SetY1NDC(y1 + 0.00);
palette->SetX1NDC(x2 + 0.005);
示例12: draw_2D
void draw_2D(bool isPrompt = true, bool is8rap9pt2gev = true)
{
gROOT->Macro("./JpsiStyle2D.C");
gStyle->SetPaintTextFormat(".3f");
// --- read-in file
TFile * f2D;
char* sampleName;
char* strPrompt;
char* strBin;
if (isPrompt) { strPrompt = "PRMC";}
else { strPrompt = "NPMC";}
if (is8rap9pt2gev) { strBin = "8rap9pt2gev";}
else { strBin = "6rap3pt";}
// f2D = new TFile(Form("./EffCounting_%s_%spythia_Pbp_useCtErr_1_useDataDriven_1_useZvtxStep1_0_Step2_1.root",strBin,strPrompt));
f2D = new TFile(Form("./EffCounting_%s_%spythia_Pbp_useCtErr_1_useDataDriven_0_useZvtxStep1_0_Step2_1.root",strBin,strPrompt));
sampleName = Form("%s_%s",strBin,strPrompt);
cout << "sampleName = " << sampleName << endl;
// --- read-in 2D hist
TH2D* h2D_Den = (TH2D*)f2D->Get("h2D_Den_pt_y");
TH2D* h2D_Num = (TH2D*)f2D->Get("h2D_Num_pt_y");
TH2D* h2D_Eff = (TH2D*)f2D->Get("h2D_Eff_pt_y");
//latex box for beam, rapidity, pT info
TLatex* latex = new TLatex();
latex->SetNDC();
latex->SetTextAlign(12);
latex->SetTextSize(0.04);
//////////////////////////////////////////////////////////////////
// --- Draw histograms
TCanvas* c1 = new TCanvas("c1","c1",700,600);
TPaletteAxis* pal;
c1->cd();
/*
h2D_Den->GetXaxis()->SetTitle("y_{lab}");
h2D_Den->GetXaxis()->CenterTitle();
h2D_Den->GetYaxis()->SetTitle("p_{T} (GeV/c)");
h2D_Den->Draw("colz");
c1->Update();
pal = (TPaletteAxis*)h2D_Den->GetListOfFunctions()->FindObject("palette");
pal->SetX2NDC(0.92);
c1->Modified();
c1->Update();
c1->SaveAs(Form("acc2Dplots/h2D_Den_isPrompt%d.pdf",(int)isPrompt));
h2D_Num->GetXaxis()->SetTitle("y_{lab}");
h2D_Num->GetXaxis()->CenterTitle();
h2D_Num->GetYaxis()->SetTitle("p_{T} (GeV/c)");
h2D_Num->Draw("colz");
c1->Update();
pal = (TPaletteAxis*)h2D_Num->GetListOfFunctions()->FindObject("palette");
pal->SetX2NDC(0.92);
c1->Modified();
c1->Update();
c1->SaveAs(Form("acc2Dplots/h2D_Num_isPrompt%d.pdf",(int)isPrompt));
*/
h2D_Eff->GetXaxis()->SetTitle("y_{lab}");
h2D_Eff->GetXaxis()->CenterTitle();
h2D_Eff->GetYaxis()->SetTitle("p_{T} (GeV/c)");
h2D_Eff->SetMaximum(1.);
h2D_Eff->Draw("colz");
//h2D_Eff->SetMarkerSize(0.8);
//h2D_Eff->Draw("text e colz");
c1->Update();
pal = (TPaletteAxis*)h2D_Eff->GetListOfFunctions()->FindObject("palette");
pal->SetX2NDC(0.92);
c1->Modified();
c1->Update();
if (is8rap9pt2gev) {
dashedLine(-2.4,2.0,-1.97,2.0,1,4);
dashedLine(-1.97,2.0,-1.97,3.0,1,4);
dashedLine(-1.97,3.0,-1.37,3.0,1,4);
dashedLine(-1.37,3.0,-1.37,6.5,1,4);
dashedLine(-1.37,6.5,1.03,6.5,1,4);
dashedLine(1.03,5.0,1.03,6.5,1,4);
dashedLine(1.03,5.0,1.46,5.0,1,4);
dashedLine(1.46,3.0,1.46,5.0,1,4);
dashedLine(1.46,3.0,1.93,3.0,1,4);
dashedLine(1.93,2.0,1.93,3.0,1,4);
dashedLine(1.93,2.0,2.4,2.0,1,4);
dashedLine(2.4,2.0,2.4,30.0,1,4);
dashedLine(-2.4,30.0,2.4,30.0,1,4);
dashedLine(-2.4,2.0,-2.4,30.0,1,4);
}
else {
dashedLine(-2.4,5.0,-1.97,5.0,1,4);
dashedLine(-1.97,5.0,-1.97,6.5,1,4);
dashedLine(-1.97,6.5,1.03,6.5,1,4);
dashedLine(1.03,5.0,1.03,6.5,1,4);
dashedLine(1.03,5.0,1.46,5.0,1,4);
dashedLine(1.46,5.0,1.46,30.0,1,4);
dashedLine(-2.4,30.0,1.46,30.0,1,4);
dashedLine(-2.4,5.0,-2.4,30.0,1,4);
}
c1->SaveAs(Form("eff2Dplots/h2D_Eff_%s.pdf",sampleName));
//.........这里部分代码省略.........
示例13: PlotField2D
//.........这里部分代码省略.........
// Define the frames for plotting
Int_t fonttype = 43;
Int_t fontsize = 28;
Int_t tfontsize = 30;
Float_t txoffset = 1.3;
Float_t lxoffset = 0.02;
Float_t tyoffset = 1.0;
Float_t lyoffset = 0.01;
Float_t tylength = 0.02;
Float_t txlength = 0.04;
TH2F *hFrame = (TH2F*) gROOT->FindObject("hFrame");
if(hFrame) delete hFrame;
hFrame = (TH2F*) hE2D[index]->Clone("hFrame");
hFrame->Reset();
// Format for y axis
hFrame->GetYaxis()->SetTitleFont(fonttype);
hFrame->GetYaxis()->SetTitleSize(tfontsize);
hFrame->GetYaxis()->SetTitleOffset(tyoffset);
hFrame->GetYaxis()->SetLabelFont(fonttype);
hFrame->GetYaxis()->SetLabelSize(fontsize);
hFrame->GetYaxis()->SetLabelOffset(lyoffset);
hFrame->GetYaxis()->SetTickLength(tylength);
// Format for x axis
hFrame->GetXaxis()->SetTitleFont(fonttype);
hFrame->GetXaxis()->SetTitleSize(tfontsize+2);
hFrame->GetXaxis()->SetTitleOffset(txoffset);
hFrame->GetXaxis()->SetLabelFont(fonttype);
hFrame->GetXaxis()->SetLabelSize(fontsize+2);
hFrame->GetXaxis()->SetLabelOffset(lxoffset);
hFrame->GetXaxis()->SetTickLength(txlength);
hFrame->Draw("col");
// hE2D[index]->GetZaxis()->SetNdivisions(505);
hE2D[index]->GetZaxis()->SetTitleFont(fonttype);
hE2D[index]->Draw("colz same");
// Re-touchs
gPad->Update();
Float_t y1 = gPad->GetBottomMargin();
Float_t y2 = 1 - gPad->GetTopMargin();
Float_t x1 = gPad->GetLeftMargin();
Float_t x2 = 1 - gPad->GetRightMargin();
Float_t gap = 0.005;
TPaletteAxis *palette = (TPaletteAxis*)hE2D[index]->GetListOfFunctions()->FindObject("palette");
if(palette) {
palette->SetY2NDC(y2 - gap);
palette->SetY1NDC(y1 + gap);
palette->SetX1NDC(x2 + 0.005);
palette->SetX2NDC(x2 + 0.03);
palette->SetTitleOffset(tyoffset);
palette->SetTitleSize(tfontsize);
palette->SetLabelFont(fonttype);
palette->SetLabelSize(fontsize);
if(opt.Contains("logz"))
palette->SetLabelOffset(0);
else
palette->SetLabelOffset(lyoffset);
palette->SetBorderSize(2);
palette->SetLineColor(1);
}
// Text objects
TPaveText *textTime = new TPaveText(xMax - 0.30*xRange, yMax-0.10*yRange, xMax-0.02*xRange, yMax-0.02*yRange);
PGlobals::SetPaveTextStyle(textTime,32);
char ctext[128];
if(opt.Contains("units") && n0)
sprintf(ctext,"z = %5.1f #mum", Time * skindepth / PUnits::um);
else
sprintf(ctext,"#omega_{p} t = %5.1f",Time);
textTime->AddText(ctext);
TPaveText *textDen = new TPaveText(xMin + 0.02*xRange, yMax-0.10*yRange, xMin + 0.40*xRange, yMax-0.02*yRange);
PGlobals::SetPaveTextStyle(textDen,12);
textDen->SetTextColor(kOrange+10);
if(opt.Contains("units") && n0) {
sprintf(ctext,"n_{0} = %5.2f x 10^{17} / cm^{3}", 1e-17 * n0 * PUnits::cm3);
textDen->AddText(ctext);
textDen->Draw();
}
textTime->Draw();
gPad->RedrawAxis();
C->cd();
// Print to a file
PGlobals::imgconv(C,fOutName,opt);
// ---------------------------------------------------------
}