Running Scripts

I am trying to run a script (testscript.C) on ROOT, but I get an error that says:

root.exe [0] .L testscipt.C
Error in TRint::ProcessLine: macro testscipt.C not found in path .:./StRoot/macros:./StRoot/macros/graphics:./StRoot/macros/analysis:./StRoot/macros/test:./StRoot/macros/examples:./StRoot/macros/html:./StRoot/macros/qa:./StRoot/macros/calib:/afs/rhic//star/packages/SL09b/StRoot/macros:/afs/rhic//star/packages/SL09b/StRoot/macros/graphics:/afs/rhic//star/packages/SL09b/StRoot/macros/analysis:/afs/rhic//star/packages/SL09b/StRoot/macros/test:/afs/rhic//star/packages/SL09b/StRoot/macros/examples:/afs/rhic//star/packages/SL09b/StRoot/macros/html:/afs/rhic//star/packages/SL09b/StRoot/macros/qa:/afs/rhic//star/packages/SL09b/StRoot/macros/calib:/afs/rhic//star/ROOT/5.12.00/.sl302_gcc323/rootdeb/macros:/afs/rhic//star/ROOT/5.12.00/.sl302_gcc323/rootdeb/tutorials

I’ve tried adding my script to one of these paths, but I don’t have permission to write in these directories. Is there any way to add a custom path so that I can run the script from one of my home folders? Thanks for the help.

[quote=“bpourhamzeh”]I am trying to run a script (testscript.C) on ROOT, but I get an error that says:

root.exe [0] .L testscipt.C
Error in TRint::ProcessLine: macro testscipt.C not found in path .:…

[/quote]

The first one on the list is ‘.’ or the current working directory. So if you run root in the same directory, you should be good to go.

You can also specify a path (either .L /an/absolute/path/file.C or .L relative/Path/file.C).

Cheers,
Charles

Thanks. But now I get a message like this:

root.exe [0] .L testscript.C 
Error: Unexpected EOF G__fgetstream_template():2 testscript.C:28:
Advice: You may need to use +P or -p option
Error: Unexpected EOF G__fgetstream_template():2 testscript.C:28:
Advice: You may need to use +P or -p option
Error: Unexpected EOF G__fignorestream():3 testscript.C:28:
Advice: You may need to use +P or -p option
*** Interpreter error recovered ***

This is my script:

//intitialize historgram
TH1F h1("h1","Invariant Mass",100,1.65,2.1);

//intialize variables for input
string filename = "M.txt";
ifstream input;
input.open(filename.c_str());
vector<double> M_vec;
double mass;

//load values from file into vector
while(input >> mass)
{M_vec.push_back(mass);}

//file values from vector into h1
for(int j=0; j<(long)M_vec.size(); j++)
{h1->Fill(M_vec.at(j));}

//plot
//h1.Draw();

When I type all of these commands manually, it works fine, so I don’t know why this isn’t working.

enclose your macro in { }. Cheers, Charles

1 Like

you need to encapsule your script into a function:
void function()
{

}

then you can load it with .L script.c
and execute the function with function()

you can also used unnamed scripts without the function but you still need the { } around your code and you can only call it with .x (which immediatly executes it)

more information in the CINT user guide
ftp://root.cern.ch/root/doc/7CINT.pdf
under “The ROOT Script Processor”

THANK YOU!