Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

64bit index #6

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/base/inc/Rtypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ typedef float Float_t; //Float 4 bytes (float)
typedef float Float16_t; //Float 4 bytes written with a truncated mantissa
typedef double Double_t; //Double 8 bytes
typedef double Double32_t; //Double 8 bytes in memory, written as a 4 bytes float
typedef long double LongDouble_t;//Long Double
typedef char Text_t; //General string (char)
typedef bool Bool_t; //Boolean (0=false, 1=true) (bool)
typedef unsigned char Byte_t; //Byte (8 bits) (unsigned char)
Expand Down
14 changes: 9 additions & 5 deletions io/io/inc/TStreamerInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class TStreamerInfo : public TVirtualStreamerInfo {

static Int_t fgCount; //Number of TStreamerInfo instances
static TStreamerElement *fgElement; //Pointer to current TStreamerElement
static Double_t GetValueAux(Int_t type, void *ladd, int k, Int_t len);
template <typename T> static T GetTypedValueAux(Int_t type, void *ladd, int k, Int_t len);
static void PrintValueAux(char *ladd, Int_t atype, TStreamerElement * aElement, Int_t aleng, Int_t *count);

UInt_t GenerateIncludes(FILE *fp, char *inclist, const TList *extrainfos);
Expand Down Expand Up @@ -220,10 +220,14 @@ class TStreamerInfo : public TVirtualStreamerInfo {
TStreamerElement *GetStreamerElement(const char*datamember, Int_t& offset) const;
TStreamerElement *GetStreamerElementReal(Int_t i, Int_t j) const;
Int_t *GetTypes() const {return fType;}
Double_t GetValue(char *pointer, Int_t i, Int_t j, Int_t len) const;
Double_t GetValueClones(TClonesArray *clones, Int_t i, Int_t j, Int_t k, Int_t eoffset) const;
Double_t GetValueSTL(TVirtualCollectionProxy *cont, Int_t i, Int_t j, Int_t k, Int_t eoffset) const;
Double_t GetValueSTLP(TVirtualCollectionProxy *cont, Int_t i, Int_t j, Int_t k, Int_t eoffset) const;
template <typename T> T GetTypedValue(char *pointer, Int_t i, Int_t j, Int_t len) const;
template <typename T> T GetTypedValueClones(TClonesArray *clones, Int_t i, Int_t j, Int_t k, Int_t eoffset) const;
template <typename T> T GetTypedValueSTL(TVirtualCollectionProxy *cont, Int_t i, Int_t j, Int_t k, Int_t eoffset) const;
template <typename T> T GetTypedValueSTLP(TVirtualCollectionProxy *cont, Int_t i, Int_t j, Int_t k, Int_t eoffset) const;
Double_t GetValue(char *pointer, Int_t i, Int_t j, Int_t len) const { return GetTypedValue<Double_t>(pointer, i, j, len); }
Double_t GetValueClones(TClonesArray *clones, Int_t i, Int_t j, Int_t k, Int_t eoffset) const { return GetTypedValueClones<Double_t>(clones, i, j, k, eoffset); }
Double_t GetValueSTL(TVirtualCollectionProxy *cont, Int_t i, Int_t j, Int_t k, Int_t eoffset) const { return GetTypedValueSTL<Double_t>(cont, i, j, k, eoffset); }
Double_t GetValueSTLP(TVirtualCollectionProxy *cont, Int_t i, Int_t j, Int_t k, Int_t eoffset) const { return GetTypedValueSTLP<Double_t>(cont, i, j, k, eoffset); }
void ls(Option_t *option="") const;
TVirtualStreamerInfo *NewInfo(TClass *cl) {return new TStreamerInfo(cl);}
void *New(void *obj = 0);
Expand Down
111 changes: 66 additions & 45 deletions io/io/src/TStreamerInfo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3485,7 +3485,8 @@ TStreamerElement* TStreamerInfo::GetStreamerElementReal(Int_t i, Int_t j) const
}

//______________________________________________________________________________
Double_t TStreamerInfo::GetValueAux(Int_t type, void *ladd, Int_t k, Int_t len)
template <typename T>
T TStreamerInfo::GetTypedValueAux(Int_t type, void *ladd, Int_t k, Int_t len)
{
// Get the value from inside a collection.

Expand All @@ -3494,46 +3495,46 @@ Double_t TStreamerInfo::GetValueAux(Int_t type, void *ladd, Int_t k, Int_t len)
}
switch (type) {
// basic types
case kBool: {Bool_t *val = (Bool_t*)ladd; return Double_t(*val);}
case kChar: {Char_t *val = (Char_t*)ladd; return Double_t(*val);}
case kShort: {Short_t *val = (Short_t*)ladd; return Double_t(*val);}
case kInt: {Int_t *val = (Int_t*)ladd; return Double_t(*val);}
case kLong: {Long_t *val = (Long_t*)ladd; return Double_t(*val);}
case kLong64: {Long64_t *val = (Long64_t*)ladd; return Double_t(*val);}
case kFloat: {Float_t *val = (Float_t*)ladd; return Double_t(*val);}
case kFloat16: {Float_t *val = (Float_t*)ladd; return Double_t(*val);}
case kDouble: {Double_t *val = (Double_t*)ladd; return Double_t(*val);}
case kDouble32: {Double_t *val = (Double_t*)ladd; return Double_t(*val);}
case kUChar: {UChar_t *val = (UChar_t*)ladd; return Double_t(*val);}
case kUShort: {UShort_t *val = (UShort_t*)ladd; return Double_t(*val);}
case kUInt: {UInt_t *val = (UInt_t*)ladd; return Double_t(*val);}
case kULong: {ULong_t *val = (ULong_t*)ladd; return Double_t(*val);}
case kBool: {Bool_t *val = (Bool_t*)ladd; return T(*val);}
case kChar: {Char_t *val = (Char_t*)ladd; return T(*val);}
case kShort: {Short_t *val = (Short_t*)ladd; return T(*val);}
case kInt: {Int_t *val = (Int_t*)ladd; return T(*val);}
case kLong: {Long_t *val = (Long_t*)ladd; return T(*val);}
case kLong64: {Long64_t *val = (Long64_t*)ladd; return T(*val);}
case kFloat: {Float_t *val = (Float_t*)ladd; return T(*val);}
case kFloat16: {Float_t *val = (Float_t*)ladd; return T(*val);}
case kDouble: {Double_t *val = (Double_t*)ladd; return T(*val);}
case kDouble32: {Double_t *val = (Double_t*)ladd; return T(*val);}
case kUChar: {UChar_t *val = (UChar_t*)ladd; return T(*val);}
case kUShort: {UShort_t *val = (UShort_t*)ladd; return T(*val);}
case kUInt: {UInt_t *val = (UInt_t*)ladd; return T(*val);}
case kULong: {ULong_t *val = (ULong_t*)ladd; return T(*val);}
#if defined(_MSC_VER) && (_MSC_VER <= 1200)
case kULong64: {Long64_t *val = (Long64_t*)ladd; return Double_t(*val);}
case kULong64: {Long64_t *val = (Long64_t*)ladd; return T(*val);}
#else
case kULong64: {ULong64_t *val= (ULong64_t*)ladd; return Double_t(*val);}
case kULong64: {ULong64_t *val= (ULong64_t*)ladd; return T(*val);}
#endif
case kBits: {UInt_t *val = (UInt_t*)ladd; return Double_t(*val);}
case kBits: {UInt_t *val = (UInt_t*)ladd; return T(*val);}

// array of basic types array[8]
case kOffsetL + kBool: {Bool_t *val = (Bool_t*)ladd; return Double_t(val[k]);}
case kOffsetL + kChar: {Char_t *val = (Char_t*)ladd; return Double_t(val[k]);}
case kOffsetL + kShort: {Short_t *val = (Short_t*)ladd; return Double_t(val[k]);}
case kOffsetL + kInt: {Int_t *val = (Int_t*)ladd; return Double_t(val[k]);}
case kOffsetL + kLong: {Long_t *val = (Long_t*)ladd; return Double_t(val[k]);}
case kOffsetL + kLong64: {Long64_t *val = (Long64_t*)ladd; return Double_t(val[k]);}
case kOffsetL + kFloat: {Float_t *val = (Float_t*)ladd; return Double_t(val[k]);}
case kOffsetL + kFloat16: {Float_t *val = (Float_t*)ladd; return Double_t(val[k]);}
case kOffsetL + kDouble: {Double_t *val = (Double_t*)ladd; return Double_t(val[k]);}
case kOffsetL + kDouble32:{Double_t *val = (Double_t*)ladd; return Double_t(val[k]);}
case kOffsetL + kUChar: {UChar_t *val = (UChar_t*)ladd; return Double_t(val[k]);}
case kOffsetL + kUShort: {UShort_t *val = (UShort_t*)ladd; return Double_t(val[k]);}
case kOffsetL + kUInt: {UInt_t *val = (UInt_t*)ladd; return Double_t(val[k]);}
case kOffsetL + kULong: {ULong_t *val = (ULong_t*)ladd; return Double_t(val[k]);}
case kOffsetL + kBool: {Bool_t *val = (Bool_t*)ladd; return T(val[k]);}
case kOffsetL + kChar: {Char_t *val = (Char_t*)ladd; return T(val[k]);}
case kOffsetL + kShort: {Short_t *val = (Short_t*)ladd; return T(val[k]);}
case kOffsetL + kInt: {Int_t *val = (Int_t*)ladd; return T(val[k]);}
case kOffsetL + kLong: {Long_t *val = (Long_t*)ladd; return T(val[k]);}
case kOffsetL + kLong64: {Long64_t *val = (Long64_t*)ladd; return T(val[k]);}
case kOffsetL + kFloat: {Float_t *val = (Float_t*)ladd; return T(val[k]);}
case kOffsetL + kFloat16: {Float_t *val = (Float_t*)ladd; return T(val[k]);}
case kOffsetL + kDouble: {Double_t *val = (Double_t*)ladd; return T(val[k]);}
case kOffsetL + kDouble32:{Double_t *val = (Double_t*)ladd; return T(val[k]);}
case kOffsetL + kUChar: {UChar_t *val = (UChar_t*)ladd; return T(val[k]);}
case kOffsetL + kUShort: {UShort_t *val = (UShort_t*)ladd; return T(val[k]);}
case kOffsetL + kUInt: {UInt_t *val = (UInt_t*)ladd; return T(val[k]);}
case kOffsetL + kULong: {ULong_t *val = (ULong_t*)ladd; return T(val[k]);}
#if defined(_MSC_VER) && (_MSC_VER <= 1200)
case kOffsetL + kULong64: {Long64_t *val = (Long64_t*)ladd; return Double_t(val[k]);}
case kOffsetL + kULong64: {Long64_t *val = (Long64_t*)ladd; return T(val[k]);}
#else
case kOffsetL + kULong64:{ULong64_t *val= (ULong64_t*)ladd; return Double_t(val[k]);}
case kOffsetL + kULong64:{ULong64_t *val= (ULong64_t*)ladd; return T(val[k]);}
#endif

#define READ_ARRAY(TYPE_t) \
Expand All @@ -3548,7 +3549,7 @@ Double_t TStreamerInfo::GetValueAux(Int_t type, void *ladd, Int_t k, Int_t len)
sub_instance = 0; \
} \
TYPE_t **val =(TYPE_t**)(ladd); \
return Double_t((val[sub_instance])[index]); \
return T((val[sub_instance])[index]); \
}

// pointer to an array of basic types array[n]
Expand All @@ -3573,13 +3574,18 @@ Double_t TStreamerInfo::GetValueAux(Int_t type, void *ladd, Int_t k, Int_t len)
#endif

// array counter //[n]
case kCounter: {Int_t *val = (Int_t*)ladd; return Double_t(*val);}
case kCounter: {Int_t *val = (Int_t*)ladd; return T(*val);}
}
return 0;
}

//______________________________________________________________________________
Double_t TStreamerInfo::GetValue(char *pointer, Int_t i, Int_t j, Int_t len) const
template Double_t TStreamerInfo::GetTypedValue(char *pointer, Int_t i, Int_t j, Int_t len) const;
template Long64_t TStreamerInfo::GetTypedValue(char *pointer, Int_t i, Int_t j, Int_t len) const;
template LongDouble_t TStreamerInfo::GetTypedValue(char *pointer, Int_t i, Int_t j, Int_t len) const;

template <typename T>
T TStreamerInfo::GetTypedValue(char *pointer, Int_t i, Int_t j, Int_t len) const
{
// return value of element i in object at pointer.
// The function may be called in two ways:
Expand Down Expand Up @@ -3615,15 +3621,20 @@ Double_t TStreamerInfo::GetValue(char *pointer, Int_t i, Int_t j, Int_t len) con
Int_t nc = proxy->Size();
if (j >= nc) return 0;
char *element_ptr = (char*)proxy->At(j);
return GetValueAux(atype,element_ptr,0,1);
return GetTypedValueAux<T>(atype,element_ptr,0,1);
}
}
}
return GetValueAux(atype,ladd,j,len);
return GetTypedValueAux<T>(atype,ladd,j,len);
}

//______________________________________________________________________________
Double_t TStreamerInfo::GetValueClones(TClonesArray *clones, Int_t i, Int_t j, int k, Int_t eoffset) const
template Double_t TStreamerInfo::GetTypedValueClones<Double_t>(TClonesArray *clones, Int_t i, Int_t j, int k, Int_t eoffset) const;
template Long64_t TStreamerInfo::GetTypedValueClones(TClonesArray *clones, Int_t i, Int_t j, int k, Int_t eoffset) const;
template LongDouble_t TStreamerInfo::GetTypedValueClones(TClonesArray *clones, Int_t i, Int_t j, int k, Int_t eoffset) const;

template <typename T>
T TStreamerInfo::GetTypedValueClones(TClonesArray *clones, Int_t i, Int_t j, int k, Int_t eoffset) const
{
// return value of element i in object number j in a TClonesArray and eventually
// element k in a sub-array.
Expand All @@ -3633,11 +3644,16 @@ Double_t TStreamerInfo::GetValueClones(TClonesArray *clones, Int_t i, Int_t j, i

char *pointer = (char*)clones->UncheckedAt(j);
char *ladd = pointer + eoffset + fOffset[i];
return GetValueAux(fType[i],ladd,k,((TStreamerElement*)fElem[i])->GetArrayLength());
return GetTypedValueAux<T>(fType[i],ladd,k,((TStreamerElement*)fElem[i])->GetArrayLength());
}

//______________________________________________________________________________
Double_t TStreamerInfo::GetValueSTL(TVirtualCollectionProxy *cont, Int_t i, Int_t j, int k, Int_t eoffset) const
template Double_t TStreamerInfo::GetTypedValueSTL(TVirtualCollectionProxy *cont, Int_t i, Int_t j, int k, Int_t eoffset) const;
template Long64_t TStreamerInfo::GetTypedValueSTL(TVirtualCollectionProxy *cont, Int_t i, Int_t j, int k, Int_t eoffset) const;
template LongDouble_t TStreamerInfo::GetTypedValueSTL(TVirtualCollectionProxy *cont, Int_t i, Int_t j, int k, Int_t eoffset) const;

template <typename T>
T TStreamerInfo::GetTypedValueSTL(TVirtualCollectionProxy *cont, Int_t i, Int_t j, int k, Int_t eoffset) const
{
// return value of element i in object number j in a TClonesArray and eventually
// element k in a sub-array.
Expand All @@ -3647,11 +3663,16 @@ Double_t TStreamerInfo::GetValueSTL(TVirtualCollectionProxy *cont, Int_t i, Int_

char *pointer = (char*)cont->At(j);
char *ladd = pointer + eoffset + fOffset[i];
return GetValueAux(fType[i],ladd,k,((TStreamerElement*)fElem[i])->GetArrayLength());
return GetTypedValueAux<T>(fType[i],ladd,k,((TStreamerElement*)fElem[i])->GetArrayLength());
}

//______________________________________________________________________________
Double_t TStreamerInfo::GetValueSTLP(TVirtualCollectionProxy *cont, Int_t i, Int_t j, int k, Int_t eoffset) const
template Double_t TStreamerInfo::GetTypedValueSTLP(TVirtualCollectionProxy *cont, Int_t i, Int_t j, int k, Int_t eoffset) const;
template Long64_t TStreamerInfo::GetTypedValueSTLP(TVirtualCollectionProxy *cont, Int_t i, Int_t j, int k, Int_t eoffset) const;
template LongDouble_t TStreamerInfo::GetTypedValueSTLP(TVirtualCollectionProxy *cont, Int_t i, Int_t j, int k, Int_t eoffset) const;

template <typename T>
T TStreamerInfo::GetTypedValueSTLP(TVirtualCollectionProxy *cont, Int_t i, Int_t j, int k, Int_t eoffset) const
{
// return value of element i in object number j in a TClonesArray and eventually
// element k in a sub-array.
Expand All @@ -3663,7 +3684,7 @@ Double_t TStreamerInfo::GetValueSTLP(TVirtualCollectionProxy *cont, Int_t i, Int
char *pointer = *ptr;

char *ladd = pointer + eoffset + fOffset[i];
return GetValueAux(fType[i],ladd,k,((TStreamerElement*)fElem[i])->GetArrayLength());
return GetTypedValueAux<T>(fType[i],ladd,k,((TStreamerElement*)fElem[i])->GetArrayLength());
}

//______________________________________________________________________________
Expand Down
3 changes: 2 additions & 1 deletion tree/tree/inc/TBranchElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ class TBranchElement : public TBranch {
Int_t GetStreamerType() const { return fStreamerType; }
virtual TClass *GetTargetClass() { return fTargetClass; }
virtual const char *GetTypeName() const;
Double_t GetValue(Int_t i, Int_t len, Bool_t subarr = kFALSE) const;
Double_t GetValue(Int_t i, Int_t len, Bool_t subarr = kFALSE) const { return GetTypedValue<Double_t>(i, len, subarr); }
template<typename T > T GetTypedValue(Int_t i, Int_t len, Bool_t subarr = kFALSE) const;
virtual void *GetValuePointer() const;
Int_t GetClassVersion() { return fClassVersion; }
Bool_t IsBranchFolder() const { return TestBit(kBranchFolder); }
Expand Down
22 changes: 22 additions & 0 deletions tree/tree/inc/TLeaf.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ class TLeaf : public TNamed {
TLeaf(const TLeaf&);
TLeaf& operator=(const TLeaf&);

template <typename T> struct GetValueHelper {
static T Exec(const TLeaf *leaf, Int_t i = 0) { return leaf->GetValue(i); }
};

public:
enum {
kIndirectAddress = BIT(11), // Data member is a pointer to an array of basic types.
Expand All @@ -75,7 +79,12 @@ class TLeaf : public TNamed {
virtual Int_t GetOffset() const { return fOffset; }
virtual void *GetValuePointer() const { return 0; }
virtual const char *GetTypeName() const { return ""; }

virtual Double_t GetValue(Int_t i = 0) const;
virtual Long64_t GetValueLong64(Int_t i = 0) const { return GetValue(i); } //overload only when it matters.
virtual LongDouble_t GetValueLongDouble(Int_t i = 0) const { return GetValue(i); } // overload only when it matters.
template <typename T > T GetTypedValue(Int_t i = 0) const { return GetValueHelper<T>::Exec(this, i); }

virtual void Import(TClonesArray*, Int_t) {}
virtual Bool_t IsOnTerminalBranch() const { return kTRUE; }
virtual Bool_t IsRange() const { return fIsRange; }
Expand All @@ -98,6 +107,19 @@ class TLeaf : public TNamed {
ClassDef(TLeaf,2); //Leaf: description of a Branch data type
};


template <> struct TLeaf::GetValueHelper<Long64_t> {
static Long64_t Exec(const TLeaf *leaf, Int_t i = 0) { return leaf->GetValueLong64(i); }
};
template <> struct TLeaf::GetValueHelper<ULong64_t> {
static ULong64_t Exec(const TLeaf *leaf, Int_t i = 0) { return (ULong64_t)leaf->GetValueLong64(i); }
};
template <> struct TLeaf::GetValueHelper<LongDouble_t> {
static LongDouble_t Exec(const TLeaf *leaf, Int_t i = 0) { return leaf->GetValueLongDouble(i); }
};



inline Double_t TLeaf::GetValue(Int_t /*i = 0*/) const { return 0.0; }
inline void TLeaf::PrintValue(Int_t /* i = 0*/) const {}
inline void TLeaf::SetAddress(void* /* add = 0 */) {}
Expand Down
8 changes: 6 additions & 2 deletions tree/tree/inc/TLeafElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ class TLeafElement : public TLeaf {
virtual Int_t GetMaximum() const {return ((TBranchElement*)fBranch)->GetMaximum();}
virtual Int_t GetNdata() const {return ((TBranchElement*)fBranch)->GetNdata()*fLen;}
virtual const char *GetTypeName() const {return ((TBranchElement*)fBranch)->GetTypeName();}
virtual Double_t GetValue(Int_t i=0) const {return ((TBranchElement*)fBranch)->GetValue(i, fLen, kFALSE);}
virtual Double_t GetValueSubArray(Int_t i=0, Int_t j=0) const {return ((TBranchElement*)fBranch)->GetValue(i, j, kTRUE);}

virtual Double_t GetValue(Int_t i=0) const { return ((TBranchElement*)fBranch)->GetValue(i, fLen, kFALSE);}
virtual Long64_t GetValueLong64(Int_t i = 0) const { return ((TBranchElement*)fBranch)->GetTypedValue<Long64_t>(i, fLen, kFALSE); }
virtual LongDouble_t GetValueLongDouble(Int_t i = 0) const { return ((TBranchElement*)fBranch)->GetTypedValue<LongDouble_t>(i, fLen, kFALSE); }
template<typename T> T GetTypedValueSubArray(Int_t i=0, Int_t j=0) const {return ((TBranchElement*)fBranch)->GetTypedValue<T>(i, j, kTRUE);}

virtual void *GetValuePointer() const { return ((TBranchElement*)fBranch)->GetValuePointer(); }
virtual Bool_t IsOnTerminalBranch() const;
virtual void PrintValue(Int_t i=0) const {((TBranchElement*)fBranch)->PrintValue(i);}
Expand Down
Loading