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.
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.
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)