CMS 3D CMS Logo

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 138 of file ALIUnitsTable.h.

Constructor & Destructor Documentation

ALIBestUnit::ALIBestUnit ( ALIdouble  internalValue,
ALIstring  category 
)

Definition at line 309 of file ALIUnitsTable.cc.

References MessageLogger_cfi::cerr, gather_cfg::cout, ALIUnitsCategory::GetName(), ALIUnitDefinition::GetUnitsTable(), mps_fire::i, and relativeConstraints::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 }
std::vector< ALIUnitsCategory * > ALIUnitsTable
Definition: ALIUnitsTable.h:47
ALIint nbOfVals
size_t IndexOfCategory
ALIdouble Value[3]
static ALIUnitsTable & GetUnitsTable()
Definition: ALIUnitsTable.h:82
ALIBestUnit::ALIBestUnit ( const CLHEP::Hep3Vector &  internalValue,
ALIstring  category 
)

Definition at line 331 of file ALIUnitsTable.cc.

References MessageLogger_cfi::cerr, ALIUnitsCategory::GetName(), ALIUnitDefinition::GetUnitsTable(), and mps_fire::i.

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 }
std::vector< ALIUnitsCategory * > ALIUnitsTable
Definition: ALIUnitsTable.h:47
ALIint nbOfVals
size_t IndexOfCategory
ALIdouble Value[3]
Definition: value.py:1
static ALIUnitsTable & GetUnitsTable()
Definition: ALIUnitsTable.h:82
ALIBestUnit::~ALIBestUnit ( )

Definition at line 354 of file ALIUnitsTable.cc.

355 {}

Member Function Documentation

ALIstring ALIBestUnit::GetCategory ( ) const
inline

Definition at line 153 of file ALIUnitsTable.h.

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

Definition at line 154 of file ALIUnitsTable.h.

References operator<<().

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

Definition at line 152 of file ALIUnitsTable.h.

References ALIUnitDefinition::Value.

152 {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:47
int ALIint
Definition: CocoaGlobals.h:15
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Definition: value.py:1
int k[5][pyjets_maxn]
std::vector< std::shared_ptr< ALIUnitDefinition >> ALIUnitsContainer
double a
Definition: hdecay.h:121
static ALIUnitsTable & GetUnitsTable()
Definition: ALIUnitsTable.h:82

Member Data Documentation

ALIstring ALIBestUnit::Category
private

Definition at line 166 of file ALIUnitsTable.h.

size_t ALIBestUnit::IndexOfCategory
private

Definition at line 167 of file ALIUnitsTable.h.

Referenced by operator<<().

ALIint ALIBestUnit::nbOfVals
private

Definition at line 165 of file ALIUnitsTable.h.

Referenced by operator<<().

ALIdouble ALIBestUnit::Value[3]
private

Definition at line 164 of file ALIUnitsTable.h.

Referenced by operator<<().