//*CMZ : 2.22/00 08/04/99 14.20.22 by Rene Brun
//*CMZ : 2.21/07 06/03/99 19.08.11 by Rene Brun
//*CMZ : 2.00/13 03/03/99 14.18.31 by Rene Brun
//*CMZ : 2.00/11 21/08/98 23.23.42 by Rene Brun
//*CMZ : 2.00/00 17/02/98 10.56.06 by Rene Brun
//*CMZ : 1.02/00 18/07/97 12.17.20 by Rene Brun
//*-- Author : Rene Brun 12/01/96
//*KEEP,CopyRight,T=C.
/*************************************************************************
* Copyright(c) 1995-1999, The ROOT System, All rights reserved. *
* Authors: Rene Brun, Fons Rademakers. *
* For list of contributors see $ROOTSYS/AA_CREDITS. *
* *
* Permission to use, copy, modify and distribute this software and its *
* documentation for non-commercial purposes is hereby granted without *
* fee, provided that the above copyright notice appears in all copies *
* and that both the copyright notice and this permission notice appear *
* in the supporting documentation. The authors make no claims about the *
* suitability of this software for any purpose. It is provided "as is" *
* without express or implied warranty. *
*************************************************************************/
//*KEND.
//////////////////////////////////////////////////////////////////////////
// //
// A TLeaf for an Integer data type. //
//////////////////////////////////////////////////////////////////////////
//*KEEP,TLeafI,T=C++.
#include "TLeafI.h"
//*KEEP,TBranch,T=C++.
#include "TBranch.h"
//*KEND.
ClassImp(TLeafI)
//______________________________________________________________________________
TLeafI::TLeafI(): TLeaf()
{
//*-*-*-*-*-*Default constructor for LeafI*-*-*-*-*-*-*-*-*-*-*-*-*-*
//*-* ============================
fValue = 0;
}
//______________________________________________________________________________
TLeafI::TLeafI(const Text_t *name, const Text_t *type)
:TLeaf(name,type)
{
//*-*-*-*-*-*-*-*-*-*-*-*-*Create a LeafI*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
//*-* ==============
//*-*
fMinimum = 0;
fMaximum = 0;
fValue = 0;
}
//______________________________________________________________________________
TLeafI::~TLeafI()
{
//*-*-*-*-*-*Default destructor for a LeafI*-*-*-*-*-*-*-*-*-*-*-*
//*-* ===============================
if (ResetAddress(0,kTRUE)) delete [] fValue;
}
//______________________________________________________________________________
void TLeafI::Export(TClonesArray *list, Int_t n)
{
//*-*-*-*-*-*Export element from local leaf buffer to ClonesArray*-*-*-*-*
//*-* ======================================================
Int_t *value = fValue;
for (Int_t i=0;i<n;i++) {
char *first = (char*)list->UncheckedAt(i);
Int_t *ii = (Int_t*)&first[fOffset];
for (Int_t j=0;j<fLen;j++) {
ii[j] = value[j];
}
value += fLen;
}
}
//______________________________________________________________________________
void TLeafI::FillBasket(TBuffer &b)
{
//*-*-*-*-*-*-*-*-*-*-*Pack leaf elements in Basket output buffer*-*-*-*-*-*-*
//*-* =========================================
Int_t i;
Int_t len = GetLen();
if (IsRange()) {
if (fValue[0] > fMaximum) fMaximum = fValue[0];
}
if (IsUnsigned()) {
for (i=0;i<len;i++) b << (UInt_t)fValue[i];
} else {
b.WriteFastArray(fValue,len);
}
}
//______________________________________________________________________________
const Text_t *TLeafI::GetTypeName() const
{
//*-*-*-*-*-*-*-*Returns name of leaf type*-*-*-*-*-*-*-*-*-*-*-*
//*-* =========================
if (fIsUnsigned) return "UInt_t";
return "Int_t";
}
//______________________________________________________________________________
Float_t TLeafI::GetValue(Int_t i, TTreeFormula *)
{
//*-*-*-*-*-*-*-*Returns current value of leaf*-*-*-*-*-*-*-*-*-*-*-*
//*-* =============================
if (fIsUnsigned) return (UInt_t)fValue[i];
return fValue[i];
}
//______________________________________________________________________________
void TLeafI::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, 4*fLen);
else memcpy(&fValue[j],&kIntUndefined, 4*fLen);
j += fLen;
}
}
//______________________________________________________________________________
void TLeafI::Print(Option_t *option)
{
//*-*-*-*-*-*-*-*-*-*-*Print a description of this leaf*-*-*-*-*-*-*-*-*
//*-* ================================
TLeaf::Print(option);
}
//______________________________________________________________________________
void TLeafI::ReadBasket(TBuffer &b)
{
//*-*-*-*-*-*-*-*-*-*-*Read leaf elements from Basket input buffer*-*-*-*-*-*
//*-* ===========================================
if (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=%dn",GetName(),len,fLeafCount->GetMaximum());
len = fLeafCount->GetMaximum();
}
b.ReadFastArray(fValue,len*fLen);
} else {
b.ReadFastArray(fValue,fLen);
}
}
}
//______________________________________________________________________________
void TLeafI::SetAddress(void *add)
{
//*-*-*-*-*-*-*-*-*-*-*Set leaf buffer data address*-*-*-*-*-*
//*-* ============================
if (ResetAddress(add)) delete [] fValue;
if (add) fValue = (Int_t*)add;
else fValue = new Int_t[fNdata];
}
ROOT page - Class index - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.