Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:18:35

0001 require 'numpy'
0002 
0003 # Variator base class, containing common code for all variators
0004 class VariatorBase
0005 
0006   ### VARIATION FUNCTIONS **************************
0007   # - you are welcome to add any variation functions here
0008   # - python methods are available via the 'pycall' gem (such as 'numpy')
0009   # - must return Array (use `.to_a` to convert a numpy array to a ruby Array)
0010 
0011   # linearly vary by `center +/- delta`, `count` times
0012   @@center_delta = Proc.new do |center, delta, count|
0013     Numpy.linspace(center-delta, center+delta, count).to_a
0014   end
0015 
0016   # linearly vary from `min` to `max`, `count` times
0017   @@min_max = Proc.new do |min, max, count|
0018     Numpy.linspace(min, max, count).to_a
0019   end
0020 
0021 
0022   ### SIMULATION COMMANDS **************************
0023   # - common pipeline lists, for example optics testing
0024   # - you are welcome to add your own here too
0025   # - see template.rb for syntax details
0026 
0027   ### run some tests for optics optimization
0028   @@test_optics = Proc.new do |settings|
0029     [
0030       ### be sure optics-debugging mode is disabled
0031       [[
0032         'scripts/edit_xml.rb',
0033         settings[:compact_drich],
0034         '//constant[@name="DRICH_debug_optics"]',
0035         'value',
0036         '0'
0037       ]],
0038       ### draw geometry
0039       [[
0040         './geometry.sh',
0041         "-c #{settings[:compact_detector]}", 
0042         "-o #{settings[:output].sub(/root$/,'geometry.root')}",
0043       ]],
0044       ### run simulation to check hit rings at varying theta
0045       [[
0046         './simulate.py',
0047         '-t 4',
0048         '-n 100',
0049         "-c #{settings[:compact_detector]}",
0050         "-o #{settings[:output]}",
0051       ]],
0052       ### draw the hits
0053       [[
0054         'bin/draw_hits',
0055         "d",
0056         settings[:output]
0057       ]],
0058       ### enable optics-debugging mode: all components become vacuum, except for mirrors
0059       [[
0060         'scripts/edit_xml.rb',
0061         settings[:compact_drich],
0062         '//constant[@name="DRICH_debug_optics"]',
0063         'value',
0064         '1'
0065       ]],
0066       ### visualize parallel-to-point focal region
0067       #   - NOTE: use Xvfb to suppress OGL windows (`xvfb-run opt/eic-shell`)
0068       #   - `exit` is piped to automatically exit the interactive G4 shell
0069       [
0070         ["exit"],
0071         [
0072           "./simulate.py",
0073           "-t 102",
0074           "-v",
0075           "-n 15",
0076           "-e svg",
0077           "-c #{settings[:compact_detector]}",
0078           "-o #{settings[:output]}",
0079         ],
0080       ],
0081     ]
0082   end
0083 
0084 
0085   ### construtor **************************
0086   # - instantiates instance variables, which are meant to be overridden in subclasses
0087   #   (see template.rb)
0088   def initialize
0089     @varied_settings  = Array.new
0090     @fixed_settings   = Array.new
0091     @derived_settings = Array.new
0092   end
0093 
0094   ### accessors
0095   attr_accessor :varied_settings, :fixed_settings, :derived_settings, :simulation_pipelines
0096 
0097 end