CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes | Friends
CocoaBestUnit Class Reference

#include <CocoaUnitsTable.h>

Public Member Functions

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

Private Attributes

ALIstring Category
 
size_t IndexOfCategory
 
ALIint nbOfVals
 
ALIdouble Value [3]
 

Friends

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

Detailed Description

Definition at line 94 of file CocoaUnitsTable.h.

Constructor & Destructor Documentation

◆ CocoaBestUnit() [1/2]

CocoaBestUnit::CocoaBestUnit ( ALIdouble  internalValue,
const ALIstring category 
)

Definition at line 288 of file CocoaUnitsTable.cc.

288  {
289  // find the category
291  if (theUnitsTable.empty())
292  CocoaUnitDefinition::BuildUnitsTable(); //t should be done somewhere else
293  size_t nbCat = theUnitsTable.size();
294  size_t i = 0;
295  while ((i < nbCat) && (theUnitsTable[i]->GetName() != category))
296  i++;
297  if (i == nbCat) {
298  std::cout << " CocoaBestUnit: the category " << category << " does not exist !!" << nbCat << std::endl;
299  std::exception(); //"Missing unit category !");
300  }
301  //
302  IndexOfCategory = i;
303  nbOfVals = 1;
304  Value[0] = value;
305  Value[1] = 0.;
306  Value[2] = 0.;
307 
308  //COCOA internal units are in meters, not mm as in CLHEP
309  if (category == "Length") {
310  Value[0] *= 1000.;
311  Value[1] *= 1000.;
312  Value[2] *= 1000.;
313  }
314 }

References CocoaUnitDefinition::BuildUnitsTable(), taus_updatedMVAIds_cff::category, gather_cfg::cout, cppFunctionSkipper::exception, CocoaUnitDefinition::GetUnitsTable(), mps_fire::i, IndexOfCategory, nbOfVals, relativeConstraints::value, and Value.

◆ CocoaBestUnit() [2/2]

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

Definition at line 318 of file CocoaUnitsTable.cc.

318  {
319  // find the category
321  size_t nbCat = theUnitsTable.size();
322  size_t i = 0;
323  while ((i < nbCat) && (theUnitsTable[i]->GetName() != category))
324  i++;
325  if (i == nbCat) {
326  std::cerr << " CocoaBestUnit: the category " << category << " does not exist." << std::endl;
327  std::exception(); //"Unit category not existing !");
328  }
329  //
330  IndexOfCategory = i;
331  nbOfVals = 3;
332  Value[0] = value.x();
333  Value[1] = value.y();
334  Value[2] = value.z();
335 }

References taus_updatedMVAIds_cff::category, beam_dqm_sourceclient-live_cfg::cerr, cppFunctionSkipper::exception, CocoaUnitDefinition::GetUnitsTable(), mps_fire::i, IndexOfCategory, nbOfVals, and Value.

◆ ~CocoaBestUnit()

CocoaBestUnit::~CocoaBestUnit ( )

Definition at line 338 of file CocoaUnitsTable.cc.

338 {}

Member Function Documentation

◆ GetCategory()

const ALIstring& CocoaBestUnit::GetCategory ( ) const
inline

Definition at line 106 of file CocoaUnitsTable.h.

106 { return Category; }

References Category.

◆ GetIndexOfCategory()

size_t CocoaBestUnit::GetIndexOfCategory ( ) const
inline

Definition at line 107 of file CocoaUnitsTable.h.

107 { return IndexOfCategory; }

References IndexOfCategory.

◆ GetValue()

ALIdouble* CocoaBestUnit::GetValue ( )
inline

Definition at line 105 of file CocoaUnitsTable.h.

105 { return Value; }

References Value.

Referenced by UnitConverter::ucstring().

Friends And Related Function Documentation

◆ operator<<

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

Definition at line 342 of file CocoaUnitsTable.cc.

342  {
344  CocoaUnitsContainer& List = theUnitsTable[a.IndexOfCategory]->GetUnitsList();
345  ALIint len = theUnitsTable[a.IndexOfCategory]->GetSymbMxLen();
346 
347  ALIint ksup(-1), kinf(-1);
348  ALIdouble umax(0.), umin(ALI_DBL_MAX);
349  ALIdouble rsup(ALI_DBL_MAX), rinf(0.);
350 
351  //for a ThreeVector, choose the best unit for the biggest value
352  ALIdouble value = std::max(std::max(std::abs(a.Value[0]), std::abs(a.Value[1])), std::abs(a.Value[2]));
353 
354  for (size_t k = 0; k < List.size(); k++) {
355  ALIdouble unit = List[k]->GetValue();
356  if (value == ALI_DBL_MAX) {
357  if (unit > umax) {
358  umax = unit;
359  ksup = k;
360  }
361  } else if (value <= ALI_DBL_MIN) {
362  if (unit < umin) {
363  umin = unit;
364  kinf = k;
365  }
366  }
367 
368  else {
370  if ((ratio >= 1.) && (ratio < rsup)) {
371  rsup = ratio;
372  ksup = k;
373  }
374  if ((ratio < 1.) && (ratio > rinf)) {
375  rinf = ratio;
376  kinf = k;
377  }
378  }
379  }
380 
381  ALIint index = ksup;
382  if (index == -1)
383  index = kinf;
384  if (index == -1)
385  index = 0;
386 
387  for (ALIint j = 0; j < a.nbOfVals; j++) {
388  flux << a.Value[j] / (List[index]->GetValue()) << " ";
389  }
390 
391  std::ios::fmtflags oldform = flux.flags();
392 
393  flux.setf(std::ios::left, std::ios::adjustfield);
394  flux << std::setw(len) << List[index]->GetSymbol();
395  flux.flags(oldform);
396 
397  return flux;
398 }

Member Data Documentation

◆ Category

ALIstring CocoaBestUnit::Category
private

Definition at line 116 of file CocoaUnitsTable.h.

Referenced by GetCategory().

◆ IndexOfCategory

size_t CocoaBestUnit::IndexOfCategory
private

Definition at line 117 of file CocoaUnitsTable.h.

Referenced by CocoaBestUnit(), and GetIndexOfCategory().

◆ nbOfVals

ALIint CocoaBestUnit::nbOfVals
private

Definition at line 115 of file CocoaUnitsTable.h.

Referenced by CocoaBestUnit().

◆ Value

ALIdouble CocoaBestUnit::Value[3]
private

Definition at line 114 of file CocoaUnitsTable.h.

Referenced by CocoaBestUnit(), and GetValue().

taus_updatedMVAIds_cff.category
category
Definition: taus_updatedMVAIds_cff.py:30
mps_fire.i
i
Definition: mps_fire.py:355
CocoaUnitsTable
std::vector< CocoaUnitsCategory * > CocoaUnitsTable
Definition: CocoaUnitsTable.h:12
CocoaUnitDefinition::GetUnitsTable
static CocoaUnitsTable & GetUnitsTable()
Definition: CocoaUnitsTable.cc:69
gather_cfg.cout
cout
Definition: gather_cfg.py:144
CocoaBestUnit::Value
ALIdouble Value[3]
Definition: CocoaUnitsTable.h:114
dqmdumpme.k
k
Definition: dqmdumpme.py:60
particleFlowDisplacedVertex_cfi.ratio
ratio
Definition: particleFlowDisplacedVertex_cfi.py:93
ALI_DBL_MAX
const double ALI_DBL_MAX
Definition: CocoaGlobals.h:24
CocoaBestUnit::nbOfVals
ALIint nbOfVals
Definition: CocoaUnitsTable.h:115
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
a
double a
Definition: hdecay.h:119
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
CocoaUnitsContainer
std::vector< CocoaUnitDefinition * > CocoaUnitsContainer
Definition: CocoaUnitsTable.h:57
beam_dqm_sourceclient-live_cfg.cerr
cerr
Definition: beam_dqm_sourceclient-live_cfg.py:17
ALIdouble
long double ALIdouble
Definition: CocoaGlobals.h:11
CocoaBestUnit::Category
ALIstring Category
Definition: CocoaUnitsTable.h:116
value
Definition: value.py:1
ALI_DBL_MIN
const double ALI_DBL_MIN
Definition: CocoaGlobals.h:25
unit
Basic3DVector unit() const
Definition: Basic3DVectorLD.h:162
CocoaUnitDefinition::BuildUnitsTable
static void BuildUnitsTable()
Definition: CocoaUnitsTable.cc:124
relativeConstraints.value
value
Definition: relativeConstraints.py:53
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
ALIint
int ALIint
Definition: CocoaGlobals.h:15
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
CocoaBestUnit::IndexOfCategory
size_t IndexOfCategory
Definition: CocoaUnitsTable.h:117