Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:12:09

0001 // @(#)root/hist:$Id$
0002 // Author: Axel Naumann (2007-09-11)
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2012, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_THnSparse_Internal
0013 #define ROOT_THnSparse_Internal
0014 
0015 /*************************************************************************
0016  * Non-API classes for THnSparse.                                        *
0017  * I.e. interesting to look at if you want to know how it works, but     *
0018  * don't use directly.                                                   *
0019  * Implementation in THnSparse.cxx.                                      *
0020  *************************************************************************/
0021 
0022 #include "TArrayD.h"
0023 
0024 #include "TObject.h"
0025 
0026 class TBrowser;
0027 class TH1;
0028 class THnSparse;
0029 
0030 class THnSparseArrayChunk: public TObject {
0031  private:
0032 
0033    THnSparseArrayChunk(const THnSparseArrayChunk&) = delete;
0034    THnSparseArrayChunk& operator=(const THnSparseArrayChunk&) = delete;
0035 
0036  public:
0037    THnSparseArrayChunk():
0038       fCoordinateAllocationSize(-1), fSingleCoordinateSize(0), fCoordinatesSize(0), fCoordinates(nullptr),
0039       fContent(nullptr), fSumw2(nullptr) {}
0040 
0041    THnSparseArrayChunk(Int_t coordsize, bool errors, TArray* cont);
0042    ~THnSparseArrayChunk() override;
0043 
0044    Int_t    fCoordinateAllocationSize; ///<! Size of the allocated coordinate buffer; -1 means none or fCoordinatesSize
0045    Int_t    fSingleCoordinateSize;     ///<  Size of a single bin coordinate
0046    Int_t    fCoordinatesSize;          ///<  Size of the bin coordinate buffer
0047    Char_t  *fCoordinates;              ///<[fCoordinatesSize] compact bin coordinate buffer
0048    TArray  *fContent;                  ///<  Bin content
0049    TArrayD *fSumw2;                    ///<  Bin errors
0050 
0051    void AddBin(Int_t idx, const Char_t* idxbuf);
0052    void AddBinContent(Int_t idx, Double_t v = 1.) {
0053       fContent->SetAt(v + fContent->GetAt(idx), idx);
0054       if (fSumw2)
0055          fSumw2->SetAt(v * v + fSumw2->GetAt(idx), idx);
0056    }
0057    void Sumw2();
0058    Int_t GetEntries() const { return fCoordinatesSize / fSingleCoordinateSize; }
0059 
0060    /// Check whether bin at idx batches idxbuf.
0061    /// If we don't store indexes we trust the caller that it does match,
0062    /// see comment in THnSparseCompactBinCoord::GetHash().
0063    Bool_t Matches(Int_t idx, const Char_t* idxbuf) const {
0064       return fSingleCoordinateSize <= 8 ||
0065          !memcmp(fCoordinates + idx * fSingleCoordinateSize, idxbuf, fSingleCoordinateSize); }
0066 
0067    ClassDefOverride(THnSparseArrayChunk, 1); // chunks of linearized bins
0068 };
0069 #endif // ROOT_THnSparse_Internal
0070