//---------------- // StandardLabels2D //---------------- void StandardLabels2D(TH2D *axes=NULL, string suffix="") { // 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.7, "August 14, 2009 DL"); ConvertFromNDC2D(lab, axes); lab->SetTextSize(0.03); lab->SetTextAlign(33); lab->SetTextColor(kBlue); lab->Draw(); // SVN Revision lab = new TLatex(0.7, 0.645, "svn revision: 5431"); ConvertFromNDC2D(lab, axes); lab->SetTextSize(0.02); lab->SetTextAlign(31); lab->SetTextColor(kBlue); lab->Draw(); // Event type lab = new TLatex(0.43, 0.675, "Single #pi^{+} MULS ON"); ConvertFromNDC2D(lab, axes); lab->SetTextSize(0.03); lab->SetTextAlign(32); lab->Draw(); // Conditions if(suffix.length()>0 && suffix[0]=='_')suffix = suffix.substr(1,suffix.length()); string cond = "Full Reconstruction ("+suffix+")"; lab = new TLatex(0.7, 0.61, cond.c_str()); ConvertFromNDC2D(lab, axes); lab->SetTextSize(0.03); lab->SetTextAlign(31); lab->Draw(); } //---------------- // ConvertFromNDC //---------------- void ConvertFromNDC2D(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(); TAxis *yaxis = h->GetYaxis(); // These seem to be sensitive to values set by "SetRangeUser" as well as pad margins double xmin = xaxis->GetBinCenter(xaxis->GetFirst()); double xmax = xaxis->GetBinCenter(xaxis->GetLast()); double ymin = yaxis->GetBinCenter(yaxis->GetFirst()); double ymax = yaxis->GetBinCenter(yaxis->GetLast()); 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); }