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 308 of file ALIUnitsTable.cc.

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

309 {
310  // find the category
312  size_t nbCat = theUnitsTable.size();
313  size_t i = 0;
314  while
315  ((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) i++;
316  if (i == nbCat)
317  { std::cout << " ALIBestUnit: the category " << category
318  << " does not exist !!" << std::endl;
319  std::cerr << "Missing unit category !" << std::endl;
320  abort();
321  }
322  //
323  IndexOfCategory = i;
324  nbOfVals = 1;
325  Value[0] = value; Value[1] = 0.; Value[2] = 0.;
326 }
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 330 of file ALIUnitsTable.cc.

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

331 {
332  // find the category
334  size_t nbCat = theUnitsTable.size();
335  size_t i = 0;
336  while
337  ((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) i++;
338  if (i == nbCat)
339  { std::cerr << " ALIBestUnit: the category " << category
340  << " does not exist." << std::endl;
341  std::cerr << "Unit category not existing !" << std::endl;
342  abort();
343  }
344  //
345  IndexOfCategory = i;
346  nbOfVals = 3;
347  Value[0] = value.x();
348  Value[1] = value.y();
349  Value[2] = value.z();
350 }
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 353 of file ALIUnitsTable.cc.

354 {}

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 358 of file ALIUnitsTable.cc.

359 {
361  ALIUnitsContainer& List = theUnitsTable[a.IndexOfCategory]
362  ->GetUnitsList();
363  ALIint len = theUnitsTable[a.IndexOfCategory]->GetSymbMxLen();
364 
365  ALIint ksup(-1), kinf(-1);
366  ALIdouble umax(0.), umin(1.E12);
367  ALIdouble rsup(1.E12), rinf(0.);
368 
369  //for a ThreeVector, choose the best unit for the biggest value
370  ALIdouble value = std::max(std::max(fabs(a.Value[0]),fabs(a.Value[1])),
371  fabs(a.Value[2]));
372 
373  for (size_t k=0; k<List.size(); k++)
374  {
375  ALIdouble unit = List[k]->GetValue();
376  if (value==1.E12) {if(unit>umax) {umax=unit; ksup=k;}}
377  else if (value<=-1.E12) {if(unit<umin) {umin=unit; kinf=k;}}
378 
379  else { ALIdouble ratio = value/unit;
380  if ((ratio>=1.)&&(ratio<rsup)) {rsup=ratio; ksup=k;}
381  if ((ratio< 1.)&&(ratio>rinf)) {rinf=ratio; kinf=k;}
382  }
383  }
384 
385  ALIint index=ksup; if(index==-1) index=kinf; if(index==-1) index=0;
386 
387  for (ALIint j=0; j<a.nbOfVals; j++)
388  {flux << a.Value[j]/(List[index]->GetValue()) << " ";}
389 
390  #ifdef ALIUSE_STD_NAMESPACE
391  std::ios::fmtflags oldform = std::cout.flags();
392  #else
393  // ALIint oldform = std::cout.flags();
394  #endif
395 
396  flux.setf(std::ios::left,std::ios::adjustfield);
397  flux << std::setw(len) << List[index]->GetSymbol();
398  //?? flux.flags(oldform);
399 
400  return flux;
401 }
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
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<<().