CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
DDCompareDBLVEC Struct Reference

#include <DDCompareTools.h>

Inheritance diagram for DDCompareDBLVEC:

Public Member Functions

 DDCompareDBLVEC ()
 
 DDCompareDBLVEC (double tol)
 
bool operator() (const std::vector< double > &lhs, const std::vector< double > &rhs) const
 

Public Attributes

double tol_
 

Detailed Description

Definition at line 70 of file DDCompareTools.h.

Constructor & Destructor Documentation

DDCompareDBLVEC::DDCompareDBLVEC ( )

Definition at line 291 of file DDCompareTools.cc.

291 : tol_(0.0004) { }
DDCompareDBLVEC::DDCompareDBLVEC ( double  tol)

Definition at line 293 of file DDCompareTools.cc.

293 : tol_(tol) { }

Member Function Documentation

bool DDCompareDBLVEC::operator() ( const std::vector< double > &  lhs,
const std::vector< double > &  rhs 
) const

Definition at line 296 of file DDCompareTools.cc.

References gather_cfg::cout, alignBH_cfg::fixed, mps_fire::i, and tol_.

297 {
298  bool ret(true);
299  std::ios_base::fmtflags originalFlags = std::cout.flags();
300  int originalPrecision = std::cout.precision();
301  if( lhs.size() != rhs.size())
302  {
303  ret = false;
304  std::cout << "Size of vectors do not match." << std::endl;
305  }
306  else
307  {
308  for( size_t i = 0; i < lhs.size() ; ++i )
309  {
310  if( std::fabs( lhs[i] - rhs[i] ) > tol_ )
311  {
312  ret = false;
313  std::cout << "Vector content at index " << i << " does not match " ;
314  std::cout << std::setw(12) << std::fixed << std::setprecision(4) << lhs[i] << " != " << rhs[i] << std::endl;
315  break;
316  }
317  }
318  }
319  // Now set everything back to defaults
320  std::cout.flags( originalFlags );
321  std::cout.precision( originalPrecision );
322  return ret;
323 }

Member Data Documentation

double DDCompareDBLVEC::tol_

Definition at line 74 of file DDCompareTools.h.

Referenced by operator()().