Back to home page

EIC code displayed by LXR

 
 

    


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

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_GEANT4PARTICLEINFORMATION_H
0014 #define DDG4_GEANT4PARTICLEINFORMATION_H
0015 
0016 /// Framework include files
0017 #include <DDG4/Geant4Particle.h>
0018 
0019 /// Geant4 include files
0020 #include <G4VUserTrackInformation.hh>
0021 
0022 /// C/C++ include files
0023 #include <string>
0024 #include <memory>
0025 
0026 
0027 /// Namespace for the AIDA detector description toolkit
0028 namespace dd4hep {
0029 
0030   /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit
0031   namespace sim {
0032 
0033     /// Wrapper to store user information in a G4Track.
0034     /** Wrapper to store user information in a G4Track.
0035      *  The data of type ParticleExtension is moved from the G4Track to the 
0036      *  Geant4Particle in the Geant4ParticleHandler if present.
0037      *  This automatically make the G4Track instance persistent as a 
0038      *  Geant4Particle.
0039      *  Hence: Be careful to not assign the entity by default!
0040      *
0041      *  The data in the subclass of ParticleExtension defined by the user
0042      *  requires a dictionary to be stored to ROOT.
0043      *
0044      *  \author  M.Frank
0045      *  \version 1.0
0046      *  \ingroup DD4HEP_SIMULATION
0047      */
0048     class Geant4ParticleInformation : public G4VUserTrackInformation {
0049       /// Keep track of the user data
0050       std::unique_ptr<ParticleExtension> extension;
0051 
0052     public:
0053       /// Default Constructor
0054       Geant4ParticleInformation() = default;
0055       /// Initializing Constructor
0056       template <typename EXTENSION_TYPE>
0057       Geant4ParticleInformation(EXTENSION_TYPE* data);
0058       /// Initializing Constructor
0059       template <typename EXTENSION_TYPE>
0060       Geant4ParticleInformation(std::unique_ptr<EXTENSION_TYPE>&& data);
0061       /// Move constructor
0062       Geant4ParticleInformation(Geant4ParticleInformation&& copy) = default;
0063       /// Disable copy constructor
0064       Geant4ParticleInformation(const Geant4ParticleInformation& copy) = delete;
0065       /// Move assignemtn operator
0066       Geant4ParticleInformation& operator=(Geant4ParticleInformation&& copy) = default;
0067       /// Disable copy assignment
0068       Geant4ParticleInformation& operator=(const Geant4ParticleInformation& copy) = delete;
0069       /// Default destructor
0070       virtual ~Geant4ParticleInformation() = default;
0071       
0072       /// Attach information
0073       void set(ParticleExtension* data)   {
0074     this->extension.reset(data);
0075       }
0076       /// Attach information
0077       template <typename EXTENSION_TYPE> void set(std::unique_ptr<EXTENSION_TYPE>&& data)   {
0078     this->extension = std::move(data);
0079       }
0080       template <typename EXTENSION_TYPE> EXTENSION_TYPE* get()   {
0081     return dynamic_cast<EXTENSION_TYPE*>(this->extension.get());
0082       }
0083       ParticleExtension* get()   {
0084     return this->extension.get();
0085       }
0086       ParticleExtension* release()   {
0087     return this->extension.release();
0088       }
0089     };
0090 
0091     /// Initializing Constructor
0092     template <typename EXTENSION_TYPE> inline
0093     Geant4ParticleInformation::Geant4ParticleInformation(std::unique_ptr<EXTENSION_TYPE>&& data)
0094       : extension(std::move(data))
0095     {
0096     }
0097 
0098     /// Initializing Constructor
0099     template <typename EXTENSION_TYPE> inline
0100     Geant4ParticleInformation::Geant4ParticleInformation(EXTENSION_TYPE* data)
0101       : extension(data)
0102     {
0103     }
0104 
0105   }    // End namespace sim
0106 }      // End namespace dd4hep
0107 #endif /* DDG4_GEANT4PARTICLEINFORMATION_H */