29 TLeafS::TLeafS(): TLeaf()
41 TLeafS::TLeafS(TBranch *parent,
const char *name,
const char *type)
42 :TLeaf(parent,name,type)
56 if (ResetAddress(0,kTRUE))
delete [] fValue;
62 void TLeafS::Export(TClonesArray *list, Int_t n)
65 for (Int_t i=0;i<n;i++) {
66 memcpy((
char*)list->UncheckedAt(i) + fOffset,&fValue[j], 2*fLen);
74 void TLeafS::FillBasket(TBuffer &b)
78 if (fPointer) fValue = *fPointer;
80 if (fValue[0] > fMaximum) fMaximum = fValue[0];
83 for (i=0;i<len;i++) b << (UShort_t)fValue[i];
85 b.WriteFastArray(fValue,len);
92 const char *TLeafS::GetTypeName()
const
94 if (fIsUnsigned)
return "UShort_t";
103 Double_t TLeafS::GetValue(Int_t i)
const
105 if (fIsUnsigned)
return (UShort_t)fValue[i];
112 Bool_t TLeafS::IncludeRange(TLeaf *input)
115 if (input->GetMaximum() > this->GetMaximum())
116 this->SetMaximum( input->GetMaximum() );
117 if (input->GetMinimum() < this->GetMinimum())
118 this->SetMinimum( input->GetMinimum() );
128 void TLeafS::Import(TClonesArray *list, Int_t n)
130 const Short_t kShortUndefined = -9999;
133 for (Int_t i=0;i<n;i++) {
134 clone = (
char*)list->UncheckedAt(i);
135 if (clone) memcpy(&fValue[j],clone + fOffset, 2*fLen);
136 else memcpy(&fValue[j],&kShortUndefined, 2*fLen);
144 void TLeafS::PrintValue(Int_t l)
const
147 UShort_t *uvalue = (UShort_t*)GetValuePointer();
148 printf(
"%u",uvalue[l]);
150 Short_t *value = (Short_t*)GetValuePointer();
151 printf(
"%d",value[l]);
158 void TLeafS::ReadBasket(TBuffer &b)
160 if (!fLeafCount && fNdata == 1) {
161 b.ReadShort(fValue[0]);
164 Long64_t entry = fBranch->GetReadEntry();
165 if (fLeafCount->GetBranch()->GetReadEntry() != entry) {
166 fLeafCount->GetBranch()->GetEntry(entry);
168 Int_t len = Int_t(fLeafCount->GetValue());
169 if (len > fLeafCount->GetMaximum()) {
170 printf(
"ERROR leaf:%s, len=%d and max=%d\n",GetName(),len,fLeafCount->GetMaximum());
171 len = fLeafCount->GetMaximum();
174 b.ReadFastArray(fValue,len*fLen);
176 b.ReadFastArray(fValue,fLen);
183 bool TLeafS::ReadBasketFast(TBuffer& input_buf, Long64_t N)
185 if (R__unlikely(fLeafCount)) {
return false;}
186 return input_buf.ByteSwapBuffer(fLen*N, kShort_t);
193 void TLeafS::ReadBasketExport(TBuffer &b, TClonesArray *list, Int_t n)
198 b.ReadFastArray(fValue,n*fLen);
202 for (Int_t i=0;i<n;i++) {
203 memcpy((
char*)list->UncheckedAt(i) + fOffset,&fValue[j], 2*fLen);
211 void TLeafS::ReadValue(std::istream &s, Char_t )
214 UShort_t *uvalue = (UShort_t*)GetValuePointer();
215 for (Int_t i=0;i<fLen;i++) s >> uvalue[i];
217 Short_t *value = (Short_t*)GetValuePointer();
218 for (Int_t i=0;i<fLen;i++) s >> value[i];
225 void TLeafS::SetAddress(
void *add)
227 if (ResetAddress(add) && (add!=fValue)) {
231 if (TestBit(kIndirectAddress)) {
232 fPointer = (Short_t**) add;
233 Int_t ncountmax = fLen;
234 if (fLeafCount) ncountmax = fLen*(fLeafCount->GetMaximum() + 1);
235 if ((fLeafCount && ncountmax > Int_t(fLeafCount->GetValue())) ||
236 ncountmax > fNdata || *fPointer == 0) {
237 if (*fPointer)
delete [] *fPointer;
238 if (ncountmax > fNdata) fNdata = ncountmax;
239 *fPointer =
new Short_t[fNdata];
243 fValue = (Short_t*)add;
246 fValue =
new Short_t[fNdata];