//---------------- // StandardLabels2D //---------------- void StandardLabels2D(TH2D *axes=NULL, string mess="") { // 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, "June 22, 2010 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 6416"); ConvertFromNDC2D(lab, axes); lab->SetTextSize(0.02); lab->SetTextAlign(31); lab->SetTextColor(kBlue); lab->Draw(); // Event type lab = new TLatex(0.35, 0.675, ""); ConvertFromNDC2D(lab, axes); lab->SetTextSize(0.03); lab->SetTextAlign(32); lab->Draw(); // Conditions lab = new TLatex(0.7, 0.61, mess.c_str()); ConvertFromNDC2D(lab, axes); lab->SetTextSize(0.03); lab->SetTextAlign(31); lab->Draw(); } //---------------- // StandardLabels1D //---------------- void StandardLabels1D(TH1D *axes=NULL, string mess="") { // 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, "June 22, 2010 DL"); ConvertFromNDC1D(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 6416"); ConvertFromNDC1D(lab, axes); lab->SetTextSize(0.02); lab->SetTextAlign(31); lab->SetTextColor(kBlue); lab->Draw(); // Event type lab = new TLatex(0.35, 0.675, ""); ConvertFromNDC1D(lab, axes); lab->SetTextSize(0.03); lab->SetTextAlign(32); lab->Draw(); // Conditions lab = new TLatex(0.7, 0.61, mess.c_str()); ConvertFromNDC1D(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); } //---------------- // ConvertFromNDC1D //---------------- void ConvertFromNDC1D(TLatex *obj, TH1D *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(); double ymin = h->GetMinimum(); double ymax = h->GetMaximum()*1.05; // 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); }