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_MATERIALMANAGER_H
0014 #define DDREC_MATERIALMANAGER_H
0015 
0016 #include "DD4hep/Detector.h"
0017 #include "DD4hep/Objects.h"
0018 #include "DDRec/Vector3D.h"
0019 #include "DDRec/Material.h"
0020 #include "DD4hep/DD4hepUnits.h"
0021 
0022 #include <vector>
0023 
0024 
0025 class TGeoManager ;
0026 
0027 namespace dd4hep {
0028   namespace rec {
0029 
0030     typedef std::vector< std::pair< Material, double > >     MaterialVec;
0031     typedef std::vector< std::pair< PlacedVolume, double > > PlacementVec;
0032     
0033     /** Material manager provides access to the material properties of the detector.
0034      *  Material can be accessed either for a given point or as a list of materials along a straight
0035      *  line between two points.
0036      *
0037      * @author F.Gaede, DESY
0038      * @date May, 19 2014
0039      * @version $Id:$
0040      */
0041     class MaterialManager {
0042 
0043     public:
0044 
0045       /// Instantiate the MaterialManager for this (world) volume
0046       MaterialManager(Volume world);
0047 
0048 #if defined(G__ROOT)
0049       MaterialManager() = default ;
0050 #else
0051       MaterialManager() = delete ;
0052 #endif
0053 
0054       ~MaterialManager();
0055       
0056       /** Get a vector with all the materials between the two points p0 and p1 with the corresponding thicknesses -
0057        *  element type is  std::pair< Material, double >. Materials with a thickness smaller than epsilon (default 1e-4=1mu)
0058        *  are ignored. Avoid calling this method in inner loops as the computation is not cheap. Ideally the result should be cached,
0059        *  for example as an averaged material @see createAveragedMaterial().
0060        */
0061       const MaterialVec& materialsBetween(const Vector3D& p0, const Vector3D& p1 , double epsilon=1e-4 );
0062 
0063       /** Get a vector with all the placements between the two points p0 and p1
0064        */
0065       const PlacementVec& placementsBetween(const Vector3D& p0, const Vector3D& p1 , double epsilon=1e-4 );
0066       
0067       /** Get the material at the given position.
0068        */
0069       const Material& materialAt(const Vector3D& pos );
0070 
0071       /** Get the placed volume at the given position.
0072        */
0073       PlacedVolume placementAt(const Vector3D& pos );
0074 
0075       /** Create a material with averaged properties from all materials in the list. 
0076        *  A and Z are averaged by relative number of atoms(molecules), rho is averaged by relative volume
0077        *  and the inverse radiation and interaction lengths are averaged by relative weight. 
0078        */
0079       MaterialData createAveragedMaterial( const MaterialVec& materials ) ;
0080 
0081     protected :
0082       /// Cached materials
0083       MaterialVec  _mV ;
0084       Material     _m ;
0085       /// Cached nodes
0086       PlacedVolume _pv;
0087       PlacementVec _placeV;
0088       /// cached last points
0089       Vector3D     _p0 , _p1, _pos ;
0090       /// Reference to the TGeoManager
0091       TGeoManager* _tgeoMgr ;
0092     };
0093 
0094     /// dump Material operator 
0095     inline std::ostream& operator<<( std::ostream& os , const Material& m ) {
0096       os << "  " << m.name() << " Z: " << m.Z() << " A: " << m.A() << " density: " << m.density() 
0097          << " radiationLength: "  <<  m.radLength() 
0098          << " interactionLength: " << m.intLength() ;
0099       return os ;
0100     }
0101     
0102     /// dump MaterialVec operator 
0103     inline std::ostream& operator<<( std::ostream& os , const MaterialVec& m ) {
0104       for( unsigned i=0,n=m.size() ; i<n ; ++i ) {
0105         os << "  material: " << m[i].first << " thickness: " << m[i].second << std::endl ; 
0106       }
0107       return os ;
0108     }
0109 
0110   } /* namespace rec */
0111 } /* namespace dd4hep */
0112 
0113 
0114 
0115 #endif // DDREC_MATERIALMANAGER_H