Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TGeoBranchArray.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#):$Id$
0002 // Author: Andrei Gheata   01/03/11
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, 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_TGeoBranchArray
0013 #define ROOT_TGeoBranchArray
0014 
0015 #include "TObject.h"
0016 
0017 #include "TGeoMatrix.h"
0018 
0019 class TGeoNavigator;
0020 class TGeoNode;
0021 
0022 class TGeoBranchArray : public TObject {
0023 protected:
0024    Int_t fLevel;            // Branch depth
0025    Int_t fMaxLevel;         // Array length
0026    TGeoHMatrix fMatrix;     // Global matrix (owned)
0027    TGeoNode **fArray;       //![fMaxLevel+1] Array of nodes
0028    TGeoNode *fRealArray[1]; // Beginning address of the array of nodes
0029 
0030 private:
0031    TGeoBranchArray(Int_t level);             // not allowed
0032    TGeoBranchArray(const TGeoBranchArray &); // not allowed
0033 public:
0034    enum EGeoBATypes {
0035       kBASelfAlloc = BIT(14) // does self allocation or not
0036    };
0037    // This replaces the dummy constructor to make sure that I/O can be
0038    // performed while the user is only allowed to use the static maker
0039    TGeoBranchArray(TRootIOCtor *) : TObject(), fLevel(0), fMaxLevel(0), fMatrix(), fArray(nullptr)
0040    {
0041       fRealArray[0] = nullptr;
0042    }
0043 
0044    // The static maker to be use to create an instance of the branch array
0045    static TGeoBranchArray *MakeInstance(size_t maxlevel);
0046 
0047    // The static maker to be use to create an instance of the branch array
0048    static TGeoBranchArray *MakeInstanceAt(size_t maxlevel, void *addr);
0049 
0050    // The equivalent of the copy constructor
0051    static TGeoBranchArray *MakeCopy(const TGeoBranchArray &other);
0052 
0053    // The equivalent of the copy constructor
0054    static TGeoBranchArray *MakeCopyAt(const TGeoBranchArray &other, void *addr);
0055 
0056    // The equivalent of the destructor
0057    static void ReleaseInstance(TGeoBranchArray *obj);
0058 
0059    // Assignment allowed
0060    TGeoBranchArray &operator=(const TGeoBranchArray &);
0061 
0062    // Fast copy based on memcpy to destination array
0063    void CopyTo(TGeoBranchArray *dest);
0064 
0065    // Equivalent of sizeof function
0066    static size_t SizeOf(size_t maxlevel) { return (sizeof(TGeoBranchArray) + sizeof(TGeoBranchArray *) * (maxlevel)); }
0067 
0068    // Equivalent of sizeof function
0069    static size_t SizeOfInstance(size_t maxlevel)
0070    {
0071       return (sizeof(TGeoBranchArray) + sizeof(TGeoBranchArray *) * (maxlevel));
0072    }
0073 
0074    inline size_t SizeOf() const { return (sizeof(TGeoBranchArray) + sizeof(TGeoBranchArray *) * (fMaxLevel)); }
0075 
0076    // The data start should point to the address of the first data member,
0077    // after the virtual table
0078    void *DataStart() const { return (void *)&fLevel; }
0079 
0080    // The actual size of the data for an instance, excluding the virtual table
0081    size_t DataSize() const { return SizeOf() - size_t(&fLevel) + (size_t)this; }
0082 
0083    // Update the internal addresses of n contiguous branch array objects, starting
0084    // with this one
0085    void UpdateArray(size_t nobj);
0086 
0087    // Destructor. Release instance to be called instead
0088    ~TGeoBranchArray() override {}
0089 
0090    Bool_t operator==(const TGeoBranchArray &other) const;
0091    Bool_t operator!=(const TGeoBranchArray &other) const;
0092    Bool_t operator>(const TGeoBranchArray &other) const;
0093    Bool_t operator<(const TGeoBranchArray &other) const;
0094    Bool_t operator>=(const TGeoBranchArray &other) const;
0095    Bool_t operator<=(const TGeoBranchArray &other) const;
0096 
0097    void AddLevel(Int_t dindex);
0098    static Long64_t BinarySearch(Long64_t n, const TGeoBranchArray **array, TGeoBranchArray *value);
0099    Int_t Compare(const TObject *obj) const override;
0100    void CleanMatrix();
0101    TGeoNode **GetArray() const { return fArray; }
0102    size_t GetLevel() const { return fLevel; }
0103    size_t GetMaxLevel() const { return fMaxLevel; }
0104    const TGeoHMatrix *GetMatrix() const { return &fMatrix; }
0105    TGeoNode *GetNode(Int_t level) const { return fArray[level]; }
0106    TGeoNode *GetCurrentNode() const { return fArray[fLevel]; }
0107    void GetPath(TString &path) const;
0108    void Init(TGeoNode **branch, TGeoMatrix *global, Int_t level);
0109    void InitFromNavigator(TGeoNavigator *nav);
0110    Bool_t IsSortable() const override { return kTRUE; }
0111    Bool_t IsOutside() const { return (fLevel < 0) ? kTRUE : kFALSE; }
0112    void Print(Option_t *option = "") const override;
0113    static void Sort(Int_t n, TGeoBranchArray **array, Int_t *index, Bool_t down = kTRUE);
0114    void UpdateNavigator(TGeoNavigator *nav) const;
0115 
0116    ClassDefOverride(TGeoBranchArray, 4)
0117 };
0118 
0119 struct compareBAasc {
0120    compareBAasc(TGeoBranchArray **d) : fData(d) {}
0121    bool operator()(Int_t i1, Int_t i2) { return **(fData + i1) < **(fData + i2); }
0122    TGeoBranchArray **fData;
0123 };
0124 
0125 struct compareBAdesc {
0126    compareBAdesc(TGeoBranchArray **d) : fData(d) {}
0127    bool operator()(Int_t i1, Int_t i2) { return **(fData + i1) > **(fData + i2); }
0128    TGeoBranchArray **fData;
0129 };
0130 
0131 #endif