CMS 3D CMS Logo

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

Generated on Tue Jun 9 17:31:49 2009 for CMSSW by  doxygen 1.5.4