CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/SimG4Core/Geometry/src/DDG4SolidConverter.cc

Go to the documentation of this file.
00001 #include<sstream>
00002 #include "SimG4Core/Geometry/interface/DDG4SolidConverter.h"
00003 #include "G4VSolid.hh"
00004 
00005 #include "FWCore/Utilities/interface/Exception.h"
00006 
00007 #include "DetectorDescription/Base/interface/DDException.h"
00008 #include "DetectorDescription/Core/interface/DDSolid.h"
00009 
00010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00011 
00012 using namespace std;
00013 const vector<double> * DDG4SolidConverter::par_ = 0; 
00014 
00015 DDG4SolidConverter::DDG4SolidConverter()
00016 {
00017    // could also be done 'dynamically' from outside 
00018    // would then need to have a 'register' method ...
00019   par_=0;
00020   convDispatch_[ddbox]            = DDG4SolidConverter::box; 
00021   convDispatch_[ddtubs]           = DDG4SolidConverter::tubs;
00022   convDispatch_[ddtrap]           = DDG4SolidConverter::trap;
00023   convDispatch_[ddcons]           = DDG4SolidConverter::cons;
00024   convDispatch_[ddpolycone_rrz]   = DDG4SolidConverter::polycone_rrz;
00025   convDispatch_[ddpolycone_rz]    = DDG4SolidConverter::polycone_rz;
00026   convDispatch_[ddpolyhedra_rrz]  = DDG4SolidConverter::polyhedra_rrz;
00027   convDispatch_[ddpolyhedra_rz]   = DDG4SolidConverter::polyhedra_rz;   
00028   convDispatch_[ddtorus]          = DDG4SolidConverter::torus;   
00029   convDispatch_[ddreflected]      = DDG4SolidConverter::reflected;
00030   convDispatch_[ddunion]          = DDG4SolidConverter::unionsolid;
00031   convDispatch_[ddintersection]   = DDG4SolidConverter::intersection;
00032   convDispatch_[ddsubtraction]    = DDG4SolidConverter::subtraction;
00033   convDispatch_[ddpseudotrap]     = DDG4SolidConverter::pseudotrap;
00034   convDispatch_[ddtrunctubs]      = DDG4SolidConverter::trunctubs;
00035   convDispatch_[ddsphere]         = DDG4SolidConverter::sphere;   
00036   convDispatch_[ddorb]            = DDG4SolidConverter::orb;   
00037   convDispatch_[ddellipticaltube] = DDG4SolidConverter::ellipticaltube;   
00038   convDispatch_[ddellipsoid]      = DDG4SolidConverter::ellipsoid;   
00039   convDispatch_[ddparallelepiped] = DDG4SolidConverter::para;   
00040 }
00041 
00042 
00043 DDG4SolidConverter::~DDG4SolidConverter() { }
00044 
00045 G4VSolid * DDG4SolidConverter::convert(const DDSolid & s)
00046 {
00047   if ( !s ) {
00048     edm::LogError("SimG4CoreGeometry") <<" DDG4SolidConverter::convert(..) found an undefined DDSolid " << s.toString();
00049     throw cms::Exception("SimG4CoreGeometry", "DDG4SolidConverter::convert(..) found an undefined DDSolid " + s.toString());
00050   }
00051    G4VSolid * result = 0;
00052    par_ = &(s.parameters());
00053    map<DDSolidShape,FNPTR>::iterator it = convDispatch_.find(s.shape());
00054    if (it != convDispatch_.end()) {
00055      result = it->second(s);
00056    } 
00057    else {
00058      ostringstream o; 
00059      o << "DDG4SolidConverter::convert: conversion failed for s=" << s << endl;
00060      o << " solid.shape()=" << s.shape() << endl;
00061      throw DDException(o.str());
00062    }
00063    return result;
00064 }
00065 
00066 
00067 #include "G4Box.hh"
00068 G4VSolid * DDG4SolidConverter::box(const DDSolid & s)
00069 {
00070    LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: box = " << s ;
00071    return new G4Box(s.name().name(), (*par_)[0],(*par_)[1],(*par_)[2]);
00072 }
00073 
00074 
00075 #include "G4Tubs.hh"
00076 G4VSolid * DDG4SolidConverter::tubs(const DDSolid & s)
00077 {
00078    LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: tubs = " << s ;  
00079    return new G4Tubs(s.name().name(), (*par_)[1], // rmin
00080                                (*par_)[2], // rmax
00081                                (*par_)[0], // dzHalf
00082                                (*par_)[3], // phiStart
00083                                (*par_)[4]);// deltaPhi
00084 }
00085 
00086 
00087 #include "G4Trap.hh"
00088 G4VSolid * DDG4SolidConverter::trap(const DDSolid & s)
00089 {
00090    LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: trap = " << s ;
00091    return new G4Trap(s.name().name(), (*par_)[0],  // pDz
00092                                (*par_)[1],  // theta
00093                                (*par_)[2],  // phi
00094                                (*par_)[3],  // y1
00095                                (*par_)[4],  // x1
00096                                (*par_)[5],  // x2
00097                                (*par_)[6],  // alpha1
00098                                (*par_)[7],  // y2
00099                                (*par_)[8],  // x3
00100                                (*par_)[9],  // x4
00101                                (*par_)[10]);// alpha2
00102 }
00103 
00104 
00105 #include "G4Cons.hh"
00106 G4VSolid * DDG4SolidConverter::cons(const DDSolid & s) 
00107 {
00108    LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: cons = " << s ;  
00109    return new G4Cons(s.name().name(), (*par_)[1],  // rmin -z
00110                                (*par_)[2],  // rmax -z
00111                                (*par_)[3],  // rmin +z
00112                                (*par_)[4],  // rmax +z
00113                                (*par_)[0],  // zHalf
00114                                (*par_)[5],  // phistart
00115                                (*par_)[6]); // deltaphi
00116 }
00117 
00118             
00119 #include "G4Polycone.hh"
00120 G4VSolid * DDG4SolidConverter::polycone_rz(const DDSolid & s)
00121 {
00122   LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: pcon_rz = " << s ;  
00123   vector<double> r;
00124   vector<double> z;
00125   vector<double>::const_iterator i = (*par_).begin()+2;
00126   int count=0;
00127   for(; i!=(*par_).end(); ++i) {
00128     LogDebug("SimG4CoreGeometry") << "z=" << *i ;
00129     z.push_back(*i); ++i;
00130     LogDebug("SimG4CoreGeometry") << " r=" << *i ;
00131     r.push_back(*i);
00132     count++;
00133    }
00134    LogDebug("SimG4CoreGeometry") << "sp=" << (*par_)[0]/deg << " ep=" << (*par_)[1]/deg ;
00135    return new G4Polycone(s.name().name(), (*par_)[0], (*par_)[1], // start,delta-phi
00136                          count, // numRZ
00137                          &(r[0]),
00138                          &(z[0]));
00139 }
00140 
00141 
00142 G4VSolid * DDG4SolidConverter::polycone_rrz(const DDSolid & s)
00143 {
00144     LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: pcon_rrz = " << s ;  
00145     vector<double> z_p;
00146     vector<double> rmin_p;
00147     vector<double> rmax_p;
00148     vector<double>::const_iterator i = par_->begin()+2;
00149     int count = 0;
00150     for (; i!=par_->end(); ++i) {
00151         LogDebug("SimG4CoreGeometry") << "z=" << *i ;
00152         z_p.push_back(*i); ++i;
00153         LogDebug("SimG4CoreGeometry") << "rmin=" << *i ;
00154         rmin_p.push_back(*i); ++i;
00155         LogDebug("SimG4CoreGeometry") << "rmax=" << *i ;
00156         rmax_p.push_back(*i); 
00157       count++;
00158     }
00159     LogDebug("SimG4CoreGeometry") << "sp=" << (*par_)[0]/deg << " ep=" << (*par_)[1]/deg ;
00160     return new G4Polycone(s.name().name(), (*par_)[0], (*par_)[1], // start,delta-phi
00161                         count, // sections
00162                         &(z_p[0]),
00163                         &(rmin_p[0]),
00164                         &(rmax_p[0]));
00165                         
00166 }
00167 
00168 
00169 #include "G4Polyhedra.hh"
00170 G4VSolid * DDG4SolidConverter::polyhedra_rz(const DDSolid & s)
00171 {
00172     LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: phed_rz = " << s ;  
00173     vector<double> r;
00174     vector<double> z;
00175     vector<double>::const_iterator i = par_->begin()+3;
00176     int count=0;
00177     
00178     for(; i!=par_->end(); ++i) {
00179       z.push_back(*i); ++i;
00180       r.push_back(*i);
00181       count++;
00182     }
00183       
00184     return new G4Polyhedra(s.name().name(), (*par_)[1], (*par_)[2], int((*par_)[0]),// start,delta-phi;sides
00185                            count, // numRZ
00186                            &(r[0]),
00187                            &(z[0]));
00188 }
00189 
00190 
00191 G4VSolid * DDG4SolidConverter::polyhedra_rrz(const DDSolid & s)
00192 {
00193     LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: phed_rrz = " << s ;  
00194     vector<double> z_p;
00195     vector<double> rmin_p;
00196     vector<double> rmax_p;
00197     vector<double>::const_iterator i = par_->begin()+3;
00198     int count = 0;
00199     for (; i!=par_->end(); ++i) {
00200         LogDebug("SimG4CoreGeometry") << "z=" << *i ;
00201         z_p.push_back(*i); ++i;
00202         LogDebug("SimG4CoreGeometry") << "rmin=" << *i ;
00203         rmin_p.push_back(*i); ++i;
00204         LogDebug("SimG4CoreGeometry") << "rmax=" << *i ;
00205         rmax_p.push_back(*i); 
00206       count++;
00207     }
00208     LogDebug("SimG4CoreGeometry") << "sp=" << (*par_)[0]/deg << " ep=" << (*par_)[1]/deg ;
00209     return new G4Polyhedra(s.name().name(), (*par_)[1], (*par_)[2], int((*par_)[0]), // start,delta-phi,sides
00210                            count, // sections
00211                            &(z_p[0]),
00212                            &(rmin_p[0]),
00213                            &(rmax_p[0]));  
00214 }
00215 
00216 #include "G4Torus.hh"
00217 G4VSolid * DDG4SolidConverter::torus(const DDSolid & s)
00218 {
00219    LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: torus = " << s ;  
00220    return new G4Torus(s.name().name(), (*par_)[0], // rmin
00221                                (*par_)[1], // rmax
00222                                (*par_)[2], // Rtor
00223                                (*par_)[3], // phiStart
00224                                (*par_)[4]);// deltaPhi
00225 }
00226 
00227 
00228 #include "G4ReflectedSolid.hh"
00229 G4VSolid * DDG4SolidConverter::reflected(const DDSolid & s)
00230 {
00231   LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: reflected = " << s ;  
00232   G4ReflectedSolid * rs = 0;
00233   DDReflectionSolid rfs(s); 
00234   if (rfs) {    
00235     static /* G4Transform3D */ HepGeom::ReflectZ3D z_reflection; // = HepGeom::ReflectZ3D;      
00236     rs = new G4ReflectedSolid(s.name().name(), 
00237                               DDG4SolidConverter().convert(rfs.unreflected()), 
00238                               z_reflection);
00239     
00240   } // else ?
00241   return rs;
00242 }
00243 
00244 
00245 #include "G4UnionSolid.hh"
00246 G4VSolid * DDG4SolidConverter::unionsolid(const DDSolid & s)
00247 {
00248   LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: unionsolid = " << s.name() ;
00249   G4UnionSolid * us = 0;
00250   DDBooleanSolid bs(s);
00251   if (bs) {
00252     LogDebug("SimG4CoreGeometry") << "SolidA=" << bs.solidA();
00253     G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
00254     LogDebug("SimG4CoreGeometry") << "SolidB=" << bs.solidB();
00255     G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
00256     LogDebug("SimG4CoreGeometry") << " name:" << s.name() << " t=" << bs.translation() << flush;
00257     LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << flush;
00258     std::vector<double> tdbl(9);
00259     bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
00260     CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
00261     CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z()); 
00262     us = new G4UnionSolid(s.name().name(),
00263                           sa,
00264                           sb,
00265                           new CLHEP::HepRotation(temprep),
00266                           temphvec);
00267     
00268   } // else?
00269   return us;       
00270 }
00271 
00272 
00273 #include "G4SubtractionSolid.hh"
00274 #include <sstream>
00275 G4VSolid * DDG4SolidConverter::subtraction(const DDSolid & s)
00276 {
00277   LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: subtraction = " << s ;
00278   G4SubtractionSolid * us = 0;
00279   DDBooleanSolid bs(s);
00280   if (bs) {
00281     G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
00282     G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
00283     LogDebug("SimG4CoreGeometry") << " name:" << s.name() << " t=" << bs.translation() << flush;
00284     //       stringstream sst;
00285     //       bs.rotation().rotation()->inverse().print(sst);
00286     //       LogDebug("SimG4CoreGeometry") << " " << sst.str() << flush;
00287     LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << flush;
00288     std::vector<double> tdbl(9);
00289     bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
00290     CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
00291     CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z()); 
00292     us = new G4SubtractionSolid(s.name().name(),
00293                                 sa,
00294                                 sb,
00295                                 new CLHEP::HepRotation(temprep),
00296                                 temphvec);
00297   }
00298   return us;       
00299 }
00300 
00301 
00302 #include "G4IntersectionSolid.hh"
00303 G4VSolid * DDG4SolidConverter::intersection(const DDSolid & s)
00304 {
00305   LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: intersection = " << s ;
00306   G4IntersectionSolid * us = 0;
00307   DDBooleanSolid bs(s);
00308   if (bs) {
00309     G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
00310     G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
00311     LogDebug("SimG4CoreGeometry") << " name:" << s.name() << " t=" << bs.translation() << flush;
00312     LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << flush;
00313     std::vector<double> tdbl(9);
00314     bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
00315     CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
00316     CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z()); 
00317     us = new G4IntersectionSolid(s.name().name(),
00318                                  sa,
00319                                  sb,
00320                                  new CLHEP::HepRotation(temprep),
00321                                  temphvec);
00322   }
00323   return us;       
00324 }
00325 
00326 
00327 #include "G4Trd.hh"
00328 G4VSolid * DDG4SolidConverter::pseudotrap(const DDSolid & s)
00329 {
00330   static G4RotationMatrix * rot = 0;
00331   static bool firstTime=true;
00332   if (firstTime) {
00333     firstTime=false;
00334     rot = new G4RotationMatrix;
00335     rot->rotateX(90.*deg);
00336     
00337   }
00338   LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: pseudoTrap = " << s ;
00339   G4Trd * trap = 0;
00340   G4Tubs * tubs = 0;
00341   G4VSolid * result = 0;
00342   DDPseudoTrap pt(s); // pt...PseudoTrap
00343   double r = pt.radius();
00344   bool atMinusZ = pt.atMinusZ();
00345   double x = 0;
00346   double h = 0;
00347   bool intersec = false; // union or intersection solid
00348   if (pt.atMinusZ()) {
00349     x = pt.x1(); // tubs radius
00350   } 
00351   else {
00352     x = pt.x2(); // tubs radius
00353   }
00354   double openingAngle = 2.*asin(x/abs(r));
00355   //trap = new G4Trd(s.name().name(), 
00356   double displacement=0;
00357   double startPhi=0;
00358   /* calculate the displacement of the tubs w.r.t. to the trap,
00359      determine the opening angle of the tubs */
00360   double delta = sqrt(r*r-x*x);
00361   if (r < 0 && abs(r) >= x) {
00362     intersec = true; // intersection solid
00363     h = pt.y1() < pt.y2() ? pt.y2() : pt.y1(); // tubs half height
00364     h += h/20.; // enlarge a bit - for subtraction solid
00365     if (atMinusZ) {
00366       displacement = - pt.halfZ() - delta; 
00367       startPhi = 270.*deg - openingAngle/2.;
00368     }
00369     else {
00370       displacement =   pt.halfZ() + delta;
00371       startPhi = 90.*deg - openingAngle/2.;
00372     }
00373   }
00374   else if ( r > 0 && abs(r) >= x )
00375     {
00376       if (atMinusZ) {
00377         displacement = - pt.halfZ() + delta;
00378         startPhi = 90.*deg - openingAngle/2.;
00379         h = pt.y1();
00380       }
00381       else {
00382         displacement =   pt.halfZ() - delta; 
00383         startPhi = 270.*deg - openingAngle/2.;
00384         h = pt.y2();
00385       }    
00386     }
00387   else {
00388     throw DDException("Check parameters of the PseudoTrap! name=" + pt.name().name());   
00389   }
00390   G4ThreeVector displ(0.,0.,displacement); // displacement of the tubs w.r.t. trap
00391   LogDebug("SimG4CoreGeometry") << "DDSolidConverter::pseudotrap(): displacement=" << displacement 
00392                                 << " openingAngle=" << openingAngle/deg << " x=" << x << " h=" << h;
00393     
00394   // Now create two solids (trd & tubs), and a boolean solid out of them 
00395   string name=pt.name().name();
00396   trap = new G4Trd(name, pt.x1(), pt.x2(), pt.y1(), pt.y2(), pt.halfZ());
00397   tubs = new G4Tubs(name, 
00398                     0., // rMin
00399                     abs(r), // rMax
00400                     h, // half height
00401                     startPhi, // start angle
00402                     openingAngle);
00403   if (intersec) {
00404     result = new G4SubtractionSolid(name, trap, tubs, rot, displ);
00405   }
00406   else {
00408     G4VSolid * tubicCap = new G4SubtractionSolid(name, 
00409                                                  tubs, 
00410                                                  new G4Box(name, 1.1*x, sqrt(r*r-x*x), 1.1*h),  
00411                                                  0, 
00412                                                  G4ThreeVector());
00413     result = new G4UnionSolid(name, trap, tubicCap, rot, displ);
00414             
00415     // approximative implementation - also fails to visualize due to G4/Iguana limitations
00416     /*
00417       delete tubs;
00418       tubs = new G4Tubs(name, 
00419       sqrt(r*r-x*x), // rMin-approximation!
00420       abs(r), // rMax
00421       h, // half height
00422       startPhi, // start angle
00423       openingAngle);
00424       result = new G4UnionSolid(name, trap, tubs, rot, displ);
00425     */
00426   }                                
00427   return result;
00428 }
00429 
00430 
00431 G4VSolid * DDG4SolidConverter::trunctubs(const DDSolid & s)
00432 {
00433   // truncated tube-section: a boolean subtraction solid:
00434   //                         from a tube-section a box is subtracted according to the  
00435   //                         given parameters
00436   LogDebug("SimG4CoreGeometry") << "MantisConverter: solidshape=" << DDSolidShapesName::name(s.shape()) << " " << s;
00437   LogDebug("SimG4CoreGeometry") << "before";
00438   DDTruncTubs tt(s);
00439   LogDebug("SimG4CoreGeometry") << "after";
00440   double rIn(tt.rIn()), rOut(tt.rOut()), zHalf(tt.zHalf()),
00441     startPhi(tt.startPhi()), deltaPhi(tt.deltaPhi()), 
00442     cutAtStart(tt.cutAtStart()), cutAtDelta(tt.cutAtDelta());
00443   bool cutInside(bool(tt.cutInside()));
00444   string name=tt.name().name();
00445 
00446   // check the parameters
00447   if (rIn <= 0 || rOut <=0 || cutAtStart <=0 || cutAtDelta <= 0) {
00448     string s = "TruncTubs " + string(tt.name().fullname()) + ": 0 <= rIn,cutAtStart,rOut,cutAtDelta,rOut violated!";
00449     throw DDException(s);
00450   }
00451   if (rIn >= rOut) {
00452     string s = "TruncTubs " + string(tt.name().fullname()) + ": rIn<rOut violated!";
00453     throw DDException(s);
00454   }
00455   if (startPhi != 0.) {
00456     string s= "TruncTubs " + string(tt.name().fullname()) + ": startPhi != 0 not supported!";
00457     throw DDException(s);
00458   }
00459   //     if (cutInside != false) {
00460   //       string s = "TruncTubs " + string(tt.name()) + " cutInside == true not supported!";
00461   //       throw DDException(s);
00462   //     }
00463 
00464   startPhi=0.;
00465   double r(cutAtStart), R(cutAtDelta);
00466   G4VSolid * result(0);
00467   G4VSolid * tubs = new G4Tubs(name,rIn,rOut,zHalf,startPhi,deltaPhi);
00468   LogDebug("SimG4CoreGeometry") << "G4Tubs: " << rIn << ' ' << rOut << ' ' << zHalf << ' ' << startPhi/deg << ' ' << deltaPhi/deg;
00469   LogDebug("SimG4CoreGeometry") << s;
00470   // length & hight of the box 
00471   double boxX(30.*rOut), boxY(20.*rOut); // exaggerate dimensions - does not matter, it's subtracted!
00472    
00473   // width of the box > width of the tubs
00474   double boxZ(1.1*zHalf);
00475    
00476   // angle of the box w.r.t. tubs
00477   double cath = r-R*cos(deltaPhi);
00478   double hypo = sqrt(r*r+R*R-2.*r*R*cos(deltaPhi));
00479   double cos_alpha = cath/hypo;
00480 
00481   double alpha = -acos(cos_alpha);
00482   LogDebug("SimG4CoreGeometry") << "cath=" << cath/m;
00483   LogDebug("SimG4CoreGeometry") << "hypo=" << hypo/m;
00484   LogDebug("SimG4CoreGeometry") << "al=" << acos(cath/hypo)/deg;
00485   LogDebug("SimG4CoreGeometry") << "deltaPhi=" << deltaPhi/deg << "\n"
00486                                 << "r=" << r/m << "\n"
00487                                 <<  "R=" << R/m;
00488 
00489   LogDebug("SimG4CoreGeometry") << "alpha=" << alpha/deg;
00490     
00491   // rotationmatrix of box w.r.t. tubs
00492   G4RotationMatrix * rot = new G4RotationMatrix;
00493   rot->rotateZ(-alpha);
00494   LogDebug("SimG4CoreGeometry") << (*rot);
00495 
00496   // center point of the box
00497   double xBox;
00498   if (!cutInside) {
00499     xBox = r+boxY/sin(abs(alpha));
00500   } else {
00501     xBox = -(boxY/sin(abs(alpha))-r);
00502   }
00503 
00504   G4ThreeVector trans(xBox,0.,0.);
00505   LogDebug("SimG4CoreGeometry") << "trans=" << trans;
00506 
00507   G4VSolid * box = new G4Box(name,boxX,boxY,boxZ);
00508   result = new G4SubtractionSolid(name,tubs,box,rot,trans);
00509       
00510   return result;
00511 
00512 }
00513 
00514 #include "G4Sphere.hh"
00515 G4VSolid * DDG4SolidConverter::sphere(const DDSolid & s) 
00516 {
00517    LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: sphere = " << s ;  
00518    DDSphere sp(s);
00519    return new G4Sphere(s.name().name(), sp.innerRadius(),
00520                        sp.outerRadius(),
00521                        sp.startPhi(),
00522                        sp.deltaPhi(),
00523                        sp.startTheta(),
00524                        sp.deltaTheta());
00525 }
00526 
00527 #include "G4Orb.hh"
00528 G4VSolid * DDG4SolidConverter::orb(const DDSolid & s) 
00529 {
00530    LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: orb = " << s ;  
00531    DDOrb sp(s);
00532    return new G4Orb(s.name().name(), sp.radius());
00533 }
00534 
00535 #include "G4EllipticalTube.hh"
00536 G4VSolid * DDG4SolidConverter::ellipticaltube(const DDSolid & s) 
00537 {
00538    LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: ellipticaltube = " << s ;  
00539    DDEllipticalTube sp(s);
00540    return new G4EllipticalTube(s.name().name(),
00541                                sp.xSemiAxis(),
00542                                sp.ySemiAxis(),
00543                                sp.zHeight());
00544 }
00545 
00546 #include "G4Ellipsoid.hh"
00547 G4VSolid * DDG4SolidConverter::ellipsoid(const DDSolid & s) 
00548 {
00549    LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: ellipsoid = " << s ;  
00550    DDEllipsoid sp(s);
00551    return new G4Ellipsoid(s.name().name(),
00552                           sp.xSemiAxis(),
00553                           sp.ySemiAxis(),
00554                           sp.zSemiAxis(),
00555                           sp.zBottomCut(),
00556                           sp.zTopCut());
00557 }
00558 
00559 #include "G4Para.hh"
00560 G4VSolid * DDG4SolidConverter::para(const DDSolid & s) 
00561 {
00562    LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: parallelepiped = " << s ;  
00563    DDParallelepiped sp(s);
00564    return new G4Para(s.name().name(),
00565                      sp.xHalf(),
00566                      sp.yHalf(),
00567                      sp.zHalf(),
00568                      sp.alpha(),
00569                      sp.theta(),
00570                      sp.phi());
00571 }
00572