Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:44:32

0001 //
0002 // This class is copied from G4UnitsTable
0003 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0004 
0005 #ifndef CocoaUnitsTable_HH
0006 #define CocoaUnitsTable_HH
0007 
0008 #include "Alignment/CocoaUtilities/interface/CocoaGlobals.h"
0009 #include <vector>
0010 #include "CLHEP/Vector/ThreeVector.h"
0011 
0012 class CocoaUnitsCategory;
0013 typedef std::vector<CocoaUnitsCategory*> CocoaUnitsTable;
0014 
0015 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0016 
0017 class CocoaUnitDefinition {
0018 public:  // with description
0019   CocoaUnitDefinition(const ALIstring& name, const ALIstring& symbol, const ALIstring& category, ALIdouble value);
0020 
0021 public:  // without description
0022   ~CocoaUnitDefinition();
0023   ALIint operator==(const CocoaUnitDefinition&) const;
0024   ALIint operator!=(const CocoaUnitDefinition&) const;
0025 
0026 private:
0027   CocoaUnitDefinition(const CocoaUnitDefinition&);
0028   CocoaUnitDefinition& operator=(const CocoaUnitDefinition&);
0029 
0030 public:  // with description
0031   const ALIstring& GetName() const { return Name; }
0032   const ALIstring& GetSymbol() const { return SymbolName; }
0033   ALIdouble GetValue() const { return Value; }
0034 
0035   void PrintDefinition();
0036 
0037   static void BuildUnitsTable();
0038   static void PrintUnitsTable();
0039 
0040   static CocoaUnitsTable& GetUnitsTable();
0041 
0042   static ALIdouble GetValueOf(const ALIstring&);
0043   static ALIstring GetCategory(const ALIstring&);
0044 
0045 private:
0046   ALIstring Name;        // SI name
0047   ALIstring SymbolName;  // SI symbol
0048   ALIdouble Value;       // value in the internal system of units
0049 
0050   static CocoaUnitsTable theUnitsTable;  // table of Units
0051 
0052   size_t CategoryIndex;  // category index of this unit
0053 };
0054 
0055 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0056 
0057 typedef std::vector<CocoaUnitDefinition*> CocoaUnitsContainer;
0058 
0059 class CocoaUnitsCategory {
0060 public:  // without description
0061   CocoaUnitsCategory(const ALIstring& name);
0062   ~CocoaUnitsCategory();
0063   ALIint operator==(const CocoaUnitsCategory&) const;
0064   ALIint operator!=(const CocoaUnitsCategory&) const;
0065 
0066 private:
0067   CocoaUnitsCategory(const CocoaUnitsCategory&);
0068   CocoaUnitsCategory& operator=(const CocoaUnitsCategory&);
0069 
0070 public:  // without description
0071   const ALIstring& GetName() const { return Name; }
0072   CocoaUnitsContainer& GetUnitsList() { return UnitsList; }
0073   ALIint GetNameMxLen() const { return NameMxLen; }
0074   ALIint GetSymbMxLen() const { return SymbMxLen; }
0075   void UpdateNameMxLen(ALIint len) {
0076     if (NameMxLen < len)
0077       NameMxLen = len;
0078   }
0079   void UpdateSymbMxLen(ALIint len) {
0080     if (SymbMxLen < len)
0081       SymbMxLen = len;
0082   }
0083   void PrintCategory();
0084 
0085 private:
0086   ALIstring Name;                 // dimensional family: Length,Volume,Energy ...
0087   CocoaUnitsContainer UnitsList;  // List of units in this family
0088   ALIint NameMxLen;               // max length of the units name
0089   ALIint SymbMxLen;               // max length of the units symbol
0090 };
0091 
0092 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0093 
0094 class CocoaBestUnit {
0095 public:  // with description
0096   CocoaBestUnit(ALIdouble internalValue, const ALIstring& category);
0097   CocoaBestUnit(const CLHEP::Hep3Vector& internalValue, const ALIstring& category);
0098   // These constructors convert a physical quantity from its internalValue
0099   // into the most appropriate unit of the same category.
0100   // In practice it builds an object VU = (newValue, newUnit)
0101 
0102   ~CocoaBestUnit();
0103 
0104 public:  // without description
0105   ALIdouble* GetValue() { return Value; }
0106   const ALIstring& GetCategory() const { return Category; }
0107   size_t GetIndexOfCategory() const { return IndexOfCategory; }
0108 
0109 public:  // with description
0110   friend std::ostream& operator<<(std::ostream&, CocoaBestUnit VU);
0111   // Default format to print the objet VU above.
0112 
0113 private:
0114   ALIdouble Value[3];      // value in the internal system of units
0115   ALIint nbOfVals;         // ALIdouble=1; CLHEP::Hep3Vector=3
0116   ALIstring Category;      // dimensional family: Length,Volume,Energy ...
0117   size_t IndexOfCategory;  // position of Category in UnitsTable
0118 };
0119 
0120 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0121 
0122 #endif