Re: Displaying graphs before main() returns

From: Christian Holm Christensen <cholm_at_nbi.dk>
Date: Wed, 31 May 2006 20:56:16 +0200


Hi,

On Wed, 2006-05-31 at 17:06 +0200, Roland Kuhn wrote:
> Yes, of course it is not impossible. Only, to set a break point in
> myscript, I'd have to jump through some hoops. Also, giving command
> line options is more cumbersome. Another problem is the use of
> external libraries which require certain flags to be passed to the
> compiler. There's certainly a way with CINT (I don't know), but it is
> more complicated than the trivial Makefile.

Take a look at the attached two scripts. Do for example

  prompt> root
  Root> .x makeRng.C
  Root> gslRandom::main(10);

Note the lines in `makeRng.C' that sets the compiler and linker flags.

To debug do

  prompt> gdb root.exe
  (gdb) run
  Root> .x makeRng.C
  ^C
  (gdb) break 'gslRandom::main(unsigned int)'   (gdb) continue
  Root> gslRandom::main(10)

That breaks execution in the `gslRandom::main' and drops to the GDB prompt.

> > In addition from the command line you can load any plug-in library.
>
> This is not about possible/impossible, it is about ease of use for
> different types of application.

For certain types of applications it can be quite useful to have a program that takes care of the event-loop, while the actual contents of the data pipeline is customised through a script:

  int main(int argc, char** argv)
  {

     TApplication app("job", 0, 0);
     if (argc < 2) {
       std::cerr << "Usage: " << argv[0] << " CONFIG " << std::endl;
       return 1;
     }
     JobManager* job = JobManager::Instance();
     gROOT->Macro(argv[1])
     
     job->Initialise();
     while (job->Event());
     return job->Finalise();

  }

with a configuration script like

  void
  Config()
  {

     JobManager* job = JobManager::Instance();

     gSystem->Load("RawReader.so");
     RawReader*  raw = new RawReader("raw.dat");

     gSystem->Load("Reco.so");
     Clusterer*  cluster = new Clusterer;
     Tracker*    tracker = new Tracker

     Output*     output  = new Output("out.root");

     job->Add(raw); 
     job->Add(cluster);
     job->Add(tracker);
     job->Add(output);

  }

And a jobmanager like

  class JobManager : ...
  {
  public:
    void Add(Task* t) { fList.Add(t); }     void Initialize() {

       TIter next(&fList);
       Task* t = 0;
       while ((t = static_cast<Task*>(next()))) t->Initialize();
    }
    void Event() {
       TIter next(&fList);
       Task* t = 0;
       while ((t = static_cast<Task*>(next()))) t->Event();
    }
    int Finalize() {
       int ret = 0;
       TIter next(&fList);
       Task* t = 0;
       while ((t = static_cast<Task*>(next()))) {
         ret = t->Finalize();
         if (ret != 0) return ret;
       }
       return ret;

    }
  protected:
    TObjArray fList;
  };     

In this way, a user can freely customise a job through editing scripts and compiling plug-ins with AClic, with out any `cumbersome' `select' calls. See also http://cern.ch/root/#framework

Yours,

-- 
 ___  |  Christian Holm Christensen 
  |_| |  -------------------------------------------------------------
    | |  Address: Sankt Hansgade 23, 1. th.  Phone:  (+45) 35 35 96 91
     _|           DK-2200 Copenhagen N       Cell:   (+45) 24 61 85 91
    _|            Denmark                    Office: (+45) 353  25 404
 ____|   Email:   cholm_at_nbi.dk               Web:    www.nbi.dk/~cholm
 | |
Received on Wed May 31 2006 - 20:59:03 MEST

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:58 MET