[ROOT] CINT scripts

From: valio@pacific.mps.ohio-state.edu
Date: Wed Feb 20 2002 - 23:26:00 MET


Hi people !

Does somebody know a better way to :

1. Save all your commands (C++ statements and commands starting with a
dot) from a root session in a text file.
2. Execute that file in your next root session.

Below is what I've found so far on the subject. Please let me know if
you have a BETTER way to do it.

1. I couldn't find any Cint command to save the current session commands
in a text file so I just copied them
from the root history file .root_hist  to a file called

              commands.cint :

                              .L topElectron.C
                              .L topHeader.C
                              .L topJet.C
                              .L topMet.C
                              .L topHepg.C
                              .L topOfflTrack.C
                              .L topPrimaryVertex.C
                              .L bbana.cc
                              .trace bbana
                              bbana* myana = new bbana;
                              myana.SetOutputHistFile("ttbar.hbk");
                              myana.BeginJob();

myana.setInputFile("TopNtuple_ElectronSample.root");

               As you can see these are C++ commands MIXED WITH Cint
commands (that start with . ).


2. I tried 3 ways to execute that "Cint script" :

              A)  I typed in root:
                                   x. commands.cint
                    Of course that gave a lot of error messages because
root expects a C script not a bunch of commands.
                    The command
                                  .L commands.cint
                    didn't work as well.

              B)  I tried to use the shell's input redirection (tcsh) to
feed my text file to root :
                                  root.exe < commands.cint
                    or just
                                  root < commands.cint
                    In the both cases it worked brilliantly, the
commands were executed BUT root EXITS after that.
                    In some cases that is desirable but in my case
actually I was doing debugging and I wanted to stay in root
                    to check some variables after executing of the
script.
                     DO YOU KNOW A WAY TO STOP ROOT FROM EXITING IN THAT
CASE ?
                     ( no I didn't give the -q option to root :) )


              C) I changed the text file to a C macro by using
ProcessLine(.....) to convert the "starting-with-dot"
                   commands to C++ statements:

                    file commands.C :

                                {
                               gROOT->ProcessLine(".L topElectron.C");
                               gROOT->ProcessLine(".L topHeader.C");
                               gROOT->ProcessLine(".L topJet.C");
                               gROOT->ProcessLine(".L topMet.C");
                               gROOT->ProcessLine(".L topHepg.C");
                               gROOT->ProcessLine(".L topOfflTrack.C");
                               gROOT->ProcessLine(".L
topPrimaryVertex.C");
                               gROOT->ProcessLine(".L bbana.cc");
                               gROOT->ProcessLine(".trace bbana");
                               bbana* myana = new bbana;
                               myana.SetOutputHistFile("ttbar.hbk");
                               myana.BeginJob();

myana.setInputFile("TopNtuple_ElectronSample.root");
                               }


                  Of course when I typed in root :
                      .x commands.C
                  it worked but I don't like the idea that the root
interpreter doesn't have a more direct way to
                  execute its own commands :)

Anyway, if you know a better solution, especially of part 2B, let me
know.


Greetings,    Valio



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:42 MET