CMS 3D CMS Logo

DDG4SolidConverter Class Reference

#include <SimG4Core/Geometry/interface/DDG4SolidConverter.h>

List of all members.

Public Types

typedef G4VSolid *(* FNPTR )(const DDSolid &)

Public Member Functions

G4VSolid * convert (const DDSolid &)
 DDG4SolidConverter ()
 ~DDG4SolidConverter ()

Static Private Member Functions

static G4VSolid * box (const DDSolid &)
static G4VSolid * cons (const DDSolid &)
static G4VSolid * intersection (const DDSolid &)
static G4VSolid * polycone_rrz (const DDSolid &)
static G4VSolid * polycone_rz (const DDSolid &)
static G4VSolid * polyhedra_rrz (const DDSolid &)
static G4VSolid * polyhedra_rz (const DDSolid &)
static G4VSolid * pseudotrap (const DDSolid &)
static G4VSolid * reflected (const DDSolid &)
static G4VSolid * shapeless (const DDSolid &)
static G4VSolid * subtraction (const DDSolid &)
static G4VSolid * torus (const DDSolid &)
static G4VSolid * trap (const DDSolid &)
static G4VSolid * trunctubs (const DDSolid &)
static G4VSolid * tubs (const DDSolid &)
static G4VSolid * unionsolid (const DDSolid &)

Private Attributes

std::map< DDSolidShape, FNPTRconvDispatch_

Static Private Attributes

static const std::vector
< double > * 
par_ = 0


Detailed Description

Definition at line 12 of file DDG4SolidConverter.h.


Member Typedef Documentation

typedef G4VSolid*(* DDG4SolidConverter::FNPTR)(const DDSolid &)


Constructor & Destructor Documentation

DDG4SolidConverter::DDG4SolidConverter (  ) 

Definition at line 15 of file DDG4SolidConverter.cc.

References box(), cons(), convDispatch_, ddbox, ddcons, ddintersection, ddpolycone_rrz, ddpolycone_rz, ddpolyhedra_rrz, ddpolyhedra_rz, ddpseudotrap, ddreflected, ddsubtraction, ddtorus, ddtrap, ddtrunctubs, ddtubs, ddunion, intersection(), par_, polycone_rrz(), polycone_rz(), polyhedra_rrz(), polyhedra_rz(), pseudotrap(), reflected(), subtraction(), torus(), trap(), trunctubs(), tubs(), and unionsolid().

Referenced by intersection(), reflected(), subtraction(), and unionsolid().

DDG4SolidConverter::~DDG4SolidConverter (  ) 

Definition at line 39 of file DDG4SolidConverter.cc.

00039 { }


Member Function Documentation

G4VSolid * DDG4SolidConverter::box ( const DDSolid s  )  [static, private]

Definition at line 64 of file DDG4SolidConverter.cc.

References LogDebug, DDName::name(), and DDBase< N, C >::name().

Referenced by DDG4SolidConverter(), and trunctubs().

00065 {
00066    LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: box = " << s ;
00067    return new G4Box(s.name().name(), (*par_)[0],(*par_)[1],(*par_)[2]);
00068 }

G4VSolid * DDG4SolidConverter::cons ( const DDSolid s  )  [static, private]

Definition at line 102 of file DDG4SolidConverter.cc.

References LogDebug, DDName::name(), and DDBase< N, C >::name().

Referenced by DDG4SolidConverter().

00103 {
00104    LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: cons = " << s ;  
00105    return new G4Cons(s.name().name(), (*par_)[1],  // rmin -z
00106                                (*par_)[2],  // rmax -z
00107                                (*par_)[3],  // rmin +z
00108                                (*par_)[4],  // rmax +z
00109                                (*par_)[0],  // zHalf
00110                                (*par_)[5],  // phistart
00111                                (*par_)[6]); // deltaphi
00112 }

G4VSolid * DDG4SolidConverter::convert ( const DDSolid s  ) 

Definition at line 41 of file DDG4SolidConverter.cc.

References convDispatch_, lat::endl(), Exception, it, par_, DDSolid::parameters(), HLT_VtxMuL3::result, DDSolid::shape(), and DDBase< N, C >::toString().

Referenced by DDG4Builder::convertSolid().

00042 {
00043   if ( !s ) {
00044     edm::LogError("SimG4CoreGeometry") <<" DDG4SolidConverter::convert(..) found an undefined DDSolid " << s.toString();
00045     throw cms::Exception("SimG4CoreGeometry", "DDG4SolidConverter::convert(..) found an undefined DDSolid " + s.toString());
00046   }
00047    G4VSolid * result = 0;
00048    par_ = &(s.parameters());
00049    map<DDSolidShape,FNPTR>::iterator it = convDispatch_.find(s.shape());
00050    if (it != convDispatch_.end()) {
00051      result = it->second(s);
00052    } 
00053    else {
00054      ostringstream o; 
00055      o << "DDG4SolidConverter::convert: conversion failed for s=" << s << endl;
00056      o << " solid.shape()=" << s.shape() << endl;
00057      throw DDException(o.str());
00058    }
00059    return result;
00060 }

G4VSolid * DDG4SolidConverter::intersection ( const DDSolid s  )  [static, private]

Definition at line 304 of file DDG4SolidConverter.cc.

References DDG4SolidConverter(), flush(), LogDebug, DDName::name(), DDBase< N, C >::name(), DDRotation::rotation(), DDBooleanSolid::rotation(), DDBooleanSolid::solidA(), DDBooleanSolid::solidB(), and DDBooleanSolid::translation().

Referenced by DDG4SolidConverter().

00305 {
00306   LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: intersection = " << s ;
00307   G4IntersectionSolid * us = 0;
00308   DDBooleanSolid bs(s);
00309   if (bs) {
00310     G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
00311     G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
00312     LogDebug("SimG4CoreGeometry") << " name:" << s.name() << " t=" << bs.translation() << flush;
00313     LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << flush;
00314     std::vector<double> tdbl(9);
00315     bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
00316     HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
00317     Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z()); 
00318     us = new G4IntersectionSolid(s.name().name(),
00319                                  sa,
00320                                  sb,
00321                                  new HepRotation(temprep),
00322                                  temphvec);
00323   }
00324   return us;       
00325 }

G4VSolid * DDG4SolidConverter::polycone_rrz ( const DDSolid s  )  [static, private]

Definition at line 140 of file DDG4SolidConverter.cc.

References count, i, LogDebug, DDName::name(), DDBase< N, C >::name(), and par_.

Referenced by DDG4SolidConverter().

00141 {
00142     LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: pcon_rrz = " << s ;  
00143     vector<double>* z_p = new vector<double>;
00144     vector<double>* rmin_p = new vector<double>;
00145     vector<double>* rmax_p = new vector<double>;
00146     vector<double>::const_iterator i = par_->begin()+2;
00147     int count = 0;
00148     for (; i!=par_->end(); ++i) {
00149         LogDebug("SimG4CoreGeometry") << "z=" << *i ;
00150       (*z_p).push_back(*i); ++i;
00151         LogDebug("SimG4CoreGeometry") << "rmin=" << *i ;
00152       (*rmin_p).push_back(*i); ++i;
00153         LogDebug("SimG4CoreGeometry") << "rmax=" << *i ;
00154       (*rmax_p).push_back(*i); 
00155       count++;
00156     }
00157     LogDebug("SimG4CoreGeometry") << "sp=" << (*par_)[0]/deg << " ep=" << (*par_)[1]/deg ;
00158     return new G4Polycone(s.name().name(), (*par_)[0], (*par_)[1], // start,delta-phi
00159                         count, // sections
00160                         &((*z_p)[0]),
00161                         &((*rmin_p)[0]),
00162                         &((*rmax_p)[0]));
00163                         
00164 }

G4VSolid * DDG4SolidConverter::polycone_rz ( const DDSolid s  )  [static, private]

Definition at line 116 of file DDG4SolidConverter.cc.

References count, i, LogDebug, DDName::name(), DDBase< N, C >::name(), r, and z.

Referenced by DDG4SolidConverter().

00117 {
00118   LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: pcon_rz = " << s ;  
00119   vector<double>* r_p = new vector<double>;
00120   vector<double>* z_p = new vector<double>;
00121   vector<double>& r = *r_p;
00122   vector<double>& z = *z_p;
00123   vector<double>::const_iterator i = (*par_).begin()+2;
00124   int count=0;
00125   for(; i!=(*par_).end(); ++i) {
00126     LogDebug("SimG4CoreGeometry") << "z=" << *i ;
00127     z.push_back(*i); ++i;
00128     LogDebug("SimG4CoreGeometry") << " r=" << *i ;
00129     r.push_back(*i);
00130     count++;
00131    }
00132    LogDebug("SimG4CoreGeometry") << "sp=" << (*par_)[0]/deg << " ep=" << (*par_)[1]/deg ;
00133    return new G4Polycone(s.name().name(), (*par_)[0], (*par_)[1], // start,delta-phi
00134                                  count, // numRZ
00135                                  &(*r.begin()),
00136                                  &(*z.begin()));
00137 }

G4VSolid * DDG4SolidConverter::polyhedra_rrz ( const DDSolid s  )  [static, private]

Definition at line 191 of file DDG4SolidConverter.cc.

References count, i, int, LogDebug, DDName::name(), DDBase< N, C >::name(), and par_.

Referenced by DDG4SolidConverter().

00192 {
00193     LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: phed_rrz = " << s ;  
00194     vector<double>* z_p = new vector<double>;
00195     vector<double>* rmin_p = new vector<double>;
00196     vector<double>* rmax_p = new vector<double>;
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 }

G4VSolid * DDG4SolidConverter::polyhedra_rz ( const DDSolid s  )  [static, private]

Definition at line 168 of file DDG4SolidConverter.cc.

References count, i, int, LogDebug, DDName::name(), DDBase< N, C >::name(), par_, r, and z.

Referenced by DDG4SolidConverter().

00169 {
00170     LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: phed_rz = " << s ;  
00171     vector<double>* r_p = new vector<double>; // geant gets the memory!
00172     vector<double>* z_p = new vector<double>;
00173     vector<double>& r = *r_p;
00174     vector<double>& z = *z_p;
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.begin()),
00187                                 &(*z.begin()));
00188 }

G4VSolid * DDG4SolidConverter::pseudotrap ( const DDSolid s  )  [static, private]

correct implementation, but fails to visualize due to G4/Iguana limitations

Definition at line 329 of file DDG4SolidConverter.cc.

References funct::abs(), DDPseudoTrap::atMinusZ(), firstTime, h, DDPseudoTrap::halfZ(), LogDebug, name, DDName::name(), DDBase< N, C >::name(), r, DDPseudoTrap::radius(), HLT_VtxMuL3::result, rot, funct::sqrt(), trap(), tubs(), x, DDPseudoTrap::x1(), DDPseudoTrap::x2(), DDPseudoTrap::y1(), and DDPseudoTrap::y2().

Referenced by DDG4SolidConverter().

00330 {
00331   static G4RotationMatrix * rot = 0;
00332   static bool firstTime=true;
00333   if (firstTime) {
00334     firstTime=false;
00335     rot = new G4RotationMatrix;
00336     rot->rotateX(90.*deg);
00337     
00338   }
00339   LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: pseudoTrap = " << s ;
00340   G4Trd * trap = 0;
00341   G4Tubs * tubs = 0;
00342   G4VSolid * result = 0;
00343   DDPseudoTrap pt(s); // pt...PseudoTrap
00344   double r = pt.radius();
00345   bool atMinusZ = pt.atMinusZ();
00346   double x = 0;
00347   double h = 0;
00348   bool intersec = false; // union or intersection solid
00349   if (pt.atMinusZ()) {
00350     x = pt.x1(); // tubs radius
00351   } 
00352   else {
00353     x = pt.x2(); // tubs radius
00354   }
00355   double openingAngle = 2.*asin(x/abs(r));
00356   //trap = new G4Trd(s.name().name(), 
00357   double displacement=0;
00358   double startPhi=0;
00359   /* calculate the displacement of the tubs w.r.t. to the trap,
00360      determine the opening angle of the tubs */
00361   double delta = sqrt(r*r-x*x);
00362   if (r < 0 && abs(r) >= x) {
00363     intersec = true; // intersection solid
00364     h = pt.y1() < pt.y2() ? pt.y2() : pt.y1(); // tubs half height
00365     h += h/20.; // enlarge a bit - for subtraction solid
00366     if (atMinusZ) {
00367       displacement = - pt.halfZ() - delta; 
00368       startPhi = 270.*deg - openingAngle/2.;
00369     }
00370     else {
00371       displacement =   pt.halfZ() + delta;
00372       startPhi = 90.*deg - openingAngle/2.;
00373     }
00374   }
00375   else if ( r > 0 && abs(r) >= x )
00376     {
00377       if (atMinusZ) {
00378         displacement = - pt.halfZ() + delta;
00379         startPhi = 90.*deg - openingAngle/2.;
00380         h = pt.y1();
00381       }
00382       else {
00383         displacement =   pt.halfZ() - delta; 
00384         startPhi = 270.*deg - openingAngle/2.;
00385         h = pt.y2();
00386       }    
00387     }
00388   else {
00389     throw DDException("Check parameters of the PseudoTrap! name=" + pt.name().name());   
00390   }
00391   G4ThreeVector displ(0.,0.,displacement); // displacement of the tubs w.r.t. trap
00392   LogDebug("SimG4CoreGeometry") << "DDSolidConverter::pseudotrap(): displacement=" << displacement 
00393                                 << " openingAngle=" << openingAngle/deg << " x=" << x << " h=" << h;
00394     
00395   // Now create two solids (trd & tubs), and a boolean solid out of them 
00396   string name=pt.name().name();
00397   trap = new G4Trd(name, pt.x1(), pt.x2(), pt.y1(), pt.y2(), pt.halfZ());
00398   tubs = new G4Tubs(name, 
00399                     0., // rMin
00400                     abs(r), // rMax
00401                     h, // half height
00402                     startPhi, // start angle
00403                     openingAngle);
00404   if (intersec) {
00405     result = new G4SubtractionSolid(name, trap, tubs, rot, displ);
00406   }
00407   else {
00409     G4VSolid * tubicCap = new G4SubtractionSolid(name, 
00410                                                  tubs, 
00411                                                  new G4Box(name, 1.1*x, sqrt(r*r-x*x), 1.1*h),  
00412                                                  0, 
00413                                                  G4ThreeVector());
00414     result = new G4UnionSolid(name, trap, tubicCap, rot, displ);
00415             
00416     // approximative implementation - also fails to visualize due to G4/Iguana limitations
00417     /*
00418       delete tubs;
00419       tubs = new G4Tubs(name, 
00420       sqrt(r*r-x*x), // rMin-approximation!
00421       abs(r), // rMax
00422       h, // half height
00423       startPhi, // start angle
00424       openingAngle);
00425       result = new G4UnionSolid(name, trap, tubs, rot, displ);
00426     */
00427   }                                
00428   return result;
00429 }

G4VSolid * DDG4SolidConverter::reflected ( const DDSolid s  )  [static, private]

Definition at line 230 of file DDG4SolidConverter.cc.

References DDG4SolidConverter(), LogDebug, DDName::name(), DDBase< N, C >::name(), and DDReflectionSolid::unreflected().

Referenced by DDG4SolidConverter().

00231 {
00232   LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: reflected = " << s ;  
00233   G4ReflectedSolid * rs = 0;
00234   DDReflectionSolid rfs(s); 
00235   if (rfs) {    
00236     static /* G4Transform3D */ HepReflectZ3D z_reflection; // = HepReflectZ3D;  
00237     rs = new G4ReflectedSolid(s.name().name(), 
00238                               DDG4SolidConverter().convert(rfs.unreflected()), 
00239                               z_reflection);
00240     
00241   } // else ?
00242   return rs;
00243 }

static G4VSolid* DDG4SolidConverter::shapeless ( const DDSolid  )  [static, private]

G4VSolid * DDG4SolidConverter::subtraction ( const DDSolid s  )  [static, private]

Definition at line 276 of file DDG4SolidConverter.cc.

References DDG4SolidConverter(), flush(), LogDebug, DDName::name(), DDBase< N, C >::name(), DDRotation::rotation(), DDBooleanSolid::rotation(), DDBooleanSolid::solidA(), DDBooleanSolid::solidB(), and DDBooleanSolid::translation().

Referenced by DDG4SolidConverter().

00277 {
00278   LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: subtraction = " << s ;
00279   G4SubtractionSolid * us = 0;
00280   DDBooleanSolid bs(s);
00281   if (bs) {
00282     G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
00283     G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
00284     LogDebug("SimG4CoreGeometry") << " name:" << s.name() << " t=" << bs.translation() << flush;
00285     //       stringstream sst;
00286     //       bs.rotation().rotation()->inverse().print(sst);
00287     //       LogDebug("SimG4CoreGeometry") << " " << sst.str() << flush;
00288     LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << flush;
00289     std::vector<double> tdbl(9);
00290     bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
00291     HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
00292     Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z()); 
00293     us = new G4SubtractionSolid(s.name().name(),
00294                                 sa,
00295                                 sb,
00296                                 new HepRotation(temprep),
00297                                 temphvec);
00298   }
00299   return us;       
00300 }

G4VSolid * DDG4SolidConverter::torus ( const DDSolid s  )  [static, private]

Definition at line 218 of file DDG4SolidConverter.cc.

References LogDebug, DDName::name(), and DDBase< N, C >::name().

Referenced by DDG4SolidConverter().

00219 {
00220    LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: torus = " << s ;  
00221    return new G4Torus(s.name().name(), (*par_)[0], // rmin
00222                                (*par_)[1], // rmax
00223                                (*par_)[2], // Rtor
00224                                (*par_)[3], // phiStart
00225                                (*par_)[4]);// deltaPhi
00226 }

G4VSolid * DDG4SolidConverter::trap ( const DDSolid s  )  [static, private]

Definition at line 84 of file DDG4SolidConverter.cc.

References LogDebug, DDName::name(), and DDBase< N, C >::name().

Referenced by DDG4SolidConverter(), and pseudotrap().

00085 {
00086    LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: trap = " << s ;
00087    return new G4Trap(s.name().name(), (*par_)[0],  // pDz
00088                                (*par_)[1],  // theta
00089                                (*par_)[2],  // phi
00090                                (*par_)[3],  // y1
00091                                (*par_)[4],  // x1
00092                                (*par_)[5],  // x2
00093                                (*par_)[6],  // alpha1
00094                                (*par_)[7],  // y2
00095                                (*par_)[8],  // x3
00096                                (*par_)[9],  // x4
00097                                (*par_)[10]);// alpha2
00098 }

G4VSolid * DDG4SolidConverter::trunctubs ( const DDSolid s  )  [static, private]

Definition at line 432 of file DDG4SolidConverter.cc.

References funct::abs(), box(), funct::cos(), DDTruncTubs::cutAtDelta(), DDTruncTubs::cutAtStart(), DDTruncTubs::cutInside(), DDTruncTubs::deltaPhi(), deltaPhi(), LogDebug, m, name, DDSolidShapesName::name(), DDName::name(), DDBase< N, C >::name(), dttmaxenums::R, r, HLT_VtxMuL3::result, DDTruncTubs::rIn(), rot, DDTruncTubs::rOut(), DDSolid::shape(), funct::sin(), funct::sqrt(), DDTruncTubs::startPhi(), tt, tubs(), and DDTruncTubs::zHalf().

Referenced by DDG4SolidConverter().

00433 {
00434   // truncated tube-section: a boolean subtraction solid:
00435   //                         from a tube-section a box is subtracted according to the  
00436   //                         given parameters
00437   LogDebug("SimG4CoreGeometry") << "MantisConverter: solidshape=" << DDSolidShapesName::name(s.shape()) << " " << s;
00438   LogDebug("SimG4CoreGeometry") << "before";
00439   DDTruncTubs tt(s);
00440   LogDebug("SimG4CoreGeometry") << "after";
00441   double rIn(tt.rIn()), rOut(tt.rOut()), zHalf(tt.zHalf()),
00442     startPhi(tt.startPhi()), deltaPhi(tt.deltaPhi()), 
00443     cutAtStart(tt.cutAtStart()), cutAtDelta(tt.cutAtDelta());
00444   bool cutInside(bool(tt.cutInside()));
00445   string name=tt.name().name();
00446 
00447   // check the parameters
00448   if (rIn <= 0 || rOut <=0 || cutAtStart <=0 || cutAtDelta <= 0) {
00449     string s = "TruncTubs " + string(tt.name()) + ": 0 <= rIn,cutAtStart,rOut,cutAtDelta,rOut violated!";
00450     throw DDException(s);
00451   }
00452   if (rIn >= rOut) {
00453     string s = "TruncTubs " + string(tt.name()) + ": rIn<rOut violated!";
00454     throw DDException(s);
00455   }
00456   if (startPhi != 0.) {
00457     string s= "TruncTubs " + string(tt.name()) + ": startPhi != 0 not supported!";
00458     throw DDException(s);
00459   }
00460   //     if (cutInside != false) {
00461   //       string s = "TruncTubs " + string(tt.name()) + " cutInside == true not supported!";
00462   //       throw DDException(s);
00463   //     }
00464 
00465   startPhi=0.;
00466   double r(cutAtStart), R(cutAtDelta);
00467   G4VSolid * result(0);
00468   G4VSolid * tubs = new G4Tubs(name,rIn,rOut,zHalf,startPhi,deltaPhi);
00469   LogDebug("SimG4CoreGeometry") << "G4Tubs: " << rIn << ' ' << rOut << ' ' << zHalf << ' ' << startPhi/deg << ' ' << deltaPhi/deg;
00470   LogDebug("SimG4CoreGeometry") << s;
00471   // length & hight of the box 
00472   double boxX(30.*rOut), boxY(20.*rOut); // exaggerate dimensions - does not matter, it's subtracted!
00473    
00474   // width of the box > width of the tubs
00475   double boxZ(1.1*zHalf);
00476    
00477   // angle of the box w.r.t. tubs
00478   double cath = r-R*cos(deltaPhi);
00479   double hypo = sqrt(r*r+R*R-2.*r*R*cos(deltaPhi));
00480   double cos_alpha = cath/hypo;
00481 
00482   double alpha = -acos(cos_alpha);
00483   LogDebug("SimG4CoreGeometry") << "cath=" << cath/m;
00484   LogDebug("SimG4CoreGeometry") << "hypo=" << hypo/m;
00485   LogDebug("SimG4CoreGeometry") << "al=" << acos(cath/hypo)/deg;
00486   LogDebug("SimG4CoreGeometry") << "deltaPhi=" << deltaPhi/deg << "\n"
00487                                 << "r=" << r/m << "\n"
00488                                 <<  "R=" << R/m;
00489 
00490   LogDebug("SimG4CoreGeometry") << "alpha=" << alpha/deg;
00491     
00492   // rotationmatrix of box w.r.t. tubs
00493   G4RotationMatrix * rot = new G4RotationMatrix;
00494   rot->rotateZ(-alpha);
00495   LogDebug("SimG4CoreGeometry") << (*rot);
00496 
00497   // center point of the box
00498   double xBox;
00499   if (!cutInside) {
00500     xBox = r+boxY/sin(abs(alpha));
00501   } else {
00502     xBox = -(boxY/sin(abs(alpha))-r);
00503   }
00504 
00505   G4ThreeVector trans(xBox,0.,0.);
00506   LogDebug("SimG4CoreGeometry") << "trans=" << trans;
00507 
00508   G4VSolid * box = new G4Box(name,boxX,boxY,boxZ);
00509   result = new G4SubtractionSolid(name,tubs,box,rot,trans);
00510       
00511   return result;
00512 
00513 }

G4VSolid * DDG4SolidConverter::tubs ( const DDSolid s  )  [static, private]

Definition at line 72 of file DDG4SolidConverter.cc.

References LogDebug, DDName::name(), and DDBase< N, C >::name().

Referenced by DDG4SolidConverter(), pseudotrap(), and trunctubs().

00073 {
00074    LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: tubs = " << s ;  
00075    return new G4Tubs(s.name().name(), (*par_)[1], // rmin
00076                                (*par_)[2], // rmax
00077                                (*par_)[0], // dzHalf
00078                                (*par_)[3], // phiStart
00079                                (*par_)[4]);// deltaPhi
00080 }

G4VSolid * DDG4SolidConverter::unionsolid ( const DDSolid s  )  [static, private]

Definition at line 247 of file DDG4SolidConverter.cc.

References DDG4SolidConverter(), flush(), LogDebug, DDName::name(), DDBase< N, C >::name(), DDRotation::rotation(), DDBooleanSolid::rotation(), DDBooleanSolid::solidA(), DDBooleanSolid::solidB(), and DDBooleanSolid::translation().

Referenced by DDG4SolidConverter().

00248 {
00249   LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: unionsolid = " << s.name() ;
00250   G4UnionSolid * us = 0;
00251   DDBooleanSolid bs(s);
00252   if (bs) {
00253     LogDebug("SimG4CoreGeometry") << "SolidA=" << bs.solidA();
00254     G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
00255     LogDebug("SimG4CoreGeometry") << "SolidB=" << bs.solidB();
00256     G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
00257     LogDebug("SimG4CoreGeometry") << " name:" << s.name() << " t=" << bs.translation() << flush;
00258     LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << flush;
00259     std::vector<double> tdbl(9);
00260     bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
00261     HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
00262     Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z()); 
00263     us = new G4UnionSolid(s.name().name(),
00264                           sa,
00265                           sb,
00266                           new HepRotation(temprep),
00267                           temphvec);
00268     
00269   } // else?
00270   return us;       
00271 }


Member Data Documentation

std::map<DDSolidShape,FNPTR> DDG4SolidConverter::convDispatch_ [private]

Definition at line 39 of file DDG4SolidConverter.h.

Referenced by convert(), and DDG4SolidConverter().

const vector< double > * DDG4SolidConverter::par_ = 0 [static, private]

Definition at line 38 of file DDG4SolidConverter.h.

Referenced by convert(), DDG4SolidConverter(), polycone_rrz(), polyhedra_rrz(), and polyhedra_rz().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:17:55 2009 for CMSSW by  doxygen 1.5.4