
---- Modify Plot_v03 and use dispatcher&observers to loop over events ----

***
Download the "Utilities" package and install it somewhere, then 
add the corresponding path in the compilation:
cd ..../corsocxx
tar -xzf util.tgz
c++ -I ..../corsocxx

***
In "AnalysisSteering.h" remove the "process" function declaration.

***
In "EventDump.h,cc" and "EnergyDist.h.cc":
- include the Observer header
#include "util/include/ActiveObserver.h"
- inherit from "ActiveObserver<Event>" in addition to the existing base,
- rename the function "process" as "update".

***
In "EventReadFromFile.h", "EventSim.h" declare the "get" function as "private".

***
In "EventSource.h,cc":
- declare the "get" function as "private",
- declare and implement a "public" function "run",
- move the event loop from the "main" function to the new "run" function,
  and use "Dispatcher<Event>::notify" in the event loop.

***
Create a class "TotalEnergy" to compute total energy,
neglecting background subtraction:
- declare it to inherit from the template "Singleton" in the util directory,
- declare it to inherit from "LazyObserver",
- compute the sum of energy measurements in the "update" function,
- use float numbers for the sum, to allow future background subtraction,
- declare and implement a function "rawSum" to check for new events and 
  return the result.

***
Create a class "BGCalc" to compute the background:
- declare it deriving from the same bases as "EventDump.h" and "EnergyDist.h" 
  and implement the pure-virtual functions "beginJob", "endJob" and "update",
- declare as member variables the min and max energies, the min and max 
  number of points, the sums of energies and squares and the number 
  of selected events,
- in function "beginJob" initialize member variables, using 3000 and 5000
  as min and max energies, 100 and 120 as min and max points,
- in function "update" get the singleton-instance of "TotalEnergy" and 
  use the function "rawSum" retrieve the total energy, then update sums 
  and event counter if total energy is inside the min-max range, otherwise 
  neglect the event,
- in function "endJob" compute mean and rms and printout the results.

***
In "BraggStatistic.cc" remove the calculation of total energy and get it 
from "TotalEnergy", by getting the instance of it and calling "rawSum". 

***
Modify the "main" function and replace the event loop with a call to 
the "run" function in the "EventSource".


********* final list of functions *********

main                   modify Plot_v03

********* final list of classes   *********

                       .h                            .cc
AnalysisInfo           copy   Plot_v03               copy   Plot_v03
Event                  copy   Plot_v03               copy   Plot_v03
EventSource            modify Plot_v03               modify Plot_v03
EventReadFromFile      copy   Plot_v03               copy   Plot_v03
EventSim               copy   Plot_v03               copy   Plot_v03
SourceFactory          copy   Plot_v03               copy   Plot_v03
AnalysisSteering       modify Plot_v03               copy   Plot_v03
AnalysisFactory        copy   Plot_v03               copy   Plot_v03
EventDump              modify Plot_v03               modify Plot_v03
TotalEnergy            to complete                   to complete
EnergyDist             modify Plot_v03               modify Plot_v03
BraggStatistic         copy   Plot_v03               modify Plot_v03
BGCalc                 to complete                   to complete

