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_GEANT4HITHANDLER_H
0014 #define DDG4_GEANT4HITHANDLER_H
0015 
0016 // Framework include files
0017 #include <DDG4/Defs.h>
0018 
0019 // Geant4 include files
0020 #include <G4EmSaturation.hh>
0021 #include <G4Version.hh>
0022 
0023 /// Namespace for the AIDA detector description toolkit
0024 namespace dd4hep {
0025 
0026   /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit
0027   namespace sim {
0028 
0029     // Forward declarations;
0030     class Geant4HitHandler;
0031 
0032     /// Helper class to ease the extraction of information from a G4Hit object.
0033     /**
0034      *
0035      * Helper/utility class to easily access Geant4 hit information.
0036      * Born by lazyness: Avoid typing millions of statements!
0037      *
0038      *  \author  M.Frank
0039      *  \version 1.0
0040      *  \ingroup DD4HEP_SIMULATION
0041      */
0042     class Geant4HitHandler {
0043     protected:
0044     public:
0045       const G4Track* track;
0046       const G4VTouchable* touchable_ptr;
0047       /// Inhibit default constructor
0048       Geant4HitHandler() = delete;
0049       /// Initializing constructor
0050       Geant4HitHandler(const G4Track* t, const G4VTouchable* h)
0051     : track(t), touchable_ptr(h)
0052       {
0053       }
0054       /// No copy constructor
0055       Geant4HitHandler(const Geant4HitHandler& copy) = delete;
0056       /// No move constructor
0057       Geant4HitHandler(Geant4HitHandler&& copy) = delete;
0058       /// Assignment operator inhibited. Should not be copied
0059       Geant4HitHandler& operator=(const Geant4HitHandler& copy) = delete;
0060       /// Move operator inhibited. Should not be copied
0061       Geant4HitHandler& operator=(Geant4HitHandler&& copy) = delete;
0062       
0063       const G4VTouchable* touchable() const {
0064         return touchable_ptr;
0065       }
0066       G4ParticleDefinition* trackDef() const {
0067         return track->GetDefinition();
0068       }
0069       int trkPdgID() const {
0070         return track->GetDefinition()->GetPDGEncoding();
0071       }
0072       /// Access the G4 track ID
0073       int trkID() const  {
0074         return track->GetTrackID();
0075       }
0076       /// Access the G4 track ID of the parent track
0077       int parentID() const  {
0078         return track->GetParentID();
0079       }
0080       double trkTime() const  {
0081         return track->GetGlobalTime();
0082       }
0083       double trkEnergy() const  {
0084         return track->GetTotalEnergy();
0085       }
0086       double trkKineEnergy() const  {
0087         return track->GetKineticEnergy();
0088       }
0089       int trkStatus()  const  {
0090         return track->GetTrackStatus();
0091       }
0092       bool trkAlive() const  {
0093         return track->GetTrackStatus() == fAlive;
0094       }
0095       const G4VProcess* trkProcess()  const  {
0096         return track->GetCreatorProcess();
0097       }
0098       Momentum trkMom() const {
0099         const G4ThreeVector& p = track->GetMomentum();
0100         return Momentum(p.x(), p.y(), p.z());
0101       }
0102       bool isSensitive(const G4LogicalVolume* lv) const {
0103         return lv ? (0 != lv->GetSensitiveDetector()) : false;
0104       }
0105       bool isSensitive(const G4VPhysicalVolume* pv) const {
0106         return pv ? isSensitive(pv->GetLogicalVolume()) : false;
0107       }
0108 
0109       /// Coordinate transformation to global coordinates.
0110       /** Note: Positions are in units of MM! */
0111       Position localToGlobal(const Position& local)  const;
0112       /// Coordinate transformation to global coordinates.
0113       /** Note: DDSegmentation points are units in CM! Conversion done inside! */
0114       Position localToGlobal(const DDSegmentation::Vector3D& local)  const;
0115       /// Coordinate transformation to global coordinates in MM
0116       Position localToGlobal(const G4ThreeVector& local)  const;
0117       /// Coordinate transformation to global coordinates in MM
0118       Position localToGlobal(double x, double y, double z)  const;
0119 
0120       /// Coordinate transformation to local coordinates
0121       Position globalToLocal(double x, double y, double z)  const;
0122       /// Coordinate transformation to local coordinates
0123       Position globalToLocal(const Position& global)  const;
0124       /// Coordinate transformation to local coordinates
0125       Position globalToLocal(const G4ThreeVector& global)  const;
0126       /// Coordinate transformation to local coordinates
0127       G4ThreeVector globalToLocalG4(double x, double y, double z)  const;
0128       /// Coordinate transformation to local coordinates with G4 objects
0129       G4ThreeVector globalToLocalG4(const G4ThreeVector& loc)  const;
0130     };
0131 
0132   }    // End namespace sim
0133 }      // End namespace dd4hep
0134 
0135 #endif // DDG4_GEANT4HITHANDLER_H