3 Materials

The surfaces classes described above provide a way that allows to augment a detector geometry description with a high level view on the detector that should be sufficient for most reconstruction tasks, such as pattern recognition, track fitting and calorimeter reconstruction as in a particle flow algorithm. However they require that care has been taken to assign all relevant surfaces with corresponding thicknesses to the volumes and detector elements. For cases where this is not possible or where other reconstruction geometries should be instantiated, DDRec provides the possibility to access the materials at any given point in the world volume of the detector or to retrieve a list of materials along a straight line between any two points.

This is done with the class MaterialManager, which also allows to create an averaged material for a list of materials (MaterialVector). The usage of this class is simple and best demonstrated with an example:

 
  DD4hep::Geometry::LCDD& lcdd = DD4hep::Geometry::LCDD::getInstance();  
 
  lcdd.fromCompact( inFile );  
 
  DDSurfaces::Vector3D p0( x0, y0, z0 ) ;  
  DDSurfaces::Vector3D p1( x1, y1, z1 ) ;  
 
  DD4hep::DDRec::MaterialManager matMgr ;  
 
  const DD4hep::DDRec::MaterialVec& materials = matMgr.materialsBetween( p0 , p1  ) ;  
 
  std::cout  << std::endl  
             << " #######  materials between the two  points : "  
             << p0 << "*cm  and " << p1 << "*cm :  "  
             << std::endl ;  
 
  double sum_x0 = 0 ;  
  double sum_lambda = 0 ;  
  double path_length = 0 ;  
  for( unsigned i=0,n=materials.size();i<n;++i){  
 
    DD4hep::DDRec::Material mat =  materials[i].first  ;  
    double length = materials[i].second  ;  
 
    double nx0 = length / mat.radLength()  ;  
    sum_x0 += nx0 ;  
 
    double nLambda = length / mat.intLength()  ;  
    sum_lambda += nLambda ;  
 
    path_length += length ;  
 
    std::cout << "      "               << mat  
              << " thickness: "         << length  
              << " path_length:"        << path_length  
              << " integrated_X0: "     << sum_x0  
              << " integrated_lambda: " << sum_lambda  
              <<  std::endl ;  
  }  

Creation of an averaged material:

  // ...  
  const DD4hep::DDRec::MaterialVec& materials = matMgr.materialsBetween( p0 , p1  ) ;  
 
  const DD4hep::DDRec::MaterialData& avMat = matMgr.createAveragedMaterial( materials ) ;  
 
  std::cout << " averaged Material : " << " Z: " << avMat.Z() << " A: " << avMat.A()  
            << " densitiy: "           << avMat.density()  
            << " radiationLength: "    << avMat.radiationLength()  
            << " interactionLength: "  << avMat.interactionLength()  
            << std::endl ;

There is a utility program print_materials that can be used to debug detector geometries:

 $ print_materials  
 usage: print_materials compact.xml x0 y0 z0 x1 y1 z1  
        -> prints the materials on a straight line between the two given points ( unit is cm)

Note: accessing the materials using the MaterialManager is a rather costly operation and should only be done at the initialization phase of a reconstruction program for caching material properties !