Pietro,
See your macro modified below
Rene Brun
int macro2 ()
{
TFile *f; TH1F * tutti[30] ; int cont = 0 ; for (int i=0 ; i<10; ++i) { char nomeFile[80] ; sprintf (nomeFile,"c0%d/salvo.root",i) ; std::cout << "opening: " << nomeFile << std::endl ; f = TFile::Open(nomeFile) ; TH2F *histo = (TH2F *) f.Get ("E25oPin_eta_gsf") ; std::cout << "histogram " << E25oPin_eta_gsf->GetName () << " found" << std::endl ; histo->FitSlicesY () ; tutti[cont] = (TH1F*)f->Get("E25oPin_eta_gsf_1"); tutti[cont]->SetDirectory(0); ++cont ; delete f; } TH2F h2 ("h2","peak distribution",10,0,1.5,10,0.8,1.1) ; h2.SetStats (0) ; TCanvas * c1 = new TCanvas ("c1") ; c1->Draw () ; h2.Draw () ; for (int i=0; i<cont; ++i) { tutti[i]->SetMarkerStyle (28) ; tutti[i]->SetMarkerColor (50+2*i) ; tutti[i]->Draw ("same") ; } c1->Draw () ; c1->Print ("prova.gif","gif") ; delete c1 ;
}
On Wed, 8
Jun
2005, Pietro
GOVONI wrote:
> Dear Rooters,
>
> in studying cuts on a dataset I produced a lot of ROOT files, each of them
> containing the same histograms, related to different cuts.
>
> I am trying to loop over the files and produce an overall plot, but I cannot,
> since:
>
> a. I need to call TH2F::FitSilcesY () on a TH2F histogram and I get the
> results in the ROOT memory only
> b. All the histograms are the same one in different files, so they have the
> same name, title, range, binning . . .
>
> How can I produce a plot, or a collection, of the result of FitSlicesY when
> applied to all the histograms?
>
> I am working with ROOT Version 4.00/06 on macosx.
>
> Let me provide the macro I was trying to use, that didn't work.
>
> Kind regards
>
> pietro
>
>
>
>
>
>
> int macro2 ()
> {
> TH1F * tutti[30] ;
> int cont = 0 ;
>
> for (int i=0 ; i<10; ++i)
> {
> char nomeFile[80] ;
> sprintf (nomeFile,"c0%d/salvo.root",i) ;
> std::cout << "opening: " << nomeFile << std::endl ;
> TFile f (nomeFile) ;
> f.cd () ;
> // TH2F * histo = (TH2F *) f.Get ("E25oPin_eta_gsf") ;
> std::cout << "histogram " << E25oPin_eta_gsf->GetName ()
> << " found" << std::endl ;
> E25oPin_eta_gsf->FitSlicesY () ;
> tutti[cont] = new TH1F ((TH1F*) E25oPin_eta_gsf_1->Clone
> (nomeFile)) ;
> ++cont ;
> f.Close () ;
> if (i>5)
> {
> sprintf (nomeFile,"c0%d5/salvo.root",i) ;
> std::cout << "opening: " << nomeFile << std::endl ;
> TFile f (nomeFile) ;
> f.cd () ;
> // TH2F * histo = (TH2F *) f.Get ("E25oPin_eta_gsf") ;
> std::cout << "histogram " << E25oPin_eta_gsf->GetName ()
> << " found" << std::endl ;
> E25oPin_eta_gsf->FitSlicesY () ;
> tutti[cont] = new TH1F ((TH1F*) E25oPin_eta_gsf_1->Clone
> (nomeFile)) ;
> ++cont ;
> f.Close () ;
> }
> }
>
> TH2F h2 ("h2","peak distribution",10,0,1.5,10,0.8,1.1) ;
> h2.SetStats (0) ;
> TCanvas * c1 = new TCanvas ("c1") ;
> c1->Draw () ;
> h2.Draw () ;
>
> for (int i=0; i<cont; ++i)
> {
> tutti[i]->SetMarkerStyle (28) ;
> tutti[i]->SetMarkerColor (50+2*i) ;
> tutti[i]->Draw ("same") ;
> }
> c1->Draw () ;
> c1->Print ("prova.gif","gif") ;
> delete c1 ;
>
> }
Received on Wed Jun 08 2005 - 19:22:29 MEST
This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:09 MET