Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:23

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 
0023 // C/C++ include files
0024 #include <map>
0025 #include <vector>
0026 
0027 // Forward declarations (TGeo)
0028 class TGeoElement;
0029 class TGeoMedium;
0030 class TGeoVolume;
0031 class TGeoShape;
0032 class TGeoNode;
0033 // Forward declarations (Geant4)
0034 class G4Isotope;
0035 class G4Element;
0036 class G4Material;
0037 class G4VSolid;
0038 class G4LogicalVolume;
0039 class G4Region;
0040 class G4UserLimits;
0041 class G4VisAttributes;
0042 class G4VPhysicalVolume;
0043 class G4OpticalSurface;
0044 class G4LogicalSkinSurface;
0045 class G4LogicalBorderSurface;
0046 class G4AssemblyVolume;
0047 class G4VSensitiveDetector;
0048 class G4PhysicsOrderedFreeVector;
0049 
0050 /// Namespace for the AIDA detector description toolkit
0051 namespace dd4hep {
0052 
0053   /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit
0054   namespace sim {
0055 
0056     // Forward declarations
0057     class Geant4Mapping;
0058     class Geant4AssemblyVolume;
0059 
0060     /// Helper namespace defining data types for the relation information between geant4 objects and dd4hep objects.
0061     /**
0062      *  \author  M.Frank
0063      *  \version 1.0
0064      *  \ingroup DD4HEP_SIMULATION
0065      */
0066     namespace Geant4GeometryMaps  {
0067       //typedef std::vector<const G4VPhysicalVolume*>           Geant4PlacementPath;
0068       typedef std::map<Atom, G4Element*>                      ElementMap;
0069       typedef std::map<const TGeoIsotope*, G4Isotope*>        IsotopeMap;
0070       typedef std::map<Material, G4Material*>                 MaterialMap;
0071       //typedef std::map<LimitSet, G4UserLimits*>               LimitMap;
0072       typedef std::map<PlacedVolume, G4VPhysicalVolume*>      PlacementMap;
0073       //typedef std::map<Region, G4Region*>                     RegionMap;
0074       typedef std::map<Volume, G4LogicalVolume*>              VolumeMap;
0075       typedef std::map<PlacedVolume, Geant4AssemblyVolume*>   AssemblyMap;
0076 
0077       typedef std::vector<const TGeoNode*>                    VolumeChain;
0078       typedef std::pair<VolumeChain,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<VisAttr, G4VisAttributes*>             VisMap;
0083       //typedef std::map<Geant4PlacementPath, VolumeID>         Geant4PathMap;
0084       typedef std::map<const G4VPhysicalVolume*, PlacedVolume> G4PlacementMap;
0085     }
0086 
0087     /// Concreate class holding the relation information between geant4 objects and dd4hep objects.
0088     /**
0089      *  \author  M.Frank
0090      *  \version 1.0
0091      *  \ingroup DD4HEP_SIMULATION
0092      */
0093     class Geant4GeometryInfo : public TNamed, public detail::GeoHandlerTypes::GeometryInfo {
0094     public:
0095       struct Placement  {
0096     VolumeID     volumeID;
0097     int          flags;
0098       };
0099       union PlacementFlags {
0100     int value;
0101     struct _flags  {
0102       unsigned     parametrised:1;
0103       unsigned     replicated:1;
0104       unsigned     path_has_parametrised:1;
0105       unsigned     path_has_replicated:1;
0106     } flags;
0107     PlacementFlags()      { this->value = 0; }
0108     PlacementFlags(int v) { this->value = v; }
0109       };
0110       typedef std::vector<const G4VPhysicalVolume*>  Geant4PlacementPath;
0111       TGeoManager*                         manager = 0;
0112       Geant4GeometryMaps::IsotopeMap       g4Isotopes;
0113       Geant4GeometryMaps::ElementMap       g4Elements;
0114       Geant4GeometryMaps::MaterialMap      g4Materials;
0115       Geant4GeometryMaps::SolidMap         g4Solids;
0116       Geant4GeometryMaps::VolumeMap        g4Volumes;
0117       Geant4GeometryMaps::PlacementMap     g4Placements;
0118       Geant4GeometryMaps::AssemblyMap      g4AssemblyVolumes;
0119       Geant4GeometryMaps::VolumeImprintMap g4VolumeImprints;
0120       Geant4GeometryMaps::G4PlacementMap   g4Parameterised;
0121       Geant4GeometryMaps::G4PlacementMap   g4Replicated;
0122       struct PropertyVector  {
0123         std::vector<double> bins;
0124         std::vector<double> values;
0125         std::string name, title;
0126         PropertyVector() = default;
0127         ~PropertyVector() = default;
0128       };
0129       std::map<PropertyTable,  PropertyVector*>                g4OpticalProperties;
0130       std::map<OpticalSurface, G4OpticalSurface*>              g4OpticalSurfaces;
0131       std::map<SkinSurface,    G4LogicalSkinSurface*>          g4SkinSurfaces;
0132       std::map<BorderSurface,  G4LogicalBorderSurface*>        g4BorderSurfaces;
0133       std::map<Region, G4Region*>                              g4Regions;
0134       std::map<VisAttr, G4VisAttributes*>                      g4Vis;
0135       std::map<LimitSet, G4UserLimits*>                        g4Limits;
0136       std::map<Geant4PlacementPath, Placement>                 g4Paths;
0137       std::map<SensitiveDetector,std::set<const TGeoVolume*> > sensitives;
0138       std::map<Region,           std::set<const TGeoVolume*> > regions;
0139       std::map<LimitSet,         std::set<const TGeoVolume*> > limits;
0140       G4VPhysicalVolume*                                       m_world;
0141       PrintLevel                                               printLevel;
0142       bool                                                     valid;
0143     private:
0144       friend class Geant4Mapping;
0145       /// Default constructor
0146       Geant4GeometryInfo();
0147       /// Default destructor
0148       virtual ~Geant4GeometryInfo();
0149     public:
0150       /// The world placement
0151       G4VPhysicalVolume* world() const;
0152       /// Set the world volume
0153       void setWorld(const TGeoNode* node);
0154       /// Assemble Geant4 volume path
0155       static std::string placementPath(const Geant4PlacementPath& path, bool reverse=true);
0156     };
0157 
0158   }    // End namespace sim
0159 }      // End namespace dd4hep
0160 #endif // DDG4_GEANT4GEOMETRYINFO_H