00001 //-------------------------------------------------------------------------- 00002 // File and Version Information: 00003 // $Id: ComPackSignedExpFloat.h,v 1.2 2009/12/23 02:59:56 zhangy Exp $ 00004 // 00005 // Description: 00006 // class ComPackSignedExpFloat; Uses ComPackExpFloat to store the 00007 // magnitude of a signed quantity, then adds in the sign. 00008 // Environment: 00009 // Software developed for the BaBar Detector at the SLAC B-Factory. 00010 // 00011 // Author List: 00012 // Dave Brown 10/12/00 00013 // 00014 // Copyright Information: 00015 // Copyright (C) 2000 LBNL 00016 // 00017 // History: 00018 // Migration for BESIII MDC 00019 // 00020 // 00021 //-------------------------------------------------------------------------- 00022 00023 #ifndef COMPACKSIGNEDEXPFLOAT_HH 00024 #define COMPACKSIGNEDEXPFLOAT_HH 00025 00026 #include "MdcRecoUtil/ComPackExpFloat.h" 00027 #include <iostream> 00028 00029 class ComPackSignedExpFloat:public ComPackBase<double> { 00030 00031 public: 00032 // See ComPackExpFloat for an explanation. Note that in this class, the number 00033 // of bits should include 1 for the sign. The invert flag specifies that the best 00034 // resolution should occur at the +-maxval end of the range instead of around 0. 00035 ComPackSignedExpFloat(unsigned nbits, 00036 unsigned maxexponent, 00037 double maxval, 00038 bool invert=false, 00039 bool center=false ); 00040 virtual ~ComPackSignedExpFloat(); 00041 // ComPackBase functions 00042 virtual StatusCode pack (const double, d_ULong &) const; 00043 virtual StatusCode unpack (const d_ULong, double &) const; 00044 void print(std::ostream& s=std::cout) const; 00045 private: 00046 // This class uses ComPackExpFloat to do the dirty work 00047 ComPackExpFloat _packer; 00048 unsigned _signbit; // sign bits location 00049 unsigned _signmask; // mask for positive 00050 }; 00051 00052 #endif 00053 00054 00055 00056 00057 00058