Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-26 08:57:39

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 // G4WeightWindowStore
0027 //
0028 // Class description:
0029 //
0030 // Implementation of a weight window store according to the
0031 // G4VWeightWindowStore interface.
0032 // See also G4VWeightWindowStore.
0033 
0034 // Author: Michael Dressel (CERN), 2003 - Created
0035 //         Alex Howard (CERN), 2013 - Changed class to a 'singleton'
0036 // ----------------------------------------------------------------------
0037 #ifndef G4WEIGHTWINDOWSTORE_HH
0038 #define G4WEIGHTWINDOWSTORE_HH
0039 
0040 #include "G4VWeightWindowStore.hh"
0041 #include "G4GeometryCellWeight.hh"
0042 #include <set>
0043 #include <vector>
0044 
0045 /**
0046  * @brief G4WeightWindowStore is an concrete implementation of a weight window
0047  * store according to the G4VWeightWindowStore interface.
0048  */
0049 
0050 class G4WeightWindowStore: public G4VWeightWindowStore
0051 {
0052   public:
0053 
0054     /**
0055      * Returns a pointer to the singleton instance of the class.
0056      */
0057     static G4WeightWindowStore* GetInstance();
0058 
0059     /**
0060      * Returns a pointer to the singleton instance of the class, given
0061      * the name of the parallel world of reference.
0062      */
0063     static G4WeightWindowStore* GetInstance(const G4String& ParallelWorldName);
0064 
0065     /**
0066      * Derives a lower weight bound value of a "cell" addressed by a 
0067      * G4GeometryCell and the corresponding energy from the store.
0068      */
0069     G4double GetLowerWeight(const G4GeometryCell& gCell, 
0070                                   G4double partEnergy) const override;
0071 
0072     /**
0073      * Returns true if 'gCell' is in the store, else false.
0074      *  @param[in] gCell The cell of reference.
0075      *  @returns true if present in the store, false otherwise.
0076      */
0077     G4bool IsKnown(const G4GeometryCell &gCell) const override;
0078 
0079     /**
0080      * Clears the cells weights map.
0081      */
0082     void Clear();
0083 
0084     /**
0085      * Sets a reference to world volume of the "weightwindow" geometry.
0086      */
0087     void SetWorldVolume();
0088 
0089     /**
0090      * Sets a reference to parallel world volume of the "weightwindow" geometry.
0091      */
0092     void SetParallelWorldVolume(const G4String& paraName);
0093 
0094     /**
0095      * Returns a reference to the world volume of the "weightwindow" geometry.
0096      */
0097     const G4VPhysicalVolume& GetWorldVolume() const override;
0098 
0099     /**
0100      * Returns a pointer to the world volume of the "weightwindow" geometry.
0101      */
0102     const G4VPhysicalVolume* GetParallelWorldVolumePointer() const;
0103 
0104     /**
0105      * Adds lower weights. Only if general upper energy bounds have been set.
0106      */
0107     void AddLowerWeights(const G4GeometryCell& gCell,
0108                          const std::vector<G4double>& lowerWeights);
0109 
0110     /**
0111      * Sets upper energy - lower weight pairs for a cell.
0112      */
0113     void AddUpperEboundLowerWeightPairs(const G4GeometryCell& gCell,
0114                                   const G4UpperEnergyToLowerWeightMap& enWeMap);
0115 
0116     /**
0117      * Sets the energy bounds.
0118      */
0119     void SetGeneralUpperEnergyBounds(const std::set<G4double,
0120                                            std::less<G4double> >& enBounds);
0121   private:
0122 
0123     /**
0124      * Constructors. Initialise the weight window store for the given geometry.
0125      */
0126     explicit G4WeightWindowStore();
0127     explicit G4WeightWindowStore(const G4String& ParallelWorldName);
0128 
0129     /**
0130      * Default Destructor.
0131      */
0132     ~G4WeightWindowStore() override = default;
0133 
0134     /**
0135      * Internal utilities.
0136      */
0137     G4bool IsInWorld(const G4VPhysicalVolume&) const;
0138     void SetInternalIterator(const G4GeometryCell& gCell) const;
0139 
0140     /**
0141      * Internal logger.
0142      */
0143     void Error(const G4String& m) const;
0144 
0145   private:
0146 
0147     const G4VPhysicalVolume* fWorldVolume = nullptr;  
0148 
0149     std::set<G4double, std::less<G4double> > fGeneralUpperEnergyBounds;
0150     G4GeometryCellWeight fCellToUpEnBoundLoWePairsMap;
0151     mutable G4GeometryCellWeight::const_iterator fCurrentIterator;
0152 
0153     static G4ThreadLocal G4WeightWindowStore* fInstance;
0154 };
0155 
0156 #endif