Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:14:06

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 DDDIGI_DIGIIO_H
0014 #define DDDIGI_DIGIIO_H
0015 
0016 // Framework include files
0017 #include <DD4hep/Printout.h>
0018 #include <DD4hep/DD4hepUnits.h>
0019 #include <DDDigi/DigiData.h>
0020 
0021 // C/C++ include files
0022 #include <any>
0023 #include <array>
0024 #include <stdexcept>
0025 
0026 /// Namespace for the AIDA detector description toolkit
0027 namespace dd4hep {
0028 
0029   /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit
0030   namespace sim {
0031     // Forward declarations
0032     class Geant4Particle;
0033   }
0034 
0035   /// Namespace for the Digitization part of the AIDA detector description toolkit
0036   namespace digi {
0037 
0038     /// Auto cast union to read objects from ROOT files
0039     template <typename T> union input_data  {
0040       /// Void type
0041       const void*      m_raw;
0042       /// Concrete type
0043       std::vector<T*>* m_data;
0044 
0045       /// Constructor
0046       input_data(const void* p)   { this->m_raw = p; }
0047       /// Vector interface: get object
0048       std::vector<T*>& get()    { 
0049         if ( this->m_data ) return *(this->m_data);
0050         throw std::runtime_error("input_data: Invalid data!");
0051       }
0052       /// Vector interface: clear items
0053       void clear()         { if ( this->m_data ) this->m_data->clear(); }
0054       /// Vector interface: access array size
0055       std::size_t size()   { return (this->m_data) ? this->m_data->size() : 0UL; }
0056     };
0057 
0058     /// Generic I/O helper to input/output digi data
0059     /**
0060      *
0061      *  \author  M.Frank
0062      *  \version 1.0
0063      *  \ingroup DD4HEP_DIGITIZATION
0064      */
0065     template <typename T> struct data_io   {
0066     public:
0067       /// Default constructor
0068       data_io() = default;
0069       /// Default destructor
0070       ~data_io() = default;
0071 
0072       template <typename FIRST, typename SECOND> static
0073       void _to_edm4hep(const FIRST& first, SECOND second);
0074 
0075       template <typename FIRST, typename SECOND> static
0076       void _to_edm4hep(const FIRST& first, SECOND& second, int hit_type);
0077 
0078       template <typename FIRST, typename SECOND, typename THIRD> static
0079       void _to_edm4hep(const FIRST& first, const SECOND& second, THIRD& third, int hit_type);
0080 
0081       template <typename FIRST, typename SECOND, typename THIRD> static
0082       void _to_digi(FIRST first, const SECOND& second, THIRD& third);
0083 
0084       template <typename FIRST, typename SECOND, typename PREDICATE> static
0085       void _to_digi_if(const FIRST& first, SECOND& second, const PREDICATE& pred);
0086     };
0087 
0088     /// Structure definitions for template specializations
0089     struct ddg4_input;
0090     struct digi_input;
0091     struct edm4hep_input;
0092   }    // End namespace digi
0093 }      // End namespace dd4hep
0094 #endif // DDDIGI_DIGIIO_H