For loop in command line

I’m trying to use a for loop in the command line to plot a bunch of sequential histograms. Each canvas gets displayed, however only the very last one is filled.

for (Int_t i=0;i<10;i++) {TString xx=“EfitA54[”;xx+=i;xx+="]:TfitA54[";xx+=i;xx+="]";h1000->Draw(xx,“LASER_FILTER==4”);char j; cin>>j
;}

Only EfitA54[9]:TfitA54[9] shows a plot, the others are blank. Anyone know how do I force the plot after each Draw? - Bob

TTree::Draw by default produces a histogram named “htemp”. The next call to Draw deletes the previous htemp and creates a new one. I suggest to replace your loop by

This will generate a histogram with a different name : htemp0, htemp1, etc

Rene

Following Rene’s reply, with a little work, I got this to loop and display my 48 consecutive plots:

for (Int_t i=0;i<48;i++) {TString xx=Form(“EfitA01[%d]:TfitA01[%d]”,i,i);h1000->Draw(xx,"",“prof”);htemp->Get
Yaxis()->SetRangeUser(400.,700.);c1->Update();htemp->Draw();char j ;cin>>j;}

[quote=“bob_stanek”]I’m trying to use a for loop in the command line to plot a bunch of sequential histograms. Each canvas gets displayed, however only the very last one is filled.

for (Int_t i=0;i<10;i++) {TString xx=“EfitA54[”;xx+=i;xx+="]:TfitA54[";xx+=i;xx+="]";h1000->Draw(xx,“LASER_FILTER==4”);char j; cin>>j
;}

Only EfitA54[9]:TfitA54[9] shows a plot, the others are blank. Anyone know how do I force the plot after each Draw? - Bob[/quote]