H5DataTypes/src/CsPadConfigV3.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id: CsPadConfigV3.cpp 6826 2013-09-24 21:08:01Z salnikov@SLAC.STANFORD.EDU $
00004 //
00005 // Description:
00006 //      Class CsPadConfigV3...
00007 //
00008 // Author List:
00009 //      Andrei Salnikov
00010 //
00011 //------------------------------------------------------------------------
00012 
00013 //-----------------------
00014 // This Class's Header --
00015 //-----------------------
00016 #include "H5DataTypes/CsPadConfigV3.h"
00017 
00018 //-----------------
00019 // C/C++ Headers --
00020 //-----------------
00021 #include <algorithm>
00022 
00023 //-------------------------------
00024 // Collaborating Class Headers --
00025 //-------------------------------
00026 #include "hdf5pp/ArrayType.h"
00027 #include "hdf5pp/CompoundType.h"
00028 #include "hdf5pp/TypeTraits.h"
00029 #include "H5DataTypes/H5DataUtils.h"
00030 
00031 //-----------------------------------------------------------------------
00032 // Local Macros, Typedefs, Structures, Unions and Forward Declarations --
00033 //-----------------------------------------------------------------------
00034 
00035 //              ----------------------------------------
00036 //              -- Public Function Member Definitions --
00037 //              ----------------------------------------
00038 
00039 namespace H5DataTypes {
00040 
00041 CsPadProtectionSystemThreshold::CsPadProtectionSystemThreshold(const Pds::CsPad::ProtectionSystemThreshold& o)
00042   : adcThreshold(o.adcThreshold())
00043   , pixelCountThreshold(o.pixelCountThreshold())
00044 {
00045 }
00046 
00047 hdf5pp::Type
00048 CsPadProtectionSystemThreshold::native_type()
00049 {
00050   hdf5pp::CompoundType protSysType = hdf5pp::CompoundType::compoundType<CsPadProtectionSystemThreshold>() ;
00051   protSysType.insert_native<uint32_t>( "adcThreshold", offsetof(CsPadProtectionSystemThreshold, adcThreshold) ) ;
00052   protSysType.insert_native<uint32_t>( "pixelCountThreshold", offsetof(CsPadProtectionSystemThreshold, pixelCountThreshold) ) ;
00053   return protSysType;
00054 }
00055 
00056 
00057 CsPadConfigV3::CsPadConfigV3 ( const XtcType& data )
00058   : concentratorVersion(data.concentratorVersion())
00059   , runDelay(data.runDelay())
00060   , eventCode(data.eventCode())
00061   , protectionEnable(data.protectionEnable())
00062   , inactiveRunMode(data.inactiveRunMode())
00063   , activeRunMode(data.activeRunMode())
00064   , testDataIndex(data.tdi())
00065   , payloadPerQuad(data.payloadSize())
00066   , badAsicMask0(data.badAsicMask0())
00067   , badAsicMask1(data.badAsicMask1())
00068   , asicMask(data.asicMask())
00069   , quadMask(data.quadMask())
00070 {
00071   for ( int q = 0; q < MaxQuadsPerSensor ; ++ q ) {
00072     roiMask[q] = data.roiMask(q);
00073   }
00074   
00075   for ( int q = 0; q < MaxQuadsPerSensor ; ++ q ) {
00076     quads[q] = data.quads(q);
00077   }
00078 
00079   const ndarray<const Pds::CsPad::ProtectionSystemThreshold, 1>& thresh = data.protectionThresholds();
00080   std::copy(thresh.begin(), thresh.end(), protectionThresholds);
00081 
00082   // fill the list of active sections from ROI bits
00083   int ns = 0 ;
00084   for ( int q = 0; q < MaxQuadsPerSensor ; ++ q ) {
00085     for ( int s = 0; s < SectionsPerQuad ; ++ s ) {
00086       sections[q][s] = -1;
00087       if ( roiMask[q] & (1<<s) ) sections[q][s] = ns++;
00088     }
00089   }
00090   
00091 }
00092 
00093 hdf5pp::Type
00094 CsPadConfigV3::stored_type()
00095 {
00096   return native_type() ;
00097 }
00098 
00099 hdf5pp::Type
00100 CsPadConfigV3::native_type()
00101 {
00102   hsize_t sdims[2] = {MaxQuadsPerSensor, SectionsPerQuad};
00103   hdf5pp::Type baseSectType = hdf5pp::TypeTraits<int8_t>::native_type();
00104   hdf5pp::ArrayType sectArrType = hdf5pp::ArrayType::arrayType(baseSectType, 2, sdims);
00105 
00106   hdf5pp::CompoundType confType = hdf5pp::CompoundType::compoundType<CsPadConfigV3>() ;
00107   confType.insert_native<uint32_t>( "concentratorVersion", offsetof(CsPadConfigV3, concentratorVersion) ) ;
00108   confType.insert_native<uint32_t>( "runDelay", offsetof(CsPadConfigV3, runDelay) ) ;
00109   confType.insert_native<uint32_t>( "eventCode", offsetof(CsPadConfigV3, eventCode) ) ;
00110   confType.insert("protectionThresholds", offsetof(CsPadConfigV3, protectionThresholds), CsPadProtectionSystemThreshold::native_type(), MaxQuadsPerSensor ) ;
00111   confType.insert_native<uint32_t>( "protectionEnable", offsetof(CsPadConfigV3, protectionEnable) ) ;
00112   confType.insert_native<uint32_t>( "inactiveRunMode", offsetof(CsPadConfigV3, inactiveRunMode) ) ;
00113   confType.insert_native<uint32_t>( "activeRunMode", offsetof(CsPadConfigV3, activeRunMode) ) ;
00114   confType.insert_native<uint32_t>( "testDataIndex", offsetof(CsPadConfigV3, testDataIndex) ) ;
00115   confType.insert_native<uint32_t>( "payloadPerQuad", offsetof(CsPadConfigV3, payloadPerQuad) ) ;
00116   confType.insert_native<uint32_t>( "badAsicMask0", offsetof(CsPadConfigV3, badAsicMask0) ) ;
00117   confType.insert_native<uint32_t>( "badAsicMask1", offsetof(CsPadConfigV3, badAsicMask1) ) ;
00118   confType.insert_native<uint32_t>( "asicMask", offsetof(CsPadConfigV3, asicMask) ) ;
00119   confType.insert_native<uint32_t>( "quadMask", offsetof(CsPadConfigV3, quadMask) ) ;
00120   confType.insert_native<uint32_t>( "roiMask", offsetof(CsPadConfigV3, roiMask) ) ;
00121   confType.insert("quads", offsetof(CsPadConfigV3, quads), CsPadConfigV1QuadReg::native_type(), MaxQuadsPerSensor ) ;
00122   confType.insert("sections", offsetof(CsPadConfigV3, sections), sectArrType ) ;
00123 
00124   return confType ;
00125 }
00126 
00127 void
00128 CsPadConfigV3::store( const XtcType& config, hdf5pp::Group grp )
00129 {
00130   // make scalar data set for main object
00131   CsPadConfigV3 data ( config ) ;
00132   storeDataObject ( data, "config", grp ) ;
00133 }
00134 
00135 } // namespace H5DataTypes

Generated on 19 Dec 2016 for PSDMSoftware by  doxygen 1.4.7