BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Reconstruction/MdcPatRec/MdcRecoUtil/include/MdcRecoUtil/ComPackExpFloat.h
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2// File and Version Information:
3// $Id: ComPackExpFloat.h,v 1.2 2009/12/23 02:59:56 zhangy Exp $
4//
5// Description:
6// class ComPackExpFloat; pack a floating (double) into a fixed range
7// mantissa with an exponential (power of 2) representation. With this class, the values
8// stored at the start of the range have the best precision, which
9// gradually decreases to the worst precision when going to the opposite
10// range. This is equivalent to flat packing of the log of the value,
11// but because the exponent storage space is variable, this class allows
12// the equivalent of scaling the (log) value.
13//
14// Environment:
15// Software developed for the BaBar Detector at the SLAC B-Factory.
16//
17// Author List:
18// Dave Brown 10/12/00
19//
20// Copyright Information:
21// Copyright (C) 2000 LBNL
22//
23// History:
24// Migration for BESIII MDC
25//
26//
27//--------------------------------------------------------------------------
28
29#ifndef COMPACKEXPFLOAT_HH
30#define COMPACKEXPFLOAT_HH
31
32#include "MdcRecoUtil/ComPackBase.h"
33#include <iostream>
34
35class ComPackExpFloat : public ComPackBase<double> {
36
37public:
38 // specify the storage space (number of total bits) and the maximum exponent.
39 // The mantissa will be stored in the bits left over after storing the exponent
40 // Note that the exponent is -UNSIGNED-. Note that the stop and start values do
41 // _not_ have to be monotonic; the order simply defines which end of the range
42 // has the fine precision (start) vs coarse (stop). The 'center' command will
43 // use the start and stop values to define the (exact) range for unpacking data
44 // (ie the packing bins will be centered about those values).
45 ComPackExpFloat( unsigned nbits, unsigned maxexponent, double start, double stop,
46 bool center = false );
48 // ComPackBase functions
49 virtual StatusCode pack( const double, d_ULong& ) const;
50 virtual StatusCode unpack( const d_ULong, double& ) const;
51 void print( std::ostream& os ) const;
52
53private:
54 unsigned _maxexp; // maximum value of the exponent (+1)
55 unsigned _expmsk; // exponent storage mask
56 unsigned _mansft; // mantissa storage shift
57 unsigned _manmsk; // mantissa storage mask
58 unsigned _maxman; // maximum integer mantissa
59 double _invrange; // inverse range
60 // pre-computed quantities to speed unpacking
61 double* _expfac;
62 double* _expoff;
63 // disallow copy and equivalence
65 ComPackExpFloat& operator=( const ComPackExpFloat& );
66};
67
68#endif
ComPackExpFloat(unsigned nbits, unsigned maxexponent, double start, double stop, bool center=false)
virtual StatusCode pack(const double, d_ULong &) const
virtual StatusCode unpack(const d_ULong, double &) const
void print(std::ostream &os) const
virtual ~ComPackExpFloat()