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 292 of file DDCompareTools.cc.

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

Definition at line 294 of file DDCompareTools.cc.

294 : tol_(tol) { }

Member Function Documentation

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

Definition at line 297 of file DDCompareTools.cc.

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

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

Member Data Documentation

double DDCompareDBLVEC::tol_

Definition at line 74 of file DDCompareTools.h.

Referenced by operator()().