CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/DetectorDescription/Algorithm/src/global_linear.cc

Go to the documentation of this file.
00001 
00002 //#include "DetectorDescription/Base/interface/DDdebug.h"
00003 // GENERATED FILE. DO NOT MODIFY!
00004 #include "global_linear.h"
00005 // I tried the following on CERN lxplus and still no MAX_DOUBLE was defined.
00006 // so I tried DBL_MAX which does exist, but I do not know the source of this.
00007 // So, in keeping with everything else I saw:
00008 #define MAX_DOUBLE DBL_MAX
00009 //#include <climits>
00010 
00011 
00012 
00013 
00014                 #include <cmath>
00015                  
00016                         
00017 
00018 
00019 // always the same ctor
00020 global_linear_0::global_linear_0(AlgoPos * a,std::string label)
00021  : AlgoImpl(a,label)
00022 { }
00023 
00024 global_linear_0::~global_linear_0() 
00025 { }
00026 
00027 bool global_linear_0::checkParameters() 
00028 {
00029 
00030                   bool result = true;   
00031                   
00032                   // check for valid delta-value
00033                   if (ParE_["delta"][0] == 0.) {
00034                     err_ += "\tdelta must not be 0\n";
00035                     result = false;
00036                   }
00037                   
00038                   // check for presence of base
00039                   if (!ParE_["base"].size()) {
00040                     result = false; // don't select this implementation, because base is missing
00041                   }               
00042                   
00043                   return result;              
00044                  
00045 }
00046 
00047 
00048 DDTranslation global_linear_0::translation()  
00049 {
00050 
00051                  // we can safely fetch all parameters, because they
00052                  // have been checked already ...
00053                  double theta  = ParE_["theta"][0]/rad;
00054                  double phi    = ParE_["phi"][0]/rad;
00055                  double offset = ParE_["offset"][0];
00056                  double delta  = ParE_["delta"][0];
00057    
00058                  DDTranslation direction( sin(theta)*cos(phi),
00059                                           sin(theta)*sin(phi),
00060                                           cos(theta) );
00061                  
00062                  DDTranslation base(ParE_["base"][0],
00063                                     ParE_["base"][1],
00064                                     ParE_["base"][2]);                            
00065                             
00066                  return base + (offset + double(curr_)*delta)*direction;              
00067                  
00068 }
00069 
00070 
00071 DDRotationMatrix global_linear_0::rotation()
00072 {
00073 
00074                 return DDRotationMatrix();
00075                 
00076 }   
00077 
00078 
00079 
00080 
00081 
00082 
00083 
00084 void global_linear_0::stream(std::ostream & os) const
00085 {
00086   os << "global_linear_0::stream(): not implemented.";
00087 }
00088 
00089 
00090 
00091                 #include <cmath>
00092                  
00093                         
00094 
00095 
00096 // always the same ctor
00097 global_linear_1::global_linear_1(AlgoPos * a,std::string label)
00098  : AlgoImpl(a,label)
00099 { }
00100 
00101 global_linear_1::~global_linear_1() 
00102 { }
00103 
00104 bool global_linear_1::checkParameters() 
00105 {
00106 
00107                  /* besides the automatic generated checking for the input params, 
00108                     we have to decide, whether the params are correct and should
00109                     select this implementation 
00110                  */
00111                   
00112                   bool result = true;   
00113                   
00114                   // check for valid delta-value
00115                   if (ParE_["delta"][0] == 0.) {
00116                     err_ += "\tdelta must not be 0\n";
00117                     result = false;
00118                   }
00119                   
00120                   // check for presence of base
00121                   if (ParE_["base"].size()) {
00122                     result = false; // don't select this implementation, because base is present
00123                   }  
00124                   
00125                   return result;  
00126                     
00127 }
00128 
00129 
00130 DDTranslation global_linear_1::translation()  
00131 {
00132 
00133                  // we can safely fetch all parameters, because they
00134                  // have been checked already ...
00135                  double theta  = ParE_["theta"][0]/rad;
00136                  double phi    = ParE_["phi"][0]/rad;
00137                  double offset = ParE_["offset"][0];
00138                  double delta  = ParE_["delta"][0];
00139    
00140                  DDTranslation direction( sin(theta)*cos(phi),
00141                                           sin(theta)*sin(phi),
00142                                           cos(theta) );
00143                             
00144                  return (offset + double(curr_)*delta)*direction;
00145                 
00146 }
00147 
00148 
00149 DDRotationMatrix global_linear_1::rotation()
00150 {
00151 
00152                 // there are no rotations involved in this algorithm.
00153                 // simply returns the unit matrix.
00154                 return DDRotationMatrix();
00155                 
00156 }   
00157 
00158 
00159 
00160 
00161 
00162 
00163 
00164 void global_linear_1::stream(std::ostream & os) const
00165 {
00166   os << "global_linear_0::stream(): not implemented.";
00167 }
00168 
00169 
00170 /***********************************************************************************/
00171 
00172 /**************************************************************************
00173  
00174  The following Code gets only generated IF the code-generator
00175  has the capability of generating evaluation/checking code for
00176  the specification of the parameters in the algorithm XML.
00177  
00178  If the following is not generated, there will be not automatic
00179  checking of the basic properties of the user-supplied parameters
00180  (bounds, occurences, default values, ...)
00181  
00182 ***************************************************************************/
00183 
00184 // IT IS ADVISABLE TO HAVE SCHEMA VALIDATION DURING PARSING THE ALGORITHM-XML
00185 // IN ORDER TO GET DEFAULT VALUES & CONTRAINTS FOR THE PARAMTERS OF THE ALGORITHM
00186 // The code-generator has to fill data-structures containing the parameter names
00187 // and their constraints. This information is only completely available during
00188 // parsing of an algorithm-defintion-xml when schema validation is turned on.
00189 global_linear_Check::global_linear_Check()
00190 {
00191   // for the time being only expression-valued parameters can be automatically checked
00192   // against their specified constraints
00193   
00194   // schema default values will be shown if necessary in the following XML comments 
00195   // on the second line. The fist shows the values as given in the instance document
00196 
00197   // expressions have to be converted into doubles. No variables [bla] shall be allowed
00198   // inside the expressions; SystemOfUnits-symbols are the only supported ones.
00199   
00200 
00201   constraintsE_["theta"] = ConstraintE( 1,      // minOccurs
00202                                         1,      // maxOccurs
00203                                         0*deg,  // min
00204                                         180*deg,  // max 
00205                                         true,    // use, true=required, false=optional
00206                                         false,    // use, true=use default, false=no default
00207                                         0.
00208                                        );
00209 
00210   constraintsE_["phi"] = ConstraintE( 1,      // minOccurs
00211                                         1,      // maxOccurs
00212                                         0*deg,  // min
00213                                         360*deg,  // max 
00214                                         true,    // use, true=required, false=optional
00215                                         false,    // use, true=use default, false=no default
00216                                         0.
00217                                        );
00218 
00219   constraintsE_["delta"] = ConstraintE( 1,      // minOccurs
00220                                         1,      // maxOccurs
00221                                         -MAX_DOUBLE,  // min
00222                                         +MAX_DOUBLE,  // max 
00223                                         true,    // use, true=required, false=optional
00224                                         false,    // use, true=use default, false=no default
00225                                         0.
00226                                        );
00227 
00228   constraintsE_["offset"] = ConstraintE( 1,      // minOccurs
00229                                         1,      // maxOccurs
00230                                         -MAX_DOUBLE,  // min
00231                                         +MAX_DOUBLE,  // max 
00232                                         false,    // use, true=required, false=optional
00233                                         true,    // use, true=use default, false=no default
00234                                         0
00235                                        );
00236 
00237   constraintsE_["base"] = ConstraintE( 3,      // minOccurs
00238                                         3,      // maxOccurs
00239                                         -MAX_DOUBLE,  // min
00240                                         +MAX_DOUBLE,  // max 
00241                                         false,    // use, true=required, false=optional
00242                                         false,    // use, true=use default, false=no default
00243                                         0.
00244                                        );
00245 
00246 }
00247 
00248