diff --git a/DDDigi/io/DigiDDG4Input.cpp b/DDDigi/io/DigiDDG4Input.cpp index 1dda13b5b6bf330571c4b4629e84c17e4aff058b..cdbda2200cd3aefad0b52011752d9e0932a6329f 100644 --- a/DDDigi/io/DigiDDG4Input.cpp +++ b/DDDigi/io/DigiDDG4Input.cpp @@ -17,6 +17,7 @@ #include "DigiIO.h" #include <DDG4/Geant4Data.h> +#include <DDG4/Geant4Particle.h> // ROOT include files #include <TBranch.h> @@ -123,4 +124,6 @@ namespace dd4hep { }; } // End namespace digi } // End namespace dd4hep + +/// Factory instantiation DECLARE_DIGIACTION_NS(dd4hep::digi,DigiDDG4ROOT) diff --git a/DDDigi/io/DigiIO.h b/DDDigi/io/DigiIO.h index ced444b50e4c04f48af0caa5a49a0ff127ca4fa3..028ae62040abfc9fde7195f7314bb96b83cca7d7 100644 --- a/DDDigi/io/DigiIO.h +++ b/DDDigi/io/DigiIO.h @@ -35,19 +35,27 @@ namespace dd4hep { /// Namespace for the Digitization part of the AIDA detector description toolkit namespace digi { + /// Auto cast union to read objects from ROOT files template <typename T> union input_data { + /// Void type const void* m_raw; - std::vector<T*>* m_items; + /// Concrete type + std::vector<T*>* m_data; + + /// Constructor input_data(const void* p) { this->m_raw = p; } - void clear() { if ( this->m_items ) this->m_items->clear(); } - std::size_t size() { return (this->m_items) ? this->m_items->size() : 0UL; } + /// Vector interface: get object std::vector<T*>& get() { - if ( this->m_items ) return *(this->m_items); + if ( this->m_data ) return *(this->m_data); throw std::runtime_error("input_data: Invalid data!"); } + /// Vector interface: clear items + void clear() { if ( this->m_data ) this->m_data->clear(); } + /// Vector interface: access array size + std::size_t size() { return (this->m_data) ? this->m_data->size() : 0UL; } }; - /// Generci I/O helper to input/output digi data + /// Generic I/O helper to input/output digi data /** * * \author M.Frank @@ -135,18 +143,18 @@ namespace dd4hep { * \ingroup DD4HEP_DIGITIZATION */ struct edm4hep_input { - typedef edm4hep::MutableMCParticle particle_type; - struct input_trackerhit_type {}; + typedef edm4hep::MutableMCParticle particle_type; + struct input_trackerhit_type {}; struct input_calorimeterhit_type {}; }; struct digi_input { typedef Particle particle_type; - struct input_trackerhit_type {}; + struct input_trackerhit_type {}; struct input_calorimeterhit_type {}; }; - /// Generci I/O helper to output digi data in edm4hep format + /// Generic I/O helper to output digi data in edm4hep format /** * * \author M.Frank