CMS 3D CMS Logo

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

Go to the source code of this file.

Functions

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

Function Documentation

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

Definition at line 377 of file CocoaUnitsTable.cc.

References ALI_DBL_MAX, ALI_DBL_MIN, CocoaUnitDefinition::GetUnitsTable(), cmsHarvester::index, CocoaBestUnit::IndexOfCategory, j, relval_steps::k, bookConverter::max, CocoaBestUnit::nbOfVals, csvLumiCalc::unit, relativeConstraints::value, and CocoaBestUnit::Value.

378 {
380  CocoaUnitsContainer& List = theUnitsTable[a.IndexOfCategory]
381  ->GetUnitsList();
382  ALIint len = theUnitsTable[a.IndexOfCategory]->GetSymbMxLen();
383 
384  ALIint ksup(-1), kinf(-1);
385  ALIdouble umax(0.), umin(ALI_DBL_MAX);
386  ALIdouble rsup(ALI_DBL_MAX), rinf(0.);
387 
388  //for a ThreeVector, choose the best unit for the biggest value
389  ALIdouble value = std::max(std::max(fabs(a.Value[0]),fabs(a.Value[1])),
390  fabs(a.Value[2]));
391 
392  for (size_t k=0; k<List.size(); k++)
393  {
394  ALIdouble unit = List[k]->GetValue();
395  if (value==ALI_DBL_MAX) {if(unit>umax) {umax=unit; ksup=k;}}
396  else if (value<=ALI_DBL_MIN) {if(unit<umin) {umin=unit; kinf=k;}}
397 
398  else { ALIdouble ratio = value/unit;
399  if ((ratio>=1.)&&(ratio<rsup)) {rsup=ratio; ksup=k;}
400  if ((ratio< 1.)&&(ratio>rinf)) {rinf=ratio; kinf=k;}
401  }
402  }
403 
404  ALIint index=ksup; if(index==-1) index=kinf; if(index==-1) index=0;
405 
406  for (ALIint j=0; j<a.nbOfVals; j++)
407  {flux << a.Value[j]/(List[index]->GetValue()) << " ";}
408 
409  std::ios::fmtflags oldform = flux.flags();
410 
411  flux.setf(std::ios::left,std::ios::adjustfield);
412  flux << std::setw(len) << List[index]->GetSymbol();
413  flux.flags(oldform);
414 
415  return flux;
416 }
std::vector< CocoaUnitDefinition * > CocoaUnitsContainer
long double ALIdouble
Definition: CocoaGlobals.h:11
const double ALI_DBL_MIN
Definition: CocoaGlobals.h:25
static CocoaUnitsTable & GetUnitsTable()
ALIdouble Value[3]
size_t IndexOfCategory
int ALIint
Definition: CocoaGlobals.h:15
string unit
Definition: csvLumiCalc.py:46
int j
Definition: DBlmapReader.cc:9
std::vector< CocoaUnitsCategory * > CocoaUnitsTable
const double ALI_DBL_MAX
Definition: CocoaGlobals.h:24