Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 //   COCOA class header file

0002 //Id:  ALIUtils.h

0003 //CAT: Model

0004 //

0005 //   Class with some utility function

0006 //

0007 //   History: v1.0

0008 //   Pedro Arce

0009 
0010 #ifndef CocoaUtils_HH
0011 #define CocoaUtils_HH
0012 
0013 #include "Alignment/CocoaUtilities/interface/CocoaGlobals.h"
0014 
0015 #include "CLHEP/Vector/ThreeVector.h"
0016 #include "CLHEP/Vector/Rotation.h"
0017 #include <vector>
0018 #include <ctime>
0019 #include <fstream>
0020 #include <iostream>
0021 #include <cmath>
0022 
0023 class ALIUtils {
0024 public:
0025   ALIUtils(){};
0026   ~ALIUtils(){};
0027 
0028   static int IsNumber(const ALIstring& str);
0029   static void dump3v(const CLHEP::Hep3Vector& vec, const std::string& msg);
0030   static void dumprm(const CLHEP::HepRotation& rm, const std::string& msg, std::ostream& out = std::cout);
0031 
0032   // public static DATA MEMBERS

0033   static ALIint report;
0034   static ALIint debug;
0035   static ALIdouble deg;
0036 
0037   static void setReportVerbosity(ALIint val) { report = val; }
0038   static void setDebugVerbosity(ALIint val) { debug = val; }
0039   static time_t time_now() { return _time_now; }
0040   static void set_time_now(time_t now) { _time_now = now; }
0041   //! Convert a string to an float, checking that it is really a number

0042   static double getFloat(const ALIstring& str);
0043   //! Convert a string to an integer, checking that it is really an integer

0044   static int getInt(const ALIstring& str);
0045   //! Convert a bool to an integer, checking that it is really a bool

0046   static bool getBool(const ALIstring& str);
0047   //! dumps a vector of strings with a message to outs

0048   static void dumpVS(const std::vector<ALIstring>& wl, const std::string& msg, std::ostream& outs = std::cout);
0049 
0050   //---------- Dimension factors

0051   static void SetLengthDimensionFactors();
0052   static void SetAngleDimensionFactors();
0053   static void SetOutputLengthDimensionFactors();
0054   static void SetOutputAngleDimensionFactors();
0055   static ALIdouble CalculateLengthDimensionFactorFromInt(ALIint ad);
0056   static ALIdouble CalculateAngleDimensionFactorFromInt(ALIint ad);
0057   static ALIdouble CalculateLengthDimensionFactorFromString(ALIstring dimstr);
0058   static ALIdouble CalculateAngleDimensionFactorFromString(ALIstring dimstr);
0059 
0060   static void dumpDimensions(std::ofstream& fout);
0061 
0062   static ALIdouble LengthValueDimensionFactor() { return _LengthValueDimensionFactor; }
0063   static ALIdouble LengthSigmaDimensionFactor() { return _LengthSigmaDimensionFactor; }
0064   static ALIdouble AngleValueDimensionFactor() { return _AngleValueDimensionFactor; }
0065   static ALIdouble AngleSigmaDimensionFactor() { return _AngleSigmaDimensionFactor; }
0066   static ALIdouble OutputLengthValueDimensionFactor() { return _OutputLengthValueDimensionFactor; }
0067   static ALIdouble OutputLengthSigmaDimensionFactor() { return _OutputLengthSigmaDimensionFactor; }
0068   static ALIdouble OutputAngleValueDimensionFactor() { return _OutputAngleValueDimensionFactor; }
0069   static ALIdouble OutputAngleSigmaDimensionFactor() { return _OutputAngleSigmaDimensionFactor; }
0070 
0071   static ALIdouble val0(ALIdouble val) {
0072     //-std::cout << val << " val " << ( (val <= 1.E-9) ? 0. : val) << std::endl;

0073     //    return (abs(val) <= 1.E-9) ? 0. : val; }

0074     if (std::fabs(val) <= 1.E-9) {
0075       return 0.;
0076     } else {
0077       return val;
0078     };
0079   }
0080 
0081   static ALIstring subQuotes(const ALIstring& str);
0082 
0083   static ALIdouble getDimensionValue(const ALIstring& dim, const ALIstring& dimType);
0084 
0085   static std::string changeName(const std::string& oldName, const std::string& subsstr1, const std::string& subsstr2);
0086 
0087   static ALIbool getFirstTime() { return firstTime; }
0088   static void setFirstTime(ALIbool val) { firstTime = val; }
0089   static ALIdouble getMaximumDeviationDerivative() { return maximum_deviation_derivative; }
0090   static void setMaximumDeviationDerivative(ALIdouble val) { maximum_deviation_derivative = val; }
0091 
0092   static std::vector<double> getRotationAnglesFromMatrix(const CLHEP::HepRotation& rmLocal,
0093                                                          double origAngleX,
0094                                                          double origAngleY,
0095                                                          double origAngleZ);
0096   static double diff2pi(double ang1, double ang2);
0097   static bool eq2ang(double ang1, double ang2);
0098   static double approxTo0(double val);
0099   static double addPii(double val);
0100   static int checkMatrixEquations(double angleX, double angleY, double angleZ, const CLHEP::HepRotation& rot);
0101 
0102 private:
0103   static ALIdouble _LengthValueDimensionFactor;
0104   static ALIdouble _LengthSigmaDimensionFactor;
0105   static ALIdouble _AngleValueDimensionFactor;
0106   static ALIdouble _AngleSigmaDimensionFactor;
0107   static ALIdouble _OutputLengthValueDimensionFactor;
0108   static ALIdouble _OutputLengthSigmaDimensionFactor;
0109   static ALIdouble _OutputAngleValueDimensionFactor;
0110   static ALIdouble _OutputAngleSigmaDimensionFactor;
0111   static time_t _time_now;
0112 
0113   static ALIbool firstTime;
0114 
0115   static ALIdouble maximum_deviation_derivative;
0116 };
0117 
0118 /*

0119 template<class T>

0120 ALIuint FindItemInVector( const T* item, const std::vector<T*>& item_vector )

0121 {

0122   std::vector<T*>::const_iterator vtcite;

0123   ALIuint vfound = 1;

0124   for( vtcite = item_vector.begin(); vtcite != item_vector.end(); vtcite++) {

0125     if( (*vtcite) == item ) {

0126     }

0127   }

0128 

0129 }

0130 */
0131 //std::ostream& operator << (std::ostream& os, const CLHEP::HepRotation& c);

0132 
0133 #endif