Ask: how to transfer the parameter for the root scritpt

Hello rooters,

I will use an example to show my question:

  1. my root script (DrawDiLepPlots.C) is like following:

void DrawDiLepPlots(int period=-1 ) {
cout<<" period: "<<period<<endl;

  1. If you run command-“root DrawDiLepPlots.C”, the output is:
    period: -1

May I ask how could I change the period by this command line mode?
I remember it is something like “root DrawDiLepPlots.C ( 3 )”. But it doesn’t work.

Can anybody tell me how to do it?

Thank you in advance!

Best regards


No spaces allowed in the call, try:
root DrawDiLepPlots.C(3)

Hi Pepe,

Thanks a lot! It works. :smiley:



Actually, you have three possibilities:

root -l -b -q DrawDiLepPlots.C(3)
root -l -b -q DrawDiLepPlots.C\ (\ 3\ )

root -l -b -q "DrawDiLepPlots.C(3)"
root -l -b -q “DrawDiLepPlots.C ( 3 )”

root -l -b -q 'DrawDiLepPlots.C(3)'
root -l -b -q ‘DrawDiLepPlots.C ( 3 )’

Added: See, for example, ROOT User’s Guide -> Getting Started -> Start and Quit a ROOT Session

Hi Pepe,

Thanks for your detailed explanation.

May I ask whether there is a official document that mention these methods?
Because I have searched many place, e.g. user guide, tutorial. But maybe because of my careless, I didn’t find these methods.



Hi Lei,

Those methods are described in the shell’s (bash, tcsh) manual and guides as they are the way that those tools provide to escape their own special characters ( parenthesis, quotes, etc.)



and what if the parameter is not an integer, but a char* or a string? E.g., users’ guide has this example:

, and I want to pass the “text” into myMacro.C from another process. I.e., to create a variable, let’s say

, and pass it to myMacro.C, how do I do that with all these quotation marks?


root -l -b -q ‘myMacro.C("’${dateAndTime}’")’

Ok, that works, thanks!