Re: [ROOT] string in a loop

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Apr 26 2004 - 19:49:49 MEST


Francesco,

Instead of:
    Slice->ProjectionY("Slice_i",i,i);
do
    Slice->ProjectionY(Form("Slice_%d",i),i,i);

Rene Brun

On Mon, 26 Apr 2004, Perfetto 
Francesco wrote:

> Hi All,
> 
> I have the following problem:
> I have to do many slice of a bidimensional histogram, and I would like to
> call it "Slice_1", "Slice_2", ..., etc. etc.
> 
> I make this in my script:
> 
> TFile *f1 = new TFile("MC.root");
> TFile *f2 = new TFile("proiezioni_MC_30x70.root","RECREATE");
> TTree *t = (TTree*)f1->Get("res");
> TH2D *Slice = new TH2D("Slice","Slice",30,0,1,70,-1,2);
> 
> ...
> 
> for(Int_t i=1;i<31;i++)
>    Slice->ProjectionY("Slice_i",i,i);
> 
> ...
> 
> f2->Write();
> 
> But I haven't that I want.
> Infact all Slice are named Slice_i.
> Can anyone help me?
> 
> Thanks
> Francesco.
> 
> I use RedHat 9.0 with root 4.00/03
> 



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:07 MET