This project has moved and is read-only. For the latest updates, please go here.

Some "external developer" walkthrough/feedback on adding a new detector to the Vts

Oct 13, 2011 at 4:15 AM

Thought I'd briefly document here the current user-developer story for extending the VTS, in the case of adding a new detector type for Monte Carlo simulation. (This is just for NEW types - there are plenty of types already implemented, some of which are listed here)

Assume Q is a new spiffy measurement axis, and you want to measure R(q, t). Here's what to do, roughly:

1) Add a new enum type, ROfQAndTime, Vts.MonteCarlo.Enums.TallyType

2) Implement class ROfQAndTimeDetector in namespace Vts.MonteCarlo.Detectors

3) Implement class ROfQAndTimeDetectorInput in namespace Vts.MonteCarlo.DataStructures.DetectorInputs

4) Add ROfQAndTimeDetector as a new known type in class Vts.IO.KnownTypes

5) Add ROfQAndTimeDetectorInput as a new known type at the top of class Vts.MonteCarlo.DataStructures.SimulationInput

6) Add the appropriate entries in class Vts.MonteCarlo.Extensions.DetectorExtensionMethods (eg. IsReflectanceTally, IsCylindricalTally, etc)

7) Add a new switch statement case for TallyType.ROfQAndTime in GetDetector method of class Vts.MonteCarlo.Factories.DetectoryFactor

8) Create your new XML SimulationInput template, "yourname_ROfQAndTime.xml"  that describes the DetectorInput class you just coded

All of this manual work is a little annoying but there are at least plenty of existing examples to emulate. Eg.

- ROfRhoAndOmega returns complex numbers,

- FluenceOfRhoAndZAndTime has lots of axes,

- DetectorBinning has some pre-fab "WhichBin" methods to use to find the right bin for your ROfQAndTimeDetector.Tally method

- we provide XML input templates from the "mc.exe geninfiles" command

Finally, just to be safe, always use our mc.exe executable to "filter" your new-fangled XML file. (Sometimes, it's hard to get the XML format just right, and this can lead to "silent" issues with mc.exe not reading the input correctly.

For example, with a small number (N=100) of photons,

1) call "mc.exe infile=yourname_ROfQAndTime.xml" and

2) use the COPY of this file, which gets saved in your results directory, as the new template

Nov 3, 2011 at 8:10 PM

A few more items for implementing your own detector:

9) Ensure Vts.MonteCarlo.IO.DetectorIO.WriteDetectorToFile has the appropriate case for your data structure (the basic 0-3D double and Complex cases are covered)

10) Add the appropriate switch statements to DetectorIO.ReadDetectorFromFile and DetectorIO.ReadDetectorFromFileInResources

11) Optional (but helpful) - modify the "loadMCResults.m" and "load_results_script.m" Matlab helper files to import your new detectors.

May 6, 2012 at 11:39 PM

Also need to keep Vts.Desktop updated with links to Vts.MonteCarlo.Detectors and Vts.MonteCarlo.DataStructures.DetectorInputs.