File indexing completed on 2024-09-07 04:34:26
0001
0002
0003
0004
0005
0006
0007
0008
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
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
0042 static double getFloat(const ALIstring& str);
0043
0044 static int getInt(const ALIstring& str);
0045
0046 static bool getBool(const ALIstring& str);
0047
0048 static void dumpVS(const std::vector<ALIstring>& wl, const std::string& msg, std::ostream& outs = std::cout);
0049
0050
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
0073
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
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133 #endif