Photons and Sensor Effects
C++ Photon Array
-
class PhotonArray
Class to hold a list of “photon” arrival positions.
Class holds arrays of information about photon arrivals: x and y positions, dxdz and dydz inclination “angles” (really slopes), a flux, and a wavelength carried by each photon. It is the intention that fluxes of photons be nearly equal in absolute value so that noise statistics can be estimated by counting number of positive and negative photons.
Unnamed Group
-
inline double *getXArray()
Accessors that provide access as numpy arrays in Python layer.
-
inline double *getYArray()
-
inline double *getFluxArray()
-
inline double *getDXDZArray()
-
inline double *getDYDZArray()
-
inline double *getWavelengthArray()
-
inline const double *getXArray() const
-
inline const double *getYArray() const
-
inline const double *getFluxArray() const
-
inline const double *getDXDZArray() const
-
inline const double *getDYDZArray() const
-
inline const double *getWavelengthArray() const
-
inline bool hasAllocatedAngles() const
-
inline bool hasAllocatedWavelengths() const
Public Functions
-
PhotonArray(int N)
Construct a PhotonArray of the given size, allocating the arrays locally.
Note: PhotonArrays made this way can only be used locally in the C++ layer, not returned back to Python. Also, only x,y,flux will be allocated.
- Parameters:
N – [in] Size of array
-
inline PhotonArray(size_t N, double *x, double *y, double *flux, double *dxdz, double *dydz, double *wave, bool is_corr)
Construct a PhotonArray of the given size with the given arrays, which should be allocated separately (in Python typically).
If angles or wavelengths are not set, these may be 0.
- Parameters:
N – [in] Size of array
x – [in] An array of the initial x values
y – [in] An array of the initial y values
flux – [in] An array of the initial flux values
dxdz – [in] An array of the initial dxdz values (may be 0)
dydz – [in] An array of the initial dydz values (may be 0)
wave – [in] An array of the initial wavelength values (may be 0)
is_corr – [in] A boolean indicating whether the current values are correlated.
-
inline size_t size() const
Accessor for array size.
- Returns:
Array size
-
inline void setPhoton(int i, double x, double y, double flux)
Set characteristics of a photon that are decided during photon shooting (i.e. only x,y,flux)
- Parameters:
i – [in] Index of desired photon (no bounds checking)
x – [in] x coordinate of photon
y – [in] y coordinate of photon
flux – [in] flux of photon
-
inline double getX(int i) const
Access x coordinate of a photon.
- Parameters:
i – [in] Index of desired photon (no bounds checking)
- Returns:
x coordinate of photon
-
inline double getY(int i) const
Access y coordinate of a photon.
- Parameters:
i – [in] Index of desired photon (no bounds checking)
- Returns:
y coordinate of photon
-
inline double getFlux(int i) const
Access flux of a photon.
- Parameters:
i – [in] Index of desired photon (no bounds checking)
- Returns:
flux of photon
-
inline double getDXDZ(int i) const
Access dxdz of a photon.
- Parameters:
i – [in] Index of desired photon (no bounds checking)
- Returns:
dxdz of photon
-
inline double getDYDZ(int i) const
Access dydz coordinate of a photon.
- Parameters:
i – [in] Index of desired photon (no bounds checking)
- Returns:
dydz coordinate of photon
-
inline double getWavelength(int i) const
Access wavelength of a photon.
- Parameters:
i – [in] Index of desired photon (no bounds checking)
- Returns:
wavelength of photon
-
double getTotalFlux() const
Return sum of all photons’ fluxes.
- Returns:
flux of photon
-
void setTotalFlux(double flux)
Rescale all photon fluxes so that total flux matches argument.
If current total flux is zero, no rescaling is done.
- Parameters:
flux – [in] desired total flux of all photons.
-
void scaleFlux(double scale)
Rescale all photon fluxes by the given factor.
- Parameters:
scale – [in] Scaling factor for all fluxes
-
void scaleXY(double scale)
Rescale all photon positions by the given factor.
- Parameters:
scale – [in] Scaling factor for all positions
-
void assignAt(int istart, const PhotonArray &rhs)
Assign the contents of another array to a portion of this one.
- Parameters:
istart – [in] The starting index at which to assign the contents of rhs
rhs – [in] PhotonArray whose contents to assign into this one
-
void convolve(const PhotonArray &rhs, BaseDeviate ud)
Convolve this array with another.
Convolution of two arrays is defined as adding the coordinates on a photon-by-photon basis and multiplying the fluxes on a photon-by-photon basis. Output photons’ flux is renormalized so that the expectation value of output total flux is product of two input totals, if the two photon streams are uncorrelated.
- Parameters:
rhs – [in] PhotonArray to convolve with this one. Must be same size.
rng – [in] A BaseDeviate in case we need to shuffle.
-
void convolveShuffle(const PhotonArray &rhs, BaseDeviate rng)
Convolve this array with another, shuffling the order in which photons are combined.
Same convolution behavior as convolve(), but the order in which the photons are multiplied into the array is randomized to destroy any flux or position correlations.
- Parameters:
rhs – [in] PhotonArray to convolve with this one. Must be same size.
rng – [in] A BaseDeviate used to shuffle the input photons.
-
template<class T>
double addTo(ImageView<T> target) const Add flux of photons to an image by binning into pixels.
Photon in this PhotonArray are binned into the pixels of the input Image and their flux summed into the pixels. Image is assumed to represent surface brightness, so photons’ fluxes are divided by image pixel area. Photons past the edges of the image are discarded.
- Parameters:
target – [in] the Image to which the photons’ flux will be added.
- Returns:
The total flux of photons the landed inside the image bounds.
-
template<class T>
int setFrom(const BaseImage<T> &image, double maxFlux, BaseDeviate ud) Set photon positions based on flux in an image.
The flux in each non-zero pixel will be turned into 1 or more photons according to the maxFlux parameter which sets an upper limit for the absolute value of the flux of any photon. Pixels with abs values > maxFlux will spawn multiple photons.
The positions of the photons will be random within the area of each pixel. TODO: This corresponds to the Nearest interpolant. Consider implementing other interpolation options here.
- Parameters:
image – The image to use for the photon fluxes and positions.
maxFlux – The maximum flux that any photon should have.
rng – A BaseDeviate in case we need to shuffle.
- Returns:
the total number of photons set.
Check if the current array has correlated photons.
Set whether the current array has correlated photons.
-
inline double *getXArray()
Silicon Sensor
-
class Silicon
Public Functions
-
Silicon(int numVertices, double numElec, int nx, int ny, int qDist, double diffStep, double pixelSize, double sensorThickness, double *vertex_data, const Table &tr_radial_table, Position<double> treeRingCenter, const Table &abs_length_table, bool transpose)
-
~Silicon()
-
bool insidePixel(int ix, int iy, double x, double y, double zconv, Bounds<int> &targetBounds, bool *off_edge, int emptypolySize, Bounds<double> *pixelInnerBoundsData, Bounds<double> *pixelOuterBoundsData, Position<float> *horizontalBoundaryPointsData, Position<float> *verticalBoundaryPointsData, Position<double> *emptypolyData) const
-
void scaleBoundsToPoly(int i, int j, int nx, int ny, const Polygon &emptypoly, Polygon &result, double factor) const
-
double calculateConversionDepth(bool photonsHasAllocatedWavelengths, const double *photonsWavelength, const double *abs_length_table_data, bool photonsHasAllocatedAngles, const double *photonsDXDZ, const double *photonsDYDZ, int i, double randomNumber) const
-
void calculateTreeRingDistortion(int i, int j, Position<int> orig_center, int nx, int ny, int i1, int j1)
-
void finalize()
-
template<typename T>
double accumulate(const PhotonArray &photons, int i1, int i2, BaseDeviate rng, ImageView<T> target)
-
double pixelArea(int i, int j, int nx, int ny) const
-
Silicon(int numVertices, double numElec, int nx, int ny, int qDist, double diffStep, double pixelSize, double sensorThickness, double *vertex_data, const Table &tr_radial_table, Position<double> treeRingCenter, const Table &abs_length_table, bool transpose)
Charge Deflection Correction
-
void galsim::ApplyCD(int n, double *x, double *y, const double *cd)