CMS 3D CMS Logo

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

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 358 of file ALIUnitsTable.cc.

References gather_cfg::cout, ALIUnitDefinition::GetUnitsTable(), getHLTprescales::index, ALIBestUnit::IndexOfCategory, j, gen::k, max(), ALIBestUnit::nbOfVals, csvLumiCalc::unit, relativeConstraints::value, and ALIBestUnit::Value.

359 {
361  ALIUnitsContainer& List = theUnitsTable[a.IndexOfCategory]
362  ->GetUnitsList();
363  ALIint len = theUnitsTable[a.IndexOfCategory]->GetSymbMxLen();
364 
365  ALIint ksup(-1), kinf(-1);
366  ALIdouble umax(0.), umin(1.E12);
367  ALIdouble rsup(1.E12), rinf(0.);
368 
369  //for a ThreeVector, choose the best unit for the biggest value
370  ALIdouble value = std::max(std::max(fabs(a.Value[0]),fabs(a.Value[1])),
371  fabs(a.Value[2]));
372 
373  for (size_t k=0; k<List.size(); k++)
374  {
375  ALIdouble unit = List[k]->GetValue();
376  if (value==1.E12) {if(unit>umax) {umax=unit; ksup=k;}}
377  else if (value<=-1.E12) {if(unit<umin) {umin=unit; kinf=k;}}
378 
379  else { ALIdouble ratio = value/unit;
380  if ((ratio>=1.)&&(ratio<rsup)) {rsup=ratio; ksup=k;}
381  if ((ratio< 1.)&&(ratio>rinf)) {rinf=ratio; kinf=k;}
382  }
383  }
384 
385  ALIint index=ksup; if(index==-1) index=kinf; if(index==-1) index=0;
386 
387  for (ALIint j=0; j<a.nbOfVals; j++)
388  {flux << a.Value[j]/(List[index]->GetValue()) << " ";}
389 
390  #ifdef ALIUSE_STD_NAMESPACE
391  std::ios::fmtflags oldform = std::cout.flags();
392  #else
393  // ALIint oldform = std::cout.flags();
394  #endif
395 
396  flux.setf(std::ios::left,std::ios::adjustfield);
397  flux << std::setw(len) << List[index]->GetSymbol();
398  //?? flux.flags(oldform);
399 
400  return flux;
401 }
long double ALIdouble
Definition: CocoaGlobals.h:11
std::vector< ALIUnitsCategory * > ALIUnitsTable
Definition: ALIUnitsTable.h:46
std::vector< ALIUnitDefinition * > ALIUnitsContainer
int ALIint
Definition: CocoaGlobals.h:15
ALIint nbOfVals
const T & max(const T &a, const T &b)
string unit
Definition: csvLumiCalc.py:46
size_t IndexOfCategory
int j
Definition: DBlmapReader.cc:9
ALIdouble Value[3]
int k[5][pyjets_maxn]
tuple cout
Definition: gather_cfg.py:121
static ALIUnitsTable & GetUnitsTable()
Definition: ALIUnitsTable.h:81