ROOT logo
// @(#)root/hist:$Id: THnSparse_Internal.h 41546 2011-10-24 14:42:42Z axel $
// Author: Axel Naumann (2007-09-11)

/*************************************************************************
 * Copyright (C) 1995-2007, 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_THnSparse_Internal
#define ROOT_THnSparse_Internal

/*************************************************************************
 * Non-API classes for THnSparse.                                        *
 * I.e. interesting to look at if you want to know how it works, but     *
 * don't use directly.                                                   *
 * Implementation in THnSparse.cxx.                                      *
 *************************************************************************/

#ifndef ROOT_TArrayD
#include "TArrayD.h"
#endif

class TBrowser;
class TH1;
class THnSparse;

class THnSparseArrayChunk: public TObject {
 private:

   THnSparseArrayChunk(const THnSparseArrayChunk&); // Not implemented
   THnSparseArrayChunk& operator=(const THnSparseArrayChunk&); // Not implemented

 public:
   THnSparseArrayChunk():
      fCoordinateAllocationSize(-1), fSingleCoordinateSize(0), fCoordinatesSize(0), fCoordinates(0),
      fContent(0), fSumw2(0) {}

   THnSparseArrayChunk(Int_t coordsize, bool errors, TArray* cont);
   virtual ~THnSparseArrayChunk();

   Int_t    fCoordinateAllocationSize; //! size of the allocated coordinate buffer; -1 means none or fCoordinatesSize
   Int_t    fSingleCoordinateSize; // size of a single bin coordinate
   Int_t    fCoordinatesSize;      // size of the bin coordinate buffer
   Char_t  *fCoordinates;          //[fCoordinatesSize] compact bin coordinate buffer
   TArray  *fContent;              // bin content
   TArrayD *fSumw2;                // bin errors

   void AddBin(Int_t idx, const Char_t* idxbuf);
   void AddBinContent(Int_t idx, Double_t v = 1.) {
      fContent->SetAt(v + fContent->GetAt(idx), idx);
      if (fSumw2)
         fSumw2->SetAt(v * v+ fSumw2->GetAt(idx), idx);
   }
   void Sumw2();
   Int_t GetEntries() const { return fCoordinatesSize / fSingleCoordinateSize; }
   Bool_t Matches(Int_t idx, const Char_t* idxbuf) const {
      // Check whether bin at idx batches idxbuf.
      // If we don't store indexes we trust the caller that it does match,
      // see comment in THnSparseCompactBinCoord::GetHash().
      return fSingleCoordinateSize <= 8 ||
         !memcmp(fCoordinates + idx * fSingleCoordinateSize, idxbuf, fSingleCoordinateSize); }

   ClassDef(THnSparseArrayChunk, 1); // chunks of linearized bins
};

namespace ROOT {
   class THnSparseBrowsable: public TNamed {
   public:
      THnSparseBrowsable(THnSparse* hist, Int_t axis);
      ~THnSparseBrowsable();
      void Browse(TBrowser *b);
      Bool_t IsFolder() const { return kFALSE; }

   private:
      THnSparse* fHist; // Original histogram
      Int_t      fAxis; // Axis to visualize
      TH1*       fProj; // Projection result
      ClassDef(THnSparseBrowsable, 0); // Browser-helper for THnSparse
   };
};
#endif // ROOT_THnSparse_Internal

 THnSparse_Internal.h:1
 THnSparse_Internal.h:2
 THnSparse_Internal.h:3
 THnSparse_Internal.h:4
 THnSparse_Internal.h:5
 THnSparse_Internal.h:6
 THnSparse_Internal.h:7
 THnSparse_Internal.h:8
 THnSparse_Internal.h:9
 THnSparse_Internal.h:10
 THnSparse_Internal.h:11
 THnSparse_Internal.h:12
 THnSparse_Internal.h:13
 THnSparse_Internal.h:14
 THnSparse_Internal.h:15
 THnSparse_Internal.h:16
 THnSparse_Internal.h:17
 THnSparse_Internal.h:18
 THnSparse_Internal.h:19
 THnSparse_Internal.h:20
 THnSparse_Internal.h:21
 THnSparse_Internal.h:22
 THnSparse_Internal.h:23
 THnSparse_Internal.h:24
 THnSparse_Internal.h:25
 THnSparse_Internal.h:26
 THnSparse_Internal.h:27
 THnSparse_Internal.h:28
 THnSparse_Internal.h:29
 THnSparse_Internal.h:30
 THnSparse_Internal.h:31
 THnSparse_Internal.h:32
 THnSparse_Internal.h:33
 THnSparse_Internal.h:34
 THnSparse_Internal.h:35
 THnSparse_Internal.h:36
 THnSparse_Internal.h:37
 THnSparse_Internal.h:38
 THnSparse_Internal.h:39
 THnSparse_Internal.h:40
 THnSparse_Internal.h:41
 THnSparse_Internal.h:42
 THnSparse_Internal.h:43
 THnSparse_Internal.h:44
 THnSparse_Internal.h:45
 THnSparse_Internal.h:46
 THnSparse_Internal.h:47
 THnSparse_Internal.h:48
 THnSparse_Internal.h:49
 THnSparse_Internal.h:50
 THnSparse_Internal.h:51
 THnSparse_Internal.h:52
 THnSparse_Internal.h:53
 THnSparse_Internal.h:54
 THnSparse_Internal.h:55
 THnSparse_Internal.h:56
 THnSparse_Internal.h:57
 THnSparse_Internal.h:58
 THnSparse_Internal.h:59
 THnSparse_Internal.h:60
 THnSparse_Internal.h:61
 THnSparse_Internal.h:62
 THnSparse_Internal.h:63
 THnSparse_Internal.h:64
 THnSparse_Internal.h:65
 THnSparse_Internal.h:66
 THnSparse_Internal.h:67
 THnSparse_Internal.h:68
 THnSparse_Internal.h:69
 THnSparse_Internal.h:70
 THnSparse_Internal.h:71
 THnSparse_Internal.h:72
 THnSparse_Internal.h:73
 THnSparse_Internal.h:74
 THnSparse_Internal.h:75
 THnSparse_Internal.h:76
 THnSparse_Internal.h:77
 THnSparse_Internal.h:78
 THnSparse_Internal.h:79
 THnSparse_Internal.h:80
 THnSparse_Internal.h:81
 THnSparse_Internal.h:82
 THnSparse_Internal.h:83
 THnSparse_Internal.h:84
 THnSparse_Internal.h:85