lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
Loading...
Searching...
No Matches
geometry::GeometryAccess Class Reference

Detector geometry built from "geometry" calibration text: each non-comment line becomes a GeometryObject, linked to its parent, and pixel arrays are computed from the tree. More...

#include <GeometryAccess.hh>

Public Types

typedef psalg::types::shape_t shape_t
 Alias for psalg::types::shape_t (uint32_t).
 
typedef GeometryObject::pGO pGO
 Alias for GeometryObject::pGO, a GeometryObject pointer.
 
typedef double image_t
 double; element type of the images from img_from_pixel_arrays() and ref_img_from_pixel_arrays().
 

Public Member Functions

 GeometryAccess (const std::string &path="")
 Class constructor accepts path to the calibration "geometry" file and verbosity control bit-word.
 
 GeometryAccess (std::stringstream &ss)
 Constructor loads parameters from string stream.
 
virtual ~GeometryAccess ()
 Free the internal index, image and projected-coordinate arrays (delete[] on each that was allocated).
 
pGO get_geo (const std::string &oname, const segindex_t &oindex)
 Returns shared pointer to the geometry object specified by name and index.
 
pGO get_top_geo ()
 Returns shared pointer to the top geometry object, for exampme CSPAD.
 
void get_pixel_coords (const pixel_coord_t *&X, const pixel_coord_t *&Y, const pixel_coord_t *&Z, gsize_t &size, const std::string &oname=std::string(), const segindex_t &oindex=0, const bool do_tilt=true, const bool do_eval=false)
 Returns pixel coordinate arrays X, Y, Z, of size for specified geometry object.
 
NDArray< const pixel_coord_t > * get_pixel_coords (const AXIS axis=AXIS_X)
 Compute the pixel coordinates of the top geometry object (tilt applied) and return a new 1-d NDArray over the X, Y or Z array chosen by axis (X for any other value).
 
void get_pixel_xy_at_z (const pixel_coord_t *&XatZ, const pixel_coord_t *&YatZ, gsize_t &size, const pixel_coord_t &Zplane=0, const std::string &oname=std::string(), const segindex_t &oindex=0)
 Returns pixel coordinate arrays XatZ, YatZ, of size for specified Zplane and geometry object.
 
NDArray< const pixel_coord_t > * get_pixel_coords_at_z (const pixel_coord_t Zplane=0, const AXIS axis=AXIS_X)
 Return a new 1-d NDArray over the X or Y pixel coordinates of the top geometry object projected to z = Zplane (get_pixel_xy_at_z()); AXIS_Y selects Y, any other value X.
 
void get_pixel_areas (const pixel_area_t *&A, gsize_t &size, const std::string &oname=std::string(), const segindex_t &oindex=0)
 Returns pixel areas array A, of size for specified geometry object.
 
NDArray< const pixel_area_t > * get_pixel_areas ()
 Return a new 1-d NDArray over the pixel areas of the top geometry object (get_pixel_areas(A, size)).
 
void get_pixel_mask (const pixel_mask_t *&mask, gsize_t &size, const std::string &oname=std::string(), const segindex_t &oindex=0, const bitword_t &mbits=0377)
 Returns pixel mask array of size for specified geometry object.
 
NDArray< const pixel_mask_t > * get_pixel_mask (const unsigned &mbits=0377)
 Return a new 1-d NDArray over the pixel mask of the top geometry object built with mbits (get_pixel_mask(mask, size, "", 0, mbits)).
 
pixel_coord_t get_pixel_scale_size (const std::string &oname=std::string(), const segindex_t &oindex=0)
 Returns pixel scale size for specified geometry object through its children segment.
 
std::map< int, std::string > & get_dict_of_comments ()
 Returns dictionary of comments.
 
void print_list_of_geos ()
 Prints the list of geometry objects.
 
void print_list_of_geos_children ()
 Prints the list of geometry objects with children.
 
void print_comments_from_dict ()
 Prints comments loaded from input file and kept in the dictionary

 
void print_pixel_coords (const std::string &oname=std::string(), const segindex_t &oindex=0)
 Prints beginning of pixel coordinate arrays for specified geometry object (top object by default)
 
void print_geometry_info (const bitword_t &pbits=255)
 Prints geometry info using all other print_* methods.
 
void get_pixel_coord_indexes (const pixel_idx_t *&iX, const pixel_idx_t *&iY, gsize_t &size, const std::string &oname=std::string(), const segindex_t &oindex=0, const pixel_coord_t &pix_scale_size_um=0, const int *xy0_off_pix=0, const bool do_tilt=true)
 Returns pixel coordinate index arrays iX, iY of size for specified geometry object.
 
NDArray< const pixel_idx_t > * get_pixel_coord_indexes (const AXIS axis=AXIS_X, const pixel_coord_t pix_scale_size_um=0, const int *xy0_off_pix=0)
 Return a new 1-d NDArray over the X or Y pixel index array of the top geometry object, computed with tilt by get_pixel_coord_indexes(iX, iY, size, ...); AXIS_Y selects Y, any other value X.
 
void get_pixel_xy_inds_at_z (const pixel_idx_t *&iX, const pixel_idx_t *&iY, gsize_t &size, const pixel_coord_t &Zplane=0, const std::string &oname=std::string(), const segindex_t &oindex=0, const pixel_coord_t &pix_scale_size_um=0, const int *xy0_off_pix=0)
 Returns pixel coordinate index arrays iX, iY of size for specified Zplane and geometry object.
 
NDArray< const pixel_idx_t > * get_pixel_inds_at_z (const pixel_coord_t Zplane=0, const AXIS axis=AXIS_X, const pixel_coord_t pix_scale_size_um=0, const int *xy0_off_pix=0)
 Return a new 1-d NDArray over the X or Y pixel index array of the top geometry object at z = Zplane (get_pixel_xy_inds_at_z()); AXIS_Y selects Y, any other value X.
 
NDArray< image_t > & ref_img_from_pixel_arrays (const pixel_idx_t *&iX, const pixel_idx_t *&iY, const double *W=0, const gsize_t &size=0)
 Returns reference to data member NDArray<image_t> image object.
 
void load_pars_from_stringstream (std::stringstream &ss)
 Loads calibration file.
 
void load_pars_from_string (const std::string &s)
 Parse s as geometry text (load_pars_from_stringstream()): the comment and object lists are cleared, '#' lines are stored as comments, empty lines are skipped, every other line becomes a geometry object, and parent/child relations are then set.
 
void load_pars_from_file (const std::string &fname=std::string())
 If fname is not empty, store it as the path; then read the file at the stored path and parse it as load_pars_from_string() does.
 
void save_pars_in_file (const std::string &path=std::string())
 Saves calibration file.
 
void set_print_bits (bitword_t pbits=0)
 Sets the m_pbits - printout control bitword.
 
void set_geo_pars (const std::string &oname=std::string(), const segindex_t &oindex=0, const pixel_coord_t &x0=0, const pixel_coord_t &y0=0, const pixel_coord_t &z0=0, const angle_t &rot_z=0, const angle_t &rot_y=0, const angle_t &rot_x=0, const angle_t &tilt_z=0, const angle_t &tilt_y=0, const angle_t &tilt_x=0)
 Sets self object geometry parameters.
 
void move_geo (const std::string &oname=std::string(), const segindex_t &oindex=0, const pixel_coord_t &dx=0, const pixel_coord_t &dy=0, const pixel_coord_t &dz=0)
 Adds offset for origin of the self object w.r.t. current position.
 
void tilt_geo (const std::string &oname=std::string(), const segindex_t &oindex=0, const pixel_coord_t &dt_x=0, const pixel_coord_t &dt_y=0, const pixel_coord_t &dt_z=0)
 Adds tilts to the self object w.r.t. current orientation.
 

Static Public Member Functions

static NDArray< image_t > img_from_pixel_arrays (const pixel_idx_t *&iX, const pixel_idx_t *&iY, const double *W=0, const gsize_t &size=0)
 Static method returns image as NDArray<image_t> object.
 
static void file_to_stringstream (const std::string &fname, std::stringstream &ss)
 Append the contents of file fname to ss; if it cannot be opened, log an ERROR and append nothing.
 

Detailed Description

Detector geometry built from "geometry" calibration text: each non-comment line becomes a GeometryObject, linked to its parent, and pixel arrays are computed from the tree.

The long comment above gives usage examples.

Member Typedef Documentation

◆ image_t

double; element type of the images from img_from_pixel_arrays() and ref_img_from_pixel_arrays().

◆ pGO

◆ shape_t

Constructor & Destructor Documentation

◆ GeometryAccess() [1/2]

geometry::GeometryAccess::GeometryAccess ( const std::string &  path = "")

Class constructor accepts path to the calibration "geometry" file and verbosity control bit-word.

Parameters
[in]pathpath to the calibration "geometry" file
[in]pbitsverbosity control bit-word;
=0 print nothing,
+1 info about loaded file,
+2 list of geometry objects,
+8 list of geometry objects with childrens,
+16 info about setting relations between geometry objects,
+32 info about pixel coordinate reconstruction

◆ GeometryAccess() [2/2]

geometry::GeometryAccess::GeometryAccess ( std::stringstream &  ss)

Constructor loads parameters from string stream.

◆ ~GeometryAccess()

virtual geometry::GeometryAccess::~GeometryAccess ( )
virtual

Free the internal index, image and projected-coordinate arrays (delete[] on each that was allocated).

Member Function Documentation

◆ file_to_stringstream()

static void geometry::GeometryAccess::file_to_stringstream ( const std::string &  fname,
std::stringstream &  ss 
)
static

Append the contents of file fname to ss; if it cannot be opened, log an ERROR and append nothing.

◆ get_dict_of_comments()

std::map< int, std::string > & geometry::GeometryAccess::get_dict_of_comments ( )
inline

Returns dictionary of comments.

◆ get_geo()

pGO geometry::GeometryAccess::get_geo ( const std::string &  oname,
const segindex_t &  oindex 
)

Returns shared pointer to the geometry object specified by name and index.

◆ get_pixel_areas() [1/2]

NDArray< const pixel_area_t > * geometry::GeometryAccess::get_pixel_areas ( )

Return a new 1-d NDArray over the pixel areas of the top geometry object (get_pixel_areas(A, size)).

No data is copied; the caller owns the NDArray object.

◆ get_pixel_areas() [2/2]

void geometry::GeometryAccess::get_pixel_areas ( const pixel_area_t *&  A,
gsize_t &  size,
const std::string &  oname = std::string(),
const segindex_t &  oindex = 0 
)

Returns pixel areas array A, of size for specified geometry object.

Parameters
[out]A- pointer to pixel areas array
[out]size- size of the pixel array (number of pixels)
[in]oname- object name
[in]oindex- object index

◆ get_pixel_coord_indexes() [1/2]

NDArray< const pixel_idx_t > * geometry::GeometryAccess::get_pixel_coord_indexes ( const AXIS  axis = AXIS_X,
const pixel_coord_t  pix_scale_size_um = 0,
const int *  xy0_off_pix = 0 
)

Return a new 1-d NDArray over the X or Y pixel index array of the top geometry object, computed with tilt by get_pixel_coord_indexes(iX, iY, size, ...); AXIS_Y selects Y, any other value X.

No data is copied; the caller owns the NDArray object.

◆ get_pixel_coord_indexes() [2/2]

void geometry::GeometryAccess::get_pixel_coord_indexes ( const pixel_idx_t *&  iX,
const pixel_idx_t *&  iY,
gsize_t &  size,
const std::string &  oname = std::string(),
const segindex_t &  oindex = 0,
const pixel_coord_t &  pix_scale_size_um = 0,
const int *  xy0_off_pix = 0,
const bool  do_tilt = true 
)

Returns pixel coordinate index arrays iX, iY of size for specified geometry object.

Parameters
[out]iX- pointer to x pixel index coordinate array
[out]iY- pointer to y pixel index coordinate array
[out]size- size of the pixel coordinate array (number of pixels)
[in]oname- object name (deafault - top object)
[in]oindex- object index (default = 0)
[in]pix_scale_size_um- ex.: 109.92 (default - search for the first segment pixel size)
[in]xy0_off_pix- array containing X and Y coordinates of the offset (default - use xmin, ymin)
[in]do_tilt- on/off tilt angle correction

◆ get_pixel_coords() [1/2]

NDArray< const pixel_coord_t > * geometry::GeometryAccess::get_pixel_coords ( const AXIS  axis = AXIS_X)

Compute the pixel coordinates of the top geometry object (tilt applied) and return a new 1-d NDArray over the X, Y or Z array chosen by axis (X for any other value).

The NDArray points at internal data without copying; the caller owns the NDArray object.

◆ get_pixel_coords() [2/2]

void geometry::GeometryAccess::get_pixel_coords ( const pixel_coord_t *&  X,
const pixel_coord_t *&  Y,
const pixel_coord_t *&  Z,
gsize_t &  size,
const std::string &  oname = std::string(),
const segindex_t &  oindex = 0,
const bool  do_tilt = true,
const bool  do_eval = false 
)

Returns pixel coordinate arrays X, Y, Z, of size for specified geometry object.

Parameters
[out]X- pointer to x pixel coordinate array
[out]Y- pointer to y pixel coordinate array
[out]Z- pointer to z pixel coordinate array
[out]size- size of the pixel coordinate array (number of pixels)
[in]oname- object name
[in]oindex- object index
[in]do_tilt- on/off tilt angle correction
[in]do_eval- update all evaluated arrays

◆ get_pixel_coords_at_z()

NDArray< const pixel_coord_t > * geometry::GeometryAccess::get_pixel_coords_at_z ( const pixel_coord_t  Zplane = 0,
const AXIS  axis = AXIS_X 
)

Return a new 1-d NDArray over the X or Y pixel coordinates of the top geometry object projected to z = Zplane (get_pixel_xy_at_z()); AXIS_Y selects Y, any other value X.

No data is copied; the caller owns the NDArray object.

◆ get_pixel_inds_at_z()

NDArray< const pixel_idx_t > * geometry::GeometryAccess::get_pixel_inds_at_z ( const pixel_coord_t  Zplane = 0,
const AXIS  axis = AXIS_X,
const pixel_coord_t  pix_scale_size_um = 0,
const int *  xy0_off_pix = 0 
)

Return a new 1-d NDArray over the X or Y pixel index array of the top geometry object at z = Zplane (get_pixel_xy_inds_at_z()); AXIS_Y selects Y, any other value X.

No data is copied; the caller owns the NDArray object.

◆ get_pixel_mask() [1/2]

void geometry::GeometryAccess::get_pixel_mask ( const pixel_mask_t *&  mask,
gsize_t &  size,
const std::string &  oname = std::string(),
const segindex_t &  oindex = 0,
const bitword_t &  mbits = 0377 
)

Returns pixel mask array of size for specified geometry object.

Parameters
[out]mask- pointer to pixel mask array
[out]size- size of the pixel array (number of pixels)
[in]oname- object name
[in]oindex- object index
[in]mbits- mask control bits; +1-mask edges, +2-two wide central columns, +4-non-bounded, +8-non-bounded neighbours.

◆ get_pixel_mask() [2/2]

NDArray< const pixel_mask_t > * geometry::GeometryAccess::get_pixel_mask ( const unsigned &  mbits = 0377)

Return a new 1-d NDArray over the pixel mask of the top geometry object built with mbits (get_pixel_mask(mask, size, "", 0, mbits)).

No data is copied; the caller owns the NDArray object.

◆ get_pixel_scale_size()

pixel_coord_t geometry::GeometryAccess::get_pixel_scale_size ( const std::string &  oname = std::string(),
const segindex_t &  oindex = 0 
)

Returns pixel scale size for specified geometry object through its children segment.

Parameters
[in]oname- object name
[in]oindex- object index

◆ get_pixel_xy_at_z()

void geometry::GeometryAccess::get_pixel_xy_at_z ( const pixel_coord_t *&  XatZ,
const pixel_coord_t *&  YatZ,
gsize_t &  size,
const pixel_coord_t &  Zplane = 0,
const std::string &  oname = std::string(),
const segindex_t &  oindex = 0 
)

Returns pixel coordinate arrays XatZ, YatZ, of size for specified Zplane and geometry object.

Parameters
[out]XatZ- pointer to x pixel coordinate array at specified Zplane
[out]YatZ- pointer to y pixel coordinate array
[out]size- size of the pixel coordinate array (number of pixels)
[in]Zplane- z-coordinate of the plane for projection
[in]oname- object name
[in]oindex- object index

◆ get_pixel_xy_inds_at_z()

void geometry::GeometryAccess::get_pixel_xy_inds_at_z ( const pixel_idx_t *&  iX,
const pixel_idx_t *&  iY,
gsize_t &  size,
const pixel_coord_t &  Zplane = 0,
const std::string &  oname = std::string(),
const segindex_t &  oindex = 0,
const pixel_coord_t &  pix_scale_size_um = 0,
const int *  xy0_off_pix = 0 
)

Returns pixel coordinate index arrays iX, iY of size for specified Zplane and geometry object.

Parameters
[out]iX- pointer to x pixel index coordinate array
[out]iY- pointer to y pixel index coordinate array
[out]size- size of the pixel coordinate array (number of pixels)
[in]Zplane- z-coordinate of the plane for projection (default=0 - evaluated as average z ovetr all pixels)
[in]oname- object name (deafault - top object)
[in]oindex- object index (default = 0)
[in]pix_scale_size_um- ex.: 109.92 (default - search for the first segment pixel size)
[in]xy0_off_pix- array containing X and Y coordinates of the offset (default - use xmin, ymin)

◆ get_top_geo()

pGO geometry::GeometryAccess::get_top_geo ( )

Returns shared pointer to the top geometry object, for exampme CSPAD.

◆ img_from_pixel_arrays()

static NDArray< image_t > geometry::GeometryAccess::img_from_pixel_arrays ( const pixel_idx_t *&  iX,
const pixel_idx_t *&  iY,
const double *  W = 0,
const gsize_t &  size = 0 
)
static

Static method returns image as NDArray<image_t> object.

Parameters
[in]iX- pointer to x pixel index coordinate array
[in]iY- pointer to y pixel index coordinate array
[in]W- pointer to the intensity (weights) array (default - set 1 for each pixel)
[in]size- size of the pixel coordinate array (number of pixels)

◆ load_pars_from_file()

void geometry::GeometryAccess::load_pars_from_file ( const std::string &  fname = std::string())

If fname is not empty, store it as the path; then read the file at the stored path and parse it as load_pars_from_string() does.

A file that cannot be opened is logged as an ERROR and nothing is read from it.

◆ load_pars_from_string()

void geometry::GeometryAccess::load_pars_from_string ( const std::string &  s)

Parse s as geometry text (load_pars_from_stringstream()): the comment and object lists are cleared, '#' lines are stored as comments, empty lines are skipped, every other line becomes a geometry object, and parent/child relations are then set.

◆ load_pars_from_stringstream()

void geometry::GeometryAccess::load_pars_from_stringstream ( std::stringstream &  ss)

Loads calibration file.

Parameters
[in]path- path to the file with calibration parameters of type "geometry"

◆ move_geo()

void geometry::GeometryAccess::move_geo ( const std::string &  oname = std::string(),
const segindex_t &  oindex = 0,
const pixel_coord_t &  dx = 0,
const pixel_coord_t &  dy = 0,
const pixel_coord_t &  dz = 0 
)

Adds offset for origin of the self object w.r.t. current position.

◆ print_comments_from_dict()

void geometry::GeometryAccess::print_comments_from_dict ( )

Prints comments loaded from input file and kept in the dictionary

◆ print_geometry_info()

void geometry::GeometryAccess::print_geometry_info ( const bitword_t &  pbits = 255)

Prints geometry info using all other print_* methods.

◆ print_list_of_geos()

void geometry::GeometryAccess::print_list_of_geos ( )

Prints the list of geometry objects.

◆ print_list_of_geos_children()

void geometry::GeometryAccess::print_list_of_geos_children ( )

Prints the list of geometry objects with children.

◆ print_pixel_coords()

void geometry::GeometryAccess::print_pixel_coords ( const std::string &  oname = std::string(),
const segindex_t &  oindex = 0 
)

Prints beginning of pixel coordinate arrays for specified geometry object (top object by default)

◆ ref_img_from_pixel_arrays()

NDArray< image_t > & geometry::GeometryAccess::ref_img_from_pixel_arrays ( const pixel_idx_t *&  iX,
const pixel_idx_t *&  iY,
const double *  W = 0,
const gsize_t &  size = 0 
)

Returns reference to data member NDArray<image_t> image object.

◆ save_pars_in_file()

void geometry::GeometryAccess::save_pars_in_file ( const std::string &  path = std::string())

Saves calibration file.

Parameters
[in]path- path to the file with calibration parameters of type "geometry"

◆ set_geo_pars()

void geometry::GeometryAccess::set_geo_pars ( const std::string &  oname = std::string(),
const segindex_t &  oindex = 0,
const pixel_coord_t &  x0 = 0,
const pixel_coord_t &  y0 = 0,
const pixel_coord_t &  z0 = 0,
const angle_t &  rot_z = 0,
const angle_t &  rot_y = 0,
const angle_t &  rot_x = 0,
const angle_t &  tilt_z = 0,
const angle_t &  tilt_y = 0,
const angle_t &  tilt_x = 0 
)

Sets self object geometry parameters.

◆ set_print_bits()

void geometry::GeometryAccess::set_print_bits ( bitword_t  pbits = 0)
inline

Sets the m_pbits - printout control bitword.

Parameters
[in]pbits- printout control bitword

◆ tilt_geo()

void geometry::GeometryAccess::tilt_geo ( const std::string &  oname = std::string(),
const segindex_t &  oindex = 0,
const pixel_coord_t &  dt_x = 0,
const pixel_coord_t &  dt_y = 0,
const pixel_coord_t &  dt_z = 0 
)

Adds tilts to the self object w.r.t. current orientation.


The documentation for this class was generated from the following file: