Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:25

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     : F.Gaede
0011 //
0012 //==========================================================================
0013 #ifndef DDREC_DDGEAR_H
0014 #define DDREC_DDGEAR_H
0015 
0016 #include "DD4hep/Detector.h"
0017 #include "DD4hep/DetElement.h"
0018 
0019 #include "gear/GEAR.h"
0020 #include "gearimpl/GearParametersImpl.h"
0021 #include "gearimpl/SimpleMaterialImpl.h"
0022 #include "gear/GearMgr.h"
0023 
0024 namespace gear{
0025   class GearParametersImpl ;
0026   class GearMgr ;
0027 }
0028 
0029 namespace dd4hep {
0030   namespace rec {
0031     
0032   /**
0033      Simple wrapper class for objects of type GearParametersImpl that
0034      can be added to DetElements with the extension mechanism.
0035      There can only be one such object added to any given DetElement 
0036      @author  F.Gaede, DESY
0037      @version $Id$
0038   */
0039 
0040   class GearHandle  { 
0041     
0042   protected:
0043     gear::GearParametersImpl* _gObj ;
0044     std::string _name ;
0045     std::vector< gear::SimpleMaterialImpl > _materials ;
0046     
0047   public :
0048     /** Default c'tor  - only used by dd4hep extenbsion mechanism.*/ 
0049     GearHandle() : _gObj( 0 ) , _name( "UNKNOWN" ) {}
0050     
0051     /** User c'tor - specify a name (should be the canonical name used in gear, eg. TPCParameters, SITParameters, etc.) and
0052     the GearParametersImpl object */
0053     GearHandle( gear::GearParametersImpl* gearObj, const std::string& nam  ) : _gObj( gearObj ) , _name( nam ) {}
0054     
0055     /** D'tor deletes GearParametersImpl object if ownerhsip has not been taken away */
0056     virtual ~GearHandle() { 
0057       if( _gObj) 
0058     delete _gObj ; 
0059     }
0060     
0061     /** Name of GearParametersImpl object - should be the canonical name used in gear, eg. TPCParameters, SITParameters, etc. */
0062     const std::string& name() { return _name ; }
0063     
0064     /** Get GearParametersImpl object */
0065     gear::GearParametersImpl* gearObject() { return _gObj ; } 
0066     
0067     /** Get GearParametersImpl object _and_ transfer ownership */
0068     gear::GearParametersImpl* takeGearObject() { 
0069       gear::GearParametersImpl* obj = _gObj ; 
0070       _gObj = 0 ;
0071       return obj ; 
0072     } 
0073     
0074 
0075     /// add a SimpleMaterial object 
0076     void addMaterial(const std::string nam, double A, double Z, double density, double radLen, double intLen){
0077 
0078       _materials.push_back( gear::SimpleMaterialImpl (nam, A,  Z,  density, radLen,  intLen) ) ;
0079     }
0080 
0081     /// get all materials assigned to this wrapper
0082     const std::vector< gear::SimpleMaterialImpl >& materials() { return _materials ; }
0083 
0084 
0085     /** dummy implementation of required c'tors to allow using the extension mechanism */
0086     GearHandle(const DetElement& /*d*/) : _gObj(0) {}
0087     GearHandle(const GearHandle& /*c*/,const DetElement& /*det*/) : _gObj(0)  {}
0088   } ;
0089   
0090 
0091   //===============================================================================================================
0092 
0093   /** Factory method that creates a GearMgr object pobulated with the GearParametersImpl objects from
0094       all (top level) DetElements in the description object
0095       @author  F.Gaede, DESY
0096       @version $Id$
0097   */
0098   gear::GearMgr* createGearMgr( Detector& description , const std::string& pluginName="GearForILD" ) ;
0099 
0100   }}
0101 
0102 
0103 
0104 #endif