CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/Alignment/CocoaModel/interface/ALIUnitsTable.h

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * DISCLAIMER                                                       *
00004 // *                                                                  *
00005 // * The following disclaimer summarizes all the specific disclaimers *
00006 // * of contributors to this software. The specific disclaimers,which *
00007 // * govern, are listed with their locations in:                      *
00008 // *   http://cern.ch/geant4/license                                  *
00009 // *                                                                  *
00010 // * Neither the authors of this software system, nor their employing *
00011 // * institutes,nor the agencies providing financial support for this *
00012 // * work  make  any representation or  warranty, express or implied, *
00013 // * regarding  this  software system or assume any liability for its *
00014 // * use.                                                             *
00015 // *                                                                  *
00016 // * This  code  implementation is the  intellectual property  of the *
00017 // * GEANT4 collaboration.                                            *
00018 // * By copying,  distributing  or modifying the Program (or any work *
00019 // * based  on  the Program)  you indicate  your  acceptance of  this *
00020 // * statement, and all its terms.                                    *
00021 // ********************************************************************
00022 //
00023 // -----------------------------------------------------------------
00024 //
00025 //      ------------------- class ALIUnitsTable -----------------
00026 //
00027 // Class description:
00028 //
00029 // This class maintains a table of Units.
00030 // A Unit has a name, a symbol, a value and belong to a category (i.e. its
00031 // dimensional definition): Length, Time, Energy, etc...
00032 // The Units are grouped by category. The TableOfUnits is a list of categories.
00033 // The class G4BestUnit allows to convert automaticaly a physical quantity
00034 // from its internal value into the most appropriate Unit of the same category.
00035 //
00036 
00037 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
00038 
00039 #ifndef ALIUnitsTable_HH
00040 #define ALIUnitsTable_HH
00041 
00042 #include "Alignment/CocoaUtilities/interface/CocoaGlobals.h"
00043 #include <vector>
00044 #include <CLHEP/Vector/ThreeVector.h>
00045 
00046 class ALIUnitsCategory;
00047 typedef std::vector<ALIUnitsCategory*> ALIUnitsTable;
00048 
00049 
00050 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
00051 
00052 class ALIUnitDefinition
00053 {
00054 public:  // with description
00055 
00056     ALIUnitDefinition(ALIstring name, ALIstring symbol,
00057                      ALIstring category, ALIdouble value);
00058             
00059 public:  // without description
00060             
00061    ~ALIUnitDefinition();
00062     ALIint operator==(const ALIUnitDefinition&) const;
00063     ALIint operator!=(const ALIUnitDefinition&) const;
00064     
00065 private:
00066 
00067     ALIUnitDefinition(ALIUnitDefinition&);
00068     ALIUnitDefinition& operator=(const ALIUnitDefinition&);
00069    
00070 public:  // with description
00071 
00072     ALIstring      GetName()   const {return Name;}
00073     ALIstring      GetSymbol() const {return SymbolName;}
00074     ALIdouble      GetValue()  const {return Value;}
00075     
00076     void          PrintDefinition();
00077     
00078     static void BuildUnitsTable();    
00079     static void PrintUnitsTable();
00080     
00081     static ALIUnitsTable& GetUnitsTable() {return theUnitsTable;}
00082 
00083     static ALIdouble GetValueOf (ALIstring);
00084     static ALIstring GetCategory(ALIstring);
00085 
00086 private:
00087 
00088     ALIstring Name;            // SI name
00089     ALIstring SymbolName;      // SI symbol
00090     ALIdouble Value;           // value in the internal system of units
00091     
00092     static 
00093     ALIUnitsTable theUnitsTable;   // table of Units
00094     
00095     
00096     size_t CategoryIndex;         // category index of this unit
00097 };
00098 
00099 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
00100 
00101 typedef std::vector<ALIUnitDefinition*> ALIUnitsContainer;
00102 
00103 class ALIUnitsCategory
00104 {
00105 public:  // without description
00106 
00107     ALIUnitsCategory(ALIstring name);
00108    ~ALIUnitsCategory();
00109     ALIint operator==(const ALIUnitsCategory&) const;
00110     ALIint operator!=(const ALIUnitsCategory&) const;
00111     
00112 private:
00113 
00114     ALIUnitsCategory(ALIUnitsCategory&);
00115     ALIUnitsCategory& operator=(const ALIUnitsCategory&);
00116    
00117 public:  // without description
00118 
00119     ALIstring          GetName()      const {return Name;}
00120     ALIUnitsContainer& GetUnitsList()       {return UnitsList;}
00121     ALIint             GetNameMxLen() const {return NameMxLen;}
00122     ALIint             GetSymbMxLen() const {return SymbMxLen;}
00123     void  UpdateNameMxLen(ALIint len) {if (NameMxLen<len) NameMxLen=len;}
00124     void  UpdateSymbMxLen(ALIint len) {if (SymbMxLen<len) SymbMxLen=len;}
00125     void  PrintCategory();
00126 
00127 private:
00128 
00129     ALIstring          Name;        // dimensional family: Length,Volume,Energy ...
00130     ALIUnitsContainer  UnitsList;   // List of units in this family
00131     ALIint             NameMxLen;   // max length of the units name
00132     ALIint             SymbMxLen;   // max length of the units symbol
00133 };
00134 
00135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
00136 
00137 class ALIBestUnit
00138 {
00139 public:  // with description
00140 
00141     ALIBestUnit(ALIdouble internalValue, ALIstring category);
00142     ALIBestUnit(const CLHEP::Hep3Vector& internalValue, ALIstring category);    
00143       // These constructors convert a physical quantity from its internalValue
00144       // into the most appropriate unit of the same category.
00145       // In practice it builds an object VU = (newValue, newUnit)
00146 
00147    ~ALIBestUnit();
00148    
00149 public:  // without description
00150 
00151     ALIdouble*  GetValue()                 {return Value;}
00152     ALIstring   GetCategory()        const {return Category;}
00153     size_t     GetIndexOfCategory() const {return IndexOfCategory;}
00154     
00155 public:  // with description 
00156    
00157     friend
00158     std::ostream&  operator<<(std::ostream&,ALIBestUnit VU);
00159       // Default format to print the objet VU above.
00160 
00161 private:
00162 
00163     ALIdouble   Value[3];        // value in the internal system of units
00164     ALIint      nbOfVals;        // ALIdouble=1; CLHEP::Hep3Vector=3
00165     ALIstring   Category;        // dimensional family: Length,Volume,Energy ...
00166     size_t IndexOfCategory;     // position of Category in UnitsTable
00167 };
00168 
00169 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
00170 
00171 #endif