Hello, I achieved what I wanted by removing theApp -> Run(), adding Canvas -> SaveAs(outps) and run the compiled code with -b option. Thanks for all contributions. Best regards, Michal > From owner-roottalk@pcroot.cern.ch Thu Jan 27 11:36:26 2000 > Delivered-To: lijowski@cosray2.wustl.edu > X-Authentication-Warning: pcroot.cern.ch: majordomo set sender to owner-roottalk@root.cern.ch using -f > Date: Thu, 27 Jan 2000 10:23:51 +0000 > From: Fons Rademakers <Fons.Rademakers@cern.ch> > X-Accept-Language: en > MIME-Version: 1.0 > To: lijowski@cosray2.wustl.edu > CC: roottalk@pcroot.cern.ch > Subject: Re: Batch mode question > Content-Transfer-Encoding: 7bit > > Hi Michal, > > > what exactly do you understand under batch mode? No graphics, no > interactivity, both? > In case you don't want graphics follow the recipe given by Rene, use the -b > option > and your program will run like before but you will not get anything on the > screen > (PostScript output is possible though). If you don't want to get the interactive > prompt (in case you want to run the job via a batch submission system) then you > should not call the theApp->Run() method. This Run() method will wait for user > input which is generally not possible when running in a batch system (unless you > construct some scripts whith an input file on stdin, etc.). > > Cheers, Fons. > > > lijowski@cosray2.wustl.edu wrote: > > > > Hello, > > > > How to modify the attached code to run it in the batch mode? > > > > Thank you and best regards. > > > > Michal Lijowski > > > > // This program tests splitting histogram > > > > #include <TROOT.h> > > #include <TFile.h> > > #include <Rtypes.h> > > #include <TSystem.h> > > #include <TStyle.h> > > #include <TCanvas.h> > > #include <TApplication.h> > > #include <TBenchmark.h> > > #include <TAxis.h> > > #include <TH1.h> > > #include <TH2.h> > > #include <TGraph.h> > > #include <TText.h> > > #include <TObjString.h> > > #include <TPolyMarker.h> > > #include <iostream.h> > > > > // ---------------------------------------------------------------------- > > int main(int argc, char **argv) > > > > { > > Char_t *ProgName, tmpstr[80]; > > > > TROOT TEST_HIST("TEST_HIST", "TEST HIST"); > > > > /* Kludge so that this will work under the debugger. */ > > ProgName = strrchr(argv[0], '/'); > > if (ProgName == NULL) { > > /* not running under gdb */ > > ProgName = argv[0]; > > } else { > > /* running under gdb */ > > ProgName++; > > } > > > > gBenchmark = new TBenchmark(); > > gBenchmark -> Start(ProgName); > > gROOT -> SetStyle("Plain"); > > gStyle -> SetOptStat(11); > > gStyle -> SetCanvasColor(10); > > > > const Int_t Xsize = 500, Ysize = 500; > > Int_t xk, yk; > > > > cout << gSystem -> Exec("uname -a") << endl; > > > > Text_t *rootversion = (Text_t *) gROOT -> GetVersion(); > > sprintf(tmpstr, " ROOT version %s", rootversion); > > > > cout << tmpstr << endl; > > > > // create a new Root file > > char outdir[100] = "/data3/users/lijowski/"; > > Char_t outfile[200]; > > > > sprintf(outfile, "%s%s.root", outdir, ProgName); > > printf(" Output file %s\n", outfile); > > > > TFile *FF = new TFile(outfile, "recreate"); > > > > Char_t htitle[80], ctitle[40], cname[40], outps[120]; > > > > Float_t AA = 100.0; > > Float_t BB1 = 250.0; > > Float_t BB2 = 250.0; > > Float_t CC1 = 50.0; > > Float_t CC2 = 50.0; > > > > sprintf(htitle, "TEST HISTOGRAM"); > > > > Float_t xxmin = 0, xxmax = Xsize, yymin = 0, yymax = Ysize; > > TH2F *HH = new TH2F("HH", htitle, Xsize, xxmin, xxmax, Ysize, yymin, yymax); > > HH -> SetXTitle("X - coordinate (half pixel)"); > > HH -> GetXaxis() -> CenterTitle(kTRUE); > > HH -> SetYTitle("Y - coordinate (half pixel)"); > > HH -> GetYaxis() -> CenterTitle(kTRUE); > > > > // fill the histogram > > for (yk = 0; yk < Ysize; yk++) { > > Float_t YY = (Float_t) yk; > > for (xk = 0; xk < Xsize; xk++) { > > Float_t XX = (Float_t) xk; > > Float_t argx = (XX - BB1) / CC1; > > Float_t argy = (YY - BB2) / CC2; > > Float_t ZZ1 = TMath::Exp(-0.5 * argx * argx); > > Float_t ZZ2 = TMath::Exp(-0.5 * argy * argy); > > Float_t ww = AA * ZZ1 * ZZ2; > > > > HH -> Fill(XX, YY, ww); > > } > > } > > > > printf(" Done filling histogram %d\n", HH -> GetEntries()); > > > > TApplication theApp("App", &argc, argv); > > > > Int_t ii = 0; > > TCanvas *CNVS[5]; > > sprintf(cname, "CVS_%02d", ii); > > sprintf(ctitle, "Canvas %02d", ii); > > CNVS[ii] = new TCanvas(cname, ctitle, 500, 500); > > gPad -> SetTicks(); > > HH -> DrawCopy(); > > CNVS[ii] -> Update(); > > ii++; > > > > // Enter event loop, one can now interact with the objects in > > // the canvas. Select "Exit ROOT" from Canvas "File" menu to exit > > // the event loop and execute the next statements. > > theApp.Run(kTRUE); > > > > Float_t XLimits[4][2] = { > > 0.0, 250.0, > > 250.0, 500.0}; > > > > Float_t YLimits[3][2] = { > > 0.0, 250.0, > > 250.0, 500.0}; > > > > // split this histogram into 4 parts > > for (yk = 0; yk < 2; yk++) { > > for (xk = 0; xk < 2; xk++) { > > sprintf(cname, "CVS_%02d", ii); > > sprintf(ctitle, "Canvas %02d", ii); > > CNVS[ii] = new TCanvas(cname, ctitle, 500, 500); > > gPad -> SetTicks(); > > Float_t xxmin = XLimits[xk][0]; > > Float_t xxmax = XLimits[xk][1]; > > Float_t yymin = YLimits[yk][0]; > > Float_t yymax = YLimits[yk][1]; > > cout << " xxmin " << xxmin << " xxmax " << xxmax << " yymin " << yymin << " yymax " << yymax << endl; > > Int_t IBXmin = HH -> GetXaxis() -> FindBin(xxmin); > > Int_t IBXmax = HH -> GetXaxis() -> FindBin(xxmax); > > Int_t IBYmin = HH -> GetYaxis() -> FindBin(yymin); > > Int_t IBYmax = HH -> GetYaxis() -> FindBin(yymax); > > cout << " IBXmin " << IBXmax << " IBXmax " << IBXmax << " IBYmin " << IBYmin << " IBYmax " << IBYmax << endl; > > > > HH -> GetXaxis() -> SetRange(IBXmin, IBXmax); > > HH -> GetYaxis() -> SetRange(IBYmin, IBYmax); > > HH -> DrawCopy(); > > CNVS[ii] -> Update(); > > ii++; > > // Enter event loop, one can now interact with the objects in > > // the canvas. Select "Exit ROOT" from Canvas "File" menu to exit > > // the event loop and execute the next statements. > > theApp.Run(kTRUE); > > } > > } > > > > FF -> Write(); > > FF -> Close(); > > gBenchmark -> Stop(ProgName); > > cout << " Real Time " << gBenchmark->GetRealTime(ProgName) << " secs" << endl; > > cout << " CPU Time " << gBenchmark->GetCpuTime(ProgName) << " secs" << endl; > > > > // Here we don't return from the eventloop. "Exit ROOT" will quit the app. > > theApp.Run(); > > } > > -- > Org: CERN, European Laboratory for Particle Physics. > Mail: 1211 Geneve 23, Switzerland > E-Mail: Fons.Rademakers@cern.ch Phone: +41 22 7679248 > WWW: http://root.cern.ch/~rdm/ Fax: +41 22 7677910 >
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:18 MET