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

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

Definition at line 226 of file DDCompareTools.cc.

226 : tol_(tol) { }

Member Function Documentation

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

Definition at line 229 of file DDCompareTools.cc.

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

230 {
231  bool ret(true);
232  std::ios_base::fmtflags originalFlags = std::cout.flags();
233  int originalPrecision = std::cout.precision();
234  if( lhs.size() != rhs.size())
235  {
236  ret = false;
237  std::cout << "Size of vectors do not match." << std::endl;
238  }
239  else
240  {
241  for( size_t i = 0; i < lhs.size() ; ++i )
242  {
243  if( std::fabs( lhs[i] - rhs[i] ) > tol_ )
244  {
245  ret = false;
246  std::cout << "Vector content at index " << i << " does not match " ;
247  std::cout << std::setw(12) << std::fixed << std::setprecision(4) << lhs[i] << " != " << rhs[i] << std::endl;
248  break;
249  }
250  }
251  }
252  // Now set everything back to defaults
253  std::cout.flags( originalFlags );
254  std::cout.precision( originalPrecision );
255  return ret;
256 }

Member Data Documentation

double DDCompareDBLVEC::tol_

Definition at line 74 of file DDCompareTools.h.

Referenced by operator()().