Tutorial illustrating use and precision of the Double32_t data type You must run this tutorial with ACLIC: a dictionary will be automatically created.
The following cases are supported for streaming a Double32_t type depending on the range declaration in the comment field of the data member:
Case | Declaration |
A | Double32_t fNormal; |
B | Double32_t fTemperature; //[0,100] |
C | Double32_t fCharge; //[-1,1,2] |
D | Double32_t fVertex[3]; //[-30,30,10] |
E | Double32_t fChi2; //[0,0,6] |
F | Int_t fNsp;
Double32_t* fPointValue; //[fNsp][0,3] |
- Case A fNormal is converted from a Double_t to a Float_t
- Case B fTemperature is converted to a 32 bit unsigned integer
- Case C fCharge is converted to a 2 bits unsigned integer
- Case D the array elements of fVertex are converted to an unsigned 10 bits integer
- Case E fChi2 is converted to a Float_t with truncated precision at 6 bits
- Case F the fNsp elements of array fPointvalue are converted to an unsigned 32 bit integer. Note that the range specifier must follow the dimension specifier.
Case B has more precision than case A: 9 to 10 significative digits and 6 to 7 digits respectively. The range specifier has the general format: [xmin,xmax] or [xmin,xmax,nbits]. Examples
- [0,1]
- [-10,100];
- [-pi,pi], [-pi/2,pi/4],[-2pi,2*pi]
- [-10,100,16]
- [0,0,8] Note that:
- If nbits is not specified, or nbits <2 or nbits>32 it is set to 32
- If (xmin==0 and xmax==0 and nbits <=14) the double word will be converted to a float and its mantissa truncated to nbits significative bits.
IMPORTANT NOTE
Lets assume an original variable double x. When using the format 0,0,8 you get the best relative precision when storing and reading back the truncated x, say xt. The variance of (x-xt)/x will be better than when specifying a range for the same number of bits. However the precision relative to the range (x-xt)/(xmax-xmin) will be worst, and vice-versa. The format [0,0,8] is also interesting when the range of x is infinite or unknown.
class DemoDouble32 {
private:
public:
DemoDouble32() {;}
};
fD64 = fF32 = fI32 = fI30 = fI28 = fI26 = fI24 = fI22 = fI20 = ref;
fI18 = fI16 = fI14 = fI12 = fI10 = fI8 = fI6 = fI4 = fI2 = ref;
fR14 = fR12 = fR10 = fR8 = fR6 = fR4 = fR2 = ref;
}
void double32() {
DemoDouble32 *
d =
new DemoDouble32();
TBranch *bd =
T->Branch(
"d",
"DemoDouble32",&
d,4000);
}
c1->SetHighLightColor(0);
c1->SetFrameFillColor(20);
c1->SetFrameBorderSize(10);
c1->GetFrame()->SetFillColor(21);
c1->GetFrame()->SetBorderSize(12);
for (i=0;i<nb;i++) {
h->GetXaxis()->SetBinLabel(i+1,br->
GetName());
if (i > 0) {
}
if (i > 0) {
T->Draw(
Form(
"(fD64-%s)/(fD64+0.01)",br->
GetName()),
"",
"goff");
}
}
legend->
AddEntry(gcx,
"Compression factor",
"lp");
legend->
AddEntry(gdrange,
"Log of precision wrt range",
"lp");
legend->
AddEntry(gdval,
"Log of precision wrt value",
"lp");
}
char * Form(const char *fmt,...)
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
A TTree is a list of TBranches.
TObjArray * GetListOfBranches()
Long64_t GetZipBytes(Option_t *option="") const
Return total number of zip bytes in the branch if option ="*" includes all sub-branches of this branc...
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseGeneralPurpose, Int_t netopt=0)
Create / open a file.
A Graph is a graphics object made of two arrays X and Y with npoints each.
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
virtual void SetName(const char *name="")
Set graph name.
virtual void Draw(Option_t *chopt="")
Draw this graph with its current attributes.
1-D histogram with a float per channel (see TH1 documentation)}
This class displays a legend box (TPaveText) containing several legend entries.
TLegendEntry * AddEntry(const TObject *obj, const char *label="", Option_t *option="lpf")
Add a new entry to this legend.
virtual void Draw(Option_t *option="")
Draw this legend with its current attributes.
virtual const char * GetName() const
Returns name of object.
A Pave (see TPave) with a text centered in the Pave.
virtual void Draw(Option_t *option="")
Draw this pavelabel with its current attributes.
Random number generator class based on M.
A TTree object has a header with a name and a title.
Short_t Max(Short_t a, Short_t b)
Double_t RMS(Long64_t n, const T *a, const Double_t *w=0)
Return the Standard Deviation of an array a with length n.
Double_t Log10(Double_t x)
- Author
- Rene Brun
Definition in file double32.C.