GROG Meeting
(meeting of the groggy?)
September 6,2001
Disclaimer:
I don't know anything about object oriented programming or ROOT.
Everything I will show you has been copied out of various parts of the ROOT User Guide and web pages.
I
will not be offended when you point out that I have made things
hopelessly more complicated than they need to be...
First, Some History:
On SLD (my previous experiment) we used a program known as IDA (Interactive Data Analysis) which, coincidentally, was authored by Toby Burnett. It contained an IDAL interpreter which allowed users to write macros for performing data analysis.
IDAL is/was not a standard programming language and is/was relatively simple
It allowed for calling compiled (and linked) Fortran (=prepmort in SLD) routines
Macros tended to grow and become unwieldy
Converting macros to Fortran code required rewriting completely
But
I learned to love it and refused to convert to PAW along with the
rest of the world
On
GLAST (my current experiment) we use a program known as ROOT which has
been authored by some people that know Toby Burnett... It contains an
interpreter which purports to allow the use of c++ macros with the
promise that, as the analysis becomes more sophisticated, the macros can
be compiled without any need to rewrite them.
What I have discovered so far:
Macros can quickly grow and become unwieldy
My macros mostly resemble poorly written c code and do not look at all like c++ (mostly)
It requires a lot of discipline to write your macros in a manner which allows them to be compiled easily when it becomes necessary
I have tried hard (recently) to pretend to write macros in c++
But
I must admit that I haven't (yet) been completely successful at linking
my code into a real ROOT analysis...
Some examples (all using the pdr ntuple):
My first example is effectively a clone of the macros from the Balloon analysis
The second example is an attempt to make a more c++ like macro which can be used by other macros
Its output is the PSF:
with entries selected by a TCut
with automatic scaling of the x axis (max x is 95% containment point)
with the integral of the psf overlaid
and the 68% and 95% crossing points output
The output from the above example is here
An example of its reusability is here
It
is a brute force macro... basically it first defines a histogram
with a very large range on the x axis (and lots of bins to maintain
some granularity). A first pass is made to find the 95% containment
point, done by integrating the psf plot outward from zero.
Then
My
final example (for today) is my approach to solving a particular problem
encountered when trying to apply the energy and angle dependent
"Jose Cuts." I couldn't figure out how to craft a TCut (or
series of them) which could be functions of more than one tuple
variable.
For example, the cut I want to apply is:
Float_t CutVal(bool top, Float_t kalEne, Float_t zDir)
{
Float_t tolerance = -1;
if (kalEne > 0)
{
//Determine the energy and angle dependent tolerance
Float_t
kalFit;
if (!top) {kalFit = (2.8 /kalEne) + (2.1 /sqrt(kalEne));}
else
{kalFit = (6.35/kalEne) + (3.75/sqrt(kalEne));}
kalFit = - (0.001*kalFit) / zDir;
tolerance = 3.5 * kalFit;
}
return tolerance;
}
Where
kalEne and zDir are tuple variables. The cut is applied by comparing the
returned tolerance to the tuple variables in question...
What
I decided to do in the end was to extract the tuple variables into local
variables where I could work with them. I decided to abstract the event
loop part (the extraction of the variables, if you like) into their own
class. This class is found here. This
particular method of doing this
An
example analysis macro which uses this class is here
(which uses a plotting macro located here).
An example macro which ties it all together is here. Some features:
The class which extracts the variables is instantiated with the input file name,
The particular analysis class is instantiated
The analysis proceeds by starting a while loop which will stop when there are no more events to read.
Inside the loop the analysis class is called with a pointer to the class containing the tuple varialbes.
When
the last event is read the analysis class outputs its plots
An
example of the output is given here.
An
interesting feature is that this seems to run MUCH faster than the
macros which repeatedly use the Draw method of TTree. This based solely
on time waiting for results on my laptop pc.
Current plans are to modify the PSF class described above to work with the local tuple variables just described. But it would be much easier if someone knew how to solve the TCut problem I had so I didn't have to do this...