test
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>
#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 359 of file ALIUnitsTable.cc.

References funct::abs(), gather_cfg::cout, ALIUnitDefinition::GetUnitsTable(), cmsHarvester::index, ALIBestUnit::IndexOfCategory, j, relval_2017::k, bookConverter::max, ALIBestUnit::nbOfVals, csvLumiCalc::unit, relativeConstraints::value, and ALIBestUnit::Value.

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