Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:17:26

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 
0014 // Framework include files
0015 #include <DDG4/Geant4Data.h>
0016 
0017 using namespace dd4hep::sim;
0018 
0019 /// Namespace for the AIDA detector description toolkit
0020 namespace dd4hep {
0021 
0022   /// Namespace for the dd4hep event display specializations
0023   namespace DDEve  {
0024 
0025     /// SimulationHit definition
0026     /**
0027      *  \author  M.Frank
0028      *  \version 1.0
0029      *  \ingroup DD4HEP_SIMULATION
0030      *  \ingroup DD4HEP_EVE
0031      */
0032     class SimulationHit   {
0033     public:
0034       Position position;
0035       float deposit;
0036       /// Default constructor
0037       SimulationHit() : deposit(0.0) {}
0038       /// Standard initializing constructor
0039       SimulationHit(const Position& p, float d) : position(p), deposit(d) {}
0040       /// Copy constructor
0041       SimulationHit(const SimulationHit& c) : position(c.position), deposit(c.deposit) {}
0042       /// Standard Destructor
0043       ~SimulationHit()  {}
0044       /// Assignment operator
0045       SimulationHit& operator=(const SimulationHit& c)  {
0046         if ( this != &c )  {
0047           position = c.position;
0048           deposit = c.deposit;
0049         }
0050         return *this;
0051       }
0052     };
0053   }
0054 }
0055 
0056 /// Hit conversion function  \ingroup DD4HEP_EVE
0057 static void* _convertHitCollection(const char* source)  {
0058   typedef dd4hep::DDEve::SimulationHit SimulationHit;
0059   const std::vector<SimpleHit*>* c = (std::vector<SimpleHit*>*)source;
0060   std::vector<SimulationHit>* pv = new std::vector<SimulationHit>();
0061   if ( source && c->size() > 0 )   {
0062     for(std::vector<SimpleHit*>::const_iterator k=c->begin(); k!=c->end(); ++k)   {
0063       SimpleTracker::Hit* trh = dynamic_cast<SimpleTracker::Hit*>(*k);
0064       if ( trh )   {
0065         pv->emplace_back(SimulationHit(trh->position, trh->energyDeposit));
0066         continue;
0067       }
0068       SimpleCalorimeter::Hit* cah = dynamic_cast<SimpleCalorimeter::Hit*>(*k);
0069       if ( cah )   {
0070         pv->emplace_back(SimulationHit(cah->position, cah->energyDeposit));
0071         continue;
0072       }
0073     }
0074   }
0075   return pv;
0076 }
0077 
0078 #include <DD4hep/Factories.h>
0079 using namespace dd4hep::detail;
0080 DECLARE_CONSTRUCTOR(DDEve_DDG4CollectionAccess,_convertHitCollection)