Isn't it such that since version 2.23/10 the syntax is : root -q file.C (i.e. drop the -b flag). Cheers, Nick. Rene Brun wrote: > > Hi Michal, > To run a Root application (including graphics or not) in batch mode > do > root -b -q file.C > > For example, to execute the tutorials macro "benchmarks.C" > - interactively, you do > cd $ROOTSYS/tutorials > root > Root > .x benchmarks.C > Root > .q > > - in batch, you do: > root -b -q benchmarks.C > > The same is true if you build your own application with your own > main program providing you use TApplication or better TRint as in the > Root main program. > > Rene Brun > > 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(); > > } -- Dr. Nick van Eijndhoven Organisation: Utrecht University/Nikhef, Department of Subatomic Physics Address: P.O. Box 80.000, NL-3508 TA Utrecht, The Netherlands Phone: +31-30-2532331 (direct) +31-30-2531492 (secr.) Fax: +31-30-2518689 Electronic: nick@phys.uu.nl http://www.phys.uu.nl/~nick Office: Ornstein lab. 172 At NIKHEF: H350 Tel: +31-20-5922028 (direct) +31-20-5922000 (secr.) Fax: +31-20-5925155 At CERN: B160 1-012 Tel: +41-22-7679751 (direct) +41-22-7675857 (secr.) Fax: +41-22-7679480 -------------------------------------------------------------------------------------------------
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:17 MET