00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "H5DataTypes/CsPadPixelStatusV1.h"
00017
00018
00019
00020
00021 #include <algorithm>
00022
00023
00024
00025
00026 #include "ErrSvc/Issue.h"
00027 #include "hdf5pp/ArrayType.h"
00028 #include "hdf5pp/TypeTraits.h"
00029 #include "H5DataTypes/H5DataUtils.h"
00030 #include "MsgLogger/MsgLogger.h"
00031
00032
00033
00034
00035
00036 namespace {
00037
00038 class BadShape: public ErrSvc::Issue {
00039 public:
00040 BadShape(const ErrSvc::Context& ctx) : ErrSvc::Issue(ctx, "Illegal shape of data array") {}
00041 };
00042
00043 }
00044
00045
00046
00047
00048
00049 namespace H5DataTypes {
00050
00051
00052
00053
00054 CsPadPixelStatusV1::CsPadPixelStatusV1 ()
00055 {
00056
00057 pdscalibdata::CsPadPixelStatusV1::status_t zero=0;
00058 std::fill_n(&status[0][0][0][0], int(DataType::Size), zero);
00059 }
00060
00061 CsPadPixelStatusV1::CsPadPixelStatusV1 (const DataType& data)
00062 {
00063 const ndarray<DataType::status_t, 4>& sdata = data.status();
00064
00065
00066 const unsigned* shape = sdata.shape();
00067 if (shape[0] != DataType::Quads or shape[1] != DataType::Sections or
00068 shape[2] != DataType::Columns or shape[3] != DataType::Rows) {
00069 throw BadShape(ERR_LOC);
00070 }
00071
00072 const DataType::status_t* src = &sdata[0][0][0][0];
00073 DataType::status_t* dst = &status[0][0][0][0];
00074 std::copy(src, src+int(DataType::Size), dst );
00075 }
00076
00077
00078
00079
00080 CsPadPixelStatusV1::~CsPadPixelStatusV1 ()
00081 {
00082 }
00083
00084
00085 hdf5pp::Type
00086 CsPadPixelStatusV1::stored_type()
00087 {
00088 return native_type() ;
00089 }
00090
00091 hdf5pp::Type
00092 CsPadPixelStatusV1::native_type()
00093 {
00094 hsize_t dims[4] = { DataType::Quads,
00095 DataType::Sections,
00096 DataType::Columns,
00097 DataType::Rows};
00098 hdf5pp::ArrayType arrType =
00099 hdf5pp::ArrayType::arrayType(hdf5pp::TypeTraits<DataType::status_t>::native_type(), 4, dims) ;
00100 return arrType;
00101 }
00102
00103 void
00104 CsPadPixelStatusV1::store( const DataType& data, hdf5pp::Group grp, const std::string& fileName )
00105 {
00106 CsPadPixelStatusV1 obj(data);
00107 hdf5pp::DataSet ds = storeDataObject ( obj, "pixel_status", grp ) ;
00108
00109
00110 ds.createAttr<const char*>("source").store(fileName.c_str());
00111 }
00112
00113 }