CMS 3D CMS Logo

Functions

/data/refman/pasoursint/CMSSW_5_3_0/src/Alignment/CocoaModel/src/ALIUnitsTable.cc File Reference

#include "Alignment/CocoaModel/interface/ALIUnitsTable.h"
#include "CLHEP/Units/GlobalSystemOfUnits.h"
#include <iomanip>
#include <cstdlib>

Go to the source code of this file.

Functions

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

Function Documentation

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

Definition at line 358 of file ALIUnitsTable.cc.

References gather_cfg::cout, ALIUnitDefinition::GetUnitsTable(), getHLTprescales::index, ALIBestUnit::IndexOfCategory, j, gen::k, max(), ALIBestUnit::nbOfVals, csvLumiCalc::unit, ALIBestUnit::Value, and relativeConstraints::value.

{
  ALIUnitsTable& theUnitsTable = ALIUnitDefinition::GetUnitsTable();
  ALIUnitsContainer& List = theUnitsTable[a.IndexOfCategory]
                           ->GetUnitsList();
  ALIint len = theUnitsTable[a.IndexOfCategory]->GetSymbMxLen();
                           
  ALIint    ksup(-1), kinf(-1);
  ALIdouble umax(0.), umin(1.E12);
  ALIdouble rsup(1.E12), 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==1.E12) {if(unit>umax) {umax=unit; ksup=k;}}
       else if (value<=-1.E12) {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()) << " ";}

  #ifdef ALIUSE_STD_NAMESPACE
    std::ios::fmtflags oldform = std::cout.flags();
  #else
    //    ALIint oldform = std::cout.flags();
  #endif

  flux.setf(std::ios::left,std::ios::adjustfield);
  flux << std::setw(len) << List[index]->GetSymbol();       
  //??  flux.flags(oldform);

  return flux;
}