Re: gROOT->Macro(..) for steering cards?

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed May 06 1998 - 13:31:13 MEST


Ludger Janauschek wrote:
> 
> Hello,
> 
> is it possible to use
> 
>    gROOT->Macro("steeringcards.cc")
> 
> for a macro like
> 
>    {
>       Char_t* aFileName = "...";
>       Int_t   someNumber = 16838;
>    }
> 
> in a compiled ROOT-program to get the values? How?
> 

In a compiled Root program, you can call gROOT->Macro
to execute instructions in the macro without recompiling
your program. This is a very convenient way to replace
the "conventional approach" with data cards.
In this macro, you will typically calls methods of a compiled
class to set some parameters.
A good example is given in the ATLFast application
(see http://root.cern.ch/root/Atlfast.html).
The program is started by executing for example the macro umain.C
below. This macro, in turn, executes another macro user.C
where some ATLFast parameters are set.

Rene Brun

//----macro  umain.C
//   example of main program/macro to run ATLFast
void umain(Int_t prodmode=1, Int_t nevents=1000)
{
   gROOT->Reset();

   gROOT->Macro("$ATLFAST/loadlibs");

   // Open the root output file
   TFile file("atlfast.root","recreate","ATLFast root file",2);
   
   ATLFast atlfast("atlfast");     // create main object to run atlfast

   atlfast.MCMaker()->SetProductionMode(prodmode);

   gROOT->Macro("user.C");  // execute user macro to change some
parameters

   atlfast.Init();      // Initialise event (maker histograms,etc)
   atlfast.MakeTree();  // Create the Root tree

   TPythia *pythia = (TPythia *)gATLFast->MCMaker()->Generator();
   pythia->PyStat(2);
   atlfast.PrintInfo();

   for (Int_t i=0; i<nevents; i++) {
      if (i%20 == 0) printf("In loop:%d\n",i);
      atlfast.Make(i);       // Generate and Reconstruct event
      atlfast.FillTree();
      if (i < 1) pythia->LuList(1);
      atlfast.Clear();       // Clear reconstructed event lists
   }

   atlfast.Finish();
   // save objects in Root file
//   atlfast.Tree()->Print();
   atlfast.Write();  //save main atlfast object (and run parameters)
//   file.Write();     // save histograms and tree
}



//---macro user.C
{
  // change ATLfast default parameters

   gATLFast->SetSmearing(1);
   gATLFast->SetTrackFinding(1);
   gATLFast->ClusterMaker()->SetGranBarrelEta(0.1);
   gATLFast->ClusterMaker()->Save(0);
   gATLFast->PhotonMaker()->SetMinPT(5.);
   gATLFast->TriggerMaker()->SetMuoEtaCoverage(2.5);
   gATLFast->MCMaker()->Save(2);     //give 2 to save all particles
   gATLFast->TrackMaker()->Save(1);  // give 1 to save tracks
}



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:32 MET