Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TLeafD.cxx
Go to the documentation of this file.
1// @(#)root/tree:$Id$
2// Author: Rene Brun 12/01/96
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/** \class TLeafD
13\ingroup tree
14
15A TLeaf for a 64 bit floating point data type.
16*/
17
18#include "TLeafD.h"
19#include "TBranch.h"
20#include "TBuffer.h"
21#include "TClonesArray.h"
22#include <iostream>
23
25
26////////////////////////////////////////////////////////////////////////////////
27/// Default constructor for LeafD.
28
30{
31 fLenType = 8;
32 fMinimum = 0;
33 fMaximum = 0;
34 fValue = nullptr;
35 fPointer = nullptr;
36}
37
38////////////////////////////////////////////////////////////////////////////////
39/// Create a LeafD.
40
41TLeafD::TLeafD(TBranch *parent, const char *name, const char *type)
42 :TLeaf(parent, name,type)
43{
44 fLenType = 8;
45 fMinimum = 0;
46 fMaximum = 0;
47 fValue = nullptr;
48 fPointer = nullptr;
49}
50
51////////////////////////////////////////////////////////////////////////////////
52/// Default destructor for a LeafD.
53
55{
56 if (ResetAddress(nullptr,true)) delete [] fValue;
57}
58
59////////////////////////////////////////////////////////////////////////////////
60/// Export element from local leaf buffer to ClonesArray.
61
63{
64 Int_t j = 0;
65 for (Int_t i=0;i<n;i++) {
66 memcpy((char*)list->UncheckedAt(i) + fOffset,&fValue[j], 8*fLen);
67 j += fLen;
68 }
69}
70
71////////////////////////////////////////////////////////////////////////////////
72/// Pack leaf elements in Basket output buffer.
73
75{
76 Int_t len = GetLen();
77 if (fPointer) fValue = *fPointer;
78 b.WriteFastArray(fValue,len);
79}
80
81////////////////////////////////////////////////////////////////////////////////
82/// Import element from ClonesArray into local leaf buffer.
83
85{
86 const Double_t kDoubleUndefined = -9999.;
87 Int_t j = 0;
88 char *clone;
89 for (Int_t i=0;i<n;i++) {
90 clone = (char*)list->UncheckedAt(i);
91 if (clone)
92 memcpy(&fValue[j],clone + fOffset, 8*fLen);
93 else
94 for (Int_t k = 0; k < fLen; ++k)
96 j += fLen;
97 }
98}
99
100////////////////////////////////////////////////////////////////////////////////
101/// Prints leaf value.
102
104{
106 printf("%g",value[l]);
107}
108
109////////////////////////////////////////////////////////////////////////////////
110/// Read leaf elements from Basket input buffer.
111
113{
114 if (!fLeafCount && fNdata == 1) {
115 b.ReadDouble(fValue[0]);
116 }else {
117 if (fLeafCount) {
119 if (fLeafCount->GetBranch()->GetReadEntry() != entry) {
121 }
123 if (len > fLeafCount->GetMaximum()) {
124 printf("ERROR leaf:%s, len=%d and max=%d\n",GetName(),len,fLeafCount->GetMaximum());
126 }
127 fNdata = len*fLen;
128 b.ReadFastArray(fValue,len*fLen);
129 } else {
130 b.ReadFastArray(fValue,fLen);
131 }
132 }
133}
134
135// Deserialize N events from an input buffer.
137 if (R__unlikely(fLeafCount)) { return false; }
138 return input_buf.ByteSwapBuffer(fLen*N, kDouble_t);
139}
140
141////////////////////////////////////////////////////////////////////////////////
142/// Read leaf elements from Basket input buffer and export buffer to
143/// TClonesArray objects.
144
146{
147 b.ReadFastArray(fValue,n*fLen);
148
149 Int_t j = 0;
150 for (Int_t i=0;i<n;i++) {
151 memcpy((char*)list->UncheckedAt(i) + fOffset,&fValue[j], 8*fLen);
152 j += fLen;
153 }
154}
155
156////////////////////////////////////////////////////////////////////////////////
157/// Read a double from std::istream s and store it into the branch buffer.
158
159void TLeafD::ReadValue(std::istream &s, Char_t /*delim = ' '*/)
160{
162 for (Int_t i=0;i<fLen;i++) s >> value[i];
163}
164
165////////////////////////////////////////////////////////////////////////////////
166/// Set leaf buffer data address.
167
168void TLeafD::SetAddress(void *add)
169{
170 if (ResetAddress(add) && (add!= fValue)) {
171 delete [] fValue;
172 }
173 if (add) {
175 fPointer = (Double_t**) add;
179 ncountmax > fNdata || *fPointer == nullptr) {
180 if (*fPointer) delete [] *fPointer;
182 *fPointer = new Double_t[fNdata];
183 }
184 fValue = *fPointer;
185 } else {
186 fValue = (Double_t*)add;
187 }
188 } else {
189 fValue = new Double_t[fNdata];
190 fValue[0] = 0;
191 }
192}
#define R__unlikely(expr)
Definition RConfig.hxx:594
#define b(i)
Definition RSha256.hxx:100
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
char Char_t
Character 1 byte (char)
Definition RtypesCore.h:51
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:83
#define ClassImp(name)
Definition Rtypes.h:376
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
@ kDouble_t
Definition TDataType.h:31
#define N
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char name[80]
Definition TGX11.cxx:110
A TTree is a list of TBranches.
Definition TBranch.h:93
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Read all leaves of entry and return total number of bytes read.
Definition TBranch.cxx:1706
Long64_t GetReadEntry() const
Definition TBranch.h:237
Buffer base class used for serializing objects.
Definition TBuffer.h:43
An array of clone (identical) objects.
A TLeaf for a 64 bit floating point data type.
Definition TLeafD.h:26
void * GetValuePointer() const override
Definition TLeafD.h:44
bool ReadBasketFast(TBuffer &, Long64_t) override
Definition TLeafD.cxx:136
void FillBasket(TBuffer &b) override
Pack leaf elements in Basket output buffer.
Definition TLeafD.cxx:74
Double_t fMaximum
Maximum value if leaf range is specified.
Definition TLeafD.h:30
void SetAddress(void *add=nullptr) override
Set leaf buffer data address.
Definition TLeafD.cxx:168
Double_t * fValue
! Pointer to data buffer
Definition TLeafD.h:31
void ReadValue(std::istream &s, Char_t delim=' ') override
Read a double from std::istream s and store it into the branch buffer.
Definition TLeafD.cxx:159
Double_t fMinimum
Minimum value if leaf range is specified.
Definition TLeafD.h:29
~TLeafD() override
Default destructor for a LeafD.
Definition TLeafD.cxx:54
void PrintValue(Int_t i=0) const override
Prints leaf value.
Definition TLeafD.cxx:103
TLeafD()
Default constructor for LeafD.
Definition TLeafD.cxx:29
Double_t ** fPointer
! Address of pointer to data buffer
Definition TLeafD.h:32
void ReadBasket(TBuffer &b) override
Read leaf elements from Basket input buffer.
Definition TLeafD.cxx:112
void Export(TClonesArray *list, Int_t n) override
Export element from local leaf buffer to ClonesArray.
Definition TLeafD.cxx:62
void Import(TClonesArray *list, Int_t n) override
Import element from ClonesArray into local leaf buffer.
Definition TLeafD.cxx:84
void ReadBasketExport(TBuffer &b, TClonesArray *list, Int_t n) override
Read leaf elements from Basket input buffer and export buffer to TClonesArray objects.
Definition TLeafD.cxx:145
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
Definition TLeaf.h:57
virtual Double_t GetValue(Int_t i=0) const
Definition TLeaf.h:183
Int_t fLenType
Number of bytes for this data type.
Definition TLeaf.h:73
virtual Int_t GetMaximum() const
Definition TLeaf.h:134
Int_t fLen
Number of fixed length elements in the leaf's data.
Definition TLeaf.h:72
Int_t fNdata
! Number of elements in fAddress data buffer.
Definition TLeaf.h:71
virtual Int_t GetLen() const
Return the number of effective elements of this leaf, for the current entry.
Definition TLeaf.cxx:406
Int_t ResetAddress(void *add, bool calledFromDestructor=false)
Helper routine for TLeafX::SetAddress.
Definition TLeaf.cxx:431
TBranch * GetBranch() const
Definition TLeaf.h:116
Int_t fOffset
Offset in ClonesArray object (if one)
Definition TLeaf.h:74
TBranch * fBranch
! Pointer to supporting branch (we do not own the branch)
Definition TLeaf.h:78
TLeaf * fLeafCount
Pointer to Leaf count if variable length (we do not own the counter)
Definition TLeaf.h:77
@ kIndirectAddress
Data member is a pointer to an array of basic types.
Definition TLeaf.h:95
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:202
const Int_t n
Definition legend1.C:16
TLine l
Definition textangle.C:4