CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/Alignment/CocoaUtilities/interface/ALIUtils.h

Go to the documentation of this file.
00001 //   COCOA class header file
00002 //Id:  ALIUtils.h
00003 //CAT: Model
00004 //
00005 //   Class with some utility function
00006 // 
00007 //   History: v1.0 
00008 //   Pedro Arce
00009 
00010 #ifndef CocoaUtils_HH
00011 #define CocoaUtils_HH
00012 
00013 
00014 #include "Alignment/CocoaUtilities/interface/CocoaGlobals.h" 
00015 
00016 #include "CLHEP/Vector/ThreeVector.h"
00017 #include "CLHEP/Vector/Rotation.h"
00018 #include <vector>
00019 #include <time.h>
00020 #include <fstream> 
00021 #include <iostream> 
00022 
00023 class ALIUtils
00024 {
00025 public:
00026   ALIUtils(){};
00027   ~ALIUtils(){};
00028 
00029   static int IsNumber( const ALIstring& str);
00030   static void dump3v( const CLHEP::Hep3Vector& vec, const std::string& msg);
00031   static void dumprm( const CLHEP::HepRotation& rm, const std::string& msg, std::ostream& out = std::cout );
00032 
00033  // public static DATA MEMBERS 
00034   static ALIint report;
00035   static ALIint debug;
00036   static ALIdouble deg;
00037 
00038   static void setReportVerbosity( ALIint val ) {
00039     report = val;
00040   }
00041   static void setDebugVerbosity( ALIint val ) {
00042     debug = val;
00043   }
00044   static time_t time_now() {
00045     return _time_now;
00046   }
00047   static void set_time_now(time_t now) {
00048     _time_now = now;
00049   }
00051   static double getFloat( const ALIstring& str );
00053   static int getInt( const ALIstring& str );
00055   static bool getBool( const ALIstring& str );
00057   static void dumpVS( const std::vector<ALIstring>& wl , const std::string& msg, std::ostream& outs = std::cout) ;
00058  
00059  //---------- Dimension factors
00060   static void SetLengthDimensionFactors(); 
00061   static void SetAngleDimensionFactors(); 
00062   static void SetOutputLengthDimensionFactors(); 
00063   static void SetOutputAngleDimensionFactors(); 
00064   static ALIdouble CalculateLengthDimensionFactorFromInt( ALIint ad );
00065   static ALIdouble CalculateAngleDimensionFactorFromInt( ALIint ad );
00066   static ALIdouble CalculateLengthDimensionFactorFromString( ALIstring dimstr );
00067   static ALIdouble CalculateAngleDimensionFactorFromString( ALIstring dimstr );
00068 
00069   static void dumpDimensions( std::ofstream& fout );
00070 
00071   static ALIdouble LengthValueDimensionFactor(){
00072     return _LengthValueDimensionFactor;}
00073   static ALIdouble LengthSigmaDimensionFactor(){
00074     return _LengthSigmaDimensionFactor;}
00075   static ALIdouble AngleValueDimensionFactor(){
00076     return _AngleValueDimensionFactor;}
00077   static ALIdouble AngleSigmaDimensionFactor(){
00078     return _AngleSigmaDimensionFactor;}
00079   static ALIdouble OutputLengthValueDimensionFactor(){
00080     return _OutputLengthValueDimensionFactor;}
00081   static ALIdouble OutputLengthSigmaDimensionFactor(){
00082     return _OutputLengthSigmaDimensionFactor;}
00083   static ALIdouble OutputAngleValueDimensionFactor(){
00084     return _OutputAngleValueDimensionFactor;}
00085   static ALIdouble OutputAngleSigmaDimensionFactor(){
00086     return _OutputAngleSigmaDimensionFactor;}
00087 
00088   static ALIdouble val0( ALIdouble val ) {
00089     //-std::cout << val << " val " << ( (val <= 1.E-9) ? 0. : val) << std::endl; 
00090 //    return (abs(val) <= 1.E-9) ? 0. : val; }
00091     if( fabs(val) <= 1.E-9) { return 0.;
00092     }else { return val; }; }
00093 
00094   static ALIstring subQuotes( const ALIstring& str );
00095 
00096   static ALIdouble getDimensionValue( const ALIstring& dim, const ALIstring& dimType );
00097 
00098   static std::string changeName( const std::string& oldName, const std::string& subsstr1,  const std::string& subsstr2 );
00099 
00100   static ALIbool getFirstTime(){
00101     return firstTime;
00102   }
00103   static void setFirstTime( ALIbool val ){
00104     firstTime = val;
00105   }
00106   static ALIdouble getMaximumDeviationDerivative() {
00107     return maximum_deviation_derivative; }
00108   static void setMaximumDeviationDerivative( ALIdouble val ) {
00109     maximum_deviation_derivative = val; }
00110 
00111   static std::vector<double> getRotationAnglesFromMatrix( CLHEP::HepRotation& rmLocal, double origAngleX, double origAngleY, double origAngleZ );
00112   static double diff2pi( double ang1, double ang2 );
00113   static bool eq2ang( double ang1, double ang2 );
00114   static double approxTo0( double val );
00115   static double addPii( double val );
00116   static int checkMatrixEquations( double angleX, double angleY, double angleZ, CLHEP::HepRotation* rot);
00117 
00118 
00119  private:
00120   static ALIdouble _LengthValueDimensionFactor;
00121   static ALIdouble _LengthSigmaDimensionFactor;
00122   static ALIdouble _AngleValueDimensionFactor;
00123   static ALIdouble _AngleSigmaDimensionFactor;
00124   static ALIdouble _OutputLengthValueDimensionFactor;
00125   static ALIdouble _OutputLengthSigmaDimensionFactor;
00126   static ALIdouble _OutputAngleValueDimensionFactor;
00127   static ALIdouble _OutputAngleSigmaDimensionFactor;
00128   static time_t _time_now;
00129 
00130   static ALIbool firstTime;
00131 
00132   static ALIdouble maximum_deviation_derivative;
00133 
00134 };
00135 
00136 /*
00137 template<class T>
00138 ALIuint FindItemInVector( const T* item, const std::vector<T*>& item_vector )
00139 {
00140  
00141   std::vector<T*>::const_iterator vtcite;
00142   ALIuint vfound = 1;
00143   for( vtcite = item_vector.begin(); vtcite != item_vector.end(); vtcite++) {
00144     if( (*vtcite) == item ) {
00145       
00146     }
00147   }
00148 
00149 }
00150 */
00151 //std::ostream& operator << (std::ostream& os, const CLHEP::HepRotation& c);
00152 
00153 #endif 
00154 
00155