Table Of Contents

Previous topic

Cheat Sheet

Next topic

Genie Hints

This Page

gnomon Package

On this page, the code related to the infrastructure of gnomon will be discussed which is mostly contained in the base of the gnomon package. Please see the User Documentation for information on the processors.

At a basic level, the core of gnomon is either code to satify Geant4 interfaces (EventActions, etc.) or internal bookkeeping (configuration, etc.).

Configuration Module

Manage how gnomon configures itself and its proceesors

This class is used within gnomon to tell various classes how to configure themselves. Each Configuration class will generate or retrieve a JSON file that is used afterwards by various other classes.

Any proposed configuration JSON file is compared against a configuration schema. The schema requires certain attributes be specified in order to start gnomon. The schema checker is forgiving in that new configuration keys are allowed without changing the schema; the schema only requires certain things be defined, it doesn’t prevent you from defining new things.

Any new configuration must inherit from ConfigurationBase.

class gnomon.Configuration.ConfigurationBase(name, run, overload=None)

Base class for all configuration classes

If the run number is zero, replace it with a random run number

get_configuration_dict()

Return configuration as a dictionary

set_json(config_json)

Permanently set the JSON configuration

Unable to call twice.

gnomon.Configuration.DEFAULT

alias of LocalConfiguration

class gnomon.Configuration.LocalConfiguration(name, run=0, overload=None, filename='ConfigurationDefaults.json')

Read a configuration from disk and overload if necessary

class gnomon.Configuration.MockConfiguration(name, run=0, overload=None, filename='ConfigurationDefaults.json')

Mock configuration for testing

This is just a copy of LocalConfiguration for now

gnomon.Configuration.fetch_config(filename)

Fetch the Configuration schema information

Finds the schema file, loads the file and reads the JSON, then converts to a dictionary that is returned

gnomon.Configuration.get_data_dir()

Find the data directory that stores geometries, cross sections, etc.

gnomon.Configuration.get_log_dir()

Find the directory used for saving log files

gnomon.Configuration.get_source_dir()

Find where the truth path to the directory containing the Configuration module source code

It can be useful to know the full path to the Configuration module’s source code in order to try to guess where the data and log files are stored. It does this by inspecting the current running python instance.

gnomon.Configuration.populate_args(parser)

Add commandline arguments to parser from schema

gnomon.Configuration.populate_args_level(schema, parser)

Use a schema to populate a command line argument parser

DetectorConstruction Module

Construct a detector within Geant4

This module deals with creating detectors (geometries, sensitive detectors, etc.) and interfacing them with Geant4. There is, for example, a class that loads geometries from GDML.

TODO: can box construction and calorimeter construction be superclassed? Ideally with superclass handling the Geant4 interface and the subclasses tweaking the detector for their specific need.

class gnomon.DetectorConstruction.BoxDetectorConstruction(name)

Create a cuboid geometry of uniform material

Useful for testing particle interactions with uniform materials

Construct()

Construct a cuboid from a GDML file without sensitive detector

class gnomon.DetectorConstruction.MagIronSamplingCaloDetectorConstruction(field_polarity)

Create a magnetized iron sampling calorimeter

Construct()

Construct nuSTORM from a GDML file

get_sensitive_detector()

Return the SD

EventAction Module

The EventAction is used by Geant4 to determine what to do before and after each MC event.

class gnomon.EventAction.EventAction(processor_names)

A Geant4 interface that subclasses G4UserEventAction and runs processors over Geant4 events

BeginOfEventAction(event)

Save event number

EndOfEventAction(event)

At the end of an event, grab sensitive detector hits then run processor loop

setSD(sd)

Hook to the sensitive detector class

User for fetching hits from sensitive detector to pass to processor loop

shutdown()

Shutdown each processor

GeneratorAction Module

Generator actions

These classes are used to tell Geant4 what particles it is meant to simulate. One always has to inherit from a UserPrimaryGeneratorAction base class in Geant4 and then define the function GeneratePrimaries.

class gnomon.GeneratorAction.Distribution(some_obj)
dist()
get()
get_cache()
is_static()
set_cache(value)
class gnomon.GeneratorAction.Generator(position, momentum, pid)

Generator base class

set_momentum(momentum)
set_pid(pid)
set_position(position)
class gnomon.GeneratorAction.GenieGenerator(position, momentum, pid)

Generate events from a Genie ntuple

A Genie ntuple that already knew the GDML would be useful. Otherwise, we run gevgen per material and have to do nasty geometry stuff here

generate()
class gnomon.GeneratorAction.GnomonGeneratorAction(generator)

Geant4 interface class

GeneratePrimaries(event)
setMCInfo(info)
class gnomon.GeneratorAction.ParticleGenerator(position, momentum, pid)

Baseclass for gnomon particle generators

generate()
class gnomon.GeneratorAction.composite_z(config)

Deriving from scipy.stats failed, so just overloaded rvs. This really should hook into the GDML or something since it is geo dependent this way

get_material()

Return material of last rvs call

rvs()
gnomon.GeneratorAction.convert_3vector_to_dict(value)
gnomon.GeneratorAction.convert_dict_to_g4vector(value, new_vector=<G4ThreeVector object at 0x3088f90>)
gnomon.GeneratorAction.is_neutrino_code(pdg_code)
gnomon.GeneratorAction.lookup_cc_partner(nu_pid)

Lookup the charge current partner

Takes as an input neutrino nu_pid is a PDG code, then returns the charged lepton partner. So 12 (nu_e) returns 11. Keeps sign

Graph Module

class gnomon.Graph.Graph
ComputeLongestPath(gr, parent_node)
CreateDirectedEdges(points, gr, layer_width)

Take each key (ie. point) in the graph and for that point create an edge to every point downstream of it where the weight of the edge is the tuple (distance, angle)

CreateVertices(points)

Returns a dictionary object with keys that are 2tuples represnting a point.

FindParentNode(gr)
GetFarthestNode(gr, node)

node is start node

NegateGraph(gr)

Logging Module

Handle routing output, errors, and exceptions to disk and screen

class gnomon.Logging.StreamToLogger(logger, log_level=20)

Fake file-like stream object that redirects writes to a logger instance.

write(buf)
gnomon.Logging.addLogLevelOptionToArgs(parser)

Add log level arguments to command line parser

This is not in the schema because the log level needs to be known when setting up the Configuration classes

gnomon.Logging.getLogLevels()

Return log levels that Python’s logging facilities understands

gnomon.Logging.setupLogging(console_level, name)

MagneticField Module

class gnomon.MagneticField.WandsToroidField(scale=1.0, B0=1.53, B1=0.032, B2=0.64, H=0.28)

Toroid Field from Bob Wands simulation parameterization

scale has the sign of the field. Focus signal with scale = 1, focus background with scale = -1. Have 80% field with scale = 0.8

B0, B1, B2, and H are fit parameters.

Default values from Ryan Bayes, March 15th, 2012, talk to Valencia grp. B0 = 1.36 # T B1 = 0.0406 # T m B2 = 0.8 # T H = 0.16 # 1/m

Field to field map from Bob Wands, 1 cm plate, Jan. 30, 2012

GetFieldValue(pos, time)
PhenomModel(r)

Fit to field map

A phenomenological fit by Ryan Bayes (Glasgow) to a field map generated by Bob Wands (FNAL). It assumes a 1 cm plate. This is dated January 30th, 2012. Not defined for r <= 0

SensitiveDetector Module

class gnomon.SensitiveDetector.EmitNothingSD

Emits hits without energy deposit

Useful for testing purposes

clearDocs()
getDocs()
setEventNumber(number)
class gnomon.SensitiveDetector.ScintSD

SD for scint bar

ProcessHits(step, rohist)
clearDocs()
getDocs()
getMCHitBarPosition(layer_number, bar_number, view, position, guess_z)
getNumberOfBars()

Return the number of bars per view

getNumberOfLayers()

Return the number of layers in z, where a layer is steel plus two views

getView(lv)

Determine the detector view starting with a G4LogicalVolume

setEventNumber(number)