CMS 3D CMS Logo

Public Types | Public Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes

DDG4SolidConverter Class Reference

#include <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 * ellipsoid (const DDSolid &)
static G4VSolid * ellipticaltube (const DDSolid &)
static G4VSolid * intersection (const DDSolid &)
static G4VSolid * orb (const DDSolid &)
static G4VSolid * para (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 * sphere (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 &)

Definition at line 17 of file DDG4SolidConverter.h.


Constructor & Destructor Documentation

DDG4SolidConverter::DDG4SolidConverter ( )

Definition at line 15 of file DDG4SolidConverter.cc.

References box(), cons(), ddbox, ddcons, ddellipsoid, ddellipticaltube, ddintersection, ddorb, ddparallelepiped, ddpolycone_rrz, ddpolycone_rz, ddpolyhedra_rrz, ddpolyhedra_rz, ddpseudotrap, ddreflected, ddsphere, ddsubtraction, ddtorus, ddtrap, ddtrunctubs, ddtubs, ddunion, ellipsoid(), ellipticaltube(), reco::helper::VirtualJetProducerHelper::intersection(), orb(), para(), polycone_rrz(), polycone_rz(), polyhedra_rrz(), polyhedra_rz(), pseudotrap(), reflected(), sphere(), subtraction(), torus(), trap(), trunctubs(), tubs(), and unionsolid().

DDG4SolidConverter::~DDG4SolidConverter ( )

Definition at line 43 of file DDG4SolidConverter.cc.

{ }

Member Function Documentation

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

Definition at line 68 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

{
   LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: box = " << s ;
   return new G4Box(s.name().name(), (*par_)[0],(*par_)[1],(*par_)[2]);
}
G4VSolid * DDG4SolidConverter::cons ( const DDSolid s) [static, private]

Definition at line 106 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

{
   LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: cons = " << s ;  
   return new G4Cons(s.name().name(), (*par_)[1],  // rmin -z
                               (*par_)[2],  // rmax -z
                               (*par_)[3],  // rmin +z
                               (*par_)[4],  // rmax +z
                               (*par_)[0],  // zHalf
                               (*par_)[5],  // phistart
                               (*par_)[6]); // deltaphi
}
G4VSolid * DDG4SolidConverter::convert ( const DDSolid s)

Definition at line 45 of file DDG4SolidConverter.cc.

References Exception, connectstrParser::o, DDSolid::parameters(), query::result, DDSolid::shape(), and DDBase< N, C >::toString().

Referenced by DDG4Builder::convertSolid(), intersection(), reflected(), subtraction(), and unionsolid().

{
  if ( !s ) {
    edm::LogError("SimG4CoreGeometry") <<" DDG4SolidConverter::convert(..) found an undefined DDSolid " << s.toString();
    throw cms::Exception("SimG4CoreGeometry", "DDG4SolidConverter::convert(..) found an undefined DDSolid " + s.toString());
  }
   G4VSolid * result = 0;
   par_ = &(s.parameters());
   map<DDSolidShape,FNPTR>::iterator it = convDispatch_.find(s.shape());
   if (it != convDispatch_.end()) {
     result = it->second(s);
   } 
   else {
     ostringstream o; 
     o << "DDG4SolidConverter::convert: conversion failed for s=" << s << endl;
     o << " solid.shape()=" << s.shape() << endl;
     throw DDException(o.str());
   }
   return result;
}
G4VSolid * DDG4SolidConverter::ellipsoid ( const DDSolid s) [static, private]

Definition at line 552 of file DDG4SolidConverter.cc.

References LogDebug, DDName::name(), DDBase< N, C >::name(), asciidump::s, DDEllipsoid::xSemiAxis(), DDEllipsoid::ySemiAxis(), DDEllipsoid::zBottomCut(), DDEllipsoid::zSemiAxis(), and DDEllipsoid::zTopCut().

Referenced by DDG4SolidConverter().

{
   LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: ellipsoid = " << s ;  
   DDEllipsoid sp(s);
   return new G4Ellipsoid(s.name().name(),
                          sp.xSemiAxis(),
                          sp.ySemiAxis(),
                          sp.zSemiAxis(),
                          sp.zBottomCut(),
                          sp.zTopCut());
}
G4VSolid * DDG4SolidConverter::ellipticaltube ( const DDSolid s) [static, private]

Definition at line 541 of file DDG4SolidConverter.cc.

References LogDebug, DDName::name(), DDBase< N, C >::name(), asciidump::s, DDEllipticalTube::xSemiAxis(), DDEllipticalTube::ySemiAxis(), and DDEllipticalTube::zHeight().

Referenced by DDG4SolidConverter().

{
   LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: ellipticaltube = " << s ;  
   DDEllipticalTube sp(s);
   return new G4EllipticalTube(s.name().name(),
                               sp.xSemiAxis(),
                               sp.ySemiAxis(),
                               sp.zHeight());
}
G4VSolid * DDG4SolidConverter::intersection ( const DDSolid s) [static, private]

Definition at line 308 of file DDG4SolidConverter.cc.

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

{
  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: intersection = " << s ;
  G4IntersectionSolid * us = 0;
  DDBooleanSolid bs(s);
  if (bs) {
    G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
    G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
    LogDebug("SimG4CoreGeometry") << " name:" << s.name() << " t=" << bs.translation() << flush;
    LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << flush;
    std::vector<double> tdbl(9);
    bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
    CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
    CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z()); 
    us = new G4IntersectionSolid(s.name().name(),
                                 sa,
                                 sb,
                                 new CLHEP::HepRotation(temprep),
                                 temphvec);
  }
  return us;       
}
G4VSolid * DDG4SolidConverter::orb ( const DDSolid s) [static, private]

Definition at line 533 of file DDG4SolidConverter.cc.

References LogDebug, DDName::name(), DDBase< N, C >::name(), DDOrb::radius(), and asciidump::s.

Referenced by DDG4SolidConverter().

{
   LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: orb = " << s ;  
   DDOrb sp(s);
   return new G4Orb(s.name().name(), sp.radius());
}
G4VSolid * DDG4SolidConverter::para ( const DDSolid s) [static, private]

Definition at line 565 of file DDG4SolidConverter.cc.

References DDParallelepiped::alpha(), LogDebug, DDName::name(), DDBase< N, C >::name(), DDParallelepiped::phi(), asciidump::s, DDParallelepiped::theta(), DDParallelepiped::xHalf(), DDParallelepiped::yHalf(), and DDParallelepiped::zHalf().

Referenced by DDG4SolidConverter().

{
   LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: parallelepiped = " << s ;  
   DDParallelepiped sp(s);
   return new G4Para(s.name().name(),
                     sp.xHalf(),
                     sp.yHalf(),
                     sp.zHalf(),
                     sp.alpha(),
                     sp.theta(),
                     sp.phi());
}
G4VSolid * DDG4SolidConverter::polycone_rrz ( const DDSolid s) [static, private]

Definition at line 144 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

{
    LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: pcon_rrz = " << s ;  
    vector<double>* z_p = new vector<double>;
    vector<double>* rmin_p = new vector<double>;
    vector<double>* rmax_p = new vector<double>;
    vector<double>::const_iterator i = par_->begin()+2;
    int count = 0;
    for (; i!=par_->end(); ++i) {
        LogDebug("SimG4CoreGeometry") << "z=" << *i ;
      (*z_p).push_back(*i); ++i;
        LogDebug("SimG4CoreGeometry") << "rmin=" << *i ;
      (*rmin_p).push_back(*i); ++i;
        LogDebug("SimG4CoreGeometry") << "rmax=" << *i ;
      (*rmax_p).push_back(*i); 
      count++;
    }
    LogDebug("SimG4CoreGeometry") << "sp=" << (*par_)[0]/deg << " ep=" << (*par_)[1]/deg ;
    return new G4Polycone(s.name().name(), (*par_)[0], (*par_)[1], // start,delta-phi
                        count, // sections
                        &((*z_p)[0]),
                        &((*rmin_p)[0]),
                        &((*rmax_p)[0]));
                        
}
G4VSolid * DDG4SolidConverter::polycone_rz ( const DDSolid s) [static, private]

Definition at line 120 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

{
  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: pcon_rz = " << s ;  
  vector<double>* r_p = new vector<double>;
  vector<double>* z_p = new vector<double>;
  vector<double>& r = *r_p;
  vector<double>& z = *z_p;
  vector<double>::const_iterator i = (*par_).begin()+2;
  int count=0;
  for(; i!=(*par_).end(); ++i) {
    LogDebug("SimG4CoreGeometry") << "z=" << *i ;
    z.push_back(*i); ++i;
    LogDebug("SimG4CoreGeometry") << " r=" << *i ;
    r.push_back(*i);
    count++;
   }
   LogDebug("SimG4CoreGeometry") << "sp=" << (*par_)[0]/deg << " ep=" << (*par_)[1]/deg ;
   return new G4Polycone(s.name().name(), (*par_)[0], (*par_)[1], // start,delta-phi
                                 count, // numRZ
                                 &(*r.begin()),
                                 &(*z.begin()));
}
G4VSolid * DDG4SolidConverter::polyhedra_rrz ( const DDSolid s) [static, private]

Definition at line 195 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

{
    LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: phed_rrz = " << s ;  
    vector<double>* z_p = new vector<double>;
    vector<double>* rmin_p = new vector<double>;
    vector<double>* rmax_p = new vector<double>;
    vector<double>::const_iterator i = par_->begin()+3;
    int count = 0;
    for (; i!=par_->end(); ++i) {
        LogDebug("SimG4CoreGeometry") << "z=" << *i ;
      (*z_p).push_back(*i); ++i;
        LogDebug("SimG4CoreGeometry") << "rmin=" << *i ;
      (*rmin_p).push_back(*i); ++i;
        LogDebug("SimG4CoreGeometry") << "rmax=" << *i ;
      (*rmax_p).push_back(*i); 
      count++;
    }
    LogDebug("SimG4CoreGeometry") << "sp=" << (*par_)[0]/deg << " ep=" << (*par_)[1]/deg ;
    return new G4Polyhedra(s.name().name(), (*par_)[1], (*par_)[2], int((*par_)[0]), // start,delta-phi,sides
                         count, // sections
                         &((*z_p)[0]),
                         &((*rmin_p)[0]),
                         &((*rmax_p)[0]));  
}
G4VSolid * DDG4SolidConverter::polyhedra_rz ( const DDSolid s) [static, private]

Definition at line 172 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

{
    LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: phed_rz = " << s ;  
    vector<double>* r_p = new vector<double>; // geant gets the memory!
    vector<double>* z_p = new vector<double>;
    vector<double>& r = *r_p;
    vector<double>& z = *z_p;
    vector<double>::const_iterator i = par_->begin()+3;
    int count=0;
    
    for(; i!=par_->end(); ++i) {
      z.push_back(*i); ++i;
      r.push_back(*i);
      count++;
    }
      
    return new G4Polyhedra(s.name().name(), (*par_)[1], (*par_)[2], int((*par_)[0]),// start,delta-phi;sides
                                count, // numRZ
                                &(*r.begin()),
                                &(*z.begin()));
}
G4VSolid * DDG4SolidConverter::pseudotrap ( const DDSolid s) [static, private]

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

Definition at line 333 of file DDG4SolidConverter.cc.

References abs, DDPseudoTrap::atMinusZ(), delta, firstTime, h, DDPseudoTrap::halfZ(), LogDebug, DDName::name(), DDBase< N, C >::name(), mergeVDriftHistosByStation::name, csvReporter::r, DDPseudoTrap::radius(), query::result, asciidump::s, mathSSE::sqrt(), x, DDPseudoTrap::x1(), DDPseudoTrap::x2(), DDPseudoTrap::y1(), and DDPseudoTrap::y2().

Referenced by DDG4SolidConverter().

{
  static G4RotationMatrix * rot = 0;
  static bool firstTime=true;
  if (firstTime) {
    firstTime=false;
    rot = new G4RotationMatrix;
    rot->rotateX(90.*deg);
    
  }
  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: pseudoTrap = " << s ;
  G4Trd * trap = 0;
  G4Tubs * tubs = 0;
  G4VSolid * result = 0;
  DDPseudoTrap pt(s); // pt...PseudoTrap
  double r = pt.radius();
  bool atMinusZ = pt.atMinusZ();
  double x = 0;
  double h = 0;
  bool intersec = false; // union or intersection solid
  if (pt.atMinusZ()) {
    x = pt.x1(); // tubs radius
  } 
  else {
    x = pt.x2(); // tubs radius
  }
  double openingAngle = 2.*asin(x/abs(r));
  //trap = new G4Trd(s.name().name(), 
  double displacement=0;
  double startPhi=0;
  /* calculate the displacement of the tubs w.r.t. to the trap,
     determine the opening angle of the tubs */
  double delta = sqrt(r*r-x*x);
  if (r < 0 && abs(r) >= x) {
    intersec = true; // intersection solid
    h = pt.y1() < pt.y2() ? pt.y2() : pt.y1(); // tubs half height
    h += h/20.; // enlarge a bit - for subtraction solid
    if (atMinusZ) {
      displacement = - pt.halfZ() - delta; 
      startPhi = 270.*deg - openingAngle/2.;
    }
    else {
      displacement =   pt.halfZ() + delta;
      startPhi = 90.*deg - openingAngle/2.;
    }
  }
  else if ( r > 0 && abs(r) >= x )
    {
      if (atMinusZ) {
        displacement = - pt.halfZ() + delta;
        startPhi = 90.*deg - openingAngle/2.;
        h = pt.y1();
      }
      else {
        displacement =   pt.halfZ() - delta; 
        startPhi = 270.*deg - openingAngle/2.;
        h = pt.y2();
      }    
    }
  else {
    throw DDException("Check parameters of the PseudoTrap! name=" + pt.name().name());   
  }
  G4ThreeVector displ(0.,0.,displacement); // displacement of the tubs w.r.t. trap
  LogDebug("SimG4CoreGeometry") << "DDSolidConverter::pseudotrap(): displacement=" << displacement 
                                << " openingAngle=" << openingAngle/deg << " x=" << x << " h=" << h;
    
  // Now create two solids (trd & tubs), and a boolean solid out of them 
  string name=pt.name().name();
  trap = new G4Trd(name, pt.x1(), pt.x2(), pt.y1(), pt.y2(), pt.halfZ());
  tubs = new G4Tubs(name, 
                    0., // rMin
                    abs(r), // rMax
                    h, // half height
                    startPhi, // start angle
                    openingAngle);
  if (intersec) {
    result = new G4SubtractionSolid(name, trap, tubs, rot, displ);
  }
  else {
    G4VSolid * tubicCap = new G4SubtractionSolid(name, 
                                                 tubs, 
                                                 new G4Box(name, 1.1*x, sqrt(r*r-x*x), 1.1*h),  
                                                 0, 
                                                 G4ThreeVector());
    result = new G4UnionSolid(name, trap, tubicCap, rot, displ);
            
    // approximative implementation - also fails to visualize due to G4/Iguana limitations
    /*
      delete tubs;
      tubs = new G4Tubs(name, 
      sqrt(r*r-x*x), // rMin-approximation!
      abs(r), // rMax
      h, // half height
      startPhi, // start angle
      openingAngle);
      result = new G4UnionSolid(name, trap, tubs, rot, displ);
    */
  }                                
  return result;
}
G4VSolid * DDG4SolidConverter::reflected ( const DDSolid s) [static, private]

Definition at line 234 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

{
  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: reflected = " << s ;  
  G4ReflectedSolid * rs = 0;
  DDReflectionSolid rfs(s); 
  if (rfs) {    
    static /* G4Transform3D */ HepGeom::ReflectZ3D z_reflection; // = HepGeom::ReflectZ3D;      
    rs = new G4ReflectedSolid(s.name().name(), 
                              DDG4SolidConverter().convert(rfs.unreflected()), 
                              z_reflection);
    
  } // else ?
  return rs;
}
static G4VSolid* DDG4SolidConverter::shapeless ( const DDSolid ) [static, private]
G4VSolid * DDG4SolidConverter::sphere ( const DDSolid s) [static, private]

Definition at line 520 of file DDG4SolidConverter.cc.

References DDSphere::deltaPhi(), DDSphere::deltaTheta(), DDSphere::innerRadius(), LogDebug, DDName::name(), DDBase< N, C >::name(), DDSphere::outerRadius(), asciidump::s, DDSphere::startPhi(), and DDSphere::startTheta().

Referenced by DDG4SolidConverter().

{
   LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: sphere = " << s ;  
   DDSphere sp(s);
   return new G4Sphere(s.name().name(), sp.innerRadius(),
                       sp.outerRadius(),
                       sp.startPhi(),
                       sp.deltaPhi(),
                       sp.startTheta(),
                       sp.deltaTheta());
}
G4VSolid * DDG4SolidConverter::subtraction ( const DDSolid s) [static, private]

Definition at line 280 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

{
  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: subtraction = " << s ;
  G4SubtractionSolid * us = 0;
  DDBooleanSolid bs(s);
  if (bs) {
    G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
    G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
    LogDebug("SimG4CoreGeometry") << " name:" << s.name() << " t=" << bs.translation() << flush;
    //       stringstream sst;
    //       bs.rotation().rotation()->inverse().print(sst);
    //       LogDebug("SimG4CoreGeometry") << " " << sst.str() << flush;
    LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << flush;
    std::vector<double> tdbl(9);
    bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
    CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
    CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z()); 
    us = new G4SubtractionSolid(s.name().name(),
                                sa,
                                sb,
                                new CLHEP::HepRotation(temprep),
                                temphvec);
  }
  return us;       
}
G4VSolid * DDG4SolidConverter::torus ( const DDSolid s) [static, private]

Definition at line 222 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

{
   LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: torus = " << s ;  
   return new G4Torus(s.name().name(), (*par_)[0], // rmin
                               (*par_)[1], // rmax
                               (*par_)[2], // Rtor
                               (*par_)[3], // phiStart
                               (*par_)[4]);// deltaPhi
}
G4VSolid * DDG4SolidConverter::trap ( const DDSolid s) [static, private]

Definition at line 88 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

{
   LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: trap = " << s ;
   return new G4Trap(s.name().name(), (*par_)[0],  // pDz
                               (*par_)[1],  // theta
                               (*par_)[2],  // phi
                               (*par_)[3],  // y1
                               (*par_)[4],  // x1
                               (*par_)[5],  // x2
                               (*par_)[6],  // alpha1
                               (*par_)[7],  // y2
                               (*par_)[8],  // x3
                               (*par_)[9],  // x4
                               (*par_)[10]);// alpha2
}
G4VSolid * DDG4SolidConverter::trunctubs ( const DDSolid s) [static, private]

Definition at line 436 of file DDG4SolidConverter.cc.

References abs, alpha, funct::cos(), DDTruncTubs::cutAtDelta(), DDTruncTubs::cutAtStart(), DDTruncTubs::cutInside(), DDTruncTubs::deltaPhi(), Geom::deltaPhi(), DDName::fullname(), LogDebug, m, DDName::name(), mergeVDriftHistosByStation::name, DDBase< N, C >::name(), csvReporter::r, dttmaxenums::R, query::result, DDTruncTubs::rIn(), DDTruncTubs::rOut(), asciidump::s, DDSolid::shape(), funct::sin(), mathSSE::sqrt(), DDTruncTubs::startPhi(), and DDTruncTubs::zHalf().

Referenced by DDG4SolidConverter().

{
  // truncated tube-section: a boolean subtraction solid:
  //                         from a tube-section a box is subtracted according to the  
  //                         given parameters
  LogDebug("SimG4CoreGeometry") << "MantisConverter: solidshape=" << DDSolidShapesName::name(s.shape()) << " " << s;
  LogDebug("SimG4CoreGeometry") << "before";
  DDTruncTubs tt(s);
  LogDebug("SimG4CoreGeometry") << "after";
  double rIn(tt.rIn()), rOut(tt.rOut()), zHalf(tt.zHalf()),
    startPhi(tt.startPhi()), deltaPhi(tt.deltaPhi()), 
    cutAtStart(tt.cutAtStart()), cutAtDelta(tt.cutAtDelta());
  bool cutInside(bool(tt.cutInside()));
  string name=tt.name().name();

  // check the parameters
  if (rIn <= 0 || rOut <=0 || cutAtStart <=0 || cutAtDelta <= 0) {
    string s = "TruncTubs " + string(tt.name().fullname()) + ": 0 <= rIn,cutAtStart,rOut,cutAtDelta,rOut violated!";
    throw DDException(s);
  }
  if (rIn >= rOut) {
    string s = "TruncTubs " + string(tt.name().fullname()) + ": rIn<rOut violated!";
    throw DDException(s);
  }
  if (startPhi != 0.) {
    string s= "TruncTubs " + string(tt.name().fullname()) + ": startPhi != 0 not supported!";
    throw DDException(s);
  }
  //     if (cutInside != false) {
  //       string s = "TruncTubs " + string(tt.name()) + " cutInside == true not supported!";
  //       throw DDException(s);
  //     }

  startPhi=0.;
  double r(cutAtStart), R(cutAtDelta);
  G4VSolid * result(0);
  G4VSolid * tubs = new G4Tubs(name,rIn,rOut,zHalf,startPhi,deltaPhi);
  LogDebug("SimG4CoreGeometry") << "G4Tubs: " << rIn << ' ' << rOut << ' ' << zHalf << ' ' << startPhi/deg << ' ' << deltaPhi/deg;
  LogDebug("SimG4CoreGeometry") << s;
  // length & hight of the box 
  double boxX(30.*rOut), boxY(20.*rOut); // exaggerate dimensions - does not matter, it's subtracted!
   
  // width of the box > width of the tubs
  double boxZ(1.1*zHalf);
   
  // angle of the box w.r.t. tubs
  double cath = r-R*cos(deltaPhi);
  double hypo = sqrt(r*r+R*R-2.*r*R*cos(deltaPhi));
  double cos_alpha = cath/hypo;

  double alpha = -acos(cos_alpha);
  LogDebug("SimG4CoreGeometry") << "cath=" << cath/m;
  LogDebug("SimG4CoreGeometry") << "hypo=" << hypo/m;
  LogDebug("SimG4CoreGeometry") << "al=" << acos(cath/hypo)/deg;
  LogDebug("SimG4CoreGeometry") << "deltaPhi=" << deltaPhi/deg << "\n"
                                << "r=" << r/m << "\n"
                                <<  "R=" << R/m;

  LogDebug("SimG4CoreGeometry") << "alpha=" << alpha/deg;
    
  // rotationmatrix of box w.r.t. tubs
  G4RotationMatrix * rot = new G4RotationMatrix;
  rot->rotateZ(-alpha);
  LogDebug("SimG4CoreGeometry") << (*rot);

  // center point of the box
  double xBox;
  if (!cutInside) {
    xBox = r+boxY/sin(abs(alpha));
  } else {
    xBox = -(boxY/sin(abs(alpha))-r);
  }

  G4ThreeVector trans(xBox,0.,0.);
  LogDebug("SimG4CoreGeometry") << "trans=" << trans;

  G4VSolid * box = new G4Box(name,boxX,boxY,boxZ);
  result = new G4SubtractionSolid(name,tubs,box,rot,trans);
      
  return result;

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

Definition at line 76 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

{
   LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: tubs = " << s ;  
   return new G4Tubs(s.name().name(), (*par_)[1], // rmin
                               (*par_)[2], // rmax
                               (*par_)[0], // dzHalf
                               (*par_)[3], // phiStart
                               (*par_)[4]);// deltaPhi
}
G4VSolid * DDG4SolidConverter::unionsolid ( const DDSolid s) [static, private]

Definition at line 251 of file DDG4SolidConverter.cc.

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

Referenced by DDG4SolidConverter().

{
  LogDebug("SimG4CoreGeometry") << "DDG4SolidConverter: unionsolid = " << s.name() ;
  G4UnionSolid * us = 0;
  DDBooleanSolid bs(s);
  if (bs) {
    LogDebug("SimG4CoreGeometry") << "SolidA=" << bs.solidA();
    G4VSolid * sa = DDG4SolidConverter().convert(bs.solidA());
    LogDebug("SimG4CoreGeometry") << "SolidB=" << bs.solidB();
    G4VSolid * sb = DDG4SolidConverter().convert(bs.solidB());
    LogDebug("SimG4CoreGeometry") << " name:" << s.name() << " t=" << bs.translation() << flush;
    LogDebug("SimG4CoreGeometry") << " " << bs.rotation().rotation()->Inverse() << flush;
    std::vector<double> tdbl(9);
    bs.rotation().rotation()->Inverse().GetComponents(tdbl.begin(), tdbl.end());
    CLHEP::HepRep3x3 temprep(tdbl[0], tdbl[1], tdbl[2], tdbl[3], tdbl[4], tdbl[5], tdbl[6], tdbl[7], tdbl[8]);
    CLHEP::Hep3Vector temphvec(bs.translation().X(), bs.translation().Y(), bs.translation().Z()); 
    us = new G4UnionSolid(s.name().name(),
                          sa,
                          sb,
                          new CLHEP::HepRotation(temprep),
                          temphvec);
    
  } // else?
  return us;       
}

Member Data Documentation

Definition at line 44 of file DDG4SolidConverter.h.

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

Definition at line 43 of file DDG4SolidConverter.h.