当前位置: 首页>>代码示例>>C++>>正文


C++ MaterialManager::materialsBetween方法代码示例

本文整理汇总了C++中MaterialManager::materialsBetween方法的典型用法代码示例。如果您正苦于以下问题:C++ MaterialManager::materialsBetween方法的具体用法?C++ MaterialManager::materialsBetween怎么用?C++ MaterialManager::materialsBetween使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MaterialManager的用法示例。


在下文中一共展示了MaterialManager::materialsBetween方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char** argv ){
    
  if( argc != 8 ) {
    std::cout << " usage: print_materials compact.xml x0 y0 z0 x1 y1 z1 " << std::endl 
              << "        -> prints the materials on a straight line between the two given points ( unit is cm) "  
              << std::endl ;
    exit(1) ;
  }
  
  std::string inFile =  argv[1] ;

  std::stringstream sstr ;
  sstr << argv[2] << " " << argv[3] << " " << argv[4] << " " << argv[5] << " " << argv[6] << " " << argv[7] ;

  double x0,y0,z0,x1,y1,z1 ;
  sstr >> x0 ;
  sstr >> y0 ;
  sstr >> z0 ;
  sstr >> x1 ;
  sstr >> y1 ;
  sstr >> z1 ;

  LCDD& lcdd = LCDD::getInstance();

  lcdd.fromCompact( inFile );

  Vector3D p0( x0, y0, z0 ) ;
  Vector3D p1( x1, y1, z1 ) ;

  MaterialManager matMgr ;

  const 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){

    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 ;
  }

  std::cout << "############################################################################### "  << std::endl  << std::endl  ;
	

  const 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 << std::endl  ;
  

  std::cout << "     Total length : "  << path_length / dd4hep::mm << " mm "  << std::endl  ;

  std::cout << "     Integrated radiation lengths : "     << path_length / avMat.radiationLength()  << " X0 " << std::endl  ;

  std::cout << "     Integrated interaction lengths : "  << path_length / avMat.interactionLength() << " lambda "   << std::endl  ;

  std::cout << "############################################################################### "  << std::endl  << std::endl  ;


  return 0;
}
开发者ID:vvolkl,项目名称:DD4hep,代码行数:75,代码来源:print_materials.cpp


注:本文中的MaterialManager::materialsBetween方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。