CMS 3D CMS Logo

CocoaUnitsTable.cc File Reference

#include "Alignment/CocoaToDDL/interface/CocoaUnitsTable.h"
#include "CLHEP/Units/SystemOfUnits.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(), index, CocoaBestUnit::IndexOfCategory, j, k, len, max, CocoaBestUnit::nbOfVals, CocoaBestUnit::Value, and value.

00378 {
00379   CocoaUnitsTable& theUnitsTable = CocoaUnitDefinition::GetUnitsTable();
00380   CocoaUnitsContainer& List = theUnitsTable[a.IndexOfCategory]
00381                            ->GetUnitsList();
00382   ALIint len = theUnitsTable[a.IndexOfCategory]->GetSymbMxLen();
00383                            
00384   ALIint    ksup(-1), kinf(-1);
00385   ALIdouble umax(0.), umin(ALI_DBL_MAX);
00386   ALIdouble rsup(ALI_DBL_MAX), rinf(0.);
00387 
00388   //for a ThreeVector, choose the best unit for the biggest value 
00389   ALIdouble value = std::max(std::max(fabs(a.Value[0]),fabs(a.Value[1])),
00390                               fabs(a.Value[2]));
00391 
00392   for (size_t k=0; k<List.size(); k++)
00393      {
00394        ALIdouble unit = List[k]->GetValue();
00395             if (value==ALI_DBL_MAX) {if(unit>umax) {umax=unit; ksup=k;}}
00396        else if (value<=ALI_DBL_MIN) {if(unit<umin) {umin=unit; kinf=k;}}
00397        
00398        else { ALIdouble ratio = value/unit;
00399               if ((ratio>=1.)&&(ratio<rsup)) {rsup=ratio; ksup=k;}
00400               if ((ratio< 1.)&&(ratio>rinf)) {rinf=ratio; kinf=k;}
00401             } 
00402      }
00403          
00404   ALIint index=ksup; if(index==-1) index=kinf; if(index==-1) index=0;
00405   
00406   for (ALIint j=0; j<a.nbOfVals; j++) 
00407      {flux << a.Value[j]/(List[index]->GetValue()) << " ";}
00408 
00409   std::ios::fmtflags oldform = flux.flags();
00410 
00411   flux.setf(std::ios::left,std::ios::adjustfield);
00412   flux << std::setw(len) << List[index]->GetSymbol();       
00413   flux.flags(oldform);
00414 
00415   return flux;
00416 }       


Generated on Tue Jun 9 17:50:34 2009 for CMSSW by  doxygen 1.5.4