CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/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           DDRotationMatrix rm = *(myDDRotation.rotation());
00277           return *(myDDRotation.rotation());
00278         }
00279       else
00280         std::cout << "MAJOR PROBLEM: expected a fully qualified DDName but got " 
00281              << name << " therefore could not look up the rotation." << std::endl;
00282 
00283       return DDRotationMatrix();
00284     }
00285   else
00286     {
00287       return DDRotationMatrix(); // return identity matrix.
00288     }
00289 }   
00290 
00291 
00292 
00293 
00294 
00295 // optional, not in the XML, omitted.
00296 void global_simpleAngular_1::checkTermination()
00297 {
00298   //double delta = (360.0 / ParE_["number"][0]) * deg;
00299   //  if ((ParE_["offset"][0] + count_ * delta) / deg > 360.)
00300   if (count_ > ParE_["number"][0])
00301     terminate();
00302 }
00303 
00304 
00305 void global_simpleAngular_1::stream(std::ostream & os) const
00306 {
00307   os << "global_simpleAngular_0::stream(): not implemented.";
00308 }
00309 
00310 
00311 
00312 
00313 // always the same ctor
00314 global_simpleAngular_2::global_simpleAngular_2(AlgoPos * a,std::string label)
00315  : AlgoImpl(a,label)
00316 { }
00317 
00318 global_simpleAngular_2::~global_simpleAngular_2() 
00319 { }
00320 
00321 bool global_simpleAngular_2::checkParameters() 
00322 {
00323   bool result = true;
00324                   
00325   // check for delta 
00326   if (ParE_["number"].size() == 0) {
00327     result = false; // don't select this implementation, because number is missing
00328   }               
00329   else {
00330     // check for valid number value
00331     if (ParE_["number"][0] == 0.) {
00332       err_ += "\tnumber must not be 0\n";
00333       result = false;
00334     }
00335   }
00336                   
00337   // check for presence of delta
00338   if (ParE_["delta"].size() == 0) {
00339     result = false; // don't select this implementation, because delta is missing.
00340   }               
00341   else {
00342     // check for valid delta value
00343     if (ParE_["delta"][0] == 0.) {
00344       err_ += "\tdelta must not be 0\n";
00345       result = false;
00346     }
00347   }
00348 
00349   double delta = ParE_["delta"][0];
00350   double number = ParE_["number"][0];
00351   if (delta * number > 360. * deg) {
00352     err_ += "\tat this time delta * number can not be greater than 360 degrees\n";
00353     result = false;
00354   }
00355   return result;   
00356 }
00357 
00358 
00359 DDTranslation global_simpleAngular_2::translation()  
00360 {
00361     // we can safely fetch all parameters, because they
00362   // have been checked already ...
00363   double offset = ParE_["offset"][0];
00364 //  double number = ParE_["number"][0];
00365   double delta = ParE_["delta"][0];
00366   double radius  = ParE_["radius"][0];
00367 //  std::cout << "x = " << radius * cos(offset + delta * (count_ - 1)) << "  y = " << radius * sin(offset + delta * (count_ - 1)) << std::endl;
00368   DDTranslation trans(radius * cos(offset + delta * (count_ - 1)),
00369                       radius * sin(offset + delta * (count_ - 1)),
00370                       0. );
00371    
00372   return trans;
00373 }
00374 
00375 
00376 DDRotationMatrix global_simpleAngular_2::rotation()
00377 {
00378   
00379 //  double number = ParE_["number"][0];
00380   double delta = ParE_["delta"][0];
00381   if (ParS_["rotate"][0] == "T" || ParS_["rotate"][0] == "1"
00382       || ParS_["rotate"][0] == "True")
00383     {
00384       double angle = -(ParE_["offset"][0]/rad + (delta/rad) * (count_ - 1));
00385       DDRotationMatrix rm1;
00386       if (ParS_["orientation"].size() != 0)
00387         {
00388           std::string name=ParS_["orientation"][0];
00389           size_t foundColon = 0;
00390           std::string rn = "";
00391           std::string ns = "";
00392           while (foundColon < name.size() && name[foundColon] != ':')
00393             ++foundColon;
00394           if (foundColon != name.size())
00395             {
00396               for (size_t j = foundColon + 1; j < name.size(); ++j)
00397                 rn = rn + name[j];
00398               for (size_t i = 0; i < foundColon; ++i)
00399                 ns = ns + name[i];
00400             }
00401           if (rn != "" && ns != "")
00402             {
00403               DDRotation myDDRotation(DDName(rn, ns));
00404               rm1 = *(myDDRotation.rotation());
00405             }
00406           else
00407             std::cout << "MAJOR PROBLEM: expected a fully qualified DDName but got :" 
00408                  << name << std::endl;
00409         }
00410       ROOT::Math::RotationZ rm(angle);
00411       rm1.Invert(); 
00412       rm.Invert();
00413       return rm * rm1;
00414     }
00415   else if (ParS_["orientation"].size() != 0)
00416     {
00417       // return the orientation matrix
00418       std::string name=ParS_["orientation"][0];
00419       size_t foundColon = 0;
00420       std::string rn = "";
00421       std::string ns = "";
00422       while (foundColon < name.size() && name[foundColon] != ':')
00423         ++foundColon;
00424       if (foundColon != name.size())
00425         {
00426           for (size_t j = foundColon + 1; j < name.size(); ++j)
00427             rn = rn + name[j];
00428           for (size_t i = 0; i < foundColon; ++i)
00429             ns = ns + name[i];
00430         }
00431       if (rn != "" && ns != "")
00432         {
00433           
00434           DDRotation myDDRotation(DDName(rn, ns));
00435           DDRotationMatrix rm = *(myDDRotation.rotation());
00436           return *(myDDRotation.rotation());
00437         }
00438       else
00439         std::cout << "MAJOR PROBLEM: expected a fully qualified DDName but got " 
00440              << name << " therefore could not look up the rotation." << std::endl;
00441       return DDRotationMatrix();
00442     }
00443   else
00444     {
00445       return DDRotationMatrix(); // return identity matrix.
00446     }
00447 }   
00448 
00449 
00450 
00451 
00452 
00453 // optional, not in the XML, omitted.
00454 void global_simpleAngular_2::checkTermination()
00455 {
00456   //double delta = (360.0 / ParE_["number"][0]) * deg;
00457   //  if ((ParE_["offset"][0] + count_ * delta) / deg > 360.)
00458   if (count_ > ParE_["number"][0])
00459     terminate();
00460 }
00461 
00462 
00463 void global_simpleAngular_2::stream(std::ostream & os) const
00464 {
00465   os << "global_simpleAngular_0::stream(): not implemented.";
00466 }
00467 
00468 
00469 /***********************************************************************************/
00470 
00471 /**************************************************************************
00472  
00473  The following Code gets only generated IF the code-generator
00474  has the capability of generating evaluation/checking code for
00475  the specification of the parameters in the algorithm XML.
00476  
00477  If the following is not generated, there will be not automatic
00478  checking of the basic properties of the user-supplied parameters
00479  (bounds, occurences, default values, ...)
00480  
00481 ***************************************************************************/
00482 
00483 // IT IS ADVISABLE TO HAVE SCHEMA VALIDATION DURING PARSING THE ALGORITHM-XML
00484 // IN ORDER TO GET DEFAULT VALUES & CONTRAINTS FOR THE PARAMTERS OF THE ALGORITHM
00485 // The code-generator has to fill data-structures containing the parameter names
00486 // and their constraints. This information is only completely available during
00487 // parsing of an algorithm-defintion-xml when schema validation is turned on.
00488 global_simpleAngular_Check::global_simpleAngular_Check()
00489 {
00490   // for the time being only expression-valued parameters can be automatically checked
00491   // against their specified constraints
00492   
00493   // schema default values will be shown if necessary in the following XML comments 
00494   // on the second line. The fist shows the values as given in the instance document
00495 
00496   // expressions have to be converted into doubles. No variables [bla] shall be allowed
00497   // inside the expressions; SystemOfUnits-symbols are the only supported ones.
00498   
00499 
00500   constraintsE_["radius"] = ConstraintE( 1,      // minOccurs
00501                                         1,      // maxOccurs
00502                                         -MAX_DOUBLE,  // min
00503                                         +MAX_DOUBLE,  // max 
00504                                         false,    // use, true=required, false=optional
00505                                         true,    // use, true=use default, false=no default
00506                                         0.0
00507                                        );
00508 
00509   constraintsE_["offset"] = ConstraintE( 1,      // minOccurs
00510                                         1,      // maxOccurs
00511                                         0.0*deg,  // min
00512                                         360.0*deg,  // max 
00513                                         false,    // use, true=required, false=optional
00514                                         true,    // use, true=use default, false=no default
00515                                         0.0
00516                                        );
00517 
00518   constraintsE_["delta"] = ConstraintE( 1,      // minOccurs
00519                                         1,      // maxOccurs
00520                                         0.0*deg,  // min
00521                                         360.0*deg,  // max 
00522                                         false,    // use, true=required, false=optional
00523                                         false,    // use, true=use default, false=no default
00524                                         0.
00525                                        );
00526 
00527   constraintsE_["number"] = ConstraintE( 1,      // minOccurs
00528                                         1,      // maxOccurs
00529                                         -MAX_DOUBLE,  // min
00530                                         +MAX_DOUBLE,  // max 
00531                                         false,    // use, true=required, false=optional
00532                                         false,    // use, true=use default, false=no default
00533                                         0.
00534                                        );
00535 
00536   constraintsE_["radius"] = ConstraintE( 1,      // minOccurs
00537                                         1,      // maxOccurs
00538                                         -MAX_DOUBLE,  // min
00539                                         +MAX_DOUBLE,  // max 
00540                                         true,    // use, true=required, false=optional
00541                                         true,    // use, true=use default, false=no default
00542                                         0.0
00543                                        );
00544 
00545   constraintsS_["rotate"] = ConstraintS( 1,      // minOccurs
00546                                         1,      // maxOccurs
00547                                         
00548                                          
00549                                         false,   // use, true=required, false=optional
00550                                         true,    // use, true=use default, false=no default
00551                                         "1"
00552                                        );
00553 
00554   constraintsS_["orientation"] = ConstraintS( 1,      // minOccurs
00555                                         1,      // maxOccurs
00556                                         
00557                                          
00558                                         false,    // use, true=required, false=optional
00559                                         false,    // use, true=use default, false=no default
00560                                         ""
00561                                        );
00562 
00563 }
00564 
00565