Research: The code of the ken for the asymmetry

Hi All,
During the last FROST call there were various claims made about root not being able to handle errors correctly when scaling, adding, subtracting histograms, and in particular getting the asymmetry of 2 histograms. I suggested that it was incorrect use that was the problem, and volunteered to send round some example code on how to do asymmetries. The code is at: http://nuclear.gla.ac.uk/~kl/g8b/linpol/asym_example.C The comments at the top of the code explain how to run it. A gif file showing the output and arguments used is at http://nuclear.gla.ac.uk/~kl/g8b/linpol/asym_example.gif

The aim here is to illustrate how to extract photon asymmetry using root. I've tried to write it as a well commented example for inexperienced root users. It also allows users to try various binning and statistics options to see what accuracy an extracted asymmetry is likely to have for any set of pol,para and amo statistics.

Here's some explanation:

In general, for some channel where we want to measure the photon asymmetry we'll have some phi distributions from PARA, PERP and AMO running, cut on a specific range of photon energies.
If we wish to compare these histograms, we have to normalise them in some way - the best way is by counting the number of photons in the required energy range to get npara, nperp and namo. Eg. in root to scale perp to be the same as para perpHist->Scale(npara/nperp) ... etc.
If is assumed from here on in that we refer to normalised histograms like that.
The photon asymmetry can be found
a) by dividing the para or per histogram by the amo histogram,
or
b) by taking the para-perp/para+perp histograms
The ideal method is b).
In the general situation where the polarization is different (but known) for para and perp the asymmetry has the form:
para-perp / para+perp = (Ppara + Pperp) * sigma * cos (2 phi) / [ 2 + (Ppara - Pperp) * sigma * cos (2 phi) ]
which in the case of Ppara=Pperp=P reduces to the better known:
para-perp / para+perp = P * sigma * cos (2 phi)
However, using method a) is also valuable, particularly where there are high statistics and data can be binned in small photon energy bins. The sample code generates para,perp and amo data sets for a given sigma (asym) and set of conditions, and them calculates the photon asymmetry in the 3 different possible ways.
As far as the errors go, I have not done any rigorous examination, but the error bars and chisq for the fits all look correct to me for a wide range of tested input parameters.
Of course the photon asymmety can also be found from a moment analysis, or a likelihood analysis - but neither of these is shown in the example.
Ken