Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:14:37

0001 #include "DD4hep/DDTest.h"
0002 
0003 #include "DD4hep/Detector.h"
0004 #include "DD4hep/DD4hepUnits.h"
0005 #include "STR.h"
0006 
0007 #include <exception>
0008 #include <iostream>
0009 #include <assert.h>
0010 #include <cmath>
0011 
0012 using namespace std ;
0013 using namespace dd4hep ;
0014 using namespace detail;
0015 using namespace dd4hep ;
0016 
0017 // this should be the first line in your test
0018 static DDTest test( "units" ) ; 
0019 
0020 //=============================================================================
0021 //=============================================================================
0022 
0023 int main(int argc, char** argv ){
0024     
0025   test.log( "test units" );
0026   
0027   if( argc < 2 ) {
0028     std::cout << " usage:  test_units units.xml " << std::endl ;
0029     exit(1) ;
0030   }
0031 
0032   try{
0033     
0034     // ----- write your tests in here -------------------------------------
0035 
0036     Detector& description = Detector::getInstance();
0037 
0038     description.fromCompact( argv[1] );
0039 
0040 
0041     // ======= deg and rad:
0042     double al0_rad = description.constant<double>( "alpha_half_arc_deg" )  / rad ;
0043     double al1_rad = description.constant<double>( "alpha_half_arc_rad" )  / rad ;
0044 
0045     test( STR(al0_rad), STR(al1_rad) , " alpha_half_arc in rad " ) ; 
0046 
0047     double al0_deg = description.constant<double>( "alpha_half_arc_deg" )  / deg ;
0048     double al1_deg = description.constant<double>( "alpha_half_arc_rad" )  / deg ;
0049 
0050     test( STR( al0_deg ) , STR( 180. )  , " alpha_half_arc_deg in deg is 180." ) ; 
0051     test( STR( al1_deg ) , STR( 180. )  , " alpha_half_arc_rad in deg is 180." ) ; 
0052 
0053 
0054     test( STR(al0_deg), STR(al1_deg) , " alpha_half_arc in deg " ) ; 
0055 
0056 
0057     //======== densities =========
0058     double rho1 = description.constant<double>( "rho1" )  / g * cm3 ;
0059     double rho2 = description.constant<double>( "rho2" )  / g * cm3 ;
0060 
0061     test( STR(rho1), STR(rho2) , " densities in [g/cm3]  " ) ; 
0062 
0063     rho1 = description.constant<double>( "rho1" )  / kg * m3 ;
0064     rho2 = description.constant<double>( "rho2" )  / kg * m3 ;
0065     
0066     test( STR(rho1), STR(rho2) , " densities in [kg/cm3]  " ) ; 
0067 
0068 
0069     // --------------------------------------------------------------------
0070 
0071 
0072   } catch( exception &e ){
0073     //} catch( ... ){
0074 
0075     test.log( e.what() );
0076     test.error( "exception occurred" );
0077   }
0078 
0079   return 0;
0080 }
0081 
0082 //=============================================================================