CMS 3D CMS Logo

Functions
ALIUnitsTable.cc File Reference
#include "Alignment/CocoaModel/interface/ALIUnitsTable.h"
#include <CLHEP/Units/SystemOfUnits.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

◆ operator<<()

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

Definition at line 330 of file ALIUnitsTable.cc.

References a, funct::abs(), gather_cfg::cout, ALIUnitDefinition::GetUnitsTable(), dqmiolumiharvest::j, dqmdumpme::k, SiStripPI::max, and unit().

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