Splitting up a plotting macro

Hello,

I have written many little plotting scripts which I call from the command line

root [0] .x plot.C
which simply loads up the ntuples, declares a histograms, and creates a ps file. But there are large chunks that I cut-and-paste for every plotting script. I’d like to convert the chunk into something like

string convert_mode_to_string(Int_t mode){ switch(mode){ case 0: return "thismode" ; break ; default: return "thatmode" ; break ; } }

and call convert_mode_to_string() from my script which I call from root. I am not quite sure how this works with the macro interface. I would be grateful if someone can point to an example where such things are done.

thanks,

Tae Min Hong

Hi,

I am not sure I fully understood your question. However my best guess is that you need to use a named macro instead of an unnamed macro. In a named macro you can just use the full C++ syntax including declaring and implementing functions. See the User’s Guide for more details and look at $ROOTSYS/tutorials/hadd.C for one example.

Cheers,
Philippe.