#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) |
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(), getHLTprescales::index, CocoaBestUnit::IndexOfCategory, j, gen::k, max(), CocoaBestUnit::nbOfVals, csvLumiCalc::unit, CocoaBestUnit::Value, and relativeConstraints::value.
{ CocoaUnitsTable& theUnitsTable = CocoaUnitDefinition::GetUnitsTable(); CocoaUnitsContainer& List = theUnitsTable[a.IndexOfCategory] ->GetUnitsList(); ALIint len = theUnitsTable[a.IndexOfCategory]->GetSymbMxLen(); ALIint ksup(-1), kinf(-1); ALIdouble umax(0.), umin(ALI_DBL_MAX); ALIdouble rsup(ALI_DBL_MAX), rinf(0.); //for a ThreeVector, choose the best unit for the biggest value ALIdouble value = std::max(std::max(fabs(a.Value[0]),fabs(a.Value[1])), fabs(a.Value[2])); for (size_t k=0; k<List.size(); k++) { ALIdouble unit = List[k]->GetValue(); if (value==ALI_DBL_MAX) {if(unit>umax) {umax=unit; ksup=k;}} else if (value<=ALI_DBL_MIN) {if(unit<umin) {umin=unit; kinf=k;}} else { ALIdouble ratio = value/unit; if ((ratio>=1.)&&(ratio<rsup)) {rsup=ratio; ksup=k;} if ((ratio< 1.)&&(ratio>rinf)) {rinf=ratio; kinf=k;} } } ALIint index=ksup; if(index==-1) index=kinf; if(index==-1) index=0; for (ALIint j=0; j<a.nbOfVals; j++) {flux << a.Value[j]/(List[index]->GetValue()) << " ";} std::ios::fmtflags oldform = flux.flags(); flux.setf(std::ios::left,std::ios::adjustfield); flux << std::setw(len) << List[index]->GetSymbol(); flux.flags(oldform); return flux; }