-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new class TLeafL to support Long64_t, ULong64_t data types in a T…
…Branch git-svn-id: http://root.cern.ch/svn/root/trunk@7786 27541ba8-7e3a-0410-8455-c3a389f83636
- Loading branch information
Rene Brun
authored and
Rene Brun
committed
Dec 19, 2003
1 parent
7d8533f
commit 57b449d
Showing
5 changed files
with
291 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// @(#)root/tree:$Name: $:$Id: TLeafL.h,v 1.6 2003/06/04 05:59:17 brun Exp $ | ||
// Author: Rene Brun 19/12/2003 | ||
|
||
/************************************************************************* | ||
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. * | ||
* All rights reserved. * | ||
* * | ||
* For the licensing terms see $ROOTSYS/LICENSE. * | ||
* For the list of contributors see $ROOTSYS/README/CREDITS. * | ||
*************************************************************************/ | ||
|
||
#ifndef ROOT_TLeafL | ||
#define ROOT_TLeafL | ||
|
||
|
||
////////////////////////////////////////////////////////////////////////// | ||
// // | ||
// TLeafL // | ||
// // | ||
// A TLeaf for a 64 bit integer data type. // | ||
// // | ||
////////////////////////////////////////////////////////////////////////// | ||
|
||
|
||
#ifndef ROOT_TLeaf | ||
#include "TLeaf.h" | ||
#endif | ||
|
||
class TLeafL : public TLeaf { | ||
|
||
protected: | ||
Long64_t fMinimum; //Minimum value if leaf range is specified | ||
Long64_t fMaximum; //Maximum value if leaf range is specified | ||
Long64_t *fValue; //!Pointer to data buffer | ||
Long64_t **fPointer; //!Address of pointer to data buffer | ||
|
||
public: | ||
TLeafL(); | ||
TLeafL(const char *name, const char *type); | ||
virtual ~TLeafL(); | ||
|
||
virtual void Export(TClonesArray *list, Int_t n); | ||
virtual void FillBasket(TBuffer &b); | ||
const char *GetTypeName() const; | ||
virtual Int_t GetMaximum() const {return (Int_t)fMaximum;} | ||
virtual Int_t GetMinimum() const {return (Int_t)fMinimum;} | ||
Double_t GetValue(Int_t i=0) const; | ||
virtual void *GetValuePointer() const {return fValue;} | ||
virtual void Import(TClonesArray *list, Int_t n); | ||
virtual void PrintValue(Int_t i=0) const; | ||
virtual void ReadBasket(TBuffer &b); | ||
virtual void ReadBasketExport(TBuffer &b, TClonesArray *list, Int_t n); | ||
virtual void SetAddress(void *add=0); | ||
virtual void SetMaximum(Long64_t max) {fMaximum = max;} | ||
virtual void SetMinimum(Long64_t min) {fMinimum = min;} | ||
|
||
ClassDef(TLeafL,1) //A TLeaf for a 64 bit Integer data type. | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,216 @@ | ||
// @(#)root/tree:$Name: $:$Id: TLeafL.cxx,v 1.15 2002/09/09 19:52:11 brun Exp $ | ||
// Author: Rene Brun 12/01/96 | ||
|
||
/************************************************************************* | ||
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. * | ||
* All rights reserved. * | ||
* * | ||
* For the licensing terms see $ROOTSYS/LICENSE. * | ||
* For the list of contributors see $ROOTSYS/README/CREDITS. * | ||
*************************************************************************/ | ||
|
||
////////////////////////////////////////////////////////////////////////// | ||
// // | ||
// A TLeaf for a 64 bit Integer data type. // | ||
////////////////////////////////////////////////////////////////////////// | ||
|
||
#include "TLeafL.h" | ||
#include "TBranch.h" | ||
|
||
ClassImp(TLeafL) | ||
|
||
//______________________________________________________________________________ | ||
TLeafL::TLeafL(): TLeaf() | ||
{ | ||
//*-*-*-*-*-*Default constructor for LeafI*-*-*-*-*-*-*-*-*-*-*-*-*-* | ||
//*-* ============================ | ||
|
||
fValue = 0; | ||
fPointer = 0; | ||
} | ||
|
||
//______________________________________________________________________________ | ||
TLeafL::TLeafL(const char *name, const char *type) | ||
:TLeaf(name,type) | ||
{ | ||
//*-*-*-*-*-*-*-*-*-*-*-*-*Create a LeafI*-*-*-*-*-*-*-*-*-*-*-*-*-*-* | ||
//*-* ============== | ||
//*-* | ||
|
||
fLenType = 4; | ||
fMinimum = 0; | ||
fMaximum = 0; | ||
fValue = 0; | ||
fPointer = 0; | ||
} | ||
|
||
//______________________________________________________________________________ | ||
TLeafL::~TLeafL() | ||
{ | ||
//*-*-*-*-*-*Default destructor for a LeafI*-*-*-*-*-*-*-*-*-*-*-* | ||
//*-* =============================== | ||
|
||
if (ResetAddress(0,kTRUE)) delete [] fValue; | ||
} | ||
|
||
|
||
//______________________________________________________________________________ | ||
void TLeafL::Export(TClonesArray *list, Int_t n) | ||
{ | ||
//*-*-*-*-*-*Export element from local leaf buffer to ClonesArray*-*-*-*-* | ||
//*-* ====================================================== | ||
|
||
Long64_t *value = fValue; | ||
for (Int_t i=0;i<n;i++) { | ||
char *first = (char*)list->UncheckedAt(i); | ||
Long64_t *ii = (Long64_t*)&first[fOffset]; | ||
for (Int_t j=0;j<fLen;j++) { | ||
ii[j] = value[j]; | ||
} | ||
value += fLen; | ||
} | ||
} | ||
|
||
//______________________________________________________________________________ | ||
void TLeafL::FillBasket(TBuffer &b) | ||
{ | ||
//*-*-*-*-*-*-*-*-*-*-*Pack leaf elements in Basket output buffer*-*-*-*-*-*-* | ||
//*-* ========================================= | ||
|
||
Int_t i; | ||
Int_t len = GetLen(); | ||
if (fPointer) fValue = *fPointer; | ||
if (IsRange()) { | ||
if (fValue[0] > fMaximum) fMaximum = fValue[0]; | ||
} | ||
if (IsUnsigned()) { | ||
for (i=0;i<len;i++) b << (ULong64_t)fValue[i]; | ||
} else { | ||
b.WriteFastArray(fValue,len); | ||
} | ||
} | ||
|
||
//______________________________________________________________________________ | ||
const char *TLeafL::GetTypeName() const | ||
{ | ||
//*-*-*-*-*-*-*-*Returns name of leaf type*-*-*-*-*-*-*-*-*-*-*-* | ||
//*-* ========================= | ||
|
||
if (fIsUnsigned) return "ULong64_t"; | ||
return "Long64_t"; | ||
} | ||
|
||
|
||
//______________________________________________________________________________ | ||
Double_t TLeafL::GetValue(Int_t i) const | ||
{ | ||
// Returns current value of leaf | ||
// if leaf is a simple type, i must be set to 0 | ||
// if leaf is an array, i is the array element number to be returned | ||
|
||
if (fIsUnsigned) return (ULong64_t)fValue[i]; | ||
return fValue[i]; | ||
} | ||
|
||
|
||
|
||
//______________________________________________________________________________ | ||
void TLeafL::Import(TClonesArray *list, Int_t n) | ||
{ | ||
//*-*-*-*-*-*Import element from ClonesArray into local leaf buffer*-*-*-*-* | ||
//*-* ====================================================== | ||
|
||
const Int_t kIntUndefined = -9999; | ||
Int_t j = 0; | ||
char *clone; | ||
for (Int_t i=0;i<n;i++) { | ||
clone = (char*)list->UncheckedAt(i); | ||
if (clone) memcpy(&fValue[j],clone + fOffset, 8*fLen); | ||
else memcpy(&fValue[j],&kIntUndefined, 8*fLen); | ||
j += fLen; | ||
} | ||
} | ||
|
||
//______________________________________________________________________________ | ||
void TLeafL::PrintValue(Int_t l) const | ||
{ | ||
// Prints leaf value | ||
|
||
Long64_t *value = (Long64_t*)GetValuePointer(); | ||
printf("%lld",value[l]); | ||
} | ||
|
||
//______________________________________________________________________________ | ||
void TLeafL::ReadBasket(TBuffer &b) | ||
{ | ||
//*-*-*-*-*-*-*-*-*-*-*Read leaf elements from Basket input buffer*-*-*-*-*-* | ||
//*-* =========================================== | ||
|
||
if (!fLeafCount && fNdata == 1) { | ||
b >> fValue[0]; | ||
} else { | ||
if (fLeafCount) { | ||
Int_t len = Int_t(fLeafCount->GetValue()); | ||
if (len > fLeafCount->GetMaximum()) { | ||
printf("ERROR leaf:%s, len=%d and max=%d\n",GetName(),len,fLeafCount->GetMaximum()); | ||
len = fLeafCount->GetMaximum(); | ||
} | ||
fNdata = len*fLen; | ||
b.ReadFastArray(fValue,len*fLen); | ||
} else { | ||
b.ReadFastArray(fValue,fLen); | ||
} | ||
} | ||
} | ||
|
||
//______________________________________________________________________________ | ||
void TLeafL::ReadBasketExport(TBuffer &b, TClonesArray *list, Int_t n) | ||
{ | ||
//*-*-*-*-*-*-*-*-*-*-*Read leaf elements from Basket input buffer*-*-*-*-*-* | ||
// and export buffer to TClonesArray objects | ||
|
||
if (n*fLen == 1) { | ||
b >> fValue[0]; | ||
} else { | ||
b.ReadFastArray(fValue,n*fLen); | ||
} | ||
Long64_t *value = fValue; | ||
for (Int_t i=0;i<n;i++) { | ||
char *first = (char*)list->UncheckedAt(i); | ||
Long64_t *ii = (Long64_t*)&first[fOffset]; | ||
for (Int_t j=0;j<fLen;j++) { | ||
ii[j] = value[j]; | ||
} | ||
value += fLen; | ||
} | ||
} | ||
|
||
//______________________________________________________________________________ | ||
void TLeafL::SetAddress(void *add) | ||
{ | ||
//*-*-*-*-*-*-*-*-*-*-*Set leaf buffer data address*-*-*-*-*-* | ||
//*-* ============================ | ||
|
||
if (ResetAddress(add)) { | ||
delete [] fValue; | ||
} | ||
if (add) { | ||
if (TestBit(kIndirectAddress)) { | ||
fPointer = (Long64_t**) add; | ||
Int_t ncountmax = fLen; | ||
if (fLeafCount) ncountmax = fLen*(fLeafCount->GetMaximum() + 1); | ||
if (ncountmax > fNdata || *fPointer == 0) { | ||
if (*fPointer) delete [] *fPointer; | ||
if (ncountmax > fNdata) fNdata = ncountmax; | ||
*fPointer = new Long64_t[fNdata]; | ||
} | ||
fValue = *fPointer; | ||
} else { | ||
fValue = (Long64_t*)add; | ||
} | ||
} else { | ||
fValue = new Long64_t[fNdata]; | ||
fValue[0] = 0; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters