Hi!
I am having some difficulty generating postscript plots using ROOT version 4.00-08.
When I create histograms in a loop, I get a lot of errors such as Error in <TUnixSystem::ExpandFileName>: input: $LCDROOT/Examples/Postscript, output: $LCDROOT/Examples/Postscript
Also, the postscript file
a) has 50 pages!
b) is empty
I can see the histograms when I open the ROOT file created by the program directly.
Any ideas? The code follows.
Compilation is done with
#
setenv ROOTSYS /beeraid1/babar/package/root/4.00-08
setenv LD_LIBRARY_PATH /beeraid1/babar/package/root/4.00-08/Linux24/lib
/usr/bin/g++ -g -o GenSmrFit1D -O -Wall -fPIC -I$ROOTSYS/include GenSmrFit1D.cc \
-Wno-deprecated /home/purohit/c/dgauss.o \ -L$ROOTSYS/lib -lCore -lCint -lHist \ -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lMinuit -lPhysics -lm -ldl -lpthread -rdynamic
Thanks in advance for your help!
Milind Purohit
//
void Plot1D(int ipad, TH1F * TheHist, char XTitle[], TCanvas * c1, TPostScript * ps){
c1->Modified(); // Error persists if this is commented out
if(ipad == 1){
c1->Update(); // Error persists if this is commented out
ps->NewPage(); // Error persists if this is commented out
}
c1->cd(ipad);
TheHist->SetXTitle(XTitle);
TheHist->Draw();
}
int GenSmrFit1D(){
timer.Start();
double ru;
int ihist = 0;
int nbw = 5;
int ngau = 5;
gRandom->SetSeed();
TFile hfile("GenSmrFit1D.root", "RECREATE"); cout << "Created Hist file" << endl;
TH1F * voigt[nbw][ngau];
char htitle[80];
int igam, isig;
for(int ibw = 0; ibw < nbw; ibw++){
BWgam = 0.000020 + ibw * 0.000040;
for(int igau = 0; igau < ngau; igau++){
sigma = 0.000120 + igau * 0.000040;
igam = (int)(1.E6 * BWgam); isig = (int)(1.E6 * sigma); sprintf(htitle, "SigGam%6d", 1000*isig+igam); voigt[ibw][igau] = new TH1F(htitle, "Q (GeV)", 40, 0., 0.050);
}
}
TCanvas* c1 = new TCanvas("c1", "BW convoluted with Gaussian", 10, 10, 750, 950);
c1->SetFillColor(0); c1->SetGridx(); c1->SetGridy(); c1->Divide(2, 2);
cout << "Canvas created" << endl;
TPostScript * ps = new TPostScript("GenSmrFit1D.ps", 111);
for(int ibw = 0; ibw < nbw; ibw++){
BWgam = 0.000020 + ibw * 0.000040;
for(int igau = 0; igau < ngau; igau++){
sigma = 0.000120 + igau * 0.000040;
ihist++;
igam = (int)(1.E6 * BWgam); isig = (int)(1.E6 * sigma); // Generate 80% BW, 20% background for(int idata = 0; idata < ndata; idata++){ ru = gRandom->Rndm(1); if(ru <= 0.8){ do{ ru = gRandom->Rndm(1); xdata[idata] = q0 + (BWgam / 2.) * tan((ru - 0.5) * PI); }while((xdata[idata] < xmin) || (xdata[idata] > xmax)); xdata[idata] = rngaus(xdata[idata], sigma); } else { ru = gRandom->Rndm(1); xdata[idata] = xmax * pow((xmax * ru / (1. + bpow)), (1./bpow)); } voigt[ibw][igau]->Fill(xdata[idata]); } c1->Clear(); int ipad = ihist % 4; if(ipad == 0)ipad = 4; Plot1D(ipad, voigt[ibw][igau], "Q (GeV)", c1, ps);
}
}
ps->Close();
cout << "Made ps file" << endl;
hfile.Write();
cout << "Wrote Hist file" << endl;
return 0;
}
int main(int argc, char **argv){
return GenSmrFit1D();
}
Received on Fri May 06 2005 - 18:58:38 MEST
This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:07 MET