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