Project

General

Profile

SoftwareHints » History » Version 15

Dobbs, Adam, 27 June 2014 12:10

1 1 Dobbs, Adam
h1. Software Hints and Tips
2
3
h2. Running a tracker simulation
4
5
There is a dedicated directory holding top level scripts for producing tracker data within MAUS at:
6
7
<pre>
8
bin/user/scifi
9
</pre>
10
11 7 Dobbs, Adam
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:
12 1 Dobbs, Adam
13
<pre>
14
source env.sh
15
cd bin/user/scifi
16
./simulate_scifi.py --configuration_file datacard_mc_helical
17
</pre> 
18
19
The equivalent command for no magnetic field (straight tracks) is:
20
21
<pre>
22
./simulate_scifi.py --configuration_file datacard_mc_straight
23
</pre>
24
25
h2. Datacard variables
26
27
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: 
28
29
* 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'.
30
* 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:
31
** 'binomial_n' is the number of attempts at generating a track
32 2 Dobbs, Adam
** 'binomial_p' is the probability an attempt succeeds
33
* Helical pattern recognition can be turned on or off by setting 'SciFiHelicalPROn' to 1 or 0 respectively
34
* Straight pattern recognition can be turned on or off by setting 'SciFiStraightPROn' to 1 or 0 respectively
35 1 Dobbs, Adam
36
h2. Accessing the output data
37
38 15 Dobbs, Adam
Example ROOT and PyROOT scripts for accessing the data are available "here":http://micewww.pp.rl.ac.uk/documents/89
39 11 Dobbs, Adam
40
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:
41 1 Dobbs, Adam
42
<pre>
43
.L $MAUS_ROOT_DIR/build/libMausCpp.so
44
</pre>
45
46
The equivalent command if using "PyROOT":http://root.cern.ch/drupal/content/pyroot is 
47
48
<pre>
49
import libMausCpp
50
</pre>
51
52
An example ROOT session to open a data file would be:
53
54
<pre>
55
> .L $MAUS_ROOT_DIR/build/libMausCpp.so
56
> TFile f1("maus_output.root")
57
> TBrowser b
58
</pre>
59
60
The equivalent PyROOT session would be:
61
62
<pre>
63 5 Dobbs, Adam
>>> from ROOT import *
64
>>> import libMausCpp
65
>>> f1 = TFile("maus_output.root")
66
>>> b = TBrowser()
67 1 Dobbs, Adam
</pre>
68
69 5 Dobbs, Adam
70 2 Dobbs, Adam
The tracker MC data can then be found by browsing to:
71
<pre>
72
Spill:data:_spill:_mc:_sci_fi_hits
73
</pre>
74 1 Dobbs, Adam
75
The reconstructed data is stored under:
76
<pre>
77
Spill:data:_spill:recon:_scifi_event
78 5 Dobbs, Adam
</pre>
79
80
An example PyROOT session to access some data:
81
82
<pre>
83
>>> from ROOT import *
84
>>> import libMausCpp
85
>>> f1 = TFile("maus_output.root")
86
>>> t1 = f1.Get("Spill")
87
>>> t1
88
<ROOT.TTree object ("Spill") at 0x8bfa970>
89 13 Dobbs, Adam
>>> t1.Draw("_spill._recon._scifi_event._scifitracks._f_chi2")
90 5 Dobbs, Adam
>>> data = MAUS.Data()
91
>>> t1.SetBranchAddress("data", data)
92
>>> t1.GetEntry(1)
93
51435
94
>>> spill = data.GetSpill()
95
>>> spill
96
<ROOT.MAUS::Spill object at 0x92f4a40>
97
>>> spill.GetReconEvents().size()
98
1L
99
>>> revt = spill.GetReconEvents()[0]
100
>>> sfevt = revt.GetSciFiEvent()
101
>>> htrks = sfevt.helicalprtracks()
102
>>> htrks.size()
103
2L
104 12 Dobbs, Adam
>>> spoints = htrks[0].get_spacepoints_pointers()
105
>>> spoints.size()
106 5 Dobbs, Adam
5L
107 12 Dobbs, Adam
>>> sp = spoints[0]
108 5 Dobbs, Adam
>>> sp.get_position().x()
109 1 Dobbs, Adam
8.468833333333333
110
</pre>
111 8 Dobbs, Adam
112
h2. Running the tests
113
114
All branches should pass the testing framework before being pushed up to launchpad.  The full set of tests can be run with:
115
116
<pre>
117
./tests/run_tests.bash
118
</pre>
119
120
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:
121
122
<pre>
123
python tests/style/test_cpp_style.py
124
</pre>
125
126
The python style test can be run with:
127
128
<pre>
129
python tests/style/test_python_style.py
130
</pre>
131
132
The unit tests (which include the cpp style check but not the python style check) can be run with:
133
134
<pre>
135
./tests/unit_tests.bash
136
</pre>
137
138 9 Dobbs, Adam
An individual cpp unit test module can also be run. For example, to run just the Pattern Recognition unit tests:
139
140
<pre>
141
build/test_cpp_unit --gtest_filter=PatternRecogntionTest.*
142
</pre>
143
144 8 Dobbs, Adam
Once these all pass, make sure you run full test suite before pushing to launchpad if you have made any significant code changes.
145 10 Dobbs, Adam
146
The MAUS documentation for unit tests can be found on the [[maus::Unit tests|MAUS wiki]].