Multi-panel composite detector needs in geometry constants to get arrays of pixel 3-d coordinates and derived objects. Mapping of correct constants with specific detector is a big issue if it is done manually. This note is about script automating/simplifying this job.
To get current information about geometry constants deployment script and examples, use command:
geometry_deploy_constants -h
(ana-4.0.37) [<username>@psanagpu106:~/LCLS/con-py2]$ geometry_deploy_constants -e xpptut15 -r 320 -d XppGon.0:Cspad.0 -D -c ./calib -h usage: geometry_deploy_constants -e <experiment> -d <detector> -r <run-number> [-D] [-L <logging-mode>] [...] REGULAR COMMAND EXAMPLE: geometry_deploy_constants -e cxilu9218 -d CxiDs1.0:Jungfrau.0 -r238 --posz -100000 --posx 0 --posy 0 --rotz 90 -D --runrange 10-20 TEST COMMANDS: Ex.1 for Cspad CXI : geometry_deploy_constants -e xpptut15 -r 380 -d CxiDs1.0:Cspad.0 -D -c ./calib Ex.2 for Cspad CXI : geometry_deploy_constants -e xpptut15 -r 380 -d CxiDs2.0:Cspad.0 -D -c ./calib Ex.3 for Cspad XPP : geometry_deploy_constants -e xpptut15 -r 320 -d XppGon.0:Cspad.0 -D -c ./calib Ex.4 for cspad2x2 : geometry_deploy_constants -e xpptut15 -r 460 -d MecTargetChamber.0:Cspad2x2.3 -D -c ./calib --posz -100000 --posx 10 --posy -20 --rotz 90 Ex.5 for jungfrau512k : geometry_deploy_constants -e xpptut15 -r 410 -d MfxEndstation.0:Jungfrau.1 -D -c ./calib Ex.6 for jungfrau1M : geometry_deploy_constants -e xpptut15 -r 430 -d MfxEndstation.0:Jungfrau.0 -D -c ./calib Ex.7 for jungfrau4M : geometry_deploy_constants -e xpptut15 -r 530 -d DetLab.0:Jungfrau.2 -D -c ./calib Ex.8 for epix10ka2m : geometry_deploy_constants -e xpptut15 -r 570 -d MfxEndstation.0:Epix10ka2M.0 -D -c ./calib Ex.9 for epix100a : geometry_deploy_constants -e xpptut15 -r 260 -d XcsEndstation.0:Epix100a.1 -D -c ./calib Ex.10 for pnCCD : geometry_deploy_constants -e xpptut15 -r 450 -d Camp.0:pnCCD.1 -D -c ./calib Ex.11 for epix10kaquad : geometry_deploy_constants -e xpptut15 -r 590 -d MecTargetChamber.0:Epix10kaQuad.0 -D -c ./calib Ex.12 for epix10kaquad : geometry_deploy_constants -e xpptut15 -r 590 -d MecTargetChamber.0:Epix10kaQuad.1 -D -c ./calib Ex.13 for epix10kaquad : geometry_deploy_constants -e xpptut15 -r 590 -d MecTargetChamber.0:Epix10kaQuad.2 -D -c ./calib Ex.14 for epix10kaquad : geometry_deploy_constants -e xpptut15 -r 590 -d MecTargetChamber.0:Epix10kaQuad.3 -D -c ./calib Help: geometry_deploy_constants -h Deployment of geometry calibration parameters optional arguments: -h, --help show this help message and exit -e EXP, --exp EXP experiment name, default = None -d DET, --det DET detector name, default = None -r RUN, --run RUN run number of the existing dataset to get run time- stamp, detector full name etc., default = None -t TSTAMP, --tstamp TSTAMP non-default time stamp (<YYYYmmddHHMMSS) or run number(<10000) for constants selection in repo. By default run time is used, default = None -s DSSUFFIX, --dssuffix DSSUFFIX dataset name suffix beyond exp=<expname>:run=<runnum><dssuffix>, for example ":smd:dir=<path>/xtc/", default = None -x DSNAME, --dsname DSNAME overrides exp=<expname>:run=<runnum><dssuffix> if specified, e.g. path to *.xtc file, default = None -o DIRREPO, --dirrepo DIRREPO non-default repository of calibration results, default = /reg/g/psdm/detector/calib/geometry/ -c DIRCALIB, --dircalib DIRCALIB deployment calib directory if different from standard one, default = None -l LOGLEV, --loglev LOGLEV logging mode, one of INFO, CRITICAL, WARN, WARNING, ERROR, DEBUG, NOTSET, default = INFO --dirmode DIRMODE mode for all mkdir, default = 511 --filemode FILEMODE mode for all saved files, default = 438 -D, --deploy deploy constants to the calib dir, default = False -R RUNRANGE, --runrange RUNRANGE validity run range for output calibration file, default = 0-end --parent PARENT parent frame name containing the detector geometry object, default = IP --posx POSX detector position x[um] relative IP, default = 0.000000 --posy POSY detector position y[um] relative IP, default = 0.000000 --posz POSZ detector position z[um] relative IP, default = -100000.000000 --rotx ROTX detector rotation angle [degree] around axis x, default = 0.000000 --roty ROTY detector position angle [degree] around axis y, default = 0.000000 --rotz ROTZ detector position angle [degree] around axis z, default = 0.000000 |
Command geometry_deploy_constants <parameters> checks experiment (-e, –-exp) run (-r, –-run) information for requested detector (-d, –-det), finds the run time stamp, finds appropriate file with geometry constants in the repository (-o, --dirrepo), changes detector orientation, apply translation relative IP (if parameters --parent, --pos*, --rot* specified) and deploys constants under <experiment>/calib directory, or directory specified by parameter (-c, --calibdir). Results of this command, depending on parameter (-l, --loglev), are dumped on terminal and preserved in the logfile
<dirrepo>/logs/<year>/<time-stamp>_log_geometry_deploy_constants_<user-login-name>.txt
Conventions about repository containing files with geometry calibration constants.
Currently -o,--dirrepo is set to /reg/g/psdm/detector/calib/geometry/
(ana-4.0.37) [<username>@psanagpu106:/reg/g/psdm/detector/calib/geometry]$ ls -l total 4 drwxr-xr-x 1 dubrovin br 0 Mar 22 14:13 andor drwxr-xr-x 1 dubrovin br 0 Mar 22 14:08 andor3d drwxrwxr-- 1 dubrovin br 0 Mar 24 11:30 cspad drwxrwxr-- 1 dubrovin br 0 Mar 24 11:55 cspad2x2 drwxrwxr-- 1 dubrovin br 0 Mar 24 12:00 epix100a drwxrwxr-- 1 dubrovin br 0 Mar 23 14:54 epix10ka drwxr-xr-x 1 dubrovin br 0 Mar 24 12:14 epix10ka2m drwxr-xr-x 1 dubrovin br 0 Mar 24 13:42 epix10kaquad drwxrwxr-- 1 dubrovin br 0 Mar 23 10:14 jungfrau drwxrwxrwx 1 dubrovin br 0 Mar 15 09:55 logs drwxrwxr-- 1 dubrovin br 0 Mar 17 15:02 pnccd drwxr-xr-x 1 dubrovin br 0 Mar 22 09:33 rayonix |
and beside logfiles under subdirectory logs/ it contains directories for "all" detector types which need in geometry constants.
Currently repository is fully populated for cspad, cspad2x2, epix100a, epix10ka, epix10ka2m, epix10kaquad, jungfrau, pnccd. If other detector(s) required they need to be populated here.
/reg/g/psdm/detector/calib/geometry]$ ls -l1 epix10ka2m total 68 -rw-r--r-- 1 dubrovin br 3662 Mar 22 13:16 2018-11-15-geometry-epix10ka2m.txt -rw-r--r-- 1 dubrovin br 3720 Mar 22 13:15 2020-02-25-geometry-epix10ka2m.1-v0-z0.txt -rw-r--r-- 1 dubrovin br 3350 Mar 22 13:15 2020-02-25-geometry-epix10ka2m.1-v1-mfxc00118-0044-z0.txt -rw-r--r-- 1 dubrovin br 3355 Mar 22 13:14 2020-02-25-geometry-epix10ka2m.1-v1-mfxc00318-0013-z0.txt -rw-r--r-- 1 dubrovin br 3268 Mar 22 13:15 2020-06-25-geometry-epix10ka2m.0-v1.txt -rw-r--r-- 1 dubrovin br 3424 Mar 22 13:14 2020-09-10-geometry-epix10ka2m.1-v1-cortilt-center.txt -rw-r--r-- 1 dubrovin br 3340 Mar 22 11:12 2021-02-02-geometry-epix10ks2m.1-recentred-for-psana.txt -rw-r--r-- 1 dubrovin br 3267 Mar 22 11:12 2021-02-02-geometry-epix10ks2m.1.txt -rw-r--r-- 1 dubrovin br 3355 Mar 22 13:21 epix10ka2m_default.data lrwxrwxrwx 1 dubrovin br 42 Mar 22 10:50 epix10ka2m_MfxEndstation-0-Epix10ka2M-0_20200225.data -> 2020-02-25-geometry-epix10ka2m.1-v0-z0.txt lrwxrwxrwx 1 dubrovin br 54 Mar 22 10:55 epix10ka2m_MfxEndstation-0-Epix10ka2M-0_20200910.data -> 2020-09-10-geometry-epix10ka2m.1-v1-cortilt-center.txt lrwxrwxrwx 1 dubrovin br 56 Mar 22 13:09 epix10ka2m_MfxEndstation-0-Epix10ka2M-0_20210202.data -> 2021-02-02-geometry-epix10ks2m.1-recentred-for-psana.txt lrwxrwxrwx 1 dubrovin br 34 Mar 22 10:43 epix10ka2m_XcsEndstation-0-Epix10ka2M-0_20181115.data -> 2018-11-15-geometry-epix10ka2m.txt lrwxrwxrwx 1 dubrovin br 39 Mar 22 10:45 epix10ka2m_XppGon-0-Epix10ka2M-0_20200625.data -> 2020-06-25-geometry-epix10ka2m.0-v1.txt |
Script finds path to the geometry file using its name conventions:
<dirrepo>/<det-type>/<dettype>_<full-lcls1-detector-name>_<time-stamp>.data
where the time-stamp is presented in format YYYYMMDD (it is assumed that optical metrology or variation of geometry constants do not need to be changed more often than once per day...).
If geometry file for specified detector and time-stamp is missing, constants from <dettype>_default.data will be loaded.
Command parameters allow to make a few modifications to the default geometry file before deployment. These modifications include detector position and orientation and Rayonix segment binning.
Camera position and orientation parameters (--posx/y/z, and --rotx/y/z) are included in the geometry file line beginning with "IP" (which by default set in by parameter --parent IP). It is assumed that all files in repository should have the line beginning with "IP". Otherwise, parameter --parent can be changed.
Default geometry file for Rayonix /reg/g/psdm/detector/calib/geometry/rayonix/rayonix_default.data
has pre-defined segment description like MTRX:V2:3840:3840:44.5:44.5, that can be changed by experiment dependent binning. For detector of type rayonix
this string parameters are compared with parameters from configuration object for specified experiment (-e EXP, --exp EXP) and run number (-r RUN, --run RUN). Segment binning values from configuration are substituted, e.g. for xpptut15 run 240 this line is replaced with MTRX:V2:1920:1920:88:88. For backward compatibility of already deployed geometry files similar check and substitution is done on flight at geometry loading in the Detector.geoaccess, check_rayonix_geo methods (requested by Chuck).
From log-file or dump on terminal
(ana-4.0.37) [dubrovin@psanagpu106:~/LCLS/con-py2]$ geometry_deploy_constants -e xpptut15 -r 460 -d MecTargetChamber.0:Cspad2x2.3 -D -c ./calib --posz -100000 --posx 10 --posy -20 --rotz 90 Arguments: Namespace(deploy=True, det='MecTargetChamber.0:Cspad2x2.3', dircalib='./calib', dirmode=511, dirrepo='/reg/g/psdm/detector/calib/geometry/', dsname=None, dssuffix=None, exp='xpptut15', filemode=438, loglev='INFO', parent='IP', posx=10.0, posy=-20.0, posz=-100000.0, rotx=0, roty=0, rotz=90.0, run='460', runrange='0-end', tstamp=None) [I] geometry_deploy_constants L0131 log file: /reg/g/psdm/detector/calib/geometry/logs/2022/2022-03-25T104317_log_geometry_deploy_constants_dubrovin.txt [I] UtilsCalib.py L0305 record at start: 2022-03-25T10:43:17 user:dubrovin@psanagpu106 cwd:/cds/home/d/dubrovin/LCLS/con-py2 rel:ana-4.0.37 dirrepo:/reg/g/psdm/detector/calib/geometry command:/cds/home/d/dubrovin/LCLS/con-py2/arch/x86_64-rhel7-gcc48-opt/bin/geometry_deploy_constants -e xpptut15 -r 460 -d MecTargetChamber.0:Cspad2x2.3 -D -c ./calib --posz -100000 --posx 10 --posy -20 --rotz 90 saved in: /reg/g/psdm/logs/atstart/2022/2022_lcls1_geometry_deploy_constants.txt [I] UtilsGeometryDeploy.py L0032 input parameters roty : 0 rotx : 0 dirrepo : /reg/g/psdm/detector/calib/geometry/ rotz : 90.0 run : 460 exp : xpptut15 parent : IP deploy : True det : MecTargetChamber.0:Cspad2x2.3 posy : -20.0 dsname : None dircalib : ./calib tstamp : None loglev : INFO dssuffix : None dirmode : 511 posx : 10.0 filemode : 438 posz : -100000.0 runrange : 0-end repoman : <Detector.UtilsCalib.RepoManager object at 0x7f9443b06350> [I] UtilsGeometryDeploy.py L0054 open dataset exp=xpptut15:run=460 [I] UtilsGeometryDeploy.py L0065 directory for dettype: /reg/g/psdm/detector/calib/geometry/cspad2x2 [I] UtilsGeometryDeploy.py L0070 list of found in repository geometry files for dettype_detname: cspad2x2_MecTargetChamber-0-Cspad2x2-3 cspad2x2_MecTargetChamber-0-Cspad2x2-3_20130213.data cspad2x2_MecTargetChamber-0-Cspad2x2-3_20150402.data cspad2x2_MecTargetChamber-0-Cspad2x2-3_20140425.data [I] UtilsGeometryDeploy.py L0076 file_for_timestamp(tsrun=20130428): /reg/g/psdm/detector/calib/geometry/cspad2x2/cspad2x2_MecTargetChamber-0-Cspad2x2-3_20130213.data [I] UtilsGeometryDeploy.py L0086 geo_det: parent: IP 0 geo: CSPAD2X2:V1 0 x0: 0 y0: 0 z0:-1000000 rot_z: 0.000 rot_y: 0.000 rot_x: 0.000 tilt_z: 0.00000 tilt_y: 0.00000 tilt_x: 0.00000 [I] UtilsGeometryDeploy.py L0095 geo_det updated: parent: IP 0 geo: CSPAD2X2:V1 0 x0: 10 y0: -20 z0: -100000 rot_z: 90.000 rot_y: 0.000 rot_x: 0.000 tilt_z: 0.00000 tilt_y: 0.00000 tilt_x: 0.00000 [I] GeometryAccess.py L0263 Save file: /reg/g/psdm/detector/calib/geometry/cspad2x2/cspad2x2_tmp.data [I] UtilsGeometryDeploy.py L0104 standard calib dir: /reg/d/psdm/XPP/xpptut15/calib [I] UtilsGeometryDeploy.py L0105 non-default calib dir: ./calib [I] UtilsGeometryDeploy.py L0114 deploy calib file /reg/g/psdm/detector/calib/geometry/cspad2x2/cspad2x2_tmp.data under ./calib/CsPad2x2::CalibV1/MecTargetChamber.0:Cspad2x2.3/geometry create_path: ./calib/CsPad2x2::CalibV1/MecTargetChamber.0:Cspad2x2.3/geometry/0-end.data Directory exists: . Directory exists: ./calib Directory exists: ./calib/CsPad2x2::CalibV1 Directory exists: ./calib/CsPad2x2::CalibV1/MecTargetChamber.0:Cspad2x2.3 Directory exists: ./calib/CsPad2x2::CalibV1/MecTargetChamber.0:Cspad2x2.3/geometry cmd: cat /reg/g/psdm/detector/calib/geometry/cspad2x2/cspad2x2_tmp.data > ./calib/CsPad2x2::CalibV1/MecTargetChamber.0:Cspad2x2.3/geometry/0-end.data cmd: echo "file:0-end.data copy_of:/reg/g/psdm/detector/calib/geometry/cspad2x2/cspad2x2_tmp.data ctype:geometry user:dubrovin host:psanagpu106 cptime:2022-03-25T10:43:18 cwd:/cds/home/d/dubrovin/LCLS/con-py2 cmt:" >> ./calib/CsPad2x2::CalibV1/MecTargetChamber.0:Cspad2x2.3/geometry/HISTORY (ana-4.0.37) [dubrovin@psanagpu106:~/LCLS/con-py2]$ |
it should be quite clear what script is doing and what problem might be. Please pay attention that