Some helper functions for histos

// Note: this is a named macro, so you have to load it first into root
// and then execute the function 'SetMyStyle':
//
// root [0] .L gilles.C
// root [1] SetMyStyle();
//

void  SetMyStyle(void)
{
// example for customizing styles

  gROOT->SetStyle("Plain");
  gStyle->SetFillColor(0);  //white fill color
  gStyle->SetFrameBorderMode(0);  //no frame border
  gStyle->SetCanvasBorderMode(0);  //no canvas border
  gStyle->SetOptTitle(0);  //no title
  gStyle->SetOptStat(0);  //no statistics _or_
//  gStyle->SetOptStat(11111111);
      // -->all statistics (the more 1's you put,the more statistics you get)
  gStyle->SetOptLogy();  //log. scale
}


void Draw2Legend(TH1D *histo1,TH1D *histo2,const Char_t *label1,const Char_t *label2)
{
// example for adding a legend to the plot of two histos

  TLegend *legend=new TLegend(.7,.75,.89,.89);  //geometry of legend
  legend->SetHeader(histo1->GetName());  //leg. header (name of histogram or sth. else)
  histo1->SetLineColor(2);  //histo1 in red
  histo2->SetLineColor(1);  //histo2 in black
  legend->AddEntry(histo1,label1,"L");  // see *http://root.cern.ch/root/html/TLegend.html *  for details
  legend->AddEntry(histo2,label2,"L");
  legend->SetBorderSize(0);  //no border for legend
  legend->SetFillColor(0);  //fill color is white
  legend->Draw();  //draw it
}
// e.g. Draw2Legend(myhisto1,myhisto2,"mylabel1","mylabel2")
// ( after myhisto1->Draw(); myhisto2->Draw("same"); )



void MeanPrinter(TH1D *histo1, TH1D *histo2)
{
//prints mean of histo1/histo2 in red/black in the histo-pad

   TPaveText *pt1,*pt2;
   TText *tx1,*tx2;
   const Text_t *title;

// create TPaveText

    pt1 = new TPaveText(.55,.75,0.88,0.88,"NDC");//.85,.85
    pt1->SetFillColor(0);
    pt1->SetBorderSize(0);

//print mean (black) of histo1 in pad

    Char_t buffer[250];
    sprintf (buffer,"%.3f",histo1->GetMean());   //%.3-->3 digits
    tx1 = pt1->AddText(0.,0.95,buffer);
    tx1->SetTextSize(0.04);
    tx1->SetTextFont(42);
    tx1->SetTextAlign(12);

//print mean(red)  of histo2 in pad

    Char_t buffer2[250];
    sprintf (buffer2,"%.3f",histo2->GetMean());
    tx1 = pt1->AddText(0.0,0.7,buffer2);
    tx1->SetTextSize(0.04);
    tx1->SetTextFont(42);
    tx1->SetTextAlign(12);
    tx1->SetTextColor(2);
    pt1->Draw();

  //Draw nice-looking title

    title=histo1->GetTitle();  //gets title of histogram
    pt2 = new TPaveText(0.2,0.92,0.8,0.97,"NDC");
    pt2->SetFillColor(0);
    pt2->SetBorderSize(0);
    tx2 = pt2->AddText(0.5,0.5,title);
    tx2->SetTextSize(0.07);
    tx2->SetTextFont(42);
    tx2->SetTextAlign(22);
    pt2->Draw();
}