Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:05

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4SmartVoxelHeader
0027 //
0028 // Class description:
0029 //
0030 // Represents a set of voxels, created by a single axis of virtual division.
0031 // Contains the individual voxels, which are potentially further divided
0032 // along different axes.
0033 //
0034 // Member data:
0035 //
0036 // EAxis faxis
0037 //   - The (cartesian) slicing/division axis
0038 // G4double fmaxExtent
0039 // G4double fminExtent
0040 //   - Minimum and maximum coordiantes along the axis
0041 // std::vector<G4SmartVoxelProxy*> fslices
0042 //   - The slices along the axis
0043 //
0044 // G4int fminEquivalent
0045 // G4int fmaxEquivalent
0046 //   - Minimum and maximum equivalent slice nos.
0047 //     [Applies to the level of the header, not its nodes]
0048 
0049 // 18.04.01, G.Cosmo - Migrated to STL vector
0050 // 13.07.95, P.Kent - Initial version
0051 // --------------------------------------------------------------------
0052 #ifndef G4SMARTVOXELHEADER_HH
0053 #define G4SMARTVOXELHEADER_HH 1
0054 
0055 #include <vector>
0056 
0057 #include "G4Types.hh"
0058 #include "geomdefs.hh"
0059 
0060 #include "G4SmartVoxelProxy.hh"
0061 #include "G4SmartVoxelNode.hh"
0062 
0063 // Forward declarations
0064 class G4LogicalVolume;
0065 class G4VoxelLimits;
0066 class G4VPhysicalVolume;
0067 
0068 // Aliases
0069 using G4ProxyVector = std::vector<G4SmartVoxelProxy*>;
0070 using G4NodeVector = std::vector<G4SmartVoxelNode*>;
0071 using G4VolumeNosVector = std::vector<G4int>;
0072 using G4VolumeExtentVector = std::vector<G4double>;
0073 
0074 class G4SmartVoxelHeader
0075 {
0076   public:
0077 
0078     G4SmartVoxelHeader(G4LogicalVolume* pVolume, G4int pSlice = 0);
0079       // Constructor for topmost header, to begin voxel construction at a
0080       // given logical volume. pSlice is used to set max and min equivalent
0081       // slice nos for the header - they apply to the level of the header,
0082       // not its nodes.
0083 
0084     ~G4SmartVoxelHeader();
0085       // Delete all referenced nodes [but *not* referenced physical volumes].
0086     
0087     G4int GetMaxEquivalentSliceNo() const;
0088     void SetMaxEquivalentSliceNo(G4int pMax);
0089     G4int GetMinEquivalentSliceNo() const;
0090     void SetMinEquivalentSliceNo(G4int pMin);
0091       // Access functions for min/max equivalent slices (nodes & headers).
0092 
0093     EAxis GetAxis() const;
0094       // Return the current division axis.
0095     EAxis GetParamAxis() const;
0096       // Return suggested division axis for parameterised volume.
0097 
0098     G4double GetMaxExtent() const;
0099       // Return the maximum coordinate limit along the current axis.
0100     G4double GetMinExtent() const;
0101       // Return the minimum coordinate limit along the current axis.
0102     
0103     std::size_t GetNoSlices() const;
0104       // Return the no of slices along the current axis.
0105     
0106     G4SmartVoxelProxy* GetSlice(std::size_t n) const;
0107       // Return ptr to the proxy for the nth slice (numbering from 0,
0108       // no bounds checking performed).
0109 
0110     G4bool AllSlicesEqual() const;
0111       // True if all slices equal (after collection).
0112 
0113   public:
0114 
0115     G4bool operator == (const G4SmartVoxelHeader& pHead) const;
0116 
0117     friend std::ostream&
0118     operator << (std::ostream&s, const G4SmartVoxelHeader& h);
0119 
0120     G4SmartVoxelHeader(G4LogicalVolume* pVolume,
0121                const G4VoxelLimits& pLimits,
0122                const G4VolumeNosVector* pCandidates,
0123                G4int pSlice = 0);
0124       // Build and refine voxels between specified limits, considering only
0125       // the physical volumes numbered `pCandidates'. pSlice is used to set max
0126       // and min equivalent slice nos for the header - they apply to the level
0127       // of the header, not its nodes.
0128 
0129   protected:
0130 
0131     //  `Worker' / operation functions:
0132 
0133     void BuildVoxels(G4LogicalVolume* pVolume);
0134       // Build and refine voxels for daughters of specified volume which
0135       // DOES NOT contain a REPLICATED daughter.
0136 
0137     void BuildReplicaVoxels(G4LogicalVolume* pVolume);
0138       // Build voxels for specified volume containing a single
0139       // replicated volume.
0140 
0141     void BuildConsumedNodes(G4int nReplicas);
0142       // Construct nodes in simple consuming case.
0143 
0144     void BuildVoxelsWithinLimits(G4LogicalVolume* pVolume,
0145                                  G4VoxelLimits pLimits,
0146                          const G4VolumeNosVector* pCandidates);
0147       // Build and refine voxels between specified limits, considering only
0148       // the physical volumes `pCandidates'. Main entry point for "construction".
0149       // Hardwired to stop at third level of refinement, using the xyz cartesian
0150       // axes in any order.
0151 
0152     void BuildEquivalentSliceNos();
0153       // Calculate and Store the minimum and maximum equivalent neighbour
0154       // values for all slices.
0155 
0156     void CollectEquivalentNodes();
0157       // Collect common nodes, deleting all but one to save memory,
0158       // and adjusting stored slice ptrs appropriately.
0159 
0160     void CollectEquivalentHeaders();
0161       // Collect common headers, deleting all but one to save memory,
0162       // and adjusting stored slice ptrs appropriately.
0163 
0164 
0165     G4ProxyVector* BuildNodes(G4LogicalVolume* pVolume,
0166                           G4VoxelLimits pLimits,
0167                           const G4VolumeNosVector* pCandidates,
0168                           EAxis pAxis);
0169       // Build the nodes corresponding to the specified axis, within
0170       // the specified limits, considering the daughters numbered pCandidates
0171       // of the logical volume.
0172 
0173     G4double CalculateQuality(G4ProxyVector *pSlice);
0174       // Calculate a "quality value" for the specified vector of voxels
0175       // The value returned should be >0 and such that the smaller the
0176       // number the higher the quality of the slice.
0177       // pSlice must consist of smartvoxelnodeproxies only.
0178 
0179     void RefineNodes(G4LogicalVolume* pVolume,G4VoxelLimits pLimits);
0180       // Examined each contained node, refine (create a replacement additional
0181       // dimension of voxels) when there is more than one voxel in the slice.
0182 
0183     G4int fminEquivalent;
0184     G4int fmaxEquivalent;
0185       // Min and max equivalent slice nos for previous level.
0186 
0187     EAxis faxis, fparamAxis;
0188       // Axis for slices.
0189 
0190     G4double fmaxExtent;
0191     G4double fminExtent;
0192       // Max and min coordinate along faxis.
0193 
0194     G4ProxyVector fslices;
0195       // Slices along axis.
0196 };
0197 
0198 #include "G4SmartVoxelHeader.icc"
0199 
0200 #endif