Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 #ifndef DDG4_GEANT4GEOMETRYINFO_H
0014 #define DDG4_GEANT4GEOMETRYINFO_H
0015 
0016 // Framework include files
0017 #include <DD4hep/Objects.h>
0018 #include <DD4hep/Printout.h>
0019 #include <DD4hep/GeoHandler.h>
0020 #include <DD4hep/PropertyTable.h>
0021 #include <DDG4/Geant4Primitives.h>
0022 #include <DDG4/Geant4TouchableHandler.h>
0023 
0024 
0025 // C/C++ include files
0026 #include <map>
0027 #include <vector>
0028 #include <cstdint>
0029 
0030 // Forward declarations (TGeo)
0031 class TGeoElement;
0032 class TGeoMedium;
0033 class TGeoVolume;
0034 class TGeoShape;
0035 class TGeoNode;
0036 // Forward declarations (Geant4)
0037 class G4Isotope;
0038 class G4Element;
0039 class G4Material;
0040 class G4VSolid;
0041 class G4LogicalVolume;
0042 class G4Region;
0043 class G4UserLimits;
0044 class G4VisAttributes;
0045 class G4VPhysicalVolume;
0046 class G4OpticalSurface;
0047 class G4LogicalSkinSurface;
0048 class G4LogicalBorderSurface;
0049 class G4AssemblyVolume;
0050 class G4VSensitiveDetector;
0051 class G4PhysicsOrderedFreeVector;
0052 
0053 /// Namespace for the AIDA detector description toolkit
0054 namespace dd4hep {
0055 
0056   /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit
0057   namespace sim {
0058 
0059     // Forward declarations
0060     class Geant4Mapping;
0061     class Geant4AssemblyVolume;
0062 
0063     /// Helper namespace defining data types for the relation information between geant4 objects and dd4hep objects.
0064     /**
0065      *  \author  M.Frank
0066      *  \version 1.0
0067      *  \ingroup DD4HEP_SIMULATION
0068      */
0069     namespace Geant4GeometryMaps  {
0070       typedef std::map<Atom, G4Element*>                            ElementMap;
0071       typedef std::map<const TGeoIsotope*, G4Isotope*>              IsotopeMap;
0072       typedef std::map<Material, G4Material*>                       MaterialMap;
0073       typedef std::map<PlacedVolume, G4VPhysicalVolume*>            PlacementMap;
0074       typedef std::map<Volume, G4LogicalVolume*>                    VolumeMap;
0075       typedef std::map<PlacedVolume, Geant4AssemblyVolume*>         AssemblyMap;
0076 
0077       typedef std::vector<const TGeoNode*>                          PlacedVolumeChain;
0078       typedef std::pair<PlacedVolumeChain,const G4VPhysicalVolume*> ImprintEntry;
0079       typedef std::vector<ImprintEntry>                             Imprints;
0080       typedef std::map<Volume,Imprints>                             VolumeImprintMap;
0081       typedef std::map<const TGeoShape*, G4VSolid*>                 SolidMap;
0082       typedef std::map<const G4VPhysicalVolume*, PlacedVolume>      G4PlacementMap;
0083     }
0084 
0085     /// Concreate class holding the relation information between geant4 objects and dd4hep objects.
0086     /**
0087      *  \author  M.Frank
0088      *  \version 1.0
0089      *  \ingroup DD4HEP_SIMULATION
0090      */
0091     class Geant4GeometryInfo : public TNamed, public detail::GeoHandlerTypes::GeometryInfo {
0092     public:
0093       union PlacementFlags {
0094         int value;
0095         struct _flags  {
0096           unsigned parametrised:1;
0097           unsigned replicated:1;
0098         } flags;
0099         PlacementFlags()      { this->value = 0; }
0100         PlacementFlags(int v) { this->value = v; }
0101       };
0102       struct Placement  {
0103         VolumeID volumeID;
0104         int      flags;
0105       };
0106 
0107       class DebugInfo;
0108       TGeoManager*                         manager     { nullptr };
0109       DebugInfo*                           g4DebugInfo { nullptr };
0110       Geant4GeometryMaps::IsotopeMap       g4Isotopes;
0111       Geant4GeometryMaps::ElementMap       g4Elements;
0112       Geant4GeometryMaps::MaterialMap      g4Materials;
0113       Geant4GeometryMaps::SolidMap         g4Solids;
0114       Geant4GeometryMaps::VolumeMap        g4Volumes;
0115       Geant4GeometryMaps::PlacementMap     g4Placements;
0116       Geant4GeometryMaps::AssemblyMap      g4AssemblyVolumes;
0117       Geant4GeometryMaps::VolumeImprintMap g4VolumeImprints;
0118       Geant4GeometryMaps::G4PlacementMap   g4Parameterised;
0119       Geant4GeometryMaps::G4PlacementMap   g4Replicated;
0120       struct PropertyVector  {
0121         std::vector<double> bins;
0122         std::vector<double> values;
0123         std::string name, title;
0124         PropertyVector() = default;
0125         ~PropertyVector() = default;
0126       };
0127       std::map<PropertyTable,    PropertyVector*>              g4OpticalProperties;
0128       std::map<OpticalSurface,   G4OpticalSurface*>            g4OpticalSurfaces;
0129       std::map<SkinSurface,      G4LogicalSkinSurface*>        g4SkinSurfaces;
0130       std::map<BorderSurface,    G4LogicalBorderSurface*>      g4BorderSurfaces;
0131       std::map<Region,           G4Region*>                    g4Regions;
0132       std::map<VisAttr,          G4VisAttributes*>             g4Vis;
0133       std::map<LimitSet,         G4UserLimits*>                g4Limits;
0134       std::map<uint64_t,         Placement>                    g4Paths;
0135       std::map<SensitiveDetector,std::set<const TGeoVolume*> > sensitives;
0136       std::map<Region,           std::set<const TGeoVolume*> > regions;
0137       std::map<LimitSet,         std::set<const TGeoVolume*> > limits;
0138       G4VPhysicalVolume*                                       m_world;
0139       PrintLevel                                               printLevel;
0140       bool                                                     has_volmgr { false };
0141       bool                                                     valid      { false };
0142 
0143       /// Assemble Geant4 volume path
0144       static std::string placementPath(const Geant4TouchableHandler::Geant4PlacementPath& path, bool reverse=true)  {
0145         return Geant4TouchableHandler::placementPath(path, reverse);
0146       }
0147 
0148     private:
0149       friend class Geant4Mapping;
0150       /// Default constructor
0151       Geant4GeometryInfo();
0152       /// Default destructor
0153       virtual ~Geant4GeometryInfo();
0154 
0155     public:
0156       /// The world placement
0157       G4VPhysicalVolume* world() const;
0158       /// Set the world volume
0159       void setWorld(const TGeoNode* node);
0160     };
0161   }    // End namespace sim
0162 }      // End namespace dd4hep
0163 #endif // DDG4_GEANT4GEOMETRYINFO_H