//---------------- // AddStandardLabels //---------------- void AddStandardLabels(TH2D *axes=NULL) { // This will draw a label or two on the // current plot using the NDC coordinates. // It is put here to make sure all plots have // a consistent labeling. // Date, Author TLatex *lab = new TLatex(0.7, 0.71, "July 10, 2009 DL"); ConvertFromNDC(lab, axes); lab->SetTextSize(0.03); lab->SetTextAlign(33); lab->Draw(); // Revision lab = new TLatex(0.7, 0.67, "release-2009-05-27"); ConvertFromNDC(lab, axes); lab->SetTextSize(0.025); lab->SetTextAlign(33); lab->Draw(); // Type lab = new TLatex(0.7, 0.63, "Single #pi^{+}, 0.5GeV/c -- FULL Reconstruction"); ConvertFromNDC(lab, axes); lab->SetTextSize(0.03); lab->SetTextAlign(33); lab->Draw(); // Spoiled field lab = new TLatex(-0.55, 0.63, "Magnetic field spoiled by 1% in R,#theta,#phi"); ConvertFromNDC(lab, axes); lab->SetTextSize(0.03); lab->SetTextAlign(13); lab->Draw(); } //---------------- // ConvertFromNDC //---------------- void ConvertFromNDC(TLatex *obj, TH2D *h=NULL) { // Bugs in ROOT make it hard to plot labels consistently. // For 1D plots, the histogram axes define the coordinate // system. For 2D plots, we seem to be forced to use the // NDC. There does not seem to be an obvious way to tell // which we're using so we pass the information in in the // form of the "axes" histogram. If it is not NULL, then // we use it to define the limits. Otherwise, we do nothing. if(h==NULL)return; TAxis *xaxis = h->GetXaxis(); int Nbinsx = xaxis->GetNbins(); double xmin = xaxis->GetBinLowEdge(1); double xmax = xmin + xaxis->GetBinLowEdge(Nbinsx); TAxis *yaxis = h->GetYaxis(); int Nbinsy = yaxis->GetNbins(); double ymin = yaxis->GetBinLowEdge(1); double ymax = yaxis->GetBinLowEdge(Nbinsy); double x = obj->GetX(); double y = obj->GetY(); x = xmin + (xmax-xmin)*(0.5+x/1.15); y = ymin + (ymax-ymin)*(0.5+y/1.15); obj->SetX(x); obj->SetY(y); }