CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/DetectorDescription/Algorithm/src/global_simpleAngular.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_simpleAngular.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 #include "DetectorDescription/Core/interface/DDTransform.h"
00013 //#include "CLHEP/Geometry/Transform3D.h"
00014 
00015 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00016 #include <Math/RotationZ.h>
00017                                   
00018 
00019 // always the same ctor
00020 global_simpleAngular_0::global_simpleAngular_0(AlgoPos * a,std::string label)
00021  : AlgoImpl(a,label)
00022 { }
00023 
00024 global_simpleAngular_0::~global_simpleAngular_0() 
00025 { }
00026 
00027 bool global_simpleAngular_0::checkParameters() 
00028 {
00029 /* besides the automatic generated checking for the input params, 
00030      we have to decide, whether the params are correct and should
00031      select this implementation 
00032   */
00033                   
00034   bool result = true;   
00035                   
00036   // check for presence of delta
00037   if (ParE_["delta"].size() == 0) {
00038     result = false; // don't select this implementation, because delta is missing
00039   }
00040   else {
00041     // check for valid delta-value
00042     if (ParE_["delta"][0] == 0.) {
00043       err_ += "\tdelta can not be zero\n";
00044       result = false;
00045     }
00046   }
00047 
00048   // check for presence of number
00049   if (ParE_["number"].size() != 0) {
00050 //    err_ += "\tcan not specify a delta and a number\n";
00051     result = false;
00052   }  
00053   return result;  
00054 }
00055 
00056 
00057 DDTranslation global_simpleAngular_0::translation()  
00058 {
00059   double offset  = ParE_["offset"][0]/rad;
00060   double delta   = ParE_["delta"][0]/rad;
00061   double radius  = ParE_["radius"][0];
00062 //  std::cout << "x = " << radius * cos(offset + delta * (count_ - 1)) << "  y = " << radius * sin(offset + delta * (count_ - 1)) << std::endl;
00063   DDTranslation trans(radius * cos(offset + delta * (count_ - 1)),
00064                       radius * sin(offset + delta * (count_ - 1)),
00065                       0. );
00066                  
00067   return trans;
00068 }
00069 
00070 
00071 DDRotationMatrix global_simpleAngular_0::rotation()
00072 {
00073   std::cout << "ParS_[\"rotate\"][0] = " << ParS_["rotate"][0] << std::endl; 
00074   if (ParS_["rotate"][0] == "T" || ParS_["rotate"][0] == "1"
00075       || ParS_["rotate"][0] == "True")
00076     {
00077       double angle = -(ParE_["offset"][0]/rad + (ParE_["delta"][0]/rad) * (count_ - 1));
00078       DDRotationMatrix rm1;
00079       if (ParS_["orientation"].size() != 0)
00080         {
00081           std::string name=ParS_["orientation"][0];
00082           size_t foundColon = 0;
00083           std::string rn = "";
00084           std::string ns = "";
00085           while (foundColon < name.size() && name[foundColon] != ':')
00086             ++foundColon;
00087           if (foundColon != name.size())
00088             {
00089               for (size_t j = foundColon + 1; j < name.size(); ++j)
00090                 rn = rn + name[j];
00091               for (size_t i = 0; i < foundColon; ++i)
00092                 ns = ns + name[i];
00093             }
00094           if (rn != "" && ns != "")
00095             {
00096               DDRotation myDDRotation(DDName(rn, ns));
00097               rm1 = *(myDDRotation.rotation());
00098             }
00099           else
00100             std::cout << "MAJOR PROBLEM: expected a fully qualified DDName but got :" 
00101                  << name << std::endl;
00102         }
00103       ROOT::Math::RotationZ rm(angle);
00104       rm1.Invert(); 
00105       rm.Invert();
00106       return rm * rm1;
00107     }
00108   else if (ParS_["orientation"].size() != 0)
00109     {
00110       // return the orientation matrix
00111       std::string name=ParS_["orientation"][0];
00112       size_t foundColon = 0;
00113       std::string rn = "";
00114       std::string ns = "";
00115       while (foundColon < name.size() && name[foundColon] != ':')
00116         ++foundColon;
00117       if (foundColon != name.size())
00118         {
00119           for (size_t j = foundColon + 1; j < name.size(); ++j)
00120             rn = rn + name[j];
00121           for (size_t i = 0; i < foundColon; ++i)
00122             ns = ns + name[i];
00123         }
00124       if (rn != "" && ns != "")
00125         {
00126           
00127           DDRotation myDDRotation(DDName(rn, ns));
00128           std::cout << "about to return *(myDDRotation.rotation())" << std::endl;
00129           std::cout << *myDDRotation.rotation() << std::endl;
00130           return *(myDDRotation.rotation());
00131         }
00132       else
00133         std::cout << "MAJOR PROBLEM: expected a fully qualified DDName but got " 
00134              << name << " therefore could not look up the rotation." << std::endl;
00135       return DDRotationMatrix();
00136     }
00137   else
00138     {
00139       return DDRotationMatrix(); // return identity matrix.
00140     }
00141 }   
00142 
00143 
00144 
00145 
00146 
00147 // optional, not in the XML, omitted.
00148 void global_simpleAngular_0::checkTermination()
00149 {
00150   // initially I thought of ending our rotation algorithm at the vertical
00151   // (+x), but decided it should always go full circle.
00152   //  if ((ParE_["offset"][0] + ParE_["delta"][0] * count_ / deg) > 360.)
00153   if (ParE_["delta"][0] * count_ / deg > 360.)
00154     terminate();
00155 
00156 }
00157 
00158 
00159 void global_simpleAngular_0::stream(std::ostream & os) const
00160 {
00161   os << "global_simplesimpleAngular_0::stream(): not implemented.";
00162 }
00163 
00164 
00165 
00166 
00167 // always the same ctor
00168 global_simpleAngular_1::global_simpleAngular_1(AlgoPos * a,std::string label)
00169  : AlgoImpl(a,label)
00170 { }
00171 
00172 global_simpleAngular_1::~global_simpleAngular_1() 
00173 { }
00174 
00175 bool global_simpleAngular_1::checkParameters() 
00176 {
00177   bool result = true;   
00178                   
00179   // check for delta 
00180   if (ParE_["number"].size() == 0) {
00181     result = false; // don't select this implementation, because number is missing
00182   }               
00183   else {
00184     // check for valid number value
00185     if (ParE_["number"][0] == 0.) {
00186       err_ += "\tnumber must not be 0\n";
00187       result = false;
00188     }
00189   }
00190                   
00191   // check for presence of delta
00192   if (ParE_["delta"].size() != 0) {
00193 //     err_ += "\tcan not specify delta and number\n";
00194     result = false;
00195   }               
00196 
00197   return result;   
00198 }
00199 
00200 
00201 DDTranslation global_simpleAngular_1::translation()  
00202 {
00203     // we can safely fetch all parameters, because they
00204   // have been checked already ...
00205   double offset = ParE_["offset"][0];
00206   double number = ParE_["number"][0];
00207   double delta = (360.0 / number) * deg;
00208   double radius  = ParE_["radius"][0];
00209 //  std::cout << "x = " << radius * cos(offset + delta * (count_ - 1)) << "  y = " << radius * sin(offset + delta * (count_ - 1)) << std::endl;
00210   DDTranslation trans(radius * cos(offset + delta * (count_ - 1)),
00211                       radius * sin(offset + delta * (count_ - 1)),
00212                       0. );
00213    
00214   return trans;
00215 }
00216 
00217 
00218 DDRotationMatrix global_simpleAngular_1::rotation()
00219 {
00220   double number = ParE_["number"][0];
00221   double delta = (360.0 / number) * deg;
00222   if (ParS_["rotate"][0] == "T" || ParS_["rotate"][0] == "1"
00223       || ParS_["rotate"][0] == "True")
00224     {
00225       double angle = -(ParE_["offset"][0]/rad + (delta/rad) * (count_ - 1));
00226 
00227       DDRotationMatrix rm1;
00228       if (ParS_["orientation"].size() != 0)
00229         {
00230           std::string name=ParS_["orientation"][0];
00231           size_t foundColon = 0;
00232           std::string rn = "";
00233           std::string ns = "";
00234           while (foundColon < name.size() && name[foundColon] != ':')
00235             ++foundColon;
00236           if (foundColon != name.size())
00237             {
00238               for (size_t j = foundColon + 1; j < name.size(); ++j)
00239                 rn = rn + name[j];
00240               for (size_t i = 0; i < foundColon; ++i)
00241                 ns = ns + name[i];
00242             }
00243           if (rn != "" && ns != "")
00244             {
00245               DDRotation myDDRotation(DDName(rn, ns));
00246               rm1 = *(myDDRotation.rotation());
00247             }
00248           else
00249             std::cout << "MAJOR PROBLEM: expected a fully qualified DDName but got :" 
00250                  << name << " therefore could not look up the rotation." << std::endl;
00251         }
00252       ROOT::Math::RotationZ rm(angle);
00253       rm1.Invert(); 
00254       rm.Invert();
00255       return rm * rm1;
00256     }
00257   else if (ParS_["orientation"].size() != 0)
00258     {
00259       std::string name=ParS_["orientation"][0];
00260       size_t foundColon = 0;
00261       std::string rn = "";
00262       std::string ns = "";
00263       while (foundColon < name.size() && name[foundColon] != ':')
00264         ++foundColon;
00265       if (foundColon != name.size())
00266         {
00267           for (size_t j = foundColon + 1; j < name.size(); ++j)
00268             rn = rn + name[j];
00269           for (size_t i = 0; i < foundColon; ++i)
00270             ns = ns + name[i];
00271         }
00272       if (rn != "" && ns != "")
00273         {
00274           
00275           DDRotation myDDRotation(DDName(rn, ns));
00276           return *(myDDRotation.rotation());
00277         }
00278       else
00279         std::cout << "MAJOR PROBLEM: expected a fully qualified DDName but got " 
00280              << name << " therefore could not look up the rotation." << std::endl;
00281 
00282       return DDRotationMatrix();
00283     }
00284   else
00285     {
00286       return DDRotationMatrix(); // return identity matrix.
00287     }
00288 }   
00289 
00290 
00291 
00292 
00293 
00294 // optional, not in the XML, omitted.
00295 void global_simpleAngular_1::checkTermination()
00296 {
00297   //double delta = (360.0 / ParE_["number"][0]) * deg;
00298   //  if ((ParE_["offset"][0] + count_ * delta) / deg > 360.)
00299   if (count_ > ParE_["number"][0])
00300     terminate();
00301 }
00302 
00303 
00304 void global_simpleAngular_1::stream(std::ostream & os) const
00305 {
00306   os << "global_simpleAngular_0::stream(): not implemented.";
00307 }
00308 
00309 
00310 
00311 
00312 // always the same ctor
00313 global_simpleAngular_2::global_simpleAngular_2(AlgoPos * a,std::string label)
00314  : AlgoImpl(a,label)
00315 { }
00316 
00317 global_simpleAngular_2::~global_simpleAngular_2() 
00318 { }
00319 
00320 bool global_simpleAngular_2::checkParameters() 
00321 {
00322   bool result = true;
00323                   
00324   // check for delta 
00325   if (ParE_["number"].size() == 0) {
00326     result = false; // don't select this implementation, because number is missing
00327   }               
00328   else {
00329     // check for valid number value
00330     if (ParE_["number"][0] == 0.) {
00331       err_ += "\tnumber must not be 0\n";
00332       result = false;
00333     }
00334   }
00335                   
00336   // check for presence of delta
00337   if (ParE_["delta"].size() == 0) {
00338     result = false; // don't select this implementation, because delta is missing.
00339   }               
00340   else {
00341     // check for valid delta value
00342     if (ParE_["delta"][0] == 0.) {
00343       err_ += "\tdelta must not be 0\n";
00344       result = false;
00345     }
00346   }
00347 
00348   double delta = ParE_["delta"][0];
00349   double number = ParE_["number"][0];
00350   if (delta * number > 360. * deg) {
00351     err_ += "\tat this time delta * number can not be greater than 360 degrees\n";
00352     result = false;
00353   }
00354   return result;   
00355 }
00356 
00357 
00358 DDTranslation global_simpleAngular_2::translation()  
00359 {
00360     // we can safely fetch all parameters, because they
00361   // have been checked already ...
00362   double offset = ParE_["offset"][0];
00363 //  double number = ParE_["number"][0];
00364   double delta = ParE_["delta"][0];
00365   double radius  = ParE_["radius"][0];
00366 //  std::cout << "x = " << radius * cos(offset + delta * (count_ - 1)) << "  y = " << radius * sin(offset + delta * (count_ - 1)) << std::endl;
00367   DDTranslation trans(radius * cos(offset + delta * (count_ - 1)),
00368                       radius * sin(offset + delta * (count_ - 1)),
00369                       0. );
00370    
00371   return trans;
00372 }
00373 
00374 
00375 DDRotationMatrix global_simpleAngular_2::rotation()
00376 {
00377   
00378 //  double number = ParE_["number"][0];
00379   double delta = ParE_["delta"][0];
00380   if (ParS_["rotate"][0] == "T" || ParS_["rotate"][0] == "1"
00381       || ParS_["rotate"][0] == "True")
00382     {
00383       double angle = -(ParE_["offset"][0]/rad + (delta/rad) * (count_ - 1));
00384       DDRotationMatrix rm1;
00385       if (ParS_["orientation"].size() != 0)
00386         {
00387           std::string name=ParS_["orientation"][0];
00388           size_t foundColon = 0;
00389           std::string rn = "";
00390           std::string ns = "";
00391           while (foundColon < name.size() && name[foundColon] != ':')
00392             ++foundColon;
00393           if (foundColon != name.size())
00394             {
00395               for (size_t j = foundColon + 1; j < name.size(); ++j)
00396                 rn = rn + name[j];
00397               for (size_t i = 0; i < foundColon; ++i)
00398                 ns = ns + name[i];
00399             }
00400           if (rn != "" && ns != "")
00401             {
00402               DDRotation myDDRotation(DDName(rn, ns));
00403               rm1 = *(myDDRotation.rotation());
00404             }
00405           else
00406             std::cout << "MAJOR PROBLEM: expected a fully qualified DDName but got :" 
00407                  << name << std::endl;
00408         }
00409       ROOT::Math::RotationZ rm(angle);
00410       rm1.Invert(); 
00411       rm.Invert();
00412       return rm * rm1;
00413     }
00414   else if (ParS_["orientation"].size() != 0)
00415     {
00416       // return the orientation matrix
00417       std::string name=ParS_["orientation"][0];
00418       size_t foundColon = 0;
00419       std::string rn = "";
00420       std::string ns = "";
00421       while (foundColon < name.size() && name[foundColon] != ':')
00422         ++foundColon;
00423       if (foundColon != name.size())
00424         {
00425           for (size_t j = foundColon + 1; j < name.size(); ++j)
00426             rn = rn + name[j];
00427           for (size_t i = 0; i < foundColon; ++i)
00428             ns = ns + name[i];
00429         }
00430       if (rn != "" && ns != "")
00431         {
00432           
00433           DDRotation myDDRotation(DDName(rn, ns));
00434           return *(myDDRotation.rotation());
00435         }
00436       else
00437         std::cout << "MAJOR PROBLEM: expected a fully qualified DDName but got " 
00438              << name << " therefore could not look up the rotation." << std::endl;
00439       return DDRotationMatrix();
00440     }
00441   else
00442     {
00443       return DDRotationMatrix(); // return identity matrix.
00444     }
00445 }   
00446 
00447 
00448 
00449 
00450 
00451 // optional, not in the XML, omitted.
00452 void global_simpleAngular_2::checkTermination()
00453 {
00454   //double delta = (360.0 / ParE_["number"][0]) * deg;
00455   //  if ((ParE_["offset"][0] + count_ * delta) / deg > 360.)
00456   if (count_ > ParE_["number"][0])
00457     terminate();
00458 }
00459 
00460 
00461 void global_simpleAngular_2::stream(std::ostream & os) const
00462 {
00463   os << "global_simpleAngular_0::stream(): not implemented.";
00464 }
00465 
00466 
00467 /***********************************************************************************/
00468 
00469 /**************************************************************************
00470  
00471  The following Code gets only generated IF the code-generator
00472  has the capability of generating evaluation/checking code for
00473  the specification of the parameters in the algorithm XML.
00474  
00475  If the following is not generated, there will be not automatic
00476  checking of the basic properties of the user-supplied parameters
00477  (bounds, occurences, default values, ...)
00478  
00479 ***************************************************************************/
00480 
00481 // IT IS ADVISABLE TO HAVE SCHEMA VALIDATION DURING PARSING THE ALGORITHM-XML
00482 // IN ORDER TO GET DEFAULT VALUES & CONTRAINTS FOR THE PARAMTERS OF THE ALGORITHM
00483 // The code-generator has to fill data-structures containing the parameter names
00484 // and their constraints. This information is only completely available during
00485 // parsing of an algorithm-defintion-xml when schema validation is turned on.
00486 global_simpleAngular_Check::global_simpleAngular_Check()
00487 {
00488   // for the time being only expression-valued parameters can be automatically checked
00489   // against their specified constraints
00490   
00491   // schema default values will be shown if necessary in the following XML comments 
00492   // on the second line. The fist shows the values as given in the instance document
00493 
00494   // expressions have to be converted into doubles. No variables [bla] shall be allowed
00495   // inside the expressions; SystemOfUnits-symbols are the only supported ones.
00496   
00497 
00498   constraintsE_["radius"] = ConstraintE( 1,      // minOccurs
00499                                         1,      // maxOccurs
00500                                         -MAX_DOUBLE,  // min
00501                                         +MAX_DOUBLE,  // max 
00502                                         false,    // use, true=required, false=optional
00503                                         true,    // use, true=use default, false=no default
00504                                         0.0
00505                                        );
00506 
00507   constraintsE_["offset"] = ConstraintE( 1,      // minOccurs
00508                                         1,      // maxOccurs
00509                                         0.0*deg,  // min
00510                                         360.0*deg,  // max 
00511                                         false,    // use, true=required, false=optional
00512                                         true,    // use, true=use default, false=no default
00513                                         0.0
00514                                        );
00515 
00516   constraintsE_["delta"] = ConstraintE( 1,      // minOccurs
00517                                         1,      // maxOccurs
00518                                         0.0*deg,  // min
00519                                         360.0*deg,  // max 
00520                                         false,    // use, true=required, false=optional
00521                                         false,    // use, true=use default, false=no default
00522                                         0.
00523                                        );
00524 
00525   constraintsE_["number"] = ConstraintE( 1,      // minOccurs
00526                                         1,      // maxOccurs
00527                                         -MAX_DOUBLE,  // min
00528                                         +MAX_DOUBLE,  // max 
00529                                         false,    // use, true=required, false=optional
00530                                         false,    // use, true=use default, false=no default
00531                                         0.
00532                                        );
00533 
00534   constraintsE_["radius"] = ConstraintE( 1,      // minOccurs
00535                                         1,      // maxOccurs
00536                                         -MAX_DOUBLE,  // min
00537                                         +MAX_DOUBLE,  // max 
00538                                         true,    // use, true=required, false=optional
00539                                         true,    // use, true=use default, false=no default
00540                                         0.0
00541                                        );
00542 
00543   constraintsS_["rotate"] = ConstraintS( 1,      // minOccurs
00544                                         1,      // maxOccurs
00545                                         
00546                                          
00547                                         false,   // use, true=required, false=optional
00548                                         true,    // use, true=use default, false=no default
00549                                         "1"
00550                                        );
00551 
00552   constraintsS_["orientation"] = ConstraintS( 1,      // minOccurs
00553                                         1,      // maxOccurs
00554                                         
00555                                          
00556                                         false,    // use, true=required, false=optional
00557                                         false,    // use, true=use default, false=no default
00558                                         ""
00559                                        );
00560 
00561 }
00562 
00563