Creating an automated plotting function

hello people,

my research partner and i are constructing a program to analyse some data. there are a lot of histograms to compare to each other and we’ve decided on constructing a function to book, fill, and write histograms once a variable type has been passed by argument.

the idea is to avoid the necessity to hard-code histogram information - title, range, binning and axis labels. we’ve created a separate class containing arrays with set information to be passed to the “plots()” function. the problem is how to correctly assign histograms to their relevant variable.

below is a rough idea of what we’re trying to do:


bool cut1 = /* variable */ < /*some value*/;

if (cut1 == 1){
                     plots(/*variable*/)
                     }
.
.
.

plots(/*argument*/)
{

if (/*some requirement*/}
{
/*book plots*/
}
else if (/*some further requirement)
{
/*fill plots*/
}
else
{
/*write plots*/
}

we were wondering if there were any suggestions as to our problem; any insights would be very helpful. thanks for your time.

ROOT is doing this automatically for you
-giving an expression of one or more variables
-an optional expression of cuts (or combination)
-automatic binning

Rene

hi rene,

thanks for the response. we’ve already used ROOT to successfully book, fill and draw histograms with cuts applied.

the aim is to create a function that can take a variable - say sum of distance of closest approach - as an argument and correctly assign the variable to predefined histograms. basically we are trying to find a way to get around hard coding axis titles etcetera each time we want to change a variable.

hope this makes it a bit clearer as to what we’re up to.

If you execute

tree.Draw("myvar","mycut");
the plot generated will have myvar in the X axis title, and myvar {mycut} in the title.

Rene