Software Hints and Tips¶
A presentation giving a tracker software "How To", covering general code design, where things are found, how to run a simulation, and access and analyse output data, is available at:
Running a tracker simulation¶
There is a dedicated directory holding top level scripts for producing tracker data within MAUS at:
For example to run a MAUS simulation of the tracker in the presence of a magnetic field (helical tracks) do the following from the MAUS root directory:
source env.sh cd bin/user/scifi ./simulate_scifi.py --configuration_file datacard_mc_helical
The equivalent command for no magnetic field (straight tracks) is:
./simulate_scifi.py --configuration_file datacard_mc_straight
Datacard variables control the various parameters passed to MAUS. The variables assume the default values set in src/common_py/ConfigurationDefaults.py unless overridden in a datacard or elsewhere. Here are a few common variables:
- Number of spills. The number of spills to simulate can be set by editing the relevant datacard file and changing the variable 'spill_generator_number_of_spills'.
- The number of particles per spill is controlled by the beam variable. This has a number of sub-variables, two of which can be set to alter the number of particles per spill:
- 'binomial_n' is the number of attempts at generating a track
- 'binomial_p' is the probability an attempt succeeds
- Helical pattern recognition can be turned on or off by setting 'SciFiHelicalPROn' to 1 or 0 respectively
- Straight pattern recognition can be turned on or off by setting 'SciFiStraightPROn' to 1 or 0 respectively
Accessing the output data¶
Example ROOT and PyROOT scripts for accessing the data are available here
In order for ROOT to understand the classes we have written, a ROOT dictionary, built automatically by MAUS, must first be loaded. In an interactive ROOT session this done with following command:
The equivalent command if using PyROOT is
An example ROOT session to open a data file would be:
> .L $MAUS_ROOT_DIR/build/libMausCpp.so > TFile f1("maus_output.root") > TBrowser b
The equivalent PyROOT session would be:
>>> from ROOT import * >>> import libMausCpp >>> f1 = TFile("maus_output.root") >>> b = TBrowser()
The tracker MC data can then be found by browsing to:
The reconstructed data is stored under:
An example PyROOT session to access some data:
>>> from ROOT import * >>> import libMausCpp >>> f1 = TFile("maus_output.root") >>> t1 = f1.Get("Spill") >>> t1 <ROOT.TTree object ("Spill") at 0x8bfa970> >>> t1.Draw("_spill._recon._scifi_event._scifitracks._f_chi2") >>> data = MAUS.Data() >>> t1.SetBranchAddress("data", data) >>> t1.GetEntry(1) 51435 >>> spill = data.GetSpill() >>> spill <ROOT.MAUS::Spill object at 0x92f4a40> >>> spill.GetReconEvents().size() 1L >>> revt = spill.GetReconEvents() >>> sfevt = revt.GetSciFiEvent() >>> htrks = sfevt.helicalprtracks() >>> htrks.size() 2L >>> spoints = htrks.get_spacepoints_pointers() >>> spoints.size() 5L >>> sp = spoints >>> sp.get_position().x() 8.468833333333333
Running the tests¶
All branches should pass the testing framework before being pushed up to launchpad. The full set of tests can be run with:
This can take quite a while to run however. Running smaller sections of the tests first will generally save you time. Two common places where test errors creep in are in cpp style and python style checks. The cpp style test can be run on its own with:
The python style test can be run with:
The unit tests (which include the cpp style check but not the python style check) can be run with:
An individual cpp unit test module can also be run. For example, to run just the Pattern Recognition unit tests:
Once these all pass, make sure you run full test suite before pushing to launchpad if you have made any significant code changes.
The MAUS documentation for unit tests can be found on the MAUS wiki.
There is currently a directory in the MAUS Software package, src/common_py/analysis, which is designed to hold useful little analysis functions and classes for python analysis scripts.
At present it is still quite a small directory, containing classes to help calculate covariance matrices and load/save root data, etc. Have a look through and if you think something else would be useful - add it! This will hopefully allow all developers to have access to the same little tricks that we all find useful.