{
    TRandom3 rnd;
    TH1D *h1 = new TH1D("h1","chisquare data",100.,0.,10.);
    h1->SetLineWidth(2);
    TH1D *h2 = (TH1D*)h1->Clone("h2");
    TH1D *h3 = (TH1D*)h1->Clone("h3");
    
    for(int i=0;i<1000000;i++) {
        h1->Fill(pow(rnd.Gaus(),2));
        h2->Fill(pow(rnd.Gaus(),2)+pow(rnd.Gaus(),2));
        h3->Fill(pow(rnd.Gaus(),2)+pow(rnd.Gaus(),2)+pow(rnd.Gaus(),2));
    }
    
    h1->SetMaximum(h1->GetMaximum()*0.25);
    h1->SetStats(0);
    h1->Draw();
    h2->SetLineColor(kRed);
    h2->Draw("same");
    h3->SetLineColor(kBlue);
    h3->Draw("same");
    
    TLegend *leg1 = new TLegend(0.55,0.65,0.88,0.85);
    leg1->AddEntry(h1,"h1 #chi^{2}(N=1)","L");
    leg1->AddEntry(h2,"h2 #chi^{2}(N=2)","L");
    leg1->AddEntry(h3,"h3 #chi^{2}(N=3)","L");
    leg1->Draw();
}