FAQ:How do I access and use unobservable statistics, like qEx?
From Daya Bay
Quick Config Example
A detector simulation job can be configured to record and store some Unobservable statistics. An quick example:
import DetSim ds = DetSim.Configure(physlist=DetSim.physics_list_basic+DetSim.physics_list_nuclear,site="dayabay", use_push_algs = False) ds.unobserver(stats=[ ["Depz", "qEz", "pdg == 22"], ["Edep", "qdE", "pdg == 22"], ])
In this example, qEz gives the quenched energy-weighted position of all gammas in an event in global coordinates, (zposition)*(energy deposited during that step), and qdE gives just the energy deposited per step. The range of possible variables are discussed in the offline manual.
Details
For details see the offline user manual section.
Reading Stored Statistics
To must determine which statistics to store at the time of running the simulation job (see above). Once you have simulation output with stored unobservable statistics you can load them into your analysis. An example in Python is:
from GaudiKernel import SystemOfUnits as units #### Retrieve simulation and truth data simhdr = evt['/Event/Sim/SimHeader'] # Get unobservables, generation vertex: statshdr = simhdr.unobservableStatistics() if statshdr : stats = statshdr.stats() if stats : zDepm = (stats["Depz"].sum()/(units.MeV*units.m)) / (stats["Edep"].sum()/units.MeV)
This example produces the variable 'zDepm' which will be the quenched-energy-weighted position of all gammas in an event. Note how the units are specified, for simple units and combinations of simple units.
Note, to see what units are defined in the code you can type the command:
pydoc GaudiKernel.SystemOfUnits