You have created the histogram "h4" above in the default directory
in memory. This default directory is pointed by gROOT.
If you had created "h4" after opening the file "ntp" above, then
"h4" would have been created in the list of objects in memory
associated to the file "ntp". A few lines below, you "delete ntp"
after your "h509->Draw.."). When deleting a file, all lists in memory
associated with this file are also deleted. That's why, correctly,
you create "h4" (and I also assume, h6,..h14) in gROOT directory,
because you want to use these histograms after having deleted ntp.
>
> if(i==0) h509->Draw("(Ue*Uft+Ve*Vft+We*Wft)>>+h4","Rfitt<600","goff");
> if(i==1) h509->Draw("(Ue*Uft+Ve*Vft+We*Wft)>>+h6","Rfitt<600","goff");
> if(i==2) h509->Draw("(Ue*Uft+Ve*Vft+We*Wft)>>+h8","Rfitt<600","goff");
> if(i==3) h509->Draw("(Ue*Uft+Ve*Vft+We*Wft)>>+h10","Rfitt<600","goff");
> if(i==4) h509->Draw("(Ue*Uft+Ve*Vft+We*Wft)>>+h12","Rfitt<600","goff");
> if(i==5) h509->Draw("(Ue*Uft+Ve*Vft+We*Wft)>>+h14","Rfitt<600","goff");
> delete ntp;
> }
>
> TF1* gaussExp = new TF1("gaussExp",gaussExp,-1,1,4); // x=-1 to 1, 4params
> gaussExp->SetParNames("Exp co-eff","Gauss Amp","Gau sigma","scale fac");
> gaussExp->SetParameters(6,0.1,2,1000);
>
> Int_t lNPlots = 6;
> TArrayD energy(lNPlots);
> TArrayD expSlope(lNPlots);
> TArrayD gaussAmp(lNPlots);
> TArrayD gaussSigma(lNPlots);
>
> pad1->cd();
> h4->Fit("gaussExp");
> energy[0] = 4.0;
> expSlope[0] = gaussExp->GetParameter(0);
> gaussAmp[0] = gaussExp->GetParameter(1);
> gaussSigma[0] = gaussExp->GetParameter(2);
>
> // This does get printed to screen correctly
> printf("%f\n",expSlope[0]);
>
> pad2->cd();
> h6->Fit("gaussExp");
> energy[1] = 6.0;
> expSlope[1] = gaussExp->GetParameter(0);
> gaussAmp[1] = gaussExp->GetParameter(1);
> gaussSigma[1] = gaussExp->GetParameter(2);
>
> ...
>
> The problem is I can't find the arrays energy,expSlope,gaussAmp, and
> gaussSigma *anywhere*. I want to make a plot to see how these parameters
> change from histogram to histogram.
>
> I try typing printf("%f\n",energy[0]); at the prompt and I get
> Error: No symbol energy[0] in current scope FILE:/tmp/03374iaa LINE:1
You show only an extract of your macro. My explanation is that
very likely you have given a name to your macro. When you exit
from the macro all objects created as objects (not via new)
are deleted (standard C++ scoping rules). Your TArrayD objects
in particular will be destroyed when exiting from the macro.
You cannot access them from the command line.
The solution to this problem is to not give a name to the macro.
In this case, it will be executed in the main scope and all objects
created in the macro will still be accessible from the command line.
Note that when you run with unnamed macros, I strongly suggest
that the first statement in your macro be:
gROOt->Reset();
to make sure to delete all objects created in a previous execution
if you want to execute your unnamed macro several times in
the same Root session.
Rene Brun