test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes | Friends
ALIBestUnit Class Reference

#include <ALIUnitsTable.h>

Public Member Functions

 ALIBestUnit (ALIdouble internalValue, ALIstring category)
 
 ALIBestUnit (const CLHEP::Hep3Vector &internalValue, ALIstring category)
 
ALIstring GetCategory () const
 
size_t GetIndexOfCategory () const
 
ALIdoubleGetValue ()
 
 ~ALIBestUnit ()
 

Private Attributes

ALIstring Category
 
size_t IndexOfCategory
 
ALIint nbOfVals
 
ALIdouble Value [3]
 

Friends

std::ostream & operator<< (std::ostream &, ALIBestUnit VU)
 

Detailed Description

Definition at line 137 of file ALIUnitsTable.h.

Constructor & Destructor Documentation

ALIBestUnit::ALIBestUnit ( ALIdouble  internalValue,
ALIstring  category 
)

Definition at line 309 of file ALIUnitsTable.cc.

References ecal_dqm_sourceclient-live_cfg::cerr, gather_cfg::cout, ALIUnitDefinition::GetUnitsTable(), i, IndexOfCategory, nbOfVals, relativeConstraints::value, and Value.

310 {
311  // find the category
313  size_t nbCat = theUnitsTable.size();
314  size_t i = 0;
315  while
316  ((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) i++;
317  if (i == nbCat)
318  { std::cout << " ALIBestUnit: the category " << category
319  << " does not exist !!" << std::endl;
320  std::cerr << "Missing unit category !" << std::endl;
321  abort();
322  }
323  //
324  IndexOfCategory = i;
325  nbOfVals = 1;
326  Value[0] = value; Value[1] = 0.; Value[2] = 0.;
327 }
int i
Definition: DBlmapReader.cc:9
std::vector< ALIUnitsCategory * > ALIUnitsTable
Definition: ALIUnitsTable.h:46
ALIint nbOfVals
size_t IndexOfCategory
ALIdouble Value[3]
tuple cout
Definition: gather_cfg.py:145
static ALIUnitsTable & GetUnitsTable()
Definition: ALIUnitsTable.h:81
ALIBestUnit::ALIBestUnit ( const CLHEP::Hep3Vector &  internalValue,
ALIstring  category 
)

Definition at line 331 of file ALIUnitsTable.cc.

References ecal_dqm_sourceclient-live_cfg::cerr, ALIUnitDefinition::GetUnitsTable(), i, IndexOfCategory, nbOfVals, and Value.

332 {
333  // find the category
335  size_t nbCat = theUnitsTable.size();
336  size_t i = 0;
337  while
338  ((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) i++;
339  if (i == nbCat)
340  { std::cerr << " ALIBestUnit: the category " << category
341  << " does not exist." << std::endl;
342  std::cerr << "Unit category not existing !" << std::endl;
343  abort();
344  }
345  //
346  IndexOfCategory = i;
347  nbOfVals = 3;
348  Value[0] = value.x();
349  Value[1] = value.y();
350  Value[2] = value.z();
351 }
int i
Definition: DBlmapReader.cc:9
std::vector< ALIUnitsCategory * > ALIUnitsTable
Definition: ALIUnitsTable.h:46
ALIint nbOfVals
size_t IndexOfCategory
ALIdouble Value[3]
static ALIUnitsTable & GetUnitsTable()
Definition: ALIUnitsTable.h:81
ALIBestUnit::~ALIBestUnit ( )

Definition at line 354 of file ALIUnitsTable.cc.

355 {}

Member Function Documentation

ALIstring ALIBestUnit::GetCategory ( ) const
inline

Definition at line 152 of file ALIUnitsTable.h.

References Category.

152 {return Category;}
ALIstring Category
size_t ALIBestUnit::GetIndexOfCategory ( ) const
inline

Definition at line 153 of file ALIUnitsTable.h.

References IndexOfCategory.

153 {return IndexOfCategory;}
size_t IndexOfCategory
ALIdouble* ALIBestUnit::GetValue ( )
inline

Definition at line 151 of file ALIUnitsTable.h.

References Value.

151 {return Value;}
ALIdouble Value[3]

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  flux,
ALIBestUnit  VU 
)
friend

Definition at line 359 of file ALIUnitsTable.cc.

360 {
362  ALIUnitsContainer& List = theUnitsTable[a.IndexOfCategory]
363  ->GetUnitsList();
364  ALIint len = theUnitsTable[a.IndexOfCategory]->GetSymbMxLen();
365 
366  ALIint ksup(-1), kinf(-1);
367  ALIdouble umax(0.), umin(1.E12);
368  ALIdouble rsup(1.E12), rinf(0.);
369 
370  //for a ThreeVector, choose the best unit for the biggest value
371  ALIdouble value = std::max(std::max(std::abs(a.Value[0]),std::abs(a.Value[1])),
372  std::abs(a.Value[2]));
373 
374  for (size_t k=0; k<List.size(); k++)
375  {
376  ALIdouble unit = List[k]->GetValue();
377  if (value==1.E12) {if(unit>umax) {umax=unit; ksup=k;}}
378  else if (value<=-1.E12) {if(unit<umin) {umin=unit; kinf=k;}}
379 
380  else { ALIdouble ratio = value/unit;
381  if ((ratio>=1.)&&(ratio<rsup)) {rsup=ratio; ksup=k;}
382  if ((ratio< 1.)&&(ratio>rinf)) {rinf=ratio; kinf=k;}
383  }
384  }
385 
386  ALIint index=ksup; if(index==-1) index=kinf; if(index==-1) index=0;
387 
388  for (ALIint j=0; j<a.nbOfVals; j++)
389  {flux << a.Value[j]/(List[index]->GetValue()) << " ";}
390 
391  #ifdef ALIUSE_STD_NAMESPACE
392  std::ios::fmtflags oldform = std::cout.flags();
393  #else
394  // ALIint oldform = std::cout.flags();
395  #endif
396 
397  flux.setf(std::ios::left,std::ios::adjustfield);
398  flux << std::setw(len) << List[index]->GetSymbol();
399  //?? flux.flags(oldform);
400 
401  return flux;
402 }
long double ALIdouble
Definition: CocoaGlobals.h:11
std::vector< ALIUnitsCategory * > ALIUnitsTable
Definition: ALIUnitsTable.h:46
std::vector< ALIUnitDefinition * > ALIUnitsContainer
int ALIint
Definition: CocoaGlobals.h:15
string unit
Definition: csvLumiCalc.py:46
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
double a
Definition: hdecay.h:121
tuple cout
Definition: gather_cfg.py:145
static ALIUnitsTable & GetUnitsTable()
Definition: ALIUnitsTable.h:81

Member Data Documentation

ALIstring ALIBestUnit::Category
private

Definition at line 165 of file ALIUnitsTable.h.

Referenced by GetCategory().

size_t ALIBestUnit::IndexOfCategory
private

Definition at line 166 of file ALIUnitsTable.h.

Referenced by ALIBestUnit(), GetIndexOfCategory(), and operator<<().

ALIint ALIBestUnit::nbOfVals
private

Definition at line 164 of file ALIUnitsTable.h.

Referenced by ALIBestUnit(), and operator<<().

ALIdouble ALIBestUnit::Value[3]
private

Definition at line 163 of file ALIUnitsTable.h.

Referenced by ALIBestUnit(), GetValue(), and operator<<().