RE:[CINT] [ROOT] CINT scripts (fwd)

From: Masaharu Goto (MXJ02154@nifty.ne.jp)
Date: Thu Feb 21 2002 - 14:18:55 MET


Hello Valio,

Similar capability is implemented in pure Cint. But I suspect
this does not work in ROOT. 

Rene and Fons, 
I think this capability has to be implemented in ROOT command
line  as command line is implemented independently between CINT
and ROOT. 

In case of Cint, command goes like below.

   $ cint
   cint> .                # change command line to ROOT mode '.'
   cint> .n comdump       # Start dumping command line 
   cint> printf("abc\N")  # type in whatever the commands
   cint> .L iostream
   cint> cout << "def" << endl;
   cint> .U iostream
   cint> .z               # stop dumping command line
   cint> .q               # Quit cint

   $ cint
   cint> .< comdump       # running dumpped commands

Thank you
Masaharu Goto


>---------- Forwarded message ----------
>Date: Wed, 20 Feb 2002 17:26:00 -0500
>From: valio@pacific.mps.ohio-state.edu
>To: roottalk@pcroot.cern.ch
>Subject: [ROOT] CINT scripts
>
>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