rename Main() to SFHped_plot_v0() and run system (“C:\root\bin\root.exe C:\root\tutorials\SFHped_plot_v0.C”);
Cheers, Axel.[/quote]
Hi Axel,
if I do as you say, I get the folowing error:
"C:\root\SFHped_output_v1.txt file written
…
*
W E L C O M E to R O O T *
*
Version 5.20/00 24 June 2008 *
*
You are welcome to visit our Web site *
[root.cern.ch](http://root.cern.ch) *
*
ROOT 5.20/00 (trunk@24524, Jun 25 2008, 12:08:00 on win32)
CINT/ROOT C/C++ Interpreter version 5.16.29, Jan 08, 2008
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0]
Processing C:\root\tutorials\SFHped_plot_v0.C…
Error: Function SFHped_plot_v0() is not defined in current scope (0)
*** Interpreter error recovered ***
root [1]"
should I add custome libraries in the c++ code?
when you say to replace script name, do you mean simply replace Main() with file name, or also suppress the curl brackets including the ROOT code?
check what you wrote in system(): You need to call root with the filename as argument, i.e.
root C:\root\.\tutorials\SFHped_plot_v0.C
Cheers, Axel.[/quote]
sorry, I still don’t succeed.
Before testing witjh the c++ code, I was doing some tests with the cmd.exe of windows.
I suppose it acts the commands as system() does. Am I right?
From the cmd.exe terminal, if I go to
path and then I write
the SFHped_plot_v0.C script is opend with Notepad and it is not executed.
Is it right like that?
thanks very much for the time you are spending to answer my questions!
regards
anna
I mean you start root (aka root.exe) and pass myCode.C as argument. I don’t know where you installed ROOT. Suppose it’s in C:\root\bin, you could do (from cmd.exe):
Hi Axel,
so, something is working, but I still have some bugs…
Yes, I have root installed in C:\root\bin.
If, from cmd.exe, I go in the C:\root directory and I write:
it works perfectly (i.e., ROOT is opened and my script succesfully run).
But I cannot do it if I stay in the C:\ directory. namely, if I write:
it doesn’t work. Root is properly run but then it says:
root [0]
Processing .\root\tutorials\SFHped_plot_v0.C...
Exception: invalid string position
Error: Symbol G__exception is not defined in current scope C:\root\tutorials\SF
Hped_plot_v0.C(57)
Error: type G__exception not defined FILE:C:\root\tutorials\SFHped_plot_v0.C LIN
E:57
*** Interpreter error recovered ***
Since I’m not able to give 2 consecutive instructions [i.e., change directory (to go in C:\root) first, and then run root and my code] to the system() function, I don’t succeed in my goal.
[code]int SFHped_plot_v0(){
Int_t Nfibres=128; //fibers number (64 hor + 64 vert fibers)
Float_t fiber[128]; //fiber numbering (1 to 64 for H fibers, 65 to 128 for V fibers) //int?
Float_t ped[128];//array da riempire con pedestal average values, per each fiber
Float_t rms[128]; //array da riempire con pedestal rms values, per each fiber
Float_t F=0; //int?
Float_t P=0;
Float_t R=0;
string detector;
string measurementlabel;
string date;
string exposure;
string gain;
string Nmeas;
string valuemean;
string rmsmean;
string basket;
// read the time the ROOT script is executed at
time_t rawtime;
time ( &rawtime );
date=ctime(&rawtime); //this string ends with a "newline" character
//let's read the input file and fill the strings:
// for each ">>", it reads until the first space
// i.e., a word at a time
ifstream infile("SFHped_output_v1.txt");
infile>>detector;
detector=detector.substr(1); #### LINE 57###
infile>>measurementlabel;
measurementlabel=measurementlabel.substr(1);
infile>>gain;
gain=gain.substr(1);
infile>>exposure;
exposure=exposure.substr(1);
but then, why does it work if I run it directly from a ROOT terminal or from a prompt command going in the C:\ROOT directory first and then writing the command “.\bin\root.exe .\tutorials\SFHped_plot_v0.C”?
I fear it is difficult to debug it in this way; I don’t want to disturb you too much.
I think I’ll do it “by hand” (i.e., not with an automatic call of ROOT from the c++ program).
I don’t know where that file SFHped_output_v1.txt is located. It should help if you specify the full path, or if you gSystem->cd() to a fixed location before accessing that file.