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

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

282  {
283  // find the category
285  size_t nbCat = theUnitsTable.size();
286  size_t i = 0;
287  while ((i < nbCat) && (theUnitsTable[i]->GetName() != category))
288  i++;
289  if (i == nbCat) {
290  std::cout << " ALIBestUnit: the category " << category << " does not exist !!" << std::endl;
291  std::cerr << "Missing unit category !" << std::endl;
292  abort();
293  }
294  //
295  IndexOfCategory = i;
296  nbOfVals = 1;
297  Value[0] = value;
298  Value[1] = 0.;
299  Value[2] = 0.;
300 }
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 304 of file ALIUnitsTable.cc.

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

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

325 {}

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

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