Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:34

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 /// \file materials/include/G4LatticeManager.hh
0027 /// \brief Definition of the G4LatticeManager class
0028 //
0029 //
0030 // 20131113  Add registry to carry unique lattice pointers, for EOJ deletion
0031 // 20131115  Drop lattice counters, not used anywhere
0032 // 20141008  Change to global singleton; must be shared across worker threads
0033 
0034 #ifndef G4LatticeManager_h
0035 #define G4LatticeManager_h 1
0036 
0037 #include "G4ThreeVector.hh"
0038 #include <map>
0039 #include <set>
0040 
0041 class G4LatticeLogical;
0042 class G4LatticePhysical;
0043 class G4Material;
0044 class G4VPhysicalVolume;
0045 
0046 
0047 class G4LatticeManager {
0048 private:
0049   static G4LatticeManager* fLM;     // Global, shared singleton
0050 
0051 public:
0052   static G4LatticeManager* GetLatticeManager(); 
0053 
0054   void SetVerboseLevel(G4int vb) { verboseLevel = vb; }
0055 
0056   void Reset();     // Remove and delete all registered lattices
0057 
0058   // Users may register physical or logical lattices with volumes
0059   G4bool RegisterLattice(G4VPhysicalVolume*, G4LatticePhysical*);
0060   G4bool RegisterLattice(G4VPhysicalVolume*, G4LatticeLogical*);
0061 
0062   // Logical lattices are associated with materials
0063   G4bool RegisterLattice(G4Material*, G4LatticeLogical*);
0064 
0065   // Logical lattices may be read from <latDir>/config.txt data file
0066   G4LatticeLogical* LoadLattice(G4Material*, const G4String& latDir);
0067   G4LatticeLogical* GetLattice(G4Material*) const;
0068   G4bool HasLattice(G4Material*) const;
0069 
0070   // Combine loading and registration (Material extracted from volume)
0071   G4LatticePhysical* LoadLattice(G4VPhysicalVolume*, const G4String& latDir);
0072 
0073   // NOTE:  Passing Vol==0 will return the default lattice
0074   G4LatticePhysical* GetLattice(G4VPhysicalVolume*) const;
0075   G4bool HasLattice(G4VPhysicalVolume*) const;
0076 
0077   G4double MapKtoV(G4VPhysicalVolume*, G4int, const G4ThreeVector &) const;
0078 
0079   G4ThreeVector MapKtoVDir(G4VPhysicalVolume*, G4int,
0080                const G4ThreeVector&) const;
0081 
0082 protected:
0083   void Clear();     // Remove entries from lookup tables w/o deletion
0084 
0085 protected:
0086   G4int verboseLevel;       // Allow users to enable diagnostic messages
0087 
0088   typedef std::map<G4Material*, G4LatticeLogical*> LatticeMatMap;
0089   typedef std::set<G4LatticeLogical*> LatticeLogReg;
0090 
0091   LatticeLogReg fLLattices; // Registry of unique lattice pointers
0092   LatticeMatMap fLLatticeList;
0093 
0094   typedef std::map<G4VPhysicalVolume*, G4LatticePhysical*> LatticeVolMap;
0095   typedef std::set<G4LatticePhysical*> LatticePhyReg;
0096 
0097   LatticePhyReg fPLattices; // Registry of unique lattice pointers
0098   LatticeVolMap fPLatticeList; 
0099 
0100 private:
0101   G4LatticeManager();
0102   virtual ~G4LatticeManager();
0103 };
0104 
0105 #endif