Re: [ROOT] Run macro inside a main macro!

From: Valeri Fine (Faine) (fine@bnl.gov)
Date: Mon Apr 02 2001 - 18:23:51 MEST


>    Hi rooters,
> i am trying to run a macro (run.C) that calls an other macro (writing.C), 
> with command:
>              gROOT->ProcessLine(.x writing.C);

   Can the simple C-approach help you:

    #include "writing.C" 

 instead of your 

    gROOT->ProcessLine(.x writing.C);


                      Valeri

> At command: .x run.C, ROOT executes all command line but does not execute
> the line gROOT->ProcessLine(.x writing.C);
> ROOT ends the main macro execution (run.C) without execute the macro
> writing.C .
> Only when you do the command to exit from ROOT (.q), ROOT executes the
> macro writing.C .
> I do not understand why.
> I send you two macro, if you want try to run them.
> Thank you in advance
>                                         Annalisa
> 
> 
> *************************************************************************
> *    University of Bologna    |                   |  decaro@bo.infn.it  *
> *     Physics Department      | +39 051  20 91103 |                     *
> *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
> *    University of Salerno    |                   |                     *
> * Physics Sciences Department | +39 089  96 5359  |                     *
> *       (INFN of Napoli)      |                   |                     *
> *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
> *     CERN - EP division      |                   | decaro@mail.cern.ch *
> *        (Bld.29 R019)        | +41  22  76 77767 |                     *
> *************************************************************************
> 


--------------------------------------------------------------------------------


> void writing() {
> file://cout<<" The strip number is "<<istrip<<endl;
> file://cout<<" The run number is "<<irun<<endl;
> cout<<" The HV is "<<hv<<'\n';
> cout<<" The rate is "<<rate<<'\n';
>     if (iscan==0) then {
>     cout<<" The scanning is in X direction (iscan = "<<iscan<<")"<<'\n';
>     }elseif (iscan==1) then {
>     cout<<" The scanning is in Z direction (iscan = "<<iscan<<")"<<'\n';
>     }
> cout<<" The channel number is "<<nch<<'\n';
>  }
> 


--------------------------------------------------------------------------------


> /* **************************************************** *
>  * This is the main program for test beam data analysis *
>  * **************************************************** */
> #include <iostream.h>;
> 
> Float_t hv = 13;
> Float_t rate = 450;
> Int_t iscan = 2;
> Int_t nch = 0;
> 
> void run() {
> 
>   do {
>      cout<<"The scanning is in x (0) or in z (1) direction? ";
>      cin >> iscan;
>      } while (iscan>=2); 
> 
>    if (iscan==0) {
>       do {
>           cout<<"Give me the channel number (1,2,3,4,5), please ";
>           cin >> nch;
>          } while (nch==0||nch>5);
>      } elseif (iscan==1) {
>       do {
>           cout<<"Give me the channel number (1,2), please ";
>           cin >> nch;
>          } while (nch==0||nch>2);
>      }
> 
> file://Open data file
> TFile* file = new TFile("strip4_z2.root");
> 
> file->Print();
> 
> gROOT->ProcessLine(".x writing.C");
> 
> file->ls();
> 
> 
> file->Close();
> 
> }
> 



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:40 MET