BOSS 7.1.1
BESIII Offline Software System
Loading...
Searching...
No Matches
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
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,
46 unsigned maxexponent,
47 double start,
48 double stop,
49 bool center=false);
50 virtual ~ComPackExpFloat();
51// ComPackBase functions
52 virtual StatusCode pack (const double, d_ULong &) const;
53 virtual StatusCode unpack (const d_ULong, double &) const;
54 void print(std::ostream& os) const;
55private:
56 unsigned _maxexp; // maximum value of the exponent (+1)
57 unsigned _expmsk; // exponent storage mask
58 unsigned _mansft; // mantissa storage shift
59 unsigned _manmsk; // mantissa storage mask
60 unsigned _maxman; // maximum integer mantissa
61 double _invrange; // inverse range
62// pre-computed quantities to speed unpacking
63 double* _expfac;
64 double* _expoff;
65// disallow copy and equivalence
67 ComPackExpFloat& operator = (const ComPackExpFloat&);
68};
69
70#endif
71
72
73
74
75
76
unsigned int d_ULong
virtual ~ComPackExpFloat()
ComPackExpFloat(unsigned nbits, unsigned maxexponent, double start, double stop, bool center=false)
virtual StatusCode unpack(const d_ULong, double &) const
virtual StatusCode pack(const double, d_ULong &) const
void print(std::ostream &os) const