HepMC Reference Documentation

HepMC

testUnits.cc

Test MomentumUnits and PositionUnits Make sure set and change methods work as expected.

00001 //
00002 // Test Units
00003 //
00004 #include <iostream>
00005 
00006 #include "HepMC/Units.h"
00007 
00008 int main()
00009 {
00010   
00011   int err = 0;
00012   double cf;
00013 
00014   std::cout << "Default units: " << HepMC::Units::name(HepMC::Units::default_momentum_unit())
00015      << " " << HepMC::Units::name(HepMC::Units::default_length_unit()) << std::endl;
00016 
00017   // check momentum conversion factors
00018   cf = conversion_factor( HepMC::Units::GEV, HepMC::Units::GEV );
00019   if( cf != 1 ) {
00020       ++err;
00021       std::cerr << "wrong conversion factor " << cf 
00022                 << " for GEV to GEV - should be 1 \n";
00023   }
00024   cf = conversion_factor( HepMC::Units::MEV, HepMC::Units::MEV );
00025   if( cf != 1 ) {
00026       ++err;
00027       std::cerr << "wrong conversion factor " << cf
00028                 << " for MEV to MEV - should be 1 \n";
00029   }
00030   cf = conversion_factor( HepMC::Units::MEV, HepMC::Units::GEV );
00031   if( cf != 0.001 ) {
00032       ++err;
00033       std::cerr << "wrong conversion factor " << cf
00034                 << " for MEV to GEV - should be 0.001 \n";
00035   }
00036   cf = conversion_factor( HepMC::Units::GEV, HepMC::Units::MEV );
00037   if( cf != 1000.0 ) {
00038       ++err;
00039       std::cerr << "wrong conversion factor " << cf
00040                 << " for GEV to MEV - should be 1000 \n";
00041   }
00042 
00043   // check length conversion factors
00044   cf = conversion_factor( HepMC::Units::MM, HepMC::Units::MM );
00045   if( cf != 1 ) {
00046       ++err;
00047       std::cerr << "wrong conversion factor " << cf
00048                 << " for MM to MM - should be 1 \n";
00049   }
00050   cf = conversion_factor( HepMC::Units::CM, HepMC::Units::CM );
00051   if( cf != 1 ) {
00052       ++err;
00053       std::cerr << "wrong conversion factor " << cf
00054                 << " for CM to CM - should be 1 \n";
00055   }
00056   cf = conversion_factor( HepMC::Units::CM, HepMC::Units::MM );
00057   if( cf != 10.0 ) {
00058       ++err;
00059       std::cerr << "wrong conversion factor " << cf
00060                 << " for CM to MM - should be 10 \n";
00061   }
00062   cf = conversion_factor( HepMC::Units::MM, HepMC::Units::CM );
00063   if( cf != 0.1 ) {
00064       ++err;
00065       std::cerr << "wrong conversion factor " << cf
00066                 << " for MM to CM - should be 0.1 \n";
00067   }
00068 
00069   return err;
00070 }

Generated on Thu Jan 7 13:10:15 2010 for HepMC by  doxygen 1.4.7