CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/DetectorDescription/Algorithm/src/global_angular.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_angular.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 #include <cfloat>
00009 #define MAX_DOUBLE DBL_MAX
00010 //#include <climits>
00011 
00012 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00013 #include <Math/RotationZ.h>
00014 
00015 
00016  //your code here 
00017 
00018 
00019 // always the same ctor
00020 global_angular_0::global_angular_0(AlgoPos * a,std::string label)
00021   : AlgoImpl( a, label ),
00022     rotate_( 0 ),
00023     center_( 3 ),
00024     rotateSolid_( 0 ),
00025     alignSolid_( true ),
00026     n_( 1 ),
00027     startCopyNo_( 1 ),
00028     incrCopyNo_( 1 ),
00029     startAngle_( 0 ),
00030     rangeAngle_( 360.*deg ),
00031     radius_( 0. ),
00032     delta_( 0. )
00033 { 
00034   DCOUT('A', "Creating angular label=" << label);
00035 }
00036 
00037 global_angular_0::~global_angular_0() 
00038 { }
00039 
00040 
00041 DD3Vector fUnitVector(double theta, double phi)
00042 {
00043   return DD3Vector(cos(phi)*sin(theta),
00044                      sin(phi)*sin(theta),
00045                      cos(theta));
00046 }
00047 
00048 
00049 bool global_angular_0::checkParameters() 
00050 {
00051   bool result = true;
00052   
00053   planeRot_   = DDRotationMatrix();
00054   solidRot_   = DDRotationMatrix();
00055   
00056   radius_     = ParE_["radius"][0];
00057   
00058   startAngle_ = ParE_["startAngle"][0];
00059   rangeAngle_ = ParE_["rangeAngle"][0];
00060   n_          = int(ParE_["n"][0]);
00061   startCopyNo_ = int(ParE_["startCopyNo"][0]);
00062   incrCopyNo_ = int(ParE_["incrCopyNo"][0]);
00063   
00064   if (fabs(rangeAngle_-360.0*deg)<0.001*deg) { // a full 360deg range
00065     delta_    =   rangeAngle_/double(n_);
00066   }
00067   else {
00068     if (n_ > 1) {
00069     delta_    =   rangeAngle_/double(n_-1);
00070     }
00071     else {
00072       delta_ = 0.;
00073     }
00074   }  
00075   
00076   DCOUT('a', "  startA=" << startAngle_/deg << " rangeA=" << rangeAngle_/deg <<
00077              " n=" << n_ << " delta=" << delta_/deg);
00078 
00079   //======= collect data concerning the rotation of the solid 
00080   typedef parE_type::mapped_type::size_type sz_type;
00081   sz_type sz = ParE_["rotateSolid"].size();
00082   rotateSolid_.clear();
00083   rotateSolid_.resize(sz);
00084   if (sz%3) {
00085     err_ += "\trotateSolid must occur 3*n times (defining n subsequent rotations)\n";
00086     err_ += "\t  currently it appears " + d2s(sz) + " times!\n";
00087     result = false;
00088   }
00089   for (sz_type i=0; i<sz; ++i) {
00090     rotateSolid_[i] = ParE_["rotateSolid"][i];
00091   }
00092   for (sz_type i=0; i<sz; i += 3 ) {
00093     if ( (rotateSolid_[i] > 180.*deg) || (rotateSolid_[i] < 0.) ) {
00094       err_ += "\trotateSolid \'theta\' must be in range [0,180*deg]\n";
00095       err_ += "\t  currently it is " + d2s(rotateSolid_[i]/deg) 
00096             + "*deg in rotateSolid[" + d2s(double(i)) + "]!\n";
00097       result = false;       
00098     }
00099     DDAxisAngle temp(fUnitVector(rotateSolid_[i],rotateSolid_[i+1]),
00100                      rotateSolid_[i+2]);
00101     DCOUT('a', "  rotsolid[" << i <<  "] axis=" << temp.Axis() << " rot.angle=" << temp.Angle()/deg);
00102     solidRot_ = temp*solidRot_;                   
00103   }
00104   //  DCOUT('a', "  rotsolid axis=" << solidRot_.getAxis() << " rot.angle=" << solidRot_.delta()/deg);                      
00105   
00106   
00107   //======== collect data concerning the rotation of the x-y plane
00108   sz = ParE_["rotate"].size();
00109   rotate_.clear();
00110   rotate_.resize(sz);
00111   if (sz%3) {
00112     err_ += "\trotate must occur 3*n times (defining n subsequent rotations)\n";
00113     err_ += "\t  currently it appears " + d2s(sz) + " times!\n";
00114     result = false;
00115   }
00116   for (sz_type i=0; i<sz; ++i) {
00117     rotate_[i] = ParE_["rotate"][i];
00118   }
00119   for (sz_type i=0; i<sz; i += 3 ) {
00120     if ( (rotate_[i] > 180.*deg) || (rotate_[i] < 0) ) {
00121       err_ += "\trotate \'theta\' must be in range [0,180*deg]\n";
00122       err_ += "\t  currently it is " + d2s(rotate_[i]/deg) 
00123             + "*deg in rotate[" + d2s(double(i)) + "]!\n";
00124       result = false;       
00125     }  
00126     DDAxisAngle temp(fUnitVector(rotateSolid_[i],rotateSolid_[i+1]),
00127                      rotateSolid_[i+2]);
00128     DCOUT('a', "  rotsolid[" << i <<  "] axis=" << temp.Axis() << " rot.angle=" << temp.Angle()/deg);
00129     planeRot_ =  planeRot_*temp;
00130   }
00131   //  DCOUT('a', "  rotplane axis=" << planeRot_.getAxis() << " rot.angle=" << planeRot_.delta()/deg);
00132 
00133   center_[0]      = ParE_["center"][0];
00134   center_[1]      = ParE_["center"][1];
00135   center_[2]      = ParE_["center"][2];
00136   
00137   if (ParS_["alignSolid"][0] != "T") {
00138     DCOUT('a', "  alignSolid = false");
00139     alignSolid_ = false;
00140   }
00141   else {
00142     alignSolid_ = true;
00143   }  
00144   
00145   return result;
00146 }
00147 
00148 
00149 DDTranslation global_angular_0::translation()  
00150 {
00151   double angle = startAngle_+ double(count_-1)*delta_;
00152   
00153   DD3Vector v = fUnitVector(90*deg,angle)*radius_ ;
00154   
00155   if (rotate_[2]!=0) {
00156     //v = planeRot_.inverse()*v;
00157     v = planeRot_*v;
00158   }
00159   
00160   v += DD3Vector(center_[0], center_[1], center_[2]); // offset
00161   
00162   DCOUT('A', "  angle=" << angle/deg << " translation=" << v << "  count_=" << count_);
00163   return v;
00164 }
00165 
00166 
00167 DDRotationMatrix global_angular_0::rotation()
00168 {
00169   //your code here
00170   DDRotationMatrix rot = solidRot_;
00171 
00172   if (alignSolid_) { // rotate the solid as well
00173     double angle = startAngle_+ double(count_-1)*delta_;
00174     ROOT::Math::RotationZ r2(angle);
00175     rot = r2*rot;
00176   }
00177   // DCOUT('A', "  rot.axis=" << rot.getAxis() << " rot.angle=" << rot.delta()/deg);
00178 
00179   if (rotate_[2]!=0) {
00180     rot = planeRot_*rot;
00181     //rot = rot*planeRot_.inverse();
00182     //rot = planeRot_.inverse()*rot;
00183   }
00184 
00185   return rot;
00186 }
00187 
00188 // optional, not in the XML, omitted.
00189 int global_angular_0::copyno() const
00190 {
00191   // for the moment rely on the automatic copy-number generation
00192   //  ( copy-no == invocation count count_ )
00193   int factor = AlgoImpl::copyno() - 1;
00194   return startCopyNo_ + factor*incrCopyNo_;
00195 }
00196 
00197 
00198 
00199 // optional, not in the XML, omitted.
00200 void global_angular_0::checkTermination()
00201 {
00202  if ( (n_-count_) == -1 ) terminate();
00203 }
00204 
00205 
00206 void global_angular_0::stream(std::ostream & os) const
00207 {
00208   os << "global_angular_0::stream(): not implemented.";
00209 }
00210 
00211 
00212 /***********************************************************************************/
00213 
00214 /**************************************************************************
00215  
00216  The following Code gets only generated IF the code-generator
00217  has the capability of generating evaluation/checking code for
00218  the specification of the parameters in the algorithm XML.
00219  
00220  If the following is not generated, there will be not automatic
00221  checking of the basic properties of the user-supplied parameters
00222  (bounds, occurences, default values, ...)
00223  
00224 ***************************************************************************/
00225 
00226 // IT IS ADVISABLE TO HAVE SCHEMA VALIDATION DURING PARSING THE ALGORITHM-XML
00227 // IN ORDER TO GET DEFAULT VALUES & CONTRAINTS FOR THE PARAMTERS OF THE ALGORITHM
00228 // The code-generator has to fill data-structures containing the parameter names
00229 // and their constraints. This information is only completely available during
00230 // parsing of an algorithm-defintion-xml when schema validation is turned on.
00231 global_angular_Check::global_angular_Check()
00232 {
00233   // for the time being only expression-valued parameters can be automatically checked
00234   // against their specified constraints
00235   
00236   // schema default values will be shown if necessary in the following XML comments 
00237   // on the second line. The fist shows the values as given in the instance document
00238 
00239   // expressions have to be converted into doubles. No variables [bla] shall be allowed
00240   // inside the expressions; SystemOfUnits-symbols are the only supported ones.
00241   
00242 
00243   constraintsE_["startAngle"] = ConstraintE( 1,      // minOccurs
00244                                         1,      // maxOccurs
00245                                         0.,  // min
00246                                         360.0*deg,  // max 
00247                                         false,    // use, true=required, false=optional
00248                                         true,    // use, true=use default, false=no default
00249                                         0.0
00250                                        );
00251 
00252   constraintsE_["rangeAngle"] = ConstraintE( 1,      // minOccurs
00253                                         1,      // maxOccurs
00254                                         0.,  // min
00255                                         360.0*deg,  // max 
00256                                         false,    // use, true=required, false=optional
00257                                         true,    // use, true=use default, false=no default
00258                                         360.0*deg
00259                                        );
00260 
00261   constraintsE_["n"] = ConstraintE( 1,      // minOccurs
00262                                         1,      // maxOccurs
00263                                         1,  // min
00264                                         +MAX_DOUBLE,  // max 
00265                                         false,    // use, true=required, false=optional
00266                                         true,    // use, true=use default, false=no default
00267                                         1
00268                                        );
00269   constraintsE_["startCopyNo"] = ConstraintE( 1,      // minOccurs
00270                                         1,      // maxOccurs
00271                                         -MAX_DOUBLE,  // min
00272                                         +MAX_DOUBLE,  // max 
00273                                         false,    // use, true=required, false=optional
00274                                         true,    // use, true=use default, false=no default
00275                                         1
00276                                        );
00277 
00278   constraintsE_["incrCopyNo"] = ConstraintE( 1,      // minOccurs
00279                                         1,      // maxOccurs
00280                                         -MAX_DOUBLE,  // min
00281                                         +MAX_DOUBLE,  // max 
00282                                         false,    // use, true=required, false=optional
00283                                         true,    // use, true=use default, false=no default
00284                                         1
00285                                        );
00286                                        
00287 
00288   constraintsE_["radius"] = ConstraintE( 1,      // minOccurs
00289                                         1,      // maxOccurs
00290                                         0.,  // min
00291                                         +MAX_DOUBLE,  // max 
00292                                         true,    // use, true=required, false=optional
00293                                         false,    // use, true=use default, false=no default
00294                                         2
00295                                        );
00296 
00297   constraintsS_["alignSolid"] = ConstraintS( 1,      // minOccurs
00298                                         1,      // maxOccurs
00299                                         
00300                                          
00301                                         false,    // use, true=required, false=optional
00302                                         true,    // use, true=use default, false=no default
00303                                         "T"
00304                                        );
00305 
00306   constraintsE_["center"] = ConstraintE( 3,      // minOccurs
00307                                         3,      // maxOccurs
00308                                         -MAX_DOUBLE,  // min
00309                                         +MAX_DOUBLE,  // max 
00310                                         false,    // use, true=required, false=optional
00311                                         true,    // use, true=use default, false=no default
00312                                         0.
00313                                        );
00314 
00315   constraintsE_["rotate"] = ConstraintE( 3,      // minOccurs
00316                                         9,      // maxOccurs
00317                                         -360.0*deg,  // min
00318                                         360.0*deg,  // max 
00319                                         false,    // use, true=required, false=optional
00320                                         true,    // use, true=use default, false=no default
00321                                         0.0
00322                                        );
00323 
00324   constraintsE_["rotateSolid"] = ConstraintE( 3,      // minOccurs
00325                                         9,      // maxOccurs
00326                                         -360.0*deg,  // min
00327                                         360.0*deg,  // max 
00328                                         false,    // use, true=required, false=optional
00329                                         true,    // use, true=use default, false=no default
00330                                         0.0
00331                                        );
00332 
00333 }
00334 
00335