Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:18:33

0001 ## Generate ePIC material map for ACTS
0002 ## read config-map.json and turn on mapping for approach 1 and 2 of each sensitive surface.
0003 import pandas as pd
0004 import numpy as np
0005 import json
0006 import os
0007 import argparse
0008 
0009 if "__main__" == __name__:
0010     p = argparse.ArgumentParser(
0011         description="Script to turn on all approach 1 and 2, and also the beampipe surface in config json file for matieral mapping"
0012     )
0013     p.add_argument(
0014         "-i","--inputFile",
0015         type=str,
0016         default="config-map.json",
0017         help=" input json file to be modified",
0018     )
0019     p.add_argument(
0020         "-o","--outputFile",
0021         type=str,
0022         default="config-map_new.json",
0023         help=" output json file",
0024     )
0025 
0026 args     = p.parse_args()
0027 print(args)
0028 fname    = args.inputFile
0029 out_name = args.outputFile
0030 
0031 
0032 ## load json file
0033 f  = open(fname)
0034 dd = json.load(f)
0035 
0036 ee=dd['Volumes']['entries']
0037 
0038 ## print volume name and ID
0039 print ("Volume ID        Name       Approaches")
0040 for vv in np.arange(len(ee)):
0041     nn = ee[vv]['value']['NAME']
0042     
0043     if  "|" not in nn and "Gap"  not in nn:
0044         print(ee[vv]['volume'], nn,"1, 2")#print(ee[vv]['value'])#['NAME'])
0045         if "acts_beampipe_central::Barrel" in nn:
0046             v_beampipe = vv+1
0047             print(v_beampipe, nn, "X")
0048           
0049 ## find apporach 1 and 2 to turn on mapping  
0050 for vv in np.arange(1,1+len(dd['Surfaces'])):
0051     for ii,tt in enumerate(dd['Surfaces'][str(vv)]):
0052         if 'approach' in tt:
0053             dd['Surfaces'][str(vv)][ii]['value']['material']['mapMaterial']=True
0054         ## turn on beampipe surface and defind binning
0055         elif vv==v_beampipe:
0056             if tt['value']['bounds']['type']=='CylinderBounds':
0057             # print (dd['Surfaces'][str(vv)][ii])
0058                 dd['Surfaces'][str(vv)][ii]['value']['material']['mapMaterial']=True
0059                 dd['Surfaces'][str(vv)][ii]['value']['material']['binUtility']['binningdata'][0]['bins']=36
0060                 dd['Surfaces'][str(vv)][ii]['value']['material']['binUtility']['binningdata'][1]['bins']=200
0061             
0062                 
0063 with open(out_name, "w") as outfile:
0064     json.dump(dd, outfile, indent=4)
0065 
0066 print("Done! Updated config file at "+out_name)