#include <CocoaUnitsTable.h>
Public Member Functions | |
CocoaUnitDefinition (const ALIstring &name, const ALIstring &symbol, const ALIstring &category, ALIdouble value) | |
const ALIstring & | GetName () const |
const ALIstring & | GetSymbol () const |
ALIdouble | GetValue () const |
ALIint | operator!= (const CocoaUnitDefinition &) const |
ALIint | operator== (const CocoaUnitDefinition &) const |
void | PrintDefinition () |
~CocoaUnitDefinition () | |
Static Public Member Functions | |
static void | BuildUnitsTable () |
static ALIstring | GetCategory (const ALIstring &) |
static CocoaUnitsTable & | GetUnitsTable () |
static ALIdouble | GetValueOf (const ALIstring &) |
static void | PrintUnitsTable () |
Private Member Functions | |
CocoaUnitDefinition (const CocoaUnitDefinition &) | |
CocoaUnitDefinition & | operator= (const CocoaUnitDefinition &) |
Private Attributes | |
size_t | CategoryIndex |
ALIstring | Name |
ALIstring | SymbolName |
ALIdouble | Value |
Static Private Attributes | |
static CocoaUnitsTable | theUnitsTable |
Definition at line 18 of file CocoaUnitsTable.h.
CocoaUnitDefinition::CocoaUnitDefinition | ( | const ALIstring & | name, |
const ALIstring & | symbol, | ||
const ALIstring & | category, | ||
ALIdouble | value | ||
) |
Definition at line 12 of file CocoaUnitsTable.cc.
References CategoryIndex, GetName(), i, and theUnitsTable.
Referenced by BuildUnitsTable().
: Name(name),SymbolName(symbol),Value(value) { // //does the Category objet already exist ? size_t nbCat = theUnitsTable.size(); size_t i = 0; while ((i<nbCat)&&(theUnitsTable[i]->GetName()!=category)) i++; if (i == nbCat) theUnitsTable.push_back( new CocoaUnitsCategory(category)); CategoryIndex = i; // //insert this Unit in the Unitstable (theUnitsTable[CategoryIndex]->GetUnitsList()).push_back(this); //update string max length for name and symbol theUnitsTable[i]->UpdateNameMxLen((ALIint)name.length()); theUnitsTable[i]->UpdateSymbMxLen((ALIint)symbol.length()); }
CocoaUnitDefinition::~CocoaUnitDefinition | ( | ) |
Definition at line 34 of file CocoaUnitsTable.cc.
References i, and theUnitsTable.
{ for (size_t i=0;i<theUnitsTable.size();i++) { delete theUnitsTable[i]; } }
CocoaUnitDefinition::CocoaUnitDefinition | ( | const CocoaUnitDefinition & | right | ) | [private] |
Definition at line 44 of file CocoaUnitsTable.cc.
{
*this = right;
}
void CocoaUnitDefinition::BuildUnitsTable | ( | ) | [static] |
Definition at line 137 of file CocoaUnitsTable.cc.
References CocoaUnitDefinition(), g, and edm::second().
Referenced by CocoaBestUnit::CocoaBestUnit(), GetCategory(), and GetValueOf().
{ //Length new CocoaUnitDefinition( "meter","m" ,"Length",meter); new CocoaUnitDefinition("centimeter","cm" ,"Length",centimeter); new CocoaUnitDefinition("millimeter","mm" ,"Length",millimeter); // new CocoaUnitDefinition("micrometer","um" ,"Length",micrometer); new CocoaUnitDefinition("micrometer","mum" ,"Length",micrometer); new CocoaUnitDefinition( "nanometer","nm" ,"Length",nanometer); new CocoaUnitDefinition( "angstrom","Ang" ,"Length",angstrom); new CocoaUnitDefinition( "fermi","fm" ,"Length",fermi); //Surface new CocoaUnitDefinition( "kilometer2","km2" ,"Surface",kilometer2); new CocoaUnitDefinition( "meter2","m2" ,"Surface",meter2); new CocoaUnitDefinition("centimeter2","cm2" ,"Surface",centimeter2); new CocoaUnitDefinition("millimeter2","mm2" ,"Surface",millimeter2); new CocoaUnitDefinition( "barn","barn" ,"Surface",barn); new CocoaUnitDefinition( "millibarn","mbarn" ,"Surface",millibarn); new CocoaUnitDefinition( "microbarn","mubarn" ,"Surface",microbarn); new CocoaUnitDefinition( "nanobarn","nbarn" ,"Surface",nanobarn); new CocoaUnitDefinition( "picobarn","pbarn" ,"Surface",picobarn); //Volume new CocoaUnitDefinition( "kilometer3","km3" ,"Volume",kilometer3); new CocoaUnitDefinition( "meter3","m3" ,"Volume",meter3); new CocoaUnitDefinition("centimeter3","cm3" ,"Volume",centimeter3); new CocoaUnitDefinition("millimeter3","mm3" ,"Volume",millimeter3); //Angle new CocoaUnitDefinition( "radian","rad" ,"Angle",radian); new CocoaUnitDefinition("milliradian","mrad" ,"Angle",milliradian); new CocoaUnitDefinition( "steradian","sr" ,"Angle",steradian); new CocoaUnitDefinition( "degree","deg" ,"Angle",degree); //Time new CocoaUnitDefinition( "second","s" ,"Time",second); new CocoaUnitDefinition("millisecond","ms" ,"Time",millisecond); new CocoaUnitDefinition("microsecond","mus" ,"Time",microsecond); new CocoaUnitDefinition( "nanosecond","ns" ,"Time",nanosecond); new CocoaUnitDefinition( "picosecond","ps" ,"Time",picosecond); //Frequency new CocoaUnitDefinition( "hertz","Hz" ,"Frequency",hertz); new CocoaUnitDefinition("kilohertz","kHz" ,"Frequency",kilohertz); new CocoaUnitDefinition("megahertz","MHz" ,"Frequency",megahertz); //Electric charge new CocoaUnitDefinition( "eplus","e+" ,"Electric charge",eplus); new CocoaUnitDefinition("coulomb","C" ,"Electric charge",coulomb); //Energy new CocoaUnitDefinition( "electronvolt","eV" ,"Energy",electronvolt); new CocoaUnitDefinition("kiloelectronvolt","keV","Energy",kiloelectronvolt); new CocoaUnitDefinition("megaelectronvolt","MeV","Energy",megaelectronvolt); new CocoaUnitDefinition("gigaelectronvolt","GeV","Energy",gigaelectronvolt); new CocoaUnitDefinition("teraelectronvolt","TeV","Energy",teraelectronvolt); new CocoaUnitDefinition("petaelectronvolt","PeV","Energy",petaelectronvolt); new CocoaUnitDefinition( "joule","J" ,"Energy",joule); //Mass new CocoaUnitDefinition("milligram","mg","Mass",milligram); new CocoaUnitDefinition( "gram","g" ,"Mass",gram); new CocoaUnitDefinition( "kilogram","kg","Mass",kilogram); //Volumic Mass new CocoaUnitDefinition( "g/cm3", "g/cm3","Volumic Mass", g/cm3); new CocoaUnitDefinition("mg/cm3","mg/cm3","Volumic Mass",mg/cm3); new CocoaUnitDefinition("kg/m3", "kg/m3", "Volumic Mass",kg/m3); //Power new CocoaUnitDefinition("watt","W","Power",watt); //Force new CocoaUnitDefinition("newton","N","Force",newton); //Pressure new CocoaUnitDefinition( "pascal","Pa" ,"Pressure",pascal); new CocoaUnitDefinition( "bar","bar","Pressure",bar); new CocoaUnitDefinition("atmosphere","atm","Pressure",atmosphere); //Electric current new CocoaUnitDefinition( "ampere","A" ,"Electric current",ampere); new CocoaUnitDefinition("milliampere","mA" ,"Electric current",milliampere); new CocoaUnitDefinition("microampere","muA","Electric current",microampere); new CocoaUnitDefinition( "nanoampere","nA" ,"Electric current",nanoampere); //Electric potential new CocoaUnitDefinition( "volt","V" ,"Electric potential",volt); new CocoaUnitDefinition("kilovolt","kV","Electric potential",kilovolt); new CocoaUnitDefinition("megavolt","MV","Electric potential",megavolt); //Magnetic flux new CocoaUnitDefinition("weber","Wb","Magnetic flux",weber); //Magnetic flux density new CocoaUnitDefinition( "tesla","T" ,"Magnetic flux density",tesla); new CocoaUnitDefinition("kilogauss","kG","Magnetic flux density",kilogauss); new CocoaUnitDefinition( "gauss","G" ,"Magnetic flux density",gauss); //Temperature new CocoaUnitDefinition("kelvin","K","Temperature",kelvin); //Amount of substance new CocoaUnitDefinition("mole","mol","Amount of substance",mole); //Activity new CocoaUnitDefinition("becquerel","Bq","Activity",becquerel); new CocoaUnitDefinition( "curie","Ci","Activity",curie); //Dose new CocoaUnitDefinition("gray","Gy","Dose",gray); }
Definition at line 106 of file CocoaUnitsTable.cc.
References BuildUnitsTable(), gather_cfg::cout, i, j, mergeVDriftHistosByStation::name, theUnitsTable, and create_public_lumi_plots::units.
{ if(theUnitsTable.size()==0) BuildUnitsTable(); ALIstring name,symbol; for (size_t i=0;i<theUnitsTable.size();i++) { CocoaUnitsContainer& units = theUnitsTable[i]->GetUnitsList(); for (size_t j=0;j<units.size();j++) { name=units[j]->GetName(); symbol=units[j]->GetSymbol(); if(str==name||str==symbol) return theUnitsTable[i]->GetName(); } } std::cout << "Warning from CocoaUnitDefinition::GetCategory(" << str << ")." << " The unit " << str << " does not exist in UnitsTable." << " Return category = None" << std::endl; name = "None"; return name; }
const ALIstring& CocoaUnitDefinition::GetName | ( | ) | const [inline] |
Definition at line 38 of file CocoaUnitsTable.h.
References Name.
Referenced by CocoaUnitDefinition().
{return Name;}
const ALIstring& CocoaUnitDefinition::GetSymbol | ( | ) | const [inline] |
CocoaUnitsTable & CocoaUnitDefinition::GetUnitsTable | ( | ) | [static] |
Definition at line 79 of file CocoaUnitsTable.cc.
References theUnitsTable.
Referenced by CocoaBestUnit::CocoaBestUnit(), and operator<<().
{ return theUnitsTable; }
ALIdouble CocoaUnitDefinition::GetValue | ( | ) | const [inline] |
Definition at line 86 of file CocoaUnitsTable.cc.
References BuildUnitsTable(), gather_cfg::cout, i, j, mergeVDriftHistosByStation::name, theUnitsTable, and create_public_lumi_plots::units.
{ if(theUnitsTable.size()==0) BuildUnitsTable(); ALIstring name,symbol; for (size_t i=0;i<theUnitsTable.size();i++) { CocoaUnitsContainer& units = theUnitsTable[i]->GetUnitsList(); for (size_t j=0;j<units.size();j++) { name=units[j]->GetName(); symbol=units[j]->GetSymbol(); if(str==name||str==symbol) return units[j]->GetValue(); } } std::cout << "Warning from CocoaUnitDefinition::GetValueOf(" << str << ")." << " The unit " << str << " does not exist in UnitsTable." << " Return Value = 0." << std::endl; return 0.; }
ALIint CocoaUnitDefinition::operator!= | ( | const CocoaUnitDefinition & | right | ) | const |
Definition at line 72 of file CocoaUnitsTable.cc.
{ return (this != (CocoaUnitDefinition *) &right); }
CocoaUnitDefinition & CocoaUnitDefinition::operator= | ( | const CocoaUnitDefinition & | right | ) | [private] |
Definition at line 51 of file CocoaUnitsTable.cc.
References CategoryIndex, Name, SymbolName, and Value.
{ if (this != &right) { Name = right.Name; SymbolName = right.SymbolName; Value = right.Value; CategoryIndex = right.CategoryIndex; } return *this; }
ALIint CocoaUnitDefinition::operator== | ( | const CocoaUnitDefinition & | right | ) | const |
Definition at line 65 of file CocoaUnitsTable.cc.
{ return (this == (CocoaUnitDefinition *) &right); }
void CocoaUnitDefinition::PrintDefinition | ( | ) |
Definition at line 127 of file CocoaUnitsTable.cc.
References CategoryIndex, gather_cfg::cout, Name, SymbolName, theUnitsTable, and Value.
{ ALIint nameL = theUnitsTable[CategoryIndex]->GetNameMxLen(); ALIint symbL = theUnitsTable[CategoryIndex]->GetSymbMxLen(); std::cout << std::setw(nameL) << Name << " (" << std::setw(symbL) << SymbolName << ") = " << Value << std::endl; }
void CocoaUnitDefinition::PrintUnitsTable | ( | ) | [static] |
Definition at line 253 of file CocoaUnitsTable.cc.
References gather_cfg::cout, i, and theUnitsTable.
{ std::cout << "\n ----- The Table of Units ----- \n"; for(size_t i=0;i<theUnitsTable.size();i++) { theUnitsTable[i]->PrintCategory(); } }
size_t CocoaUnitDefinition::CategoryIndex [private] |
Definition at line 62 of file CocoaUnitsTable.h.
Referenced by CocoaUnitDefinition(), operator=(), and PrintDefinition().
ALIstring CocoaUnitDefinition::Name [private] |
Definition at line 54 of file CocoaUnitsTable.h.
Referenced by GetName(), operator=(), and PrintDefinition().
ALIstring CocoaUnitDefinition::SymbolName [private] |
Definition at line 55 of file CocoaUnitsTable.h.
Referenced by GetSymbol(), operator=(), and PrintDefinition().
CocoaUnitsTable CocoaUnitDefinition::theUnitsTable [static, private] |
Definition at line 59 of file CocoaUnitsTable.h.
Referenced by CocoaUnitDefinition(), GetCategory(), GetUnitsTable(), GetValueOf(), PrintDefinition(), PrintUnitsTable(), and ~CocoaUnitDefinition().
ALIdouble CocoaUnitDefinition::Value [private] |
Definition at line 56 of file CocoaUnitsTable.h.
Referenced by GetValue(), operator=(), and PrintDefinition().