ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 #ifndef ROOT_TArrayD
23 #include "TArrayD.h"
24 #endif
25 
26 #include "TObject.h"
27 
28 class TBrowser;
29 class TH1;
30 class THnSparse;
31 
33  private:
34 
35  THnSparseArrayChunk(const THnSparseArrayChunk&); // Not implemented
36  THnSparseArrayChunk& operator=(const THnSparseArrayChunk&); // Not implemented
37 
38  public:
41  fContent(0), fSumw2(0) {}
42 
43  THnSparseArrayChunk(Int_t coordsize, bool errors, TArray* cont);
44  virtual ~THnSparseArrayChunk();
45 
46  Int_t fCoordinateAllocationSize; //! size of the allocated coordinate buffer; -1 means none or fCoordinatesSize
47  Int_t fSingleCoordinateSize; // size of a single bin coordinate
48  Int_t fCoordinatesSize; // size of the bin coordinate buffer
49  Char_t *fCoordinates; //[fCoordinatesSize] compact bin coordinate buffer
50  TArray *fContent; // bin content
51  TArrayD *fSumw2; // bin errors
52 
53  void AddBin(Int_t idx, const Char_t* idxbuf);
54  void AddBinContent(Int_t idx, Double_t v = 1.) {
55  fContent->SetAt(v + fContent->GetAt(idx), idx);
56  if (fSumw2)
57  fSumw2->SetAt(v * v+ fSumw2->GetAt(idx), idx);
58  }
59  void Sumw2();
61  Bool_t Matches(Int_t idx, const Char_t* idxbuf) const {
62  // Check whether bin at idx batches idxbuf.
63  // If we don't store indexes we trust the caller that it does match,
64  // see comment in THnSparseCompactBinCoord::GetHash().
65  return fSingleCoordinateSize <= 8 ||
66  !memcmp(fCoordinates + idx * fSingleCoordinateSize, idxbuf, fSingleCoordinateSize); }
67 
68  ClassDef(THnSparseArrayChunk, 1); // chunks of linearized bins
69 };
70 #endif // ROOT_THnSparse_Internal
71 
Abstract array base class.
Definition: TArray.h:33
THnSparseArrayChunk is used internally by THnSparse.
void SetAt(Double_t v, Int_t i)
Definition: TArrayD.h:53
virtual ~THnSparseArrayChunk()
Destructor.
Definition: THnSparse.cxx:441
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void Sumw2()
Turn on support of errors.
Definition: THnSparse.cxx:481
virtual void SetAt(Double_t v, Int_t i)=0
Efficient multidimensional histogram.
Definition: THnSparse.h:52
Double_t GetAt(Int_t i) const
Definition: TArrayD.h:47
void AddBinContent(Int_t idx, Double_t v=1.)
Int_t fSingleCoordinateSize
size of the allocated coordinate buffer; -1 means none or fCoordinatesSize
THnSparseArrayChunk & operator=(const THnSparseArrayChunk &)
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:41
Int_t GetEntries() const
SVector< double, 2 > v
Definition: Dict.h:5
double Double_t
Definition: RtypesCore.h:55
The TH1 histogram class.
Definition: TH1.h:80
Array of doubles (64 bits per element).
Definition: TArrayD.h:29
Mother of all ROOT objects.
Definition: TObject.h:58
void AddBin(Int_t idx, const Char_t *idxbuf)
Create a new bin in this chunk.
Definition: THnSparse.cxx:451
char Char_t
Definition: RtypesCore.h:29
Bool_t Matches(Int_t idx, const Char_t *idxbuf) const
virtual Double_t GetAt(Int_t i) const =0
std::vector< double > errors
Definition: TwoHistoFit2D.C:33
ClassDef(THnSparseArrayChunk, 1)