Project

General

Profile

Feature #445

Simulation examples

Added by Rogers, Chris over 12 years ago. Updated almost 11 years ago.

Status:
Open
Priority:
Normal
Assignee:
Category:
Simulation
Target version:
Start date:
11 May 2011
Due date:
14 November 2011 (over 12 years late)
% Done:

0%

Estimated time:
Workflow:
Under Review

Description

Some simulation examples would be useful. Would make sensible system tests.

#1

Updated by Tunnell, Christopher over 12 years ago

is this not bin/simulate_mice.py?

I view our job as providing the data and being clear on the format until we have enough manpower to teach people how to plot/analyze the data.

#2

Updated by Rogers, Chris over 12 years ago

You just requested this for virtual planes...

#3

Updated by Tunnell, Christopher over 12 years ago

Sorry, I wasn't clear (hence sounding contradictory). The problem with millions of emails going around.

It would be nice to have an example of driving the virtualplanes application so that only virtual plane information is in mausput.

#4

Updated by Rogers, Chris over 12 years ago

In the end I put virtual planes in the main stepping action again. So this just works the way it did before (but much more testing).

#5

Updated by Rogers, Chris over 12 years ago

  • Target version changed from Future MAUS release to MAUS-v0.1.0
#6

Updated by Rogers, Chris about 12 years ago

  • Due date set to 14 November 2011
  • Assignee changed from Rogers, Chris to Heidt, Christopher

Pushed to Heidt. Note deadline is two weeks time. Quite tight, see how far you get. I'll make a list of typical settings to try...

#7

Updated by Rogers, Chris about 12 years ago

First thing - just try setting up a beam, tracking through MICE step 4, making plots of particles. Use xboa to make the plots. Make sure you update to the trunk first as several changes in the last couple of days (like inclusion of argparse routine).

#8

Updated by Heidt, Christopher about 12 years ago

Just wanted to update one where I am on this.

First off, I want to make sure I understand what you are asking for. Will running simulate_mice.py with the proper setup in ConfigurationDefaults.py produce the beam and all the data I need for running through xboa? Will there be any other programs to run or code to include/change in the course of this?

Going into this I didn't know anything about xboa. I'm sure it must be in the MAUS code somewhere, but I decided to just download it from the sourceforge link. I followed the included README and it looks like it was installed, but there are some issues:

(1) The test does not seem to exist, trying to import xboa.test.Boa_Test produces an error "ImportError: No module named Boa_Test"

(2) Running Example_1 I get a message "MatPlotLib not detected - matplotlib graphing functions will not be available". I know MatPlotLib is installed and when running Example_4 I get a series of plots popping up, so I'm not sure what is up with this.

(3) Xboa does not run on its own, I have to run source MAUS's env.sh to get it to run at all.

I hope to make some movement on these fronts tomorrow, any input would be welcomed.

#9

Updated by Tunnell, Christopher about 12 years ago

Are you using the 'trunk' (ie. what you get when you follow the developer instructions on how to install)?

If you run:

bzr merge lp:maus

it shouldn't say anything. I just ask what you are using because I think xboa is in the trunk (ie. lp:maus). If you click the repository link on this website you should see what the most recent code looks like and you check to see if you have those changes.

#10

Updated by Heidt, Christopher about 12 years ago

I'm simulating the beam and Stage 4 geometry using bin/simulate_mice.py which is producing a host of files: center.dat, end1.dat, end2.dat, focus.dat, match1.dat, and match2.dat which I know nothing about. It is also producing simulation.out which seems to be a JSON file with all the information in it.

I do not know how to use xboa, I'm trying to go through the examples, but right now it is a bit daunting. To be sure, is the file I should be using for xboa that simulation.py file?

Also I noticed a very weird error(?) in my copy of MAUS. Rather than installing xboa at /home/chris/maus/third_party/install/share my copy is installed at /home/chris/maus/third_party/home/chris/maus/third_party/install/share

Is it possible something is goofy with the setup scripts?

#11

Updated by Rogers, Chris about 12 years ago

Daunting - just have to clench your teeth and have a go. Simulation makes a "simulation.out" file. Try loading that into xboa, using a python script like:

import xboa.Common
import xboa.Bunch
from xboa.Bunch import Bunch

print 'xboa version', xboa.Common.xboa_version
bunch = Bunch.new_from_read_builtin('maus_primary', 'simulation.out')
(x_canvas, x_hist) = bunch.root_histogram('x', 'mm') #make a histogram of primaries in x, units mm
(xy_canvas, xy_hist) = bunch.root_histogram('x', 'mm', 'y', 'mm') #make a 2d histogram of primaries in x, units mm
print "Press <Enter> to finish" 
raw_input() # wait for carriage return

If you add some virtual planes, you can start plotting e.g. beta function etc along the beamline:

import xboa.Common
import xboa.Bunch
from xboa.Bunch import Bunch

bunch_list = Bunch.new_list_from_read_builtin('maus_virtual_hit', 'simulation.out') # NOTE *new_list*_from_read_builtin means it makes a list of bunches
beta_canvas, beta_hist, beta_graph = Bunch.root_graph(bunch_list, 'mean', ['z'], 'beta', ['x', 'y'])

print "Press <Enter> to finish" 
raw_input() # wait for carriage return
#12

Updated by Rogers, Chris about 12 years ago

Also I noticed a very weird error(?) in my copy of MAUS. Rather than installing xboa at /home/chris/maus/third_party/install/share my copy is installed at
/home/chris/maus/third_party/home/chris/maus/third_party/install/share

This is indeed a screw up in the setup scripts, in fact know for some while. I just haven't had a chance to fix it yet.

#13

Updated by Rogers, Chris about 12 years ago

Any progress? Should I move the due date?

#14

Updated by Heidt, Christopher about 12 years ago

I have a simple tutorial written that I had hoped to finish today, however, it doesn't look like I'll have to time to complete it. A rough ETA on when I'll have it up is ~16 hours, sometime early tomorrow PST.

I have written a .bash file to run some python scripts, which I have place in a tutorial folder in the main MAUS directory. I am envisioning a first tutorial that will take the user through some basic operations.

#15

Updated by Heidt, Christopher about 12 years ago

I've uploaded some files to my branch that should serve as an outline for what I want to do with the tutorial. There is much more that should be done with it, but I think this will make a good starting point.

#16

Updated by Tunnell, Christopher about 12 years ago

lp:~cheid001/maus/devel ?

#17

Updated by Heidt, Christopher about 12 years ago

yes, I checked my launchpad profile, it was available.

#18

Updated by Rogers, Chris about 12 years ago

Great - had a look. Well done for getting everything running. Comments:

  • Better not to use paths relative to ./ - you don't know where someone is calling the script from. So your code will I think break if I do e.g. bash tutorial/tutorial.bash. Use paths relative to MAUS_ROOT_DIR instead
  • Can you put this in ${MAUS_ROOT_DIR}/doc/tutorial please?
  • Can you check for correct output? The return code for your call would be "$?" environment variable. Better still, stick everything after source env.sh into one python script (subprocess.Popen() is useful here), then use subprocess function calls to extract return value. If any of the subroutines doesn't execute properly, return a non-zero exit code. I want to check that the tutorials run okay in the test scripts (so I don't accidentally release code with broken tutorial).
  • Can you print output images in a directory like tests/integration/plots/tutorial? Use x_canvas.Print('my_folder/my_file.png')
  • You should put python scripts in a sub function like:
    def main():
      some code
    
    if __name__ == "__main__":
       main()
    
  • I think we need to add some virtual planes so that we can print some output... try looking in doc/run_control/MiceModule.pdf. Ask if it's not obvious. Then do "maus_virtual_hit".

Once you've done that I can do a merge.

#19

Updated by Rogers, Chris about 12 years ago

  • Target version changed from MAUS-v0.1.0 to Future MAUS release
#20

Updated by Rogers, Chris about 12 years ago

  • Workflow set to Under Review
#21

Updated by Rogers, Chris about 11 years ago

  • Assignee changed from Heidt, Christopher to Rogers, Chris
#22

Updated by Rogers, Chris almost 11 years ago

Humm, working on it... blocked by xboa problem

#23

Updated by Rogers, Chris almost 11 years ago

I had a go at fixing this but got hung up on #1152 - so now addressing that

Also available in: Atom PDF