
---- Modify Dump_v2 and compute mean and rms invariant mass ----

The file contains data corresponding to events with different decaying 
particles (K0 and Lambda0), plus background events; signal events have 
exactly two particles, one positive and one negative. 
Compute mean and rms invariant mass selecting signal events with 
invariant mass between 0.490 and 0.505 Gev/c^2.

The invariant mass rms is computed from the difference of very similar
numbers (square of sum and sum of squares), so the limited precision has
a non negligible effect. To solve this problems apply one or both of the
following:
- use double precision variables for mass sums, mean and rms, as well as
  for all calculations,
- subtract the min. invariant mass (i.e. 0.490) from the computed mass 
  event by event, before updating the sums, and add it back to the mean
  after all the calculations.

Add four functions as described in the following.

***
Create two functions to compute energy or invariant mass from momentum 
x,y,z components plus invariant mass or energy, respectively. 
Both functions take 4 arguments: the first one takes the 3 momentum 
components plus the invariant mass and returns the energy, the second 
one takes the 3 momentum components plus the energy and returns the 
invariant mass.

***
Create a "mass" function taking as argument a reference to const-Event 
and returning the invariant mass of the decaying particle. 
Use the following variables:
- 2   int variables to count negative and positive particles, 
- 3 float variables for the 3 sums of the momentum components,
- 2 float variables for the total energy sums, for the hypotheses of a 
  decaying K0 or Lambda0,
- 2 float variables for the invariant masses, for the hypotheses of a 
  decaying K0 or Lambda0.
Use a typedef to declare pointers to const-Particle structs.
Loop over the particles, and for each one:
- increase the corresponding counter, according to charge,
- increase the 3 momentum components sum,
- compute particle energy for the hypothesis of a decaying K0, 
  using the function described above and giving as arguments the 3 momentum 
  components and the pion mass,
- compute particle energy for the hypothesis of a decaying Lambda0, 
  using the function described above and giving as arguments the 3 momentum 
  components and the pion mass for a negative particle or proton mass 
  for a positive particle,
- update the total energy sum for both the K0 and Lambda0 hypotheses.
Check the number of positive and negative particles, and return a
negative (unphysical) value if one of the two is different than one. 
Compute the invariant mass for both the K0 and Lambda0 hypotheses, and 
compute the difference of each one with the known mass of the K0 or Lambda0 
respectively. Return the invariant mass for which the corresponding 
difference is the smallest.

***
Create a function "add" taking as arguments:
- a reference to const-Event,
- two float for min and max invariant mass
- two references to double for the sum of invariant masses
  and the the sum of squares,
Inside the function compute the invariant mass of the decay particle, 
using the "mass" function described above. 
If the mass is comprised between the minimum and maximum increase the sums 
of masses and squares, otherwise leave those sums unchanged.
Return true or false if the mass was in the range or not, respectively.
If you chose to subtract the min. mass event by event, use the same
parameter used to select events inside the mass range.

***
Modify the main function as follows.
Add 5 variables:
- one to contain the number of accepted events,
- one to contain the sum of invariant masses,
- one to contain the sum of squares of invariant masses,
- one to contain the mean invariant mass,
- one to contain the rms  invariant mass.
In the event loop call the "add" function, using 0.490 and 0.505 as 
min and max invariant mass; disable the call to the "dump" function 
with "//", if you prefer.
Compute the number of events by increasing the counter according to 
the return value of the "add" function.
Compute mean and rms mass from the sum of masses and squares and 
print the results on the screen.

********* final list of files/functions *********

main                   modify Dump_v2
struct Event           copy   Dump_v2
read                   copy   Dump_v2
clear                  copy   Dump_v2
dump                   copy   Dump_v2
mass                   to complete
add                    to do

