CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/Alignment/CocoaToDDL/interface/CocoaUnitsTable.h

Go to the documentation of this file.
00001 //
00002 // This class is copied from G4UnitsTable
00003 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
00004 
00005 #ifndef CocoaUnitsTable_HH
00006 #define CocoaUnitsTable_HH
00007 
00008 #include "Alignment/CocoaUtilities/interface/CocoaGlobals.h"
00009 #include <vector>
00010 #include "CLHEP/Vector/ThreeVector.h"
00011 
00012 class CocoaUnitsCategory;
00013 typedef std::vector<CocoaUnitsCategory*> CocoaUnitsTable;
00014 
00015 
00016 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
00017 
00018 class CocoaUnitDefinition
00019 {
00020 public:  // with description
00021 
00022     CocoaUnitDefinition(const ALIstring& name, const ALIstring& symbol,
00023                      const ALIstring& category, ALIdouble value);
00024             
00025 public:  // without description
00026             
00027    ~CocoaUnitDefinition();
00028     ALIint operator==(const CocoaUnitDefinition&) const;
00029     ALIint operator!=(const CocoaUnitDefinition&) const;
00030     
00031 private:
00032 
00033     CocoaUnitDefinition(const CocoaUnitDefinition&);
00034     CocoaUnitDefinition& operator=(const CocoaUnitDefinition&);
00035    
00036 public:  // with description
00037 
00038     const ALIstring& GetName()   const {return Name;}
00039     const ALIstring& GetSymbol() const {return SymbolName;}
00040     ALIdouble        GetValue()  const {return Value;}
00041     
00042     void          PrintDefinition();
00043     
00044     static void BuildUnitsTable();    
00045     static void PrintUnitsTable();
00046     
00047     static CocoaUnitsTable& GetUnitsTable();
00048 
00049     static ALIdouble GetValueOf (const ALIstring&);
00050     static ALIstring GetCategory(const ALIstring&);
00051 
00052 private:
00053 
00054     ALIstring Name;            // SI name
00055     ALIstring SymbolName;      // SI symbol
00056     ALIdouble Value;           // value in the internal system of units
00057     
00058     static 
00059     CocoaUnitsTable theUnitsTable;   // table of Units
00060     
00061     
00062     size_t CategoryIndex;         // category index of this unit
00063 };
00064 
00065 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
00066 
00067 typedef std::vector<CocoaUnitDefinition*> CocoaUnitsContainer;
00068 
00069 class CocoaUnitsCategory
00070 {
00071 public:  // without description
00072 
00073     CocoaUnitsCategory(const ALIstring& name);
00074    ~CocoaUnitsCategory();
00075     ALIint operator==(const CocoaUnitsCategory&) const;
00076     ALIint operator!=(const CocoaUnitsCategory&) const;
00077     
00078 private:
00079 
00080     CocoaUnitsCategory(const CocoaUnitsCategory&);
00081     CocoaUnitsCategory& operator=(const CocoaUnitsCategory&);
00082    
00083 public:  // without description
00084 
00085     const ALIstring&   GetName()      const {return Name;}
00086     CocoaUnitsContainer& GetUnitsList()       {return UnitsList;}
00087     ALIint             GetNameMxLen() const {return NameMxLen;}
00088     ALIint             GetSymbMxLen() const {return SymbMxLen;}
00089     void  UpdateNameMxLen(ALIint len) {if (NameMxLen<len) NameMxLen=len;}
00090     void  UpdateSymbMxLen(ALIint len) {if (SymbMxLen<len) SymbMxLen=len;}
00091     void  PrintCategory();
00092 
00093 private:
00094 
00095     ALIstring          Name;        // dimensional family: Length,Volume,Energy ...
00096     CocoaUnitsContainer  UnitsList;   // List of units in this family
00097     ALIint             NameMxLen;   // max length of the units name
00098     ALIint             SymbMxLen;   // max length of the units symbol
00099 };
00100 
00101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
00102 
00103 class CocoaBestUnit
00104 {
00105 public:  // with description
00106 
00107     CocoaBestUnit(ALIdouble internalValue, const ALIstring& category);
00108     CocoaBestUnit(const CLHEP::Hep3Vector& internalValue, const ALIstring& category);    
00109       // These constructors convert a physical quantity from its internalValue
00110       // into the most appropriate unit of the same category.
00111       // In practice it builds an object VU = (newValue, newUnit)
00112 
00113    ~CocoaBestUnit();
00114    
00115 public:  // without description
00116 
00117     ALIdouble*  GetValue()                 {return Value;}
00118     const ALIstring&   GetCategory() const {return Category;}
00119     size_t     GetIndexOfCategory() const {return IndexOfCategory;}
00120     
00121 public:  // with description 
00122    
00123     friend
00124     std::ostream&  operator<<(std::ostream&,CocoaBestUnit VU);
00125       // Default format to print the objet VU above.
00126 
00127 private:
00128 
00129     ALIdouble   Value[3];        // value in the internal system of units
00130     ALIint      nbOfVals;        // ALIdouble=1; CLHEP::Hep3Vector=3
00131     ALIstring   Category;        // dimensional family: Length,Volume,Energy ...
00132     size_t IndexOfCategory;     // position of Category in UnitsTable
00133 };
00134 
00135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
00136 
00137 #endif