CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/src/DetectorDescription/Core/interface/DDSolid.h

Go to the documentation of this file.
00001 #ifndef DDSolid_h
00002 #define DDSolid_h
00003 
00004 #include <stdexcept>
00005 #include <iosfwd>
00006 #include <vector>
00007 #include <utility>
00008 
00009 #include "DetectorDescription/Core/interface/DDName.h"
00010 #include "DetectorDescription/Core/interface/DDBase.h"
00011 #include "DetectorDescription/Core/interface/DDSolidShapes.h"
00012 #include "DetectorDescription/Core/interface/DDTransform.h"
00013 #include "DetectorDescription/Base/interface/DDTranslation.h"
00014 
00015 namespace DDI { class Solid; }
00016 namespace DDI { class Reflection; }
00017 namespace DDI { class BooleanSolid; }
00018 
00019 
00020 //class DDSolidImpl;
00021 class DDSolid;
00022 
00023 class DDSolidFactory;
00024 class DDStreamer;
00025 //class DDBooleanImpl;
00026 
00027 std::ostream & operator<<( std::ostream &, const DDSolid &);
00028 
00029 
00031 
00042 class DDSolid : public DDBase<DDName,DDI::Solid*>
00043 {
00044   friend std::ostream & operator<<(std::ostream &, const DDSolid &);
00045   friend class DDSolidFactory;
00046   friend class DDDToPersFactory;
00047   friend class DDPersToDDDFactory;
00048   friend class DDStreamer;
00049     
00050 public: 
00052   DDSolid();
00053   
00055 
00063   DDSolid(const DDName & name); 
00064   
00066 
00072 
00073   const std::vector<double> & parameters() const;// { return rep().parameters(); }
00074   
00076   double volume() const; // { return rep().volume(); }
00077   
00079   DDSolidShape shape() const; // { return rep().shape(); }
00080   
00082   //bool boolean() const; // { return rep().boolean(); }
00083   
00085 
00092   //DDSolidShape boolean( DDSolid & A, DDSolid & B, DDRotation &, DDTranslation &);
00093 
00094 /*   static void clear(); */
00095   
00096 private:
00097   DDSolid(const DDName &, DDI::Solid *);    
00098   DDSolid(const DDName &, DDSolidShape, const std::vector<double> &);
00099 };
00100 
00101   struct Composites {
00102      Composites (const DDSolid & A, const DDSolid & B,
00103                 const DDTranslation & T, const DDRotation & R)
00104                : a_(A), b_(B), t_(T), r_(R) { }
00105      const DDSolid a_, b_;
00106      const DDTranslation t_;
00107      const DDRotation r_;                
00108   }; 
00109 
00111 
00115 class DDTrap : public DDSolid
00116 {
00117 public:
00118   DDTrap(const DDSolid & s);
00120   double halfZ() const;
00122   double theta() const;
00124   double phi() const;
00126   double y1() const;
00128   double x1() const;
00130   double x2() const;
00132   double alpha1() const;
00134   double y2() const;
00136   double x3() const;
00138   double x4() const;
00140   double alpha2() const;
00141 };
00142 
00143 class DDPseudoTrap : public DDSolid
00144 {
00145 public:
00146    DDPseudoTrap(const DDSolid & s);
00148    double halfZ() const;
00150    double x1() const;
00152    double x2() const;
00154    double y1() const;
00156    double y2() const;   
00158    double radius() const;
00160    bool atMinusZ() const;
00161 };
00162   
00164 class DDTruncTubs : public DDSolid
00165 {
00166 public:
00167   DDTruncTubs(const DDSolid & s);
00169   double zHalf() const;
00171   double rIn() const;
00173   double rOut() const;
00175   double startPhi() const;
00177   double deltaPhi() const;
00179   double cutAtStart() const;
00181   double cutAtDelta() const;
00183   bool cutInside() const;
00184 };
00185 class DDBox : public DDSolid
00186 {
00187 public:
00188   DDBox(const DDSolid & s);
00189   double halfX() const; 
00190   double halfY() const; 
00191   double halfZ() const; 
00192 private:
00193   DDBox();
00194 };
00195 
00197 class DDShapelessSolid : public DDSolid
00198 
00199 {
00200  public:
00201   DDShapelessSolid(const DDSolid & s);
00202 
00203  private:
00204   DDShapelessSolid();
00205 };
00206 
00207 class DDReflectionSolid : public DDSolid
00208 {
00209 public:
00210   DDReflectionSolid(const DDSolid & s);
00211   DDSolid unreflected() const;
00212 private:
00213   DDReflectionSolid(); 
00214   DDI::Reflection * reflected_; 
00215 }; 
00216 
00217 
00218 class DDBooleanSolid : public DDSolid
00219 {
00220 public:
00221   DDBooleanSolid(const DDSolid & s);
00222   DDSolid solidA() const;
00223   DDSolid solidB() const;
00224   DDTranslation translation() const;
00225   DDRotation rotation() const;
00226 private:
00227   DDBooleanSolid();
00228   DDI::BooleanSolid * boolean_;  
00229 };
00230 
00232 class DDPolySolid : public DDSolid
00233 {
00234  public:
00235   DDPolySolid(const DDSolid & s);
00236 
00237  protected:
00239   virtual std::vector<double> getVec(const size_t& which, const size_t& offset = 0, const size_t& nVecs = 1) const;
00240   DDPolySolid();
00241 
00242 };
00243   
00244 class DDPolycone : public DDPolySolid
00245 {
00246  public:
00247   DDPolycone(const DDSolid & s);
00248   double startPhi() const;
00249   double deltaPhi() const;
00250   std::vector<double> zVec() const;
00251   std::vector<double> rVec() const;
00252   std::vector<double> rMinVec() const;
00253   std::vector<double> rMaxVec() const;
00254 
00255  private:
00256   DDPolycone();
00257 };
00258 
00259 class DDPolyhedra : public DDPolySolid
00260 {
00261  public:
00262   DDPolyhedra(const DDSolid & s);
00263   int sides() const;
00264   double startPhi() const;
00265   double deltaPhi() const;
00266   std::vector<double> zVec() const;
00267   std::vector<double> rVec() const;
00268   std::vector<double> rMinVec() const;
00269   std::vector<double> rMaxVec() const;
00270 
00271  private:
00272   DDPolyhedra();
00273 };
00274 
00275 class DDTubs : public DDSolid
00276 {
00277  public:
00278   DDTubs(const DDSolid & s);
00279   double zhalf() const;
00280   double rIn() const;
00281   double rOut() const;
00282   double startPhi() const;
00283   double deltaPhi() const;
00284 
00285  private:
00286   DDTubs();
00287 };
00288 
00289 class DDCons : public DDSolid
00290 {
00291  public:
00292   DDCons(const DDSolid & s);
00293   double zhalf() const;
00294   double rInMinusZ() const;
00295   double rOutMinusZ() const;
00296   double rInPlusZ() const;
00297   double rOutPlusZ() const;
00298   double phiFrom() const;
00299   double deltaPhi() const;
00300 
00301  private:
00302   DDCons();
00303 };
00304 
00305 class DDTorus : public DDSolid
00306 {
00307  public:
00308   DDTorus (const DDSolid & s);
00309   double rMin() const;
00310   double rMax() const;
00311   double rTorus() const;
00312   double startPhi() const;
00313   double deltaPhi() const;
00314 
00315  private:
00316   DDTorus
00317 ();
00318 };
00319 
00320 class DDUnion : public DDBooleanSolid
00321 {
00322  public:
00323   DDUnion(const DDSolid & s);
00324   
00325  private:
00326   DDUnion();
00327 };
00328 
00329 class DDIntersection : public DDBooleanSolid
00330 {
00331  public:
00332   DDIntersection(const DDSolid & s);
00333 
00334  private:
00335   DDIntersection();
00336 };
00337 
00338 class DDSubtraction : public DDBooleanSolid
00339 {
00340  public:
00341   DDSubtraction(const DDSolid & s);
00342 
00343  private:
00344   DDSubtraction();
00345 };
00346 
00347 
00348 class DDSphere : public DDSolid
00349 {
00350  public:
00351   DDSphere(const DDSolid & s);
00352   double innerRadius() const;
00353   double outerRadius() const;
00354   double startPhi() const;
00355   double deltaPhi() const;
00356   double startTheta() const;
00357   double deltaTheta() const;
00358 
00359  private:
00360   DDSphere();
00361 };
00362 
00363 class DDOrb : public DDSolid
00364 {
00365  public:
00366   DDOrb(const DDSolid & s);
00367   double radius() const;
00368 
00369  private:
00370   DDOrb();
00371 };
00372 
00373 class DDEllipticalTube : public DDSolid
00374 {
00375  public:
00376   DDEllipticalTube(const DDSolid & s);
00377   double xSemiAxis() const;
00378   double ySemiAxis() const;
00379   double zHeight() const;
00380   
00381  private:
00382   DDEllipticalTube();
00383 };
00384 
00385 class DDEllipsoid : public DDSolid
00386 {
00387  public:
00388   DDEllipsoid(const DDSolid & s);
00389   double xSemiAxis() const;
00390   double ySemiAxis() const;
00391   double zSemiAxis() const;
00392   double zBottomCut() const;
00393   double zTopCut() const;
00394 
00395  private:
00396   DDEllipsoid();
00397 };
00398 
00399 class DDParallelepiped : public DDSolid
00400 {
00401  public:
00402   DDParallelepiped(const DDSolid & s);
00403   double xHalf() const;
00404   double yHalf() const;
00405   double zHalf() const;
00406   double alpha() const;
00407   double theta() const;
00408   double phi() const;
00409 
00410  private:
00411   DDParallelepiped();
00412 };
00413 
00414 // Solid generation function
00416 
00422 struct DDSolidFactory {
00423 
00424 
00425 static DDSolid box(const DDName & name,
00426                      double xHalf, 
00427                      double yHalf,
00428                      double zHalf);
00429 
00431 
00434 static DDSolid   polycone(const DDName & name, double startPhi, double deltaPhi,
00435                      const std::vector<double> & z,
00436                      const std::vector<double> & rmin,
00437                      const std::vector<double> & rmax);
00438 
00440 
00443 static DDSolid   polycone(const DDName & name, double startPhi, double deltaPhi,
00444                      const std::vector<double> & z,
00445                      const std::vector<double> & r);
00446 
00448 
00451 static DDSolid polyhedra(const DDName & name,
00452                      int sides,
00453                      double startPhi, double deltaPhi,
00454                      const std::vector<double> & z,
00455                      const std::vector<double> & rmin,
00456                      const std::vector<double> & rmax);
00457                      
00459 
00462 static DDSolid polyhedra(const DDName & name,
00463                      int sides,
00464                      double startPhi, double deltaPhi,
00465                      const std::vector<double> & z,
00466                      const std::vector<double> & r);
00467 
00468 static DDSolid unionSolid(const DDName & name,
00469                      const DDSolid & a,
00470                      const DDSolid & b,
00471                      const DDTranslation & t,
00472                      const DDRotation & r);
00473 
00474 static DDSolid intersection(const DDName & name,
00475                      const DDSolid & a,
00476                      const DDSolid & b,
00477                      const DDTranslation & t,
00478                      const DDRotation & r);
00479 
00480 static DDSolid subtraction(const DDName & name,
00481                      const DDSolid & a,
00482                      const DDSolid & b,
00483                      const DDTranslation & t,
00484                      const DDRotation & r);
00485 
00486 static DDSolid trap(const DDName & name,
00487                      double pDz,
00488                      double pTheta, double pPhi,
00489                      double pDy1, double pDx1, double pDx2,
00490                      double pAlp1,
00491                      double pDy2, double pDx3, double pDx4,
00492                      double pAlp2);                                  
00493 
00494 static DDSolid pseudoTrap(const DDName & name,
00495                           double pDx1, 
00496                              double pDx2, 
00497                              double pDy1, 
00498                              double pDy2, 
00499                              double pDz, 
00500                              double radius, 
00501                              bool atMinusZ 
00502                              );
00503 
00504 static DDSolid truncTubs(const DDName & name,
00505                                   double zHalf, 
00506                                   double rIn, 
00507                                   double rOut, 
00508                                   double startPhi, 
00509                                   double deltaPhi, 
00510                                   double cutAtStart, 
00511                                   double cutAtDelta, 
00512                                   bool cutInside);
00513 
00514 static DDSolid tubs(const DDName & name,
00515                      double zhalf,
00516                      double rIn, double rOut,                 
00517                      double startPhi, 
00518                      double deltaPhi);
00519 
00520 static DDSolid cons(const DDName & name,
00521                      double zhalf,
00522                      double rInMinusZ,                
00523                      double rOutMinusZ,
00524                      double rInPlusZ,
00525                      double rOutPlusZ,
00526                      double phiFrom,
00527                      double deltaPhi);
00528 
00529 static DDSolid torus(const DDName & name,
00530                      double rMin,
00531                      double rMax,
00532                      double rTorus,
00533                      double startPhi,
00534                      double deltaPhi);
00535   
00536 static DDSolid sphere(const DDName & name,
00537                      double innerRadius,
00538                      double outerRadius,                      
00539                      double startPhi,
00540                      double deltaPhi,
00541                      double startTheta,
00542                      double deltaTheta);
00543 
00544   static DDSolid orb(const DDName & name,
00545                      double radius);
00546   
00547   static DDSolid ellipticalTube(const DDName & name,
00548                                 double xSemiAxis,
00549                                 double ySemiAxis,
00550                                 double zHeight);
00551 
00552 static DDSolid ellipsoid(const DDName & name,
00553                          double  xSemiAxis,
00554                          double  ySemiAxis,
00555                          double  zSemiAxis,
00556                          double  zBottomCut=0,
00557                          double  zTopCut=0
00558                          );
00559 
00560 static DDSolid parallelepiped(const DDName & name,
00561                               double xHalf, double yHalf, double zHalf,
00562                               double alpha, double theta, double phi);
00563 
00564 
00565 static DDSolid shapeless(const DDName & name);
00566 
00567 static DDSolid reflection(const DDName & name,
00568                           const DDSolid & s);
00569 
00570 };                                                                                                  
00571                                       
00572 /* //! Creates a cone or a cone-section (refere to \b Geant4 documentation) */
00573 /* /\** The center of the cone or cone-section (for positioning) is the center of */
00574 /*     coordinates of its definition (x=y=z=0). */
00575 /* *\/     */
00576 /* DDSolid *      DDcons(const DDName & name, */
00577 /*                      double zhalf, */
00578 /*                   double rInMinusZ, */
00579 /*                   double rOutMinusZ, */
00580 /*                   double rInPlusZ, */
00581 /*                   double rOutPlusZ, */
00582 /*                   double startPhi, */
00583 /*                   double deltaPhi); */
00584 
00585 /* //! Creates a torus or a toroidal-section (refere to \b Geant4 documentation) */
00586 /* /\** The center of the torus or toroidal-section (for positioning) is the center of */
00587 /*     coordinates of its definition (x=y=z=0). */
00588 /* *\/     */
00589 /* DDSolid *      DDtorus(const DDName & name, */
00590 /*                     double rMin, */
00591 /*                     double rMax, */
00592 /*                     double rTorus, */
00593 /*                     double startPhi, */
00594 /*                     double deltaPhi); */
00595 
00596 /* //! Creates a tube or a tube-section (refere to \b Geant4 documentation) */
00597 /* /\** The center of the tube or tube-section (for positioning) is the center of */
00598 /*     coordinates of its definition (x=y=z=0). */
00599 /* *\/     */
00600 /* DDSolid *      DDtubs(const DDName & name, */
00601 /*                      double zhalf, */
00602 /*                   double rIn, double rOut,                  */
00603 /*                   double startPhi,  */
00604 /*                   double deltaPhi); */
00605                      
00606 
00607 /* //! Creates a trapezoid (refere to \b Geant3 or \b Geant4 documentation) */
00608 /* /\** The center of the tube or tube-section (for positioning) is the center of */
00609 /*     coordinates of its definition (x=y=z=0). */
00610 /* *\/     */
00611 /* DDSolid *      DDtrap(const DDName & name, */
00612 /*                      double pDz, */
00613 /*                   double pTheta, double pPhi, */
00614 /*                   double pDy1, double pDx1, double pDx2, */
00615 /*                   double pAlp1, */
00616 /*                   double pDy2, double pDx3, double pDx4, */
00617 /*                   double pAlp2); */
00618                      
00619 /* //! Creates a shapeless solid */
00620 /* /\** When used in a mother-volume this type of solid forms an assembly */
00621 /*     in the \b Geant4 sense */
00622 /* *\/     */
00623 /* DDSolid * DDshapeless(const DDName & name); */
00624 
00625 /* /\* */
00626 /* DDSolid      DDunion(const DDName & name, */
00627 /*                      const DDSolid & a = DDSolid(),  */
00628 /*                      const DDSolid & b = DDSolid() ); */
00629 /* *\/ */
00630 
00631 /* //! Creates a boolean solid - the union of 2 compound solids */
00632 /* /\** \arg \c name unique name */
00633 /*     \arg \c a first compound of the union */
00634 /*     \arg \c b second comound of the union */
00635 /*     \arg \c r relative rotation of \c b towards \c a */
00636 /*     \arg \c t relative translation of \c b towards \c a */
00637 /* *\/                                                                                                                                    */
00638 /* DDSolid *     DDunion(const DDName & name, */
00639 /*                      const DDSolid & a,  */
00640 /*                      const DDSolid & b, */
00641 /*                   const DDRotation &r =DDRotation(), */
00642 /*                   const DDTranslation &t =DDTranslation()); */
00643 
00644 /* //! Creates a boolean solid - the union of 2 compound solids */
00645 /* /\** \arg \c name unique name */
00646 /*     \arg \c a first compound of the subtraction */
00647 /*     \arg \c b second comound of the subtraction */
00648 /*     \arg \c r relative rotation of \c b towards \c a */
00649 /*     \arg \c t relative translation of \c b towards \c a */
00650 /*     \c b is subtracted from \c a . */
00651 /* *\/                                                                                                                                    */
00652 /* DDSolid *     DDsubtraction(const DDName & name, */
00653 /*                            const DDSolid & a,  */
00654 /*                            const DDSolid & b, */
00655 /*                         const DDRotation &r =DDRotation(), */
00656 /*                         const DDTranslation &t =DDTranslation());  */
00657                      
00658 /* //! Creates a boolean solid - the intersection of 2 compound solids */
00659 /* /\** \arg \c name unique name */
00660 /*     \arg \c a first compound of the intersection */
00661 /*     \arg \c b second comound of the intersection */
00662 /*     \arg \c r relative rotation of \c b towards \c a */
00663 /*     \arg \c t relative translation of \c b towards \c a */
00664 /*     The resulting solid is the common volume of \c a and \c b . */
00665 /* *\/                                                                                                                                    */
00666 /* DDSolid *     DDintersection(const DDName & name, */
00667 /*                             const DDSolid & a,  */
00668 /*                             const DDSolid & b, */
00669 /*                          const DDRotation &r =DDRotation(), */
00670 /*                          const DDTranslation &t =DDTranslation());  */
00671                      
00672 
00673 /* //! Creates a cone or a cone-section (refere to \b Geant4 documentation) */
00674 /* /\** The center of the cone or cone-section (for positioning) is the center of */
00675 /*     coordinates of its definition (x=y=z=0). */
00676 /* *\/     */
00677 /* DDSolid *      DDcons(const DDName & name, */
00678 /*                      double zhalf, */
00679 /*                   double rInMinusZ, */
00680 /*                   double rOutMinusZ, */
00681 /*                   double rInPlusZ, */
00682 /*                   double rOutPlusZ, */
00683 /*                   double startPhi, */
00684 /*                   double deltaPhi); */
00685                         
00686 #endif