Logo ROOT  
Reference Guide
THnSparse_Internal.h
Go to the documentation of this file.
1 // @(#)root/hist:$Id$
2 // Author: Axel Naumann (2007-09-11)
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2012, 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 #ifndef ROOT_THnSparse_Internal
13 #define ROOT_THnSparse_Internal
14 
15 /*************************************************************************
16  * Non-API classes for THnSparse. *
17  * I.e. interesting to look at if you want to know how it works, but *
18  * don't use directly. *
19  * Implementation in THnSparse.cxx. *
20  *************************************************************************/
21 
22 #include "TArrayD.h"
23 
24 #include "TObject.h"
25 
26 class TBrowser;
27 class TH1;
28 class THnSparse;
29 
31  private:
32 
33  THnSparseArrayChunk(const THnSparseArrayChunk&); // Not implemented
34  THnSparseArrayChunk& operator=(const THnSparseArrayChunk&); // Not implemented
35 
36  public:
39  fContent(0), fSumw2(0) {}
40 
41  THnSparseArrayChunk(Int_t coordsize, bool errors, TArray* cont);
42  virtual ~THnSparseArrayChunk();
43 
44  Int_t fCoordinateAllocationSize; //! size of the allocated coordinate buffer; -1 means none or fCoordinatesSize
45  Int_t fSingleCoordinateSize; // size of a single bin coordinate
46  Int_t fCoordinatesSize; // size of the bin coordinate buffer
47  Char_t *fCoordinates; //[fCoordinatesSize] compact bin coordinate buffer
48  TArray *fContent; // bin content
49  TArrayD *fSumw2; // bin errors
50 
51  void AddBin(Int_t idx, const Char_t* idxbuf);
52  void AddBinContent(Int_t idx, Double_t v = 1.) {
53  fContent->SetAt(v + fContent->GetAt(idx), idx);
54  if (fSumw2)
55  fSumw2->SetAt(v * v+ fSumw2->GetAt(idx), idx);
56  }
57  void Sumw2();
59  Bool_t Matches(Int_t idx, const Char_t* idxbuf) const {
60  // Check whether bin at idx batches idxbuf.
61  // If we don't store indexes we trust the caller that it does match,
62  // see comment in THnSparseCompactBinCoord::GetHash().
63  return fSingleCoordinateSize <= 8 ||
64  !memcmp(fCoordinates + idx * fSingleCoordinateSize, idxbuf, fSingleCoordinateSize); }
65 
66  ClassDef(THnSparseArrayChunk, 1); // chunks of linearized bins
67 };
68 #endif // ROOT_THnSparse_Internal
69 
TArray::GetAt
virtual Double_t GetAt(Int_t i) const =0
THnSparseArrayChunk::Matches
Bool_t Matches(Int_t idx, const Char_t *idxbuf) const
Definition: THnSparse_Internal.h:59
TBrowser
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
THnSparseArrayChunk::fSingleCoordinateSize
Int_t fSingleCoordinateSize
size of the allocated coordinate buffer; -1 means none or fCoordinatesSize
Definition: THnSparse_Internal.h:45
THnSparseArrayChunk::Sumw2
void Sumw2()
Turn on support of errors.
Definition: THnSparse.cxx:480
THnSparseArrayChunk::fCoordinateAllocationSize
Int_t fCoordinateAllocationSize
Definition: THnSparse_Internal.h:44
THnSparseArrayChunk
THnSparseArrayChunk is used internally by THnSparse.
Definition: THnSparse_Internal.h:30
THnSparseArrayChunk::fContent
TArray * fContent
Definition: THnSparse_Internal.h:48
TArray::SetAt
virtual void SetAt(Double_t v, Int_t i)=0
THnSparseArrayChunk::GetEntries
Int_t GetEntries() const
Definition: THnSparse_Internal.h:58
Int_t
int Int_t
Definition: RtypesCore.h:45
THnSparseArrayChunk::THnSparseArrayChunk
THnSparseArrayChunk(const THnSparseArrayChunk &)
THnSparseArrayChunk::fCoordinatesSize
Int_t fCoordinatesSize
Definition: THnSparse_Internal.h:46
v
@ v
Definition: rootcling_impl.cxx:3635
TArrayD::SetAt
void SetAt(Double_t v, Int_t i)
Definition: TArrayD.h:51
bool
THnSparse
Efficient multidimensional histogram.
Definition: THnSparse.h:36
TArrayD.h
TArrayD::GetAt
Double_t GetAt(Int_t i) const
Definition: TArrayD.h:45
THnSparseArrayChunk::AddBinContent
void AddBinContent(Int_t idx, Double_t v=1.)
Definition: THnSparse_Internal.h:52
THnSparseArrayChunk::fSumw2
TArrayD * fSumw2
Definition: THnSparse_Internal.h:49
THnSparseArrayChunk::operator=
THnSparseArrayChunk & operator=(const THnSparseArrayChunk &)
Double_t
double Double_t
Definition: RtypesCore.h:59
TArray
Abstract array base class.
Definition: TArray.h:31
TObject.h
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
THnSparseArrayChunk::~THnSparseArrayChunk
virtual ~THnSparseArrayChunk()
Destructor.
Definition: THnSparse.cxx:440
TH1
TH1 is the base class of all histogramm classes in ROOT.
Definition: TH1.h:58
THnSparseArrayChunk::fCoordinates
Char_t * fCoordinates
Definition: THnSparse_Internal.h:47
TArrayD
Array of doubles (64 bits per element).
Definition: TArrayD.h:27
Char_t
char Char_t
Definition: RtypesCore.h:33
THnSparseArrayChunk::AddBin
void AddBin(Int_t idx, const Char_t *idxbuf)
Create a new bin in this chunk.
Definition: THnSparse.cxx:450
int
THnSparseArrayChunk::THnSparseArrayChunk
THnSparseArrayChunk()
Definition: THnSparse_Internal.h:37