File indexing completed on 2024-11-15 08:59:27
0001
0002
0003
0004
0005
0006
0007
0008
0009 import shutil, os, sys, argparse
0010 import xml.etree.ElementTree as et
0011
0012
0013 parser = argparse.ArgumentParser()
0014 parser.add_argument(
0015 '-o', '--output-name', dest='outFile', required=True,
0016 help='output auxiliary ROOT file name', type=str
0017 )
0018 argv = parser.parse_args()
0019
0020
0021 import DDG4
0022
0023
0024
0025
0026 if not 'DETECTOR_PATH' in os.environ:
0027 print('ERROR: env var DETECTOR_PATH not set',file=sys.stderr)
0028 exit(1)
0029 mainFile = os.environ['DETECTOR_PATH'] + '/' + os.environ['DETECTOR'] + '.xml'
0030 richFile = os.environ['DETECTOR_PATH'] + '/compact/drich.xml'
0031
0032
0033
0034
0035 shutil.copy(richFile,richFile+'.bak')
0036 richTree = et.parse(richFile)
0037
0038
0039 for constant in richTree.iter(tag='constant'):
0040 if(constant.attrib['name']=='DRICH_create_irt_file'):
0041 constant.set('value','1')
0042
0043
0044 for detector in richTree.iter(tag='detector'):
0045 detector.set('irt_filename',argv.outFile)
0046
0047
0048 richTree.write(richFile)
0049
0050
0051
0052
0053 try:
0054 kernel = DDG4.Kernel()
0055 kernel.loadGeometry(f'file:{mainFile}')
0056 kernel.terminate()
0057 print(f'\n -> produced {argv.outFile}\n')
0058 except:
0059 pass
0060
0061
0062 os.replace(richFile+'.bak',richFile)