SoftwareHints » History » Revision 6
Revision 5 (Dobbs, Adam, 02 February 2013 16:45) → Revision 6/17 (Dobbs, Adam, 02 February 2013 17:15)
h1. Software Hints and Tips h2. Running a tracker simulation There is a dedicated directory holding top level scripts for producing tracker data within MAUS at: <pre> bin/user/scifi </pre> For example to run a MAUS simulation of the tracker in the presence of a magnetic field do the following from the MAUS root directory: <pre> source env.sh cd bin/user/scifi ./simulate_scifi.py --configuration_file datacard_mc_helical </pre> The equivalent command for no magnetic field (straight tracks) is: <pre> ./simulate_scifi.py --configuration_file datacard_mc_straight </pre> h2. Datacard variables 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 h2. Accessing the output data Data is output by MAUS either as "ROOT":http://root.cern.ch/ or JSON documents. In order for ROOT to understand the classes we have written, written a ROOT dictionary, built automatically by MAUS, MAUS must first be loaded. In an interactive ROOT session this done with following command: <pre> .L $MAUS_ROOT_DIR/build/libMausCpp.so </pre> The equivalent command if using "PyROOT":http://root.cern.ch/drupal/content/pyroot is <pre> import libMausCpp </pre> An example ROOT session to open a data file would be: <pre> > .L $MAUS_ROOT_DIR/build/libMausCpp.so > TFile f1("maus_output.root") > TBrowser b </pre> The equivalent PyROOT session would be: <pre> >>> from ROOT import * >>> import libMausCpp >>> f1 = TFile("maus_output.root") >>> b = TBrowser() </pre> The tracker MC data can then be found by browsing to: <pre> Spill:data:_spill:_mc:_sci_fi_hits </pre> The reconstructed data is stored under: <pre> Spill:data:_spill:recon:_scifi_event </pre> An example PyROOT session to access some data: <pre> >>> from ROOT import * >>> import libMausCpp >>> f1 = TFile("maus_output.root") >>> t1 = f1.Get("Spill") >>> t1 <ROOT.TTree object ("Spill") at 0x8bfa970> >>> 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()[0] >>> sfevt = revt.GetSciFiEvent() >>> sfevt <ROOT.MAUS::SciFiEvent object at 0x9310cb0> >>> htrks = sfevt.helicalprtracks() >>> htrks.size() 2L >>> seeds = htrks[0].get_spacepoints() >>> seeds.size() 5L >>> sp = seeds[0] >>> sp.get_position().x() 8.468833333333333 >>> </pre>