CMS 3D CMS Logo

Functions
ALIUnitsTable.cc File Reference
#include "Alignment/CocoaModel/interface/ALIUnitsTable.h"
#include "CLHEP/Units/GlobalSystemOfUnits.h"
#include <iomanip>
#include <cstdlib>
#include <cmath>

Go to the source code of this file.

Functions

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

Function Documentation

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

Definition at line 329 of file ALIUnitsTable.cc.

References funct::abs(), gather_cfg::cout, ALIUnitDefinition::GetUnitsTable(), ALIBestUnit::IndexOfCategory, dqmiolumiharvest::j, dqmdumpme::k, SiStripPI::max, ALIBestUnit::nbOfVals, particleFlowDisplacedVertex_cfi::ratio, unit(), and ALIBestUnit::Value.

329  {
331  ALIUnitsContainer& List = theUnitsTable[a.IndexOfCategory]->GetUnitsList();
332  ALIint len = theUnitsTable[a.IndexOfCategory]->GetSymbMxLen();
333 
334  ALIint ksup(-1), kinf(-1);
335  ALIdouble umax(0.), umin(1.E12);
336  ALIdouble rsup(1.E12), rinf(0.);
337 
338  //for a ThreeVector, choose the best unit for the biggest value
340 
341  for (size_t k = 0; k < List.size(); k++) {
342  ALIdouble unit = List[k]->GetValue();
343  if (value == 1.E12) {
344  if (unit > umax) {
345  umax = unit;
346  ksup = k;
347  }
348  } else if (value <= -1.E12) {
349  if (unit < umin) {
350  umin = unit;
351  kinf = k;
352  }
353  }
354 
355  else {
356  ALIdouble ratio = value / unit;
357  if ((ratio >= 1.) && (ratio < rsup)) {
358  rsup = ratio;
359  ksup = k;
360  }
361  if ((ratio < 1.) && (ratio > rinf)) {
362  rinf = ratio;
363  kinf = k;
364  }
365  }
366  }
367 
368  ALIint index = ksup;
369  if (index == -1)
370  index = kinf;
371  if (index == -1)
372  index = 0;
373 
374  for (ALIint j = 0; j < a.nbOfVals; j++) {
375  flux << a.Value[j] / (List[index]->GetValue()) << " ";
376  }
377 
378 #ifdef ALIUSE_STD_NAMESPACE
379  std::ios::fmtflags oldform = std::cout.flags();
380 #else
381  // ALIint oldform = std::cout.flags();
382 #endif
383 
384  flux.setf(std::ios::left, std::ios::adjustfield);
385  flux << std::setw(len) << List[index]->GetSymbol();
386  //?? flux.flags(oldform);
387 
388  return flux;
389 }
long double ALIdouble
Definition: CocoaGlobals.h:11
std::vector< ALIUnitsCategory * > ALIUnitsTable
Definition: ALIUnitsTable.h:47
int ALIint
Definition: CocoaGlobals.h:15
ALIint nbOfVals
size_t IndexOfCategory
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ALIdouble Value[3]
Definition: value.py:1
std::vector< std::shared_ptr< ALIUnitDefinition >> ALIUnitsContainer
Definition: ALIUnitsTable.h:92
static ALIUnitsTable & GetUnitsTable()
Definition: ALIUnitsTable.h:75
Basic3DVector unit() const