#include "Alignment/CocoaModel/interface/ALIUnitsTable.h"
#include <CLHEP/Units/SystemOfUnits.h>
#include <iomanip>
Go to the source code of this file.
Functions | |
std::ostream & | operator<< (std::ostream &flux, ALIBestUnit a) |
std::ostream& operator<< | ( | std::ostream & | flux, | |
ALIBestUnit | a | |||
) |
Definition at line 357 of file ALIUnitsTable.cc.
References GenMuonPlsPt100GeV_cfg::cout, ALIUnitDefinition::GetUnitsTable(), index, ALIBestUnit::IndexOfCategory, j, k, len, max, ALIBestUnit::nbOfVals, and ALIBestUnit::Value.
00358 { 00359 ALIUnitsTable& theUnitsTable = ALIUnitDefinition::GetUnitsTable(); 00360 ALIUnitsContainer& List = theUnitsTable[a.IndexOfCategory] 00361 ->GetUnitsList(); 00362 ALIint len = theUnitsTable[a.IndexOfCategory]->GetSymbMxLen(); 00363 00364 ALIint ksup(-1), kinf(-1); 00365 ALIdouble umax(0.), umin(1.E12); 00366 ALIdouble rsup(1.E12), rinf(0.); 00367 00368 //for a ThreeVector, choose the best unit for the biggest value 00369 ALIdouble value = std::max(std::max(fabs(a.Value[0]),fabs(a.Value[1])), 00370 fabs(a.Value[2])); 00371 00372 for (size_t k=0; k<List.size(); k++) 00373 { 00374 ALIdouble unit = List[k]->GetValue(); 00375 if (value==1.E12) {if(unit>umax) {umax=unit; ksup=k;}} 00376 else if (value<=-1.E12) {if(unit<umin) {umin=unit; kinf=k;}} 00377 00378 else { ALIdouble ratio = value/unit; 00379 if ((ratio>=1.)&&(ratio<rsup)) {rsup=ratio; ksup=k;} 00380 if ((ratio< 1.)&&(ratio>rinf)) {rinf=ratio; kinf=k;} 00381 } 00382 } 00383 00384 ALIint index=ksup; if(index==-1) index=kinf; if(index==-1) index=0; 00385 00386 for (ALIint j=0; j<a.nbOfVals; j++) 00387 {flux << a.Value[j]/(List[index]->GetValue()) << " ";} 00388 00389 #ifdef ALIUSE_STD_NAMESPACE 00390 std::ios::fmtflags oldform = std::cout.flags(); 00391 #else 00392 // ALIint oldform = std::cout.flags(); 00393 #endif 00394 00395 flux.setf(std::ios::left,std::ios::adjustfield); 00396 flux << std::setw(len) << List[index]->GetSymbol(); 00397 //?? flux.flags(oldform); 00398 00399 return flux; 00400 }