CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions
CocoaUnitsTable.cc File Reference
#include "Alignment/CocoaToDDL/interface/CocoaUnitsTable.h"
#include "CLHEP/Units/GlobalSystemOfUnits.h"
#include <iomanip>
#include <cmath>

Go to the source code of this file.

Functions

std::ostream & operator<< (std::ostream &flux, CocoaBestUnit a)
 

Function Documentation

std::ostream& operator<< ( std::ostream &  flux,
CocoaBestUnit  a 
)

Definition at line 342 of file CocoaUnitsTable.cc.

References funct::abs(), ALI_DBL_MAX, ALI_DBL_MIN, CocoaUnitDefinition::GetUnitsTable(), CocoaBestUnit::IndexOfCategory, dqmiolumiharvest::j, isotrackApplyRegressor::k, SiStripPI::max, CocoaBestUnit::nbOfVals, unit(), relativeConstraints::value, and CocoaBestUnit::Value.

342  {
344  CocoaUnitsContainer& List = theUnitsTable[a.IndexOfCategory]->GetUnitsList();
345  ALIint len = theUnitsTable[a.IndexOfCategory]->GetSymbMxLen();
346 
347  ALIint ksup(-1), kinf(-1);
348  ALIdouble umax(0.), umin(ALI_DBL_MAX);
349  ALIdouble rsup(ALI_DBL_MAX), rinf(0.);
350 
351  //for a ThreeVector, choose the best unit for the biggest value
353 
354  for (size_t k = 0; k < List.size(); k++) {
355  ALIdouble unit = List[k]->GetValue();
356  if (value == ALI_DBL_MAX) {
357  if (unit > umax) {
358  umax = unit;
359  ksup = k;
360  }
361  } else if (value <= ALI_DBL_MIN) {
362  if (unit < umin) {
363  umin = unit;
364  kinf = k;
365  }
366  }
367 
368  else {
369  ALIdouble ratio = value / unit;
370  if ((ratio >= 1.) && (ratio < rsup)) {
371  rsup = ratio;
372  ksup = k;
373  }
374  if ((ratio < 1.) && (ratio > rinf)) {
375  rinf = ratio;
376  kinf = k;
377  }
378  }
379  }
380 
381  ALIint index = ksup;
382  if (index == -1)
383  index = kinf;
384  if (index == -1)
385  index = 0;
386 
387  for (ALIint j = 0; j < a.nbOfVals; j++) {
388  flux << a.Value[j] / (List[index]->GetValue()) << " ";
389  }
390 
391  std::ios::fmtflags oldform = flux.flags();
392 
393  flux.setf(std::ios::left, std::ios::adjustfield);
394  flux << std::setw(len) << List[index]->GetSymbol();
395  flux.flags(oldform);
396 
397  return flux;
398 }
std::vector< CocoaUnitDefinition * > CocoaUnitsContainer
long double ALIdouble
Definition: CocoaGlobals.h:11
const double ALI_DBL_MIN
Definition: CocoaGlobals.h:25
static CocoaUnitsTable & GetUnitsTable()
ALIdouble Value[3]
size_t IndexOfCategory
int ALIint
Definition: CocoaGlobals.h:15
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< CocoaUnitsCategory * > CocoaUnitsTable
const double ALI_DBL_MAX
Definition: CocoaGlobals.h:24
Basic3DVector unit() const