CMS 3D CMS Logo

Functions
CocoaUnitsTable.cc File Reference
#include "Alignment/CocoaToDDL/interface/CocoaUnitsTable.h"
#include "CLHEP/Units/GlobalSystemOfUnits.h"
#include <iomanip>
#include <cmath>

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 funct::abs(), ALI_DBL_MAX, ALI_DBL_MIN, CocoaUnitDefinition::GetUnitsTable(), diffTreeTool::index, CocoaBestUnit::IndexOfCategory, gen::k, SiStripPI::max, CocoaBestUnit::nbOfVals, particleFlowDisplacedVertex_cfi::ratio, csvLumiCalc::unit, 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
390  std::abs(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
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< CocoaUnitsCategory * > CocoaUnitsTable
Definition: value.py:1
int k[5][pyjets_maxn]
const double ALI_DBL_MAX
Definition: CocoaGlobals.h:24