CMS 3D CMS Logo

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

◆ operator<<()

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

Definition at line 342 of file CocoaUnitsTable.cc.

References a, funct::abs(), ALI_DBL_MAX, ALI_DBL_MIN, CocoaUnitDefinition::GetUnitsTable(), dqmiolumiharvest::j, dqmdumpme::k, SiStripPI::max, particleFlowDisplacedVertex_cfi::ratio, and unit().

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
352  ALIdouble value = std::max(std::max(std::abs(a.Value[0]), std::abs(a.Value[1])), std::abs(a.Value[2]));
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 {
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()
int ALIint
Definition: CocoaGlobals.h:15
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< CocoaUnitsCategory * > CocoaUnitsTable
Definition: value.py:1
Basic3DVector unit() const
double a
Definition: hdecay.h:119
const double ALI_DBL_MAX
Definition: CocoaGlobals.h:24