Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-22 09:07:43

0001 // @(#)root/geom:$Id$
0002 // Author: Andrei Gheata   04/02/02
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_TGeoVoxelFinder
0013 #define ROOT_TGeoVoxelFinder
0014 
0015 #include "TObject.h"
0016 
0017 class TGeoVolume;
0018 struct TGeoStateInfo;
0019 
0020 class TGeoVoxelFinder : public TObject {
0021 public:
0022    enum EVoxelsType {
0023       kGeoInvalidVoxels = BIT(15),
0024       kGeoRebuildVoxels = BIT(16)
0025    };
0026 
0027 private:
0028    TGeoVoxelFinder(const TGeoVoxelFinder &) = delete;
0029    TGeoVoxelFinder &operator=(const TGeoVoxelFinder &) = delete;
0030 
0031 protected:
0032    TGeoVolume *fVolume; // volume to which applies
0033 
0034    Int_t fIbx;         // number of different boundaries on X axis
0035    Int_t fIby;         // number of different boundaries on Y axis
0036    Int_t fIbz;         // number of different boundaries on Z axis
0037    Int_t fNboxes;      // length of boxes array
0038    Int_t fNox;         // length of array of X offsets
0039    Int_t fNoy;         // length of array of Y offsets
0040    Int_t fNoz;         // length of array of Z offsets
0041    Int_t fNex;         // length of array of X extra offsets
0042    Int_t fNey;         // length of array of Y extra offsets
0043    Int_t fNez;         // length of array of Z extra offsets
0044    Int_t fNx;          // length of array of X voxels
0045    Int_t fNy;          // length of array of Y voxels
0046    Int_t fNz;          // length of array of Z voxels
0047    Int_t fPriority[3]; // priority for each axis
0048    Double_t *fBoxes;   //[fNboxes] list of bounding boxes
0049    Double_t *fXb;      //[fIbx] ordered array of X box boundaries
0050    Double_t *fYb;      //[fIby] ordered array of Y box boundaries
0051    Double_t *fZb;      //[fIbz] ordered array of Z box boundaries
0052    Int_t *fOBx;        //[fNox] offsets of daughter indices for slices X
0053    Int_t *fOBy;        //[fNoy] offsets of daughter indices for slices Y
0054    Int_t *fOBz;        //[fNoz] offsets of daughter indices for slices Z
0055    Int_t *fOEx;        //[fNox] offsets of extra indices for slices X
0056    Int_t *fOEy;        //[fNoy] offsets of extra indices for slices Y
0057    Int_t *fOEz;        //[fNoz] offsets of extra indices for slices Z
0058    Int_t *fExtraX;     //[fNex] indices of extra daughters in X slices
0059    Int_t *fExtraY;     //[fNey] indices of extra daughters in Y slices
0060    Int_t *fExtraZ;     //[fNez] indices of extra daughters in Z slices
0061    Int_t *fNsliceX;    //[fNox] number of candidates in X slice
0062    Int_t *fNsliceY;    //[fNoy] number of candidates in Y slice
0063    Int_t *fNsliceZ;    //[fNoz] number of candidates in Z slice
0064    UChar_t *fIndcX;    //[fNx] array of slices bits on X
0065    UChar_t *fIndcY;    //[fNy] array of slices bits on Y
0066    UChar_t *fIndcZ;    //[fNz] array of slices bits on Z
0067 
0068    void BuildVoxelLimits();
0069    Int_t *GetExtraX(Int_t islice, Bool_t left, Int_t &nextra) const;
0070    Int_t *GetExtraY(Int_t islice, Bool_t left, Int_t &nextra) const;
0071    Int_t *GetExtraZ(Int_t islice, Bool_t left, Int_t &nextra) const;
0072    Bool_t GetIndices(const Double_t *point, TGeoStateInfo &td);
0073    Int_t GetPriority(Int_t iaxis) const { return fPriority[iaxis]; }
0074    Int_t GetNcandidates(TGeoStateInfo &td) const;
0075    Int_t *GetValidExtra(Int_t *list, Int_t &ncheck, TGeoStateInfo &td);
0076    Int_t *GetValidExtra(Int_t n1, UChar_t *array1, Int_t *list, Int_t &ncheck, TGeoStateInfo &td);
0077    Int_t *
0078    GetValidExtra(Int_t n1, UChar_t *array1, Int_t n2, UChar_t *array2, Int_t *list, Int_t &ncheck, TGeoStateInfo &td);
0079    Int_t *GetVoxelCandidates(Int_t i, Int_t j, Int_t k, Int_t &ncheck, TGeoStateInfo &td);
0080    Bool_t Intersect(Int_t n1, UChar_t *array1, Int_t &nf, Int_t *result);
0081    Bool_t Intersect(Int_t n1, UChar_t *array1, Int_t n2, UChar_t *array2, Int_t &nf, Int_t *result);
0082    Bool_t
0083    Intersect(Int_t n1, UChar_t *array1, Int_t n2, UChar_t *array2, Int_t n3, UChar_t *array3, Int_t &nf, Int_t *result);
0084    Bool_t IntersectAndStore(Int_t n1, UChar_t *array1, TGeoStateInfo &td);
0085    Bool_t IntersectAndStore(Int_t n1, UChar_t *array1, Int_t n2, UChar_t *array2, TGeoStateInfo &td);
0086    Bool_t IntersectAndStore(Int_t n1, UChar_t *array1, Int_t n2, UChar_t *array2, Int_t n3, UChar_t *array3,
0087                             TGeoStateInfo &td);
0088    void SortAll(Option_t *option = "");
0089    Bool_t Union(Int_t n1, UChar_t *array1, TGeoStateInfo &td);
0090    Bool_t Union(Int_t n1, UChar_t *array1, Int_t n2, UChar_t *array2, TGeoStateInfo &td);
0091    Bool_t Union(Int_t n1, UChar_t *array1, Int_t n2, UChar_t *array2, Int_t n3, UChar_t *array3, TGeoStateInfo &td);
0092 
0093 public:
0094    TGeoVoxelFinder();
0095    TGeoVoxelFinder(TGeoVolume *vol);
0096    ~TGeoVoxelFinder() override;
0097    void DaughterToMother(Int_t id, const Double_t *local, Double_t *master) const;
0098    virtual Double_t Efficiency();
0099    virtual Int_t *GetCheckList(const Double_t *point, Int_t &nelem, TGeoStateInfo &td);
0100    Int_t *GetCheckList(Int_t &nelem, TGeoStateInfo &td) const;
0101    virtual Int_t *GetNextCandidates(const Double_t *point, Int_t &ncheck, TGeoStateInfo &td);
0102    virtual void FindOverlaps(Int_t inode) const;
0103    Bool_t IsInvalid() const { return TObject::TestBit(kGeoInvalidVoxels); }
0104    Bool_t NeedRebuild() const { return TObject::TestBit(kGeoRebuildVoxels); }
0105    Double_t *GetBoxes() const { return fBoxes; }
0106    Bool_t IsSafeVoxel(const Double_t *point, Int_t inode, Double_t minsafe) const;
0107    Bool_t MayOverlap(UInt_t i, UInt_t j) const;
0108    void Print(Option_t *option = "") const override;
0109    void PrintVoxelLimits(const Double_t *point) const;
0110    void SetInvalid(Bool_t flag = kTRUE) { TObject::SetBit(kGeoInvalidVoxels, flag); }
0111    void SetNeedRebuild(Bool_t flag = kTRUE) { TObject::SetBit(kGeoRebuildVoxels, flag); }
0112    virtual Int_t *GetNextVoxel(const Double_t *point, const Double_t *dir, Int_t &ncheck, TGeoStateInfo &td);
0113    virtual void SortCrossedVoxels(const Double_t *point, const Double_t *dir, TGeoStateInfo &td);
0114    virtual void Voxelize(Option_t *option = "");
0115 
0116    ClassDefOverride(TGeoVoxelFinder, 4) // voxel finder class
0117 };
0118 
0119 #endif