CMS 3D CMS Logo

ALIUtils.h
Go to the documentation of this file.
1 // COCOA class header file
2 //Id: ALIUtils.h
3 //CAT: Model
4 //
5 // Class with some utility function
6 //
7 // History: v1.0
8 // Pedro Arce
9 
10 #ifndef CocoaUtils_HH
11 #define CocoaUtils_HH
12 
14 
15 #include "CLHEP/Vector/ThreeVector.h"
16 #include "CLHEP/Vector/Rotation.h"
17 #include <vector>
18 #include <ctime>
19 #include <fstream>
20 #include <iostream>
21 #include <cmath>
22 
23 class ALIUtils {
24 public:
25  ALIUtils(){};
26  ~ALIUtils(){};
27 
28  static int IsNumber(const ALIstring& str);
29  static void dump3v(const CLHEP::Hep3Vector& vec, const std::string& msg);
30  static void dumprm(const CLHEP::HepRotation& rm, const std::string& msg, std::ostream& out = std::cout);
31 
32  // public static DATA MEMBERS
33  static ALIint report;
34  static ALIint debug;
35  static ALIdouble deg;
36 
37  static void setReportVerbosity(ALIint val) { report = val; }
38  static void setDebugVerbosity(ALIint val) { debug = val; }
39  static time_t time_now() { return _time_now; }
40  static void set_time_now(time_t now) { _time_now = now; }
42  static double getFloat(const ALIstring& str);
44  static int getInt(const ALIstring& str);
46  static bool getBool(const ALIstring& str);
48  static void dumpVS(const std::vector<ALIstring>& wl, const std::string& msg, std::ostream& outs = std::cout);
49 
50  //---------- Dimension factors
51  static void SetLengthDimensionFactors();
52  static void SetAngleDimensionFactors();
53  static void SetOutputLengthDimensionFactors();
54  static void SetOutputAngleDimensionFactors();
59 
60  static void dumpDimensions(std::ofstream& fout);
61 
70 
72  //-std::cout << val << " val " << ( (val <= 1.E-9) ? 0. : val) << std::endl;
73  // return (abs(val) <= 1.E-9) ? 0. : val; }
74  if (std::fabs(val) <= 1.E-9) {
75  return 0.;
76  } else {
77  return val;
78  };
79  }
80 
81  static ALIstring subQuotes(const ALIstring& str);
82 
83  static ALIdouble getDimensionValue(const ALIstring& dim, const ALIstring& dimType);
84 
85  static std::string changeName(const std::string& oldName, const std::string& subsstr1, const std::string& subsstr2);
86 
87  static ALIbool getFirstTime() { return firstTime; }
88  static void setFirstTime(ALIbool val) { firstTime = val; }
91 
92  static std::vector<double> getRotationAnglesFromMatrix(const CLHEP::HepRotation& rmLocal,
93  double origAngleX,
94  double origAngleY,
95  double origAngleZ);
96  static double diff2pi(double ang1, double ang2);
97  static bool eq2ang(double ang1, double ang2);
98  static double approxTo0(double val);
99  static double addPii(double val);
100  static int checkMatrixEquations(double angleX, double angleY, double angleZ, const CLHEP::HepRotation& rot);
101 
102 private:
111  static time_t _time_now;
112 
114 
116 };
117 
118 /*
119 template<class T>
120 ALIuint FindItemInVector( const T* item, const std::vector<T*>& item_vector )
121 {
122  std::vector<T*>::const_iterator vtcite;
123  ALIuint vfound = 1;
124  for( vtcite = item_vector.begin(); vtcite != item_vector.end(); vtcite++) {
125  if( (*vtcite) == item ) {
126  }
127  }
128 
129 }
130 */
131 //std::ostream& operator << (std::ostream& os, const CLHEP::HepRotation& c);
132 
133 #endif
static void set_time_now(time_t now)
Definition: ALIUtils.h:40
~ALIUtils()
Definition: ALIUtils.h:26
def rm(path, rec=False)
Definition: eostools.py:363
static time_t _time_now
Definition: ALIUtils.h:111
long double ALIdouble
Definition: CocoaGlobals.h:11
static ALIdouble maximum_deviation_derivative
Definition: ALIUtils.h:115
static ALIdouble _OutputLengthValueDimensionFactor
Definition: ALIUtils.h:107
static double approxTo0(double val)
Definition: ALIUtils.cc:743
static double diff2pi(double ang1, double ang2)
Definition: ALIUtils.cc:717
static bool eq2ang(double ang1, double ang2)
Definition: ALIUtils.cc:725
static std::vector< double > getRotationAnglesFromMatrix(const CLHEP::HepRotation &rmLocal, double origAngleX, double origAngleY, double origAngleZ)
Definition: ALIUtils.cc:549
ALIUtils()
Definition: ALIUtils.h:25
static void dumprm(const CLHEP::HepRotation &rm, const std::string &msg, std::ostream &out=std::cout)
Definition: ALIUtils.cc:71
static void SetOutputLengthDimensionFactors()
Definition: ALIUtils.cc:126
static ALIdouble getMaximumDeviationDerivative()
Definition: ALIUtils.h:89
int ALIint
Definition: CocoaGlobals.h:15
static ALIdouble _AngleValueDimensionFactor
Definition: ALIUtils.h:105
static ALIint debug
Definition: ALIUtils.h:34
static ALIdouble LengthSigmaDimensionFactor()
Definition: ALIUtils.h:63
static double addPii(double val)
Definition: ALIUtils.cc:751
static void setMaximumDeviationDerivative(ALIdouble val)
Definition: ALIUtils.h:90
static ALIbool firstTime
Definition: ALIUtils.h:113
static double getFloat(const ALIstring &str)
Convert a string to an float, checking that it is really a number.
Definition: ALIUtils.cc:373
bool ALIbool
Definition: CocoaGlobals.h:19
static bool getBool(const ALIstring &str)
Convert a bool to an integer, checking that it is really a bool.
Definition: ALIUtils.cc:420
static ALIdouble OutputAngleValueDimensionFactor()
Definition: ALIUtils.h:68
static ALIdouble val0(ALIdouble val)
Definition: ALIUtils.h:71
static ALIdouble _OutputAngleSigmaDimensionFactor
Definition: ALIUtils.h:110
static ALIdouble _AngleSigmaDimensionFactor
Definition: ALIUtils.h:106
static ALIdouble CalculateAngleDimensionFactorFromString(ALIstring dimstr)
Definition: ALIUtils.cc:218
static ALIdouble CalculateLengthDimensionFactorFromInt(ALIint ad)
Definition: ALIUtils.cc:242
static int IsNumber(const ALIstring &str)
Definition: ALIUtils.cc:33
static ALIdouble OutputAngleSigmaDimensionFactor()
Definition: ALIUtils.h:69
static void setFirstTime(ALIbool val)
Definition: ALIUtils.h:88
static int checkMatrixEquations(double angleX, double angleY, double angleZ, const CLHEP::HepRotation &rot)
Definition: ALIUtils.cc:762
static ALIdouble CalculateLengthDimensionFactorFromString(ALIstring dimstr)
Definition: ALIUtils.cc:179
static void SetAngleDimensionFactors()
Definition: ALIUtils.cc:104
static void SetOutputAngleDimensionFactors()
Definition: ALIUtils.cc:153
static ALIdouble deg
Definition: ALIUtils.h:35
static ALIdouble AngleSigmaDimensionFactor()
Definition: ALIUtils.h:65
static void dump3v(const CLHEP::Hep3Vector &vec, const std::string &msg)
Definition: ALIUtils.cc:58
static void SetLengthDimensionFactors()
Definition: ALIUtils.cc:81
static ALIint report
Definition: ALIUtils.h:33
static std::string changeName(const std::string &oldName, const std::string &subsstr1, const std::string &subsstr2)
Definition: ALIUtils.cc:535
static ALIdouble _LengthSigmaDimensionFactor
Definition: ALIUtils.h:104
static ALIbool getFirstTime()
Definition: ALIUtils.h:87
tuple msg
Definition: mps_check.py:286
static void dumpVS(const std::vector< ALIstring > &wl, const std::string &msg, std::ostream &outs=std::cout)
dumps a vector of strings with a message to outs
Definition: ALIUtils.cc:465
static ALIdouble getDimensionValue(const ALIstring &dim, const ALIstring &dimType)
Definition: ALIUtils.cc:477
static ALIdouble OutputLengthValueDimensionFactor()
Definition: ALIUtils.h:66
static void setDebugVerbosity(ALIint val)
Definition: ALIUtils.h:38
static ALIdouble OutputLengthSigmaDimensionFactor()
Definition: ALIUtils.h:67
std::string ALIstring
Definition: CocoaGlobals.h:9
static ALIdouble _OutputAngleValueDimensionFactor
Definition: ALIUtils.h:109
static ALIdouble AngleValueDimensionFactor()
Definition: ALIUtils.h:64
static int getInt(const ALIstring &str)
Convert a string to an integer, checking that it is really an integer.
Definition: ALIUtils.cc:384
#define str(s)
static ALIdouble _OutputLengthSigmaDimensionFactor
Definition: ALIUtils.h:108
static void setReportVerbosity(ALIint val)
Definition: ALIUtils.h:37
static void dumpDimensions(std::ofstream &fout)
Definition: ALIUtils.cc:308
static ALIstring subQuotes(const ALIstring &str)
Definition: ALIUtils.cc:439
static ALIdouble _LengthValueDimensionFactor
Definition: ALIUtils.h:103
static ALIdouble LengthValueDimensionFactor()
Definition: ALIUtils.h:62
static time_t time_now()
Definition: ALIUtils.h:39
static ALIdouble CalculateAngleDimensionFactorFromInt(ALIint ad)
Definition: ALIUtils.cc:271