MythenFileReader

File reader to read mythen files. Supported are two file formats. RawMythenFileReader reads raw files as written by the slsDetectorPackage. The class EpicsMythenFileReader reads hdf5 files written by Epics. The EpicsMythenFileReader inherits from a wrapper class based on the C++ API of the HDF5 C Library. The provided dataset need to have fields data storing the photon counts, DetectorAngle storing the detector position in degrees and CounterMask storing which counters are active. The field CounterMask stores an integer representation of a 3-digit bit string, where each bit is set to 1 if the counter is active.

Example

CounterMask: 4 // binary representation 1 0 0
only channel 0 is active
CounterMask: 3 // binary representation 0 1 1
channel 1 and 2 are active
class MythenFileReader

abstract base class for MythenFileReader

Subclassed by angcal::EpicsMythenFileReader, angcal::RawMythenFileReader

Public Functions

MythenFileReader() = default
virtual ~MythenFileReader() = default
virtual MythenFrame read_frame(const std::filesystem::path &file_name) = 0
virtual double read_detector_angle(const std::filesystem::path &file_name) = 0
class RawMythenFileReader : public angcal::MythenFileReader

MythenFileReader to read raw files following format from slsDetectorPackage.

Public Functions

inline RawMythenFileReader(const std::filesystem::path &detector_angles, const std::filesystem::path &incident_intensities)

Constructor for MythenFileReader class.

Parameters:
  • detector_angles – path to file storing detector angles of the acquisitions (need to be stored as binary file of doubles)

  • incident_intensities – path to file storing incident intensities of the acquisitions (need to be stored as binary file of uint64_t)

inline ~RawMythenFileReader()
inline virtual MythenFrame read_frame(const std::filesystem::path &file_name) override

read Mythenframe

inline virtual double read_detector_angle(const std::filesystem::path &file_name) override

Private Functions

inline void read_detector_angle(const size_t acquisition_index, double &detector_angle)

reads the detector angle from file

inline void read_incident_intensity(const size_t acquisition_index, uint64_t &incident_intensity)

reads the incident intensity from file

inline size_t get_acquisition_index(const std::filesystem::path &filename)

gets the acquisition index from the filename

Private Members

std::string detector_angles_filename = {}
std::string incident_intensities_filename = {}
std::ifstream detector_angles_file = {}
std::ifstream incident_intensities_file = {}
class EpicsMythenFileReader : public angcal::HDF5FileReader, public angcal::MythenFileReader

class to read MythenFiles following Epics file format

Public Functions

EpicsMythenFileReader() = default

Default Constructor.

Note

incident intensities not initialized will take the ones written by epics in the hdf5 file. For newer versions this will be garbage.

inline EpicsMythenFileReader(const std::filesystem::path &incident_intensity_filename_)

Constructor.

Parameters:

incident_intensities – path to file storing incident intensities of the acquisitions (need to be stored as binary file of uint64_t)

inline ~EpicsMythenFileReader()
inline virtual double read_detector_angle(const std::filesystem::path &file_name) override

read the detector monitor position

Returns:

detector position [degrees]

inline virtual MythenFrame read_frame(const std::filesystem::path &file_name) override

read acquisition file from hdf5

Returns:

MythenFrame storing the photon counts, channel mask, detector position [degrees]

inline void read_incident_intensity(const size_t acquisition_index, uint64_t &incident_intensity)

reads the incident intensity from seperate file

inline void read_incident_intensity_from_hdf5(uint64_t &incident_intensity)

reads the incident intensity from epics hdf5 files

inline void open_file(const std::string &filename_)
inline void close_file()
inline HDF5Dataset get_dataset(const std::string &dataset_name) const

Private Functions

inline size_t get_acquisition_index(const std::filesystem::path &file_name)

get the acquisition index from the filename

Private Members

std::string incident_intensities_filename = {}
std::ifstream incident_intensities_file = {}

MythenFrame

struct MythenFrame : public aare::Frame

Public Functions

MythenFrame() = delete
inline MythenFrame(aare::Frame &&frame)
MythenFrame(MythenFrame&&) = default
inline NDView<uint32_t, 1> photon_counts()

photon counts for each channel stored as 1d array

inline uint32_t photon_counts(size_t col, size_t row = 0) const

photon counts at specfic channel

Parameters:

col – channel index

inline ssize_t size() const

size of frame (given in pixels)

Public Members

double detector_angle = {}

detector angle in degrees

uint64_t incident_intensity = {}
double exposure_time = {}

exposure time in seconds

std::array<uint8_t, 3> channel_mask = {}

counter mask given as binary representation (counter 0 is most significant bit)