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

Constructor & Destructor Documentation

◆ ALIBestUnit() [1/2]

ALIBestUnit::ALIBestUnit ( ALIdouble  internalValue,
ALIstring  category 
)

Definition at line 283 of file ALIUnitsTable.cc.

References validateAlignments::category, DMR_cfg::cerr, gather_cfg::cout, ALIUnitDefinition::GetUnitsTable(), mps_fire::i, IndexOfCategory, nbOfVals, relativeConstraints::value, and Value.

283  {
284  // find the category
286  size_t nbCat = theUnitsTable.size();
287  size_t i = 0;
288  while ((i < nbCat) && (theUnitsTable[i]->GetName() != category))
289  i++;
290  if (i == nbCat) {
291  std::cout << " ALIBestUnit: the category " << category << " does not exist !!" << std::endl;
292  std::cerr << "Missing unit category !" << std::endl;
293  abort();
294  }
295  //
296  IndexOfCategory = i;
297  nbOfVals = 1;
298  Value[0] = value;
299  Value[1] = 0.;
300  Value[2] = 0.;
301 }
std::vector< ALIUnitsCategory * > ALIUnitsTable
Definition: ALIUnitsTable.h:47
ALIint nbOfVals
size_t IndexOfCategory
ALIdouble Value[3]
static ALIUnitsTable & GetUnitsTable()
Definition: ALIUnitsTable.h:75

◆ ALIBestUnit() [2/2]

ALIBestUnit::ALIBestUnit ( const CLHEP::Hep3Vector &  internalValue,
ALIstring  category 
)

Definition at line 305 of file ALIUnitsTable.cc.

References validateAlignments::category, DMR_cfg::cerr, ALIUnitDefinition::GetUnitsTable(), mps_fire::i, IndexOfCategory, nbOfVals, and Value.

305  {
306  // find the category
308  size_t nbCat = theUnitsTable.size();
309  size_t i = 0;
310  while ((i < nbCat) && (theUnitsTable[i]->GetName() != category))
311  i++;
312  if (i == nbCat) {
313  std::cerr << " ALIBestUnit: the category " << category << " does not exist." << std::endl;
314  std::cerr << "Unit category not existing !" << std::endl;
315  abort();
316  }
317  //
318  IndexOfCategory = i;
319  nbOfVals = 3;
320  Value[0] = value.x();
321  Value[1] = value.y();
322  Value[2] = value.z();
323 }
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:75

◆ ~ALIBestUnit()

ALIBestUnit::~ALIBestUnit ( )

Definition at line 326 of file ALIUnitsTable.cc.

326 {}

Member Function Documentation

◆ GetCategory()

ALIstring ALIBestUnit::GetCategory ( ) const
inline

Definition at line 141 of file ALIUnitsTable.h.

References Category.

141 { return Category; }
ALIstring Category

◆ GetIndexOfCategory()

size_t ALIBestUnit::GetIndexOfCategory ( ) const
inline

Definition at line 142 of file ALIUnitsTable.h.

References IndexOfCategory.

142 { return IndexOfCategory; }
size_t IndexOfCategory

◆ GetValue()

ALIdouble* ALIBestUnit::GetValue ( )
inline

Definition at line 140 of file ALIUnitsTable.h.

References Value.

140 { return Value; }
ALIdouble Value[3]

Friends And Related Function Documentation

◆ operator<<

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

Definition at line 330 of file ALIUnitsTable.cc.

330  {
332  ALIUnitsContainer& List = theUnitsTable[a.IndexOfCategory]->GetUnitsList();
333  ALIint len = theUnitsTable[a.IndexOfCategory]->GetSymbMxLen();
334 
335  ALIint ksup(-1), kinf(-1);
336  ALIdouble umax(0.), umin(1.E12);
337  ALIdouble rsup(1.E12), rinf(0.);
338 
339  //for a ThreeVector, choose the best unit for the biggest value
340  ALIdouble value = std::max(std::max(std::abs(a.Value[0]), std::abs(a.Value[1])), std::abs(a.Value[2]));
341 
342  for (size_t k = 0; k < List.size(); k++) {
343  ALIdouble unit = List[k]->GetValue();
344  if (value == 1.E12) {
345  if (unit > umax) {
346  umax = unit;
347  ksup = k;
348  }
349  } else if (value <= -1.E12) {
350  if (unit < umin) {
351  umin = unit;
352  kinf = k;
353  }
354  }
355 
356  else {
357  ALIdouble ratio = value / unit;
358  if ((ratio >= 1.) && (ratio < rsup)) {
359  rsup = ratio;
360  ksup = k;
361  }
362  if ((ratio < 1.) && (ratio > rinf)) {
363  rinf = ratio;
364  kinf = k;
365  }
366  }
367  }
368 
369  ALIint index = ksup;
370  if (index == -1)
371  index = kinf;
372  if (index == -1)
373  index = 0;
374 
375  for (ALIint j = 0; j < a.nbOfVals; j++) {
376  flux << a.Value[j] / (List[index]->GetValue()) << " ";
377  }
378 
379 #ifdef ALIUSE_STD_NAMESPACE
380  std::ios::fmtflags oldform = std::cout.flags();
381 #else
382  // ALIint oldform = std::cout.flags();
383 #endif
384 
385  flux.setf(std::ios::left, std::ios::adjustfield);
386  flux << std::setw(len) << List[index]->GetSymbol();
387  //?? flux.flags(oldform);
388 
389  return flux;
390 }
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
Basic3DVector unit() const
std::vector< std::shared_ptr< ALIUnitDefinition > > ALIUnitsContainer
Definition: ALIUnitsTable.h:92
double a
Definition: hdecay.h:121
static ALIUnitsTable & GetUnitsTable()
Definition: ALIUnitsTable.h:75

Member Data Documentation

◆ Category

ALIstring ALIBestUnit::Category
private

Definition at line 151 of file ALIUnitsTable.h.

Referenced by GetCategory().

◆ IndexOfCategory

size_t ALIBestUnit::IndexOfCategory
private

Definition at line 152 of file ALIUnitsTable.h.

Referenced by ALIBestUnit(), and GetIndexOfCategory().

◆ nbOfVals

ALIint ALIBestUnit::nbOfVals
private

Definition at line 150 of file ALIUnitsTable.h.

Referenced by ALIBestUnit().

◆ Value

ALIdouble ALIBestUnit::Value[3]
private

Definition at line 149 of file ALIUnitsTable.h.

Referenced by ALIBestUnit(), and GetValue().