#include <GeometryAccess.h>
Public Types | |
typedef double | image_t |
Public Member Functions | |
GeometryAccess (const std::string &path, unsigned pbits=0) | |
Class constructor accepts path to the calibration "geometry" file and verbosity control bit-word. | |
virtual | ~GeometryAccess () |
shpGO | get_geo (const std::string &oname, const unsigned &oindex) |
Returns shared pointer to the geometry object specified by name and index. | |
shpGO | get_top_geo () |
Returns shared pointer to the top geometry object, for exampme CSPAD. | |
void | get_pixel_coords (const double *&X, const double *&Y, const double *&Z, unsigned &size, const std::string &oname=std::string(), const unsigned &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. | |
void | get_pixel_xy_at_z (const double *&XatZ, const double *&YatZ, unsigned &size, const double &Zplane=0, const std::string &oname=std::string(), const unsigned &oindex=0) |
Returns pixel coordinate arrays XatZ, YatZ, of size for specified Zplane and geometry object. | |
void | get_pixel_areas (const double *&A, unsigned &size, const std::string &oname=std::string(), const unsigned &oindex=0) |
Returns pixel areas array A, of size for specified geometry object. | |
void | get_pixel_mask (const int *&mask, unsigned &size, const std::string &oname=std::string(), const unsigned &oindex=0, const unsigned &mbits=0377) |
Returns pixel mask array of size for specified geometry object. | |
double | get_pixel_scale_size (const std::string &oname=std::string(), const unsigned &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 unsigned &oindex=0) |
Prints beginning of pixel coordinate arrays for specified geometry object (top object by default). | |
void | get_pixel_coord_indexes (const unsigned *&iX, const unsigned *&iY, unsigned &size, const std::string &oname=std::string(), const unsigned &oindex=0, const double &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. | |
void | get_pixel_xy_inds_at_z (const unsigned *&iX, const unsigned *&iY, unsigned &size, const double &Zplane=0, const std::string &oname=std::string(), const unsigned &oindex=0, const double &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< image_t, 2 > & | ref_img_from_pixel_arrays (const unsigned *&iX, const unsigned *&iY, const double *W=0, const unsigned &size=0) |
Returns pointer to the data member ndarray<image_t, 2> image object. | |
void | load_pars_from_file (const std::string &path=std::string()) |
Loads calibration file. | |
void | save_pars_in_file (const std::string &path=std::string()) |
Saves calibration file. | |
void | set_print_bits (unsigned pbits=0) |
Sets the m_pbits - printout control bitword. | |
void | set_geo_pars (const std::string &oname=std::string(), const unsigned &oindex=0, const double &x0=0, const double &y0=0, const double &z0=0, const double &rot_z=0, const double &rot_y=0, const double &rot_x=0, const double &tilt_z=0, const double &tilt_y=0, const double &tilt_x=0) |
Sets self object geometry parameters. | |
void | move_geo (const std::string &oname=std::string(), const unsigned &oindex=0, const double &dx=0, const double &dy=0, const double &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 unsigned &oindex=0, const double &dt_x=0, const double &dt_y=0, const double &dt_z=0) |
Adds tilts to the self object w.r.t. current orientation. | |
Static Public Member Functions | |
static ndarray< image_t, 2 > | img_from_pixel_arrays (const unsigned *&iX, const unsigned *&iY, const double *W=0, const unsigned &size=0) |
Static method returns image as ndarray<image_t, 2> object. |
This software was developed for the LCLS project. If you use all or part of it, please give an appropriate acknowledgment.
#include "PSCalib/GeometryAccess.h" #include "ndarray/ndarray.h" // need it if image is returned
std::string path = /reg/d/psdm/<INS>/<experiment>/calib/<calib-type>/<det-src>/geometry/0-end.data" unsigned print_bits = 0377; // or = 0 (by default) - to suppress printout from this object. PSCalib::GeometryAccess geometry(path, print_bits);
// Access and print coordinate arrays: const double* X; const double* Y; const double* Z; unsigned size; bool do_tilt=true; geometry.get_pixel_coords(X,Y,Z,size); cout << "size=" << size << '\n' << std::fixed << std::setprecision(1); cout << "X: "; for(unsigned i=0; i<10; ++i) cout << std::setw(10) << X[i] << ", "; cout << "...\n"; // or get coordinate arrays for specified geometry object: geometry.get_pixel_coords(X,Y,Z,size, "QUAD:V1", 1, do_tilt); // then use X, Y, Z, size // Access pixel X,Y coordinate [um] arrays projected toward origin on specified zplane, if zplane=0 then zplane is averaged Z: const double Zplane=12345; //[um] or 0 geometry.get_pixel_xy_at_z(X,Y,size,Zplane); // Access pixel areas: const double* A; unsigned size; geometry.get_pixel_areas(A,size); // Access pixel mask: const int* mask; unsigned size; unsigned mbits=0377; // 1-edges; 2-wide central cols; 4-non-bound; 8-non-bound neighbours geometry.get_pixel_mask(A, size, std::string(), 0, mbits); // Access pixel size for entire detector: double pix_scale_size = geometry.get_pixel_scale_size (); // or for specified geometry object, for example one quad of CSPAD double pix_scale_size = geometry.get_pixel_scale_size("QUAD:V1", 1); // Access pixel indexes for image: const unsigned * iX; const unsigned * iY; unsigned isize; // optional parameters for specified geometry const std::string ioname = "QUAD:V1"; const unsigned ioindex = 1; const double pix_scale_size_um = 109.92; const int xy0_off_pix[] = {200,200}; // this call returns index arrays iX, iY of size=isize for QUAD with offset geometry.get_pixel_coord_indexes(iX, iY, isize, ioname, ioindex, pix_scale_size_um, xy0_off_pix, do_tilt); // this call returns index arrays for entire detector with auto generated minimal offset geometry.get_pixel_coord_indexes(iX, iY, isize); // then use iX, iY, isize, for example make image as follows. // Access pixel iX, iY indexes for projected to specified z-plane coordinates: const double Zplane=12345; //[um] or 0 geometry.get_pixel_xy_inds_at_z(iX, iY, isize, Zplane); // Make image from index, iX, iY, and intensity, W, arrays ndarray<PSCalib::GeometryAccess::image_t, 2> img = PSCalib::GeometryAccess::img_from_pixel_arrays(iX, iY, 0, isize); // Access and print comments from the calibration "geometry" file: std::map<int, std::string>& dict = geometry.get_dict_of_comments (); cout << "dict[0] = " << dict[0] << '\n';
geometry.print_pixel_coords(); geometry.print_pixel_coords("QUAD:V1", 1); geometry.print_list_of_geos(); geometry.print_list_of_geos_children(); geometry.print_comments_from_dict(); // or print info about specified geometry objects (see class GeometryObject): geometry.get_geo("QUAD:V1", 1)->print_geo(); geometry.get_top_geo()->print_geo_children();
Definition at line 165 of file GeometryAccess.h.
typedef double PSCalib::GeometryAccess::image_t |
Definition at line 173 of file GeometryAccess.h.
PSCalib::GeometryAccess::GeometryAccess | ( | const std::string & | path, | |
unsigned | pbits = 0 | |||
) |
Class constructor accepts path to the calibration "geometry" file and verbosity control bit-word.
[in] | path | path to the calibration "geometry" file |
[in] | pbits | verbosity 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 |
virtual PSCalib::GeometryAccess::~GeometryAccess | ( | ) | [virtual] |
std::map<int, std::string>& PSCalib::GeometryAccess::get_dict_of_comments | ( | ) | [inline] |
shpGO PSCalib::GeometryAccess::get_geo | ( | const std::string & | oname, | |
const unsigned & | oindex | |||
) |
Returns shared pointer to the geometry object specified by name and index.
void PSCalib::GeometryAccess::get_pixel_areas | ( | const double *& | A, | |
unsigned & | size, | |||
const std::string & | oname = std::string() , |
|||
const unsigned & | oindex = 0 | |||
) |
Returns pixel areas array A, of size for specified geometry object.
[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 |
void PSCalib::GeometryAccess::get_pixel_coord_indexes | ( | const unsigned *& | iX, | |
const unsigned *& | iY, | |||
unsigned & | size, | |||
const std::string & | oname = std::string() , |
|||
const unsigned & | oindex = 0 , |
|||
const double & | 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.
[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 |
Referenced by ImgAlgos::NDArrImageProducer::getCalibPars().
void PSCalib::GeometryAccess::get_pixel_coords | ( | const double *& | X, | |
const double *& | Y, | |||
const double *& | Z, | |||
unsigned & | size, | |||
const std::string & | oname = std::string() , |
|||
const unsigned & | 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.
[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 |
void PSCalib::GeometryAccess::get_pixel_mask | ( | const int *& | mask, | |
unsigned & | size, | |||
const std::string & | oname = std::string() , |
|||
const unsigned & | oindex = 0 , |
|||
const unsigned & | mbits = 0377 | |||
) |
Returns pixel mask array of size for specified geometry object.
[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. |
double PSCalib::GeometryAccess::get_pixel_scale_size | ( | const std::string & | oname = std::string() , |
|
const unsigned & | oindex = 0 | |||
) |
Returns pixel scale size for specified geometry object through its children segment.
[in] | oname | - object name |
[in] | oindex | - object index |
Referenced by PSQt::GeoImage::getImage().
void PSCalib::GeometryAccess::get_pixel_xy_at_z | ( | const double *& | XatZ, | |
const double *& | YatZ, | |||
unsigned & | size, | |||
const double & | Zplane = 0 , |
|||
const std::string & | oname = std::string() , |
|||
const unsigned & | oindex = 0 | |||
) |
Returns pixel coordinate arrays XatZ, YatZ, of size for specified Zplane and geometry object.
[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 |
void PSCalib::GeometryAccess::get_pixel_xy_inds_at_z | ( | const unsigned *& | iX, | |
const unsigned *& | iY, | |||
unsigned & | size, | |||
const double & | Zplane = 0 , |
|||
const std::string & | oname = std::string() , |
|||
const unsigned & | oindex = 0 , |
|||
const double & | 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.
[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) |
Referenced by PSQt::GeoImage::getImage().
shpGO PSCalib::GeometryAccess::get_top_geo | ( | ) |
Returns shared pointer to the top geometry object, for exampme CSPAD.
Referenced by PSQt::GeoImage::getImage().
static ndarray<image_t, 2> PSCalib::GeometryAccess::img_from_pixel_arrays | ( | const unsigned *& | iX, | |
const unsigned *& | iY, | |||
const double * | W = 0 , |
|||
const unsigned & | size = 0 | |||
) | [static] |
Static method returns image as ndarray<image_t, 2> object.
[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) |
Referenced by Detector::DetectorAccess::get_image(), main(), and test_cspad2x2().
void PSCalib::GeometryAccess::load_pars_from_file | ( | const std::string & | path = std::string() |
) |
Loads calibration file.
[in] | path | - path to the file with calibration parameters of type "geometry" |
void PSCalib::GeometryAccess::move_geo | ( | const std::string & | oname = std::string() , |
|
const unsigned & | oindex = 0 , |
|||
const double & | dx = 0 , |
|||
const double & | dy = 0 , |
|||
const double & | dz = 0 | |||
) |
Adds offset for origin of the self object w.r.t. current position.
void PSCalib::GeometryAccess::print_comments_from_dict | ( | ) |
Prints comments loaded from input file and kept in the dictionary.
void PSCalib::GeometryAccess::print_list_of_geos | ( | ) |
Prints the list of geometry objects.
void PSCalib::GeometryAccess::print_list_of_geos_children | ( | ) |
Prints the list of geometry objects with children.
void PSCalib::GeometryAccess::print_pixel_coords | ( | const std::string & | oname = std::string() , |
|
const unsigned & | oindex = 0 | |||
) |
Prints beginning of pixel coordinate arrays for specified geometry object (top object by default).
Referenced by ImgAlgos::NDArrImageProducer::getCalibPars().
ndarray<image_t, 2>& PSCalib::GeometryAccess::ref_img_from_pixel_arrays | ( | const unsigned *& | iX, | |
const unsigned *& | iY, | |||
const double * | W = 0 , |
|||
const unsigned & | size = 0 | |||
) |
Returns pointer to the data member ndarray<image_t, 2> image object.
Referenced by PSQt::GeoImage::getImage().
void PSCalib::GeometryAccess::save_pars_in_file | ( | const std::string & | path = std::string() |
) |
Saves calibration file.
[in] | path | - path to the file with calibration parameters of type "geometry" |
Referenced by PSQt::GeoTree::saveGeometryInFile().
void PSCalib::GeometryAccess::set_geo_pars | ( | const std::string & | oname = std::string() , |
|
const unsigned & | oindex = 0 , |
|||
const double & | x0 = 0 , |
|||
const double & | y0 = 0 , |
|||
const double & | z0 = 0 , |
|||
const double & | rot_z = 0 , |
|||
const double & | rot_y = 0 , |
|||
const double & | rot_x = 0 , |
|||
const double & | tilt_z = 0 , |
|||
const double & | tilt_y = 0 , |
|||
const double & | tilt_x = 0 | |||
) |
Sets self object geometry parameters.
void PSCalib::GeometryAccess::set_print_bits | ( | unsigned | pbits = 0 |
) | [inline] |
Sets the m_pbits - printout control bitword.
[in] | pbits | - printout control bitword |
Definition at line 365 of file GeometryAccess.h.
References src::PyDetectorAccess::pbits.
void PSCalib::GeometryAccess::tilt_geo | ( | const std::string & | oname = std::string() , |
|
const unsigned & | oindex = 0 , |
|||
const double & | dt_x = 0 , |
|||
const double & | dt_y = 0 , |
|||
const double & | dt_z = 0 | |||
) |
Adds tilts to the self object w.r.t. current orientation.