DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Geant4ParticleInformation.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 #ifndef DDG4_GEANT4PARTICLEINFORMATION_H
14 #define DDG4_GEANT4PARTICLEINFORMATION_H
15 
17 #include <DDG4/Geant4Particle.h>
18 
20 #include <G4VUserTrackInformation.hh>
21 
23 #include <string>
24 #include <memory>
25 
26 
28 namespace dd4hep {
29 
31  namespace sim {
32 
34 
50  std::unique_ptr<ParticleExtension> extension;
51 
52  public:
56  template <typename EXTENSION_TYPE>
57  Geant4ParticleInformation(EXTENSION_TYPE* data);
59  template <typename EXTENSION_TYPE>
60  Geant4ParticleInformation(std::unique_ptr<EXTENSION_TYPE>&& data);
70  virtual ~Geant4ParticleInformation() = default;
71 
73  void set(ParticleExtension* data) {
74  this->extension.reset(data);
75  }
77  template <typename EXTENSION_TYPE> void set(std::unique_ptr<EXTENSION_TYPE>&& data) {
78  this->extension = std::move(data);
79  }
80  template <typename EXTENSION_TYPE> EXTENSION_TYPE* get() {
81  return dynamic_cast<EXTENSION_TYPE*>(this->extension.get());
82  }
84  return this->extension.get();
85  }
87  return this->extension.release();
88  }
89  };
90 
92  template <typename EXTENSION_TYPE> inline
93  Geant4ParticleInformation::Geant4ParticleInformation(std::unique_ptr<EXTENSION_TYPE>&& data)
94  : extension(std::move(data))
95  {
96  }
97 
99  template <typename EXTENSION_TYPE> inline
101  : extension(data)
102  {
103  }
104 
105  } // End namespace sim
106 } // End namespace dd4hep
107 #endif /* DDG4_GEANT4PARTICLEINFORMATION_H */
dd4hep::sim::Geant4ParticleInformation::operator=
Geant4ParticleInformation & operator=(Geant4ParticleInformation &&copy)=default
Move assignemtn operator.
dd4hep::sim::Geant4ParticleInformation::set
void set(ParticleExtension *data)
Attach information.
Definition: Geant4ParticleInformation.h:73
dd4hep::sim::Geant4ParticleInformation::release
ParticleExtension * release()
Definition: Geant4ParticleInformation.h:86
dd4hep::sim::Geant4ParticleInformation::extension
std::unique_ptr< ParticleExtension > extension
Keep track of the user data.
Definition: Geant4ParticleInformation.h:50
G4VUserTrackInformation
Class of the Geant4 toolkit. See http://www-geant4.kek.jp/Reference.
Definition: Geant4Classes.h:75
dd4hep::sim::Geant4ParticleInformation::~Geant4ParticleInformation
virtual ~Geant4ParticleInformation()=default
Default destructor.
dd4hep::sim::Geant4ParticleInformation::operator=
Geant4ParticleInformation & operator=(const Geant4ParticleInformation &copy)=delete
Disable copy assignment.
dd4hep::sim::Geant4ParticleInformation::get
ParticleExtension * get()
Definition: Geant4ParticleInformation.h:83
dd4hep::sim::Geant4ParticleInformation::Geant4ParticleInformation
Geant4ParticleInformation()=default
Default Constructor.
dd4hep::sim::Geant4ParticleInformation::Geant4ParticleInformation
Geant4ParticleInformation(Geant4ParticleInformation &&copy)=default
Move constructor.
dd4hep::sim::Geant4ParticleInformation::set
void set(std::unique_ptr< EXTENSION_TYPE > &&data)
Attach information.
Definition: Geant4ParticleInformation.h:77
std
Definition: Plugins.h:30
dd4hep::sim::Geant4ParticleInformation::get
EXTENSION_TYPE * get()
Definition: Geant4ParticleInformation.h:80
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::sim::Geant4ParticleInformation
Wrapper to store user information in a G4Track.
Definition: Geant4ParticleInformation.h:48
Geant4Particle.h
dd4hep::sim::ParticleExtension
Base class to extend the basic particle class used by DDG4 with user information.
Definition: Geant4Particle.h:47
dd4hep::detail::tools::copy
void copy(Alignment from, Alignment to)
Copy alignment object from source object.
Definition: AlignmentTools.cpp:43
dd4hep::sim::Geant4ParticleInformation::Geant4ParticleInformation
Geant4ParticleInformation(const Geant4ParticleInformation &copy)=delete
Disable copy constructor.