foam_demopers.C

Go to the documentation of this file.
00001 //
00002 // This simple macro demonstrates persistency of FOAM object.
00003 // First run macro foam_demo.C to create file foam_demo.root with FOAM object.
00004 //
00005 // Next type root -l foam_demopers.C from shell command line
00006 //
00007 
00008 Int_t foam_demopers()
00009 {
00010   gSystem->Load("libFoam.so");
00011   gROOT->ProcessLine(".L foam_demo.C+");
00012   //******************************************
00013   cout<<"====================== TestVector ================================"<<endl;
00014   TFile fileA("foam_demo.root");
00015   fileA.cd();
00016   cout<<"------------------------------------------------------------------"<<endl;
00017   fileA.ls();
00018   cout<<"------------------------------------------------------------------"<<endl;
00019   fileA.Map();
00020   cout<<"------------------------------------------------------------------"<<endl;
00021   fileA.ShowStreamerInfo();
00022   cout<<"------------------------------------------------------------------"<<endl;
00023   fileA.GetListOfKeys()->Print();
00024   cout<<"------------------------------------------------------------------"<<endl;
00025   //*******************************************
00026   TFoam  *FoamX = (TFoam*)fileA.Get("FoamX");
00027   //*******************************************
00028 //  FoamX->PrintCells();
00029   FoamX->CheckAll(1);
00030 
00031  Double_t *MCvect =new Double_t[2]; // 2-dim vector generated in the MC run
00032 
00033  for(long loop=0; loop<50000; loop++){
00034     FoamX->MakeEvent();            // generate MC event
00035     FoamX->GetMCvect( MCvect);     // get generated vector (x,y)
00036     Double_t x=MCvect[0];
00037     Double_t y=MCvect[1];
00038     if(loop<10) cout<<"(x,y) =  ( "<< x <<", "<< y <<" )"<<endl;
00039     }// loop
00040   //
00041   Double_t IntNorm, Errel;
00042   FoamX->Finalize(   IntNorm, Errel);     // final printout
00043   Double_t MCresult, MCerror;
00044   FoamX->GetIntegMC( MCresult, MCerror);  // get MC integral, should be one
00045   cout << " MCresult= " << MCresult << " +- " << MCerror <<endl;
00046   cout<<"===================== TestPers FINISHED ======================="<<endl;
00047   return 0;
00048 }
00049 //_____________________________________________________________________________
00050 //
00051 

Generated on Tue Jul 5 15:44:11 2011 for ROOT_528-00b_version by  doxygen 1.5.1