From 7085065ddb17a0316b006d2593c73a006f57643c Mon Sep 17 00:00:00 2001 From: Markus Frank <Markus.Frank@cern.ch> Date: Tue, 15 Nov 2016 18:24:42 +0100 Subject: [PATCH] Try to improve efficiency using C++11 default operations --- DDCore/src/Printout.cpp | 1 + DDG4/include/DDG4/Geant4EventAction.h | 6 ------ DDG4/include/DDG4/Geant4Primary.h | 12 ++++++------ DDG4/include/DDG4/Geant4SensDetAction.h | 11 +++-------- DDG4/include/DDG4/Geant4SensDetAction.inl | 1 - DDG4/include/DDG4/Geant4SteppingAction.h | 8 ++++++-- DDG4/include/DDG4/Geant4TrackingAction.h | 7 ++++++- DDG4/src/Geant4Primary.cpp | 18 ------------------ 8 files changed, 22 insertions(+), 42 deletions(-) diff --git a/DDCore/src/Printout.cpp b/DDCore/src/Printout.cpp index 071b5138b..59ce77b5d 100644 --- a/DDCore/src/Printout.cpp +++ b/DDCore/src/Printout.cpp @@ -326,6 +326,7 @@ DD4hep::PrintLevel DD4hep::printLevel(const char* value) { if ( strcmp(value,"6") == 0 ) return DD4hep::FATAL; if ( strcmp(value,"7") == 0 ) return DD4hep::ALWAYS; except("Printout","Unknown printlevel requested:%s",value); + return DD4hep::ALWAYS; } /// Translate the printer level from string to value diff --git a/DDG4/include/DDG4/Geant4EventAction.h b/DDG4/include/DDG4/Geant4EventAction.h index 9788587a0..b651e34ec 100644 --- a/DDG4/include/DDG4/Geant4EventAction.h +++ b/DDG4/include/DDG4/Geant4EventAction.h @@ -54,8 +54,6 @@ namespace DD4hep { public: typedef Geant4SharedEventAction shared_type; public: - /// Inhibit default constructor - Geant4EventAction() = delete; /// Inhibit copy constructor Geant4EventAction(const Geant4EventAction& copy) = delete; /// Standard constructor @@ -86,8 +84,6 @@ namespace DD4hep { /// Reference to the shared action Geant4EventAction* m_action; public: - /// Inhibit default constructor - Geant4SharedEventAction() = delete; /// Inhibit copy constructor Geant4SharedEventAction(const Geant4SharedEventAction& copy) = delete; /// Standard constructor @@ -131,8 +127,6 @@ namespace DD4hep { Actors<Geant4EventAction> m_actors; public: - /// Inhibit default constructor - Geant4EventActionSequence() = delete; /// Inhibit copy constructor Geant4EventActionSequence(const Geant4EventActionSequence& copy) = delete; /// Standard constructor diff --git a/DDG4/include/DDG4/Geant4Primary.h b/DDG4/include/DDG4/Geant4Primary.h index 549fd9556..162e42ea6 100644 --- a/DDG4/include/DDG4/Geant4Primary.h +++ b/DDG4/include/DDG4/Geant4Primary.h @@ -96,9 +96,9 @@ namespace DD4hep { class Geant4PrimaryInteraction { private: /// Copy constructor - Geant4PrimaryInteraction(const Geant4PrimaryInteraction& c); + Geant4PrimaryInteraction(const Geant4PrimaryInteraction& c) = delete; /// Assignment operator - Geant4PrimaryInteraction& operator=(const Geant4PrimaryInteraction& c); + Geant4PrimaryInteraction& operator=(const Geant4PrimaryInteraction& c) = delete; public: typedef Geant4Particle Particle; @@ -114,15 +114,15 @@ namespace DD4hep { /// User data extension if required ExtensionHandle extension; /// User mask to flag the interaction. Also unique identifier - int mask; + int mask = 0; /// Flag that the event is locked for G4 native generators - int locked; + int locked = 0; /// Next PID indentifier - int next_particle_identifier; + int next_particle_identifier = -1; public: /// Default constructor - Geant4PrimaryInteraction(); + Geant4PrimaryInteraction() = default; /// Default destructor virtual ~Geant4PrimaryInteraction(); /// Access a new particle identifier within the interaction diff --git a/DDG4/include/DDG4/Geant4SensDetAction.h b/DDG4/include/DDG4/Geant4SensDetAction.h index ad0f82d44..6bbcd9e7e 100644 --- a/DDG4/include/DDG4/Geant4SensDetAction.h +++ b/DDG4/include/DDG4/Geant4SensDetAction.h @@ -93,8 +93,6 @@ namespace DD4hep { */ class Geant4Filter: public Geant4Action { public: - /// Inhibit default constructor - Geant4Filter() = delete; /// Inhibit copy constructor Geant4Filter(const Geant4Filter& copy) = delete; /// Standard constructor @@ -152,9 +150,6 @@ namespace DD4hep { Actors<Geant4Filter> m_filters; public: - /// Inhibit default constructor - Geant4Sensitive() = delete; - /// Inhibit copy constructor Geant4Sensitive(const Geant4Sensitive& copy) = delete; @@ -328,9 +323,6 @@ namespace DD4hep { } public: - /// Inhibit default constructor - Geant4SensDetActionSequence() = delete; - /// Inhibit copy constructor Geant4SensDetActionSequence(const Geant4SensDetActionSequence& copy) = delete; @@ -361,10 +353,13 @@ namespace DD4hep { /// Access HitCollection container names const std::string& hitCollectionName(size_t which) const; + /// Retrieve the hits collection associated with this detector by its serial number Geant4HitCollection* collection(size_t which) const; + /// Retrieve the hits collection associated with this detector by its collection identifier Geant4HitCollection* collectionByID(size_t id) const; + /// Register begin-of-event callback template <typename T> void callAtBegin(T* p, void (T::*f)(G4HCofThisEvent*)) { m_begin.add(p, f); diff --git a/DDG4/include/DDG4/Geant4SensDetAction.inl b/DDG4/include/DDG4/Geant4SensDetAction.inl index cb78c8ac9..57c9d516c 100644 --- a/DDG4/include/DDG4/Geant4SensDetAction.inl +++ b/DDG4/include/DDG4/Geant4SensDetAction.inl @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/include/DDG4/Geant4SteppingAction.h b/DDG4/include/DDG4/Geant4SteppingAction.h index e33778e6a..d4e7ecf1d 100644 --- a/DDG4/include/DDG4/Geant4SteppingAction.h +++ b/DDG4/include/DDG4/Geant4SteppingAction.h @@ -41,8 +41,8 @@ namespace DD4hep { public: typedef Geant4SharedSteppingAction shared_type; public: - /// Inhibit default constructor - Geant4SteppingAction() = delete; + /// Inhibit copy constructor + Geant4SteppingAction(const Geant4SteppingAction& copy) = delete; /// Standard constructor Geant4SteppingAction(Geant4Context* context, const std::string& name); /// Default destructor @@ -69,6 +69,8 @@ namespace DD4hep { /// Reference to the shared action Geant4SteppingAction* m_action; public: + /// Inhibit copy constructor + Geant4SharedSteppingAction(const Geant4SteppingAction& copy) = delete; /// Standard constructor Geant4SharedSteppingAction(Geant4Context* context, const std::string& nam); /// Default destructor @@ -104,6 +106,8 @@ namespace DD4hep { Actors<Geant4SteppingAction> m_actors; public: + /// Inhibit copy constructor + Geant4SteppingActionSequence(const Geant4SteppingAction& copy) = delete; /// Standard constructor Geant4SteppingActionSequence(Geant4Context* context, const std::string& name); /// Default destructor diff --git a/DDG4/include/DDG4/Geant4TrackingAction.h b/DDG4/include/DDG4/Geant4TrackingAction.h index 2537b33da..c688bb901 100644 --- a/DDG4/include/DDG4/Geant4TrackingAction.h +++ b/DDG4/include/DDG4/Geant4TrackingAction.h @@ -43,6 +43,8 @@ namespace DD4hep { public: typedef Geant4SharedTrackingAction shared_type; public: + /// Inhibit copy constructor + Geant4TrackingAction(const Geant4TrackingAction& copy) = delete; /// Standard constructor Geant4TrackingAction(Geant4Context* context, const std::string& name = ""); /// Default destructor @@ -77,6 +79,8 @@ namespace DD4hep { /// Reference to the shared action Geant4TrackingAction* m_action; public: + /// Inhibit copy constructor + Geant4SharedTrackingAction(const Geant4TrackingAction& copy) = delete; /// Standard constructor Geant4SharedTrackingAction(Geant4Context* context, const std::string& nam); /// Default destructor @@ -119,6 +123,8 @@ namespace DD4hep { /// The list of action objects to be called Actors<Geant4TrackingAction> m_actors; public: + /// Inhibit copy constructor + Geant4TrackingActionSequence(const Geant4TrackingAction& copy) = delete; /// Standard constructor Geant4TrackingActionSequence(Geant4Context* context, const std::string& name); /// Default destructor @@ -163,5 +169,4 @@ namespace DD4hep { } // End namespace Simulation } // End namespace DD4hep - #endif // DD4HEP_DDG4_GEANT4TRACKINGACTION_H diff --git a/DDG4/src/Geant4Primary.cpp b/DDG4/src/Geant4Primary.cpp index c486eba07..64743bbba 100644 --- a/DDG4/src/Geant4Primary.cpp +++ b/DDG4/src/Geant4Primary.cpp @@ -53,24 +53,6 @@ const Geant4Particle* Geant4PrimaryMap::get(const G4PrimaryParticle* particle) c return i != m_primaryMap.end() ? (*i).second : 0; } -/// Default constructor -Geant4PrimaryInteraction::Geant4PrimaryInteraction() - : mask(0), locked(0), next_particle_identifier(-1) -{ -} - -/// Copy constructor -Geant4PrimaryInteraction::Geant4PrimaryInteraction(const Geant4PrimaryInteraction&) - : mask(0), locked(0), next_particle_identifier(-1) -{ -} - -/// Assignment operator -Geant4PrimaryInteraction& Geant4PrimaryInteraction::operator=(const Geant4PrimaryInteraction& c) { - if ( &c == this ) {} - return *this; -} - /// Default destructor Geant4PrimaryInteraction::~Geant4PrimaryInteraction() { releaseObjects(vertices); -- GitLab