CMS 3D CMS Logo

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

DDPixFwdBlades Class Reference

#include <DDPixFwdBlades.h>

List of all members.

Public Member Functions

 DDPixFwdBlades ()
void execute (DDCompactView &cpv)
void initialize (const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs)
virtual ~DDPixFwdBlades ()

Private Member Functions

void computeNippleParameters (double endcap)
int issueCopyNumber ()

Private Attributes

std::string childName
std::string childRotationName
std::vector< double > childTranslationVector
double endcap
std::string flagSelector
std::string flagString
std::string idNameSpace
static double nippleTranslationY = 0.
static double nippleTranslationZ = 0.

Static Private Attributes

static const double ancorRadius = 54.631*CLHEP::mm
static const double bladeAngle = 20.*CLHEP::deg
static const double bladeZShift = 6.*CLHEP::mm
static std::map< std::string, int > copyNumbers
static const double jX = -16.25*CLHEP::mm
static const double jY = 96.50*CLHEP::mm
static const double jZ = 1.25*CLHEP::mm
static const double kX = 16.25*CLHEP::mm
static const double kY = 96.50*CLHEP::mm
static const double kZ = -1.25*CLHEP::mm
static const int nBlades = 24
static CLHEP::HepRotation * nippleRotationZMinus = 0
static CLHEP::HepRotation * nippleRotationZPlus = 0
static double nippleTranslationX = 0.
static const double zPlane = 0.

Detailed Description

Definition at line 64 of file DDPixFwdBlades.h.


Constructor & Destructor Documentation

DDPixFwdBlades::DDPixFwdBlades ( )

Definition at line 58 of file DDPixFwdBlades.cc.

{}
DDPixFwdBlades::~DDPixFwdBlades ( ) [virtual]

Definition at line 59 of file DDPixFwdBlades.cc.

{}

Member Function Documentation

void DDPixFwdBlades::computeNippleParameters ( double  endcap) [private]

Definition at line 218 of file DDPixFwdBlades.cc.

References ancorRadius, bladeAngle, bladeZShift, funct::cos(), DDrot(), Geom::deltaPhi(), jX, jY, jZ, kX, kY, kZ, LogDebug, nBlades, nippleRotationZMinus, nippleRotationZPlus, nippleTranslationX, nippleTranslationY, nippleTranslationZ, and funct::sin().

Referenced by execute().

                                                          {
        
  double effBladeAngle = endcap * bladeAngle;
  
  CLHEP::Hep3Vector jC; // Point J in the "cover" blade frame
  CLHEP::Hep3Vector kB; // Point K in the "body" blade frame
  std::string rotNameNippleToCover;
  std::string rotNameCoverToNipple;
  std::string rotNameNippleToBody;

  if (endcap > 0.) {
    jC = CLHEP::Hep3Vector(jX, jY + ancorRadius, jZ);
    kB = CLHEP::Hep3Vector(kX, kY + ancorRadius, kZ);
    rotNameNippleToCover = "NippleToCoverZPlus";
    rotNameCoverToNipple = "CoverToNippleZPlus";
    rotNameNippleToBody = "NippleToBodyZPlus";
  } else {
    jC = CLHEP::Hep3Vector(-jX, jY + ancorRadius, jZ);
    kB = CLHEP::Hep3Vector(-kX, kY + ancorRadius, kZ);
    rotNameNippleToCover = "NippleToCoverZMinus";
    rotNameCoverToNipple = "CoverToNippleZMinus";
    rotNameNippleToBody = "NippleToBodyZMinus";
  }
                
  // Z-shift from "cover" to "body" blade frame:
  
  CLHEP::Hep3Vector tCB(bladeZShift*sin(effBladeAngle), 0., bladeZShift*cos(effBladeAngle));
  
  // Rotation from "cover" blade frame into "body" blade frame :
  
  double deltaPhi = endcap*(360./nBlades)*CLHEP::deg;
  CLHEP::HepRotation rCB(CLHEP::Hep3Vector(1.*sin(effBladeAngle), 0., 1.*cos(effBladeAngle)), deltaPhi);
  
  // Transform vector k into "cover" blade frame :
  
  CLHEP::Hep3Vector kC = rCB * (kB + tCB);
  
  // Vector JK in the "cover" blade frame:
  
  CLHEP::Hep3Vector jkC = kC - jC;
  double* jkLength = new double(jkC.mag());
  DDConstant JK(DDName("JK", "pixfwdNipple"), jkLength);
  LogDebug("PixelGeom") << "+++++++++++++++ DDPixFwdBlades: " << "JK Length " <<  *jkLength * CLHEP::mm;
  
  // Position of the center of a nipple in "cover" blade frame :
  
  CLHEP::Hep3Vector nippleTranslation((kC+jC)/2. - CLHEP::Hep3Vector(0., ancorRadius, 0.));
  if (endcap > 0) {
    nippleTranslationX = nippleTranslation.x();
    nippleTranslationY = nippleTranslation.y();
    nippleTranslationZ = nippleTranslation.z();
  }
  LogDebug("PixelGeom") << "Child translation : " << nippleTranslation;
  
  // Rotations from nipple frame to "cover" blade frame and back :
  
  CLHEP::Hep3Vector vZ(0.,0.,1.);
  CLHEP::Hep3Vector axis = vZ.cross(jkC);
  double angleCover = vZ.angle(jkC);
  LogDebug("PixelGeom") << " Angle to Cover: " << angleCover;
  CLHEP::HepRotation* rpCN = new CLHEP::HepRotation(axis, angleCover);
  if (endcap > 0.) {
    nippleRotationZPlus = rpCN;
  } else {
    nippleRotationZMinus = rpCN;
  }
  //( endcap > 0. ? nippleRotationZPlus : nippleRotationZMinus ) = rpCN;

  DDRotationMatrix* ddrpCN = new DDRotationMatrix(rpCN->xx(), rpCN->xy(), rpCN->xz(),
                                                  rpCN->yx(), rpCN->yy(), rpCN->yz(),
                                                  rpCN->zx(), rpCN->zy(), rpCN->zz() );

  DDrot(DDName(rotNameCoverToNipple, "pixfwdNipple"), ddrpCN);
  CLHEP::HepRotation rpNC(axis, -angleCover);
  DDRotationMatrix* ddrpNC = new DDRotationMatrix(rpNC.xx(), rpNC.xy(), rpNC.xz(),
                                                  rpNC.yx(), rpNC.yy(), rpNC.yz(),
                                                  rpNC.zx(), rpNC.zy(), rpNC.zz() );

  DDrot(DDName(rotNameNippleToCover, "pixfwdNipple"), ddrpNC);
  
  // Rotation from nipple frame to "body" blade frame :
  
  CLHEP::HepRotation rpNB( rpNC * rCB );
  DDRotationMatrix* ddrpNB = new DDRotationMatrix(rpNB.xx(), rpNB.xy(), rpNB.xz(),
                                                  rpNB.yx(), rpNB.yy(), rpNB.yz(),
                                                  rpNB.zx(), rpNB.zy(), rpNB.zz() );

  DDrot(DDName(rotNameNippleToBody, "pixfwdNipple"), ddrpNB);
  double angleBody = vZ.angle(rpNB * vZ);
  LogDebug("PixelGeom") << " Angle to body : " << angleBody;  
}
void DDPixFwdBlades::execute ( DDCompactView cpv)

Definition at line 106 of file DDPixFwdBlades.cc.

References ancorRadius, bladeAngle, bladeZShift, childName, childRotationName, childTranslationVector, computeNippleParameters(), filterCSVwithJSON::copy, DDrot(), DDSplit(), Geom::deltaPhi(), endcap, first, flagSelector, flagString, idNameSpace, int_to_string(), issueCopyNumber(), nBlades, nippleRotationZMinus, nippleRotationZPlus, nippleTranslationX, nippleTranslationY, nippleTranslationZ, dbtoconf::parent, phi, DDCompactView::position(), DDRotation::rotation(), edm::second(), cond::rpcobtemp::temp, x, detailsBasic3DVector::y, z, and zPlane.

                                               {

  // -- Compute Nipple parameters if not already computed :
  
  if (!nippleRotationZPlus) {
    computeNippleParameters(1.);   // Z Plus endcap
    computeNippleParameters(-1.);  // Z Minus endcap
  }
  if (childName == "") return;
  
  // -- Signed versions of blade angle and z-shift :
  
  double effBladeAngle = - endcap * bladeAngle;
  double effBladeZShift = endcap * bladeZShift;
  
  // -- Names of mother and child volumes :

  DDName mother = parent().name();
  DDName child(DDSplit(childName).first, DDSplit(childName).second);
  
  // -- Get translation and rotation from "blade frame" to "child frame", if any :
  
  CLHEP::HepRotation childRotMatrix = CLHEP::HepRotation();
  if (childRotationName != "") {
    DDRotation childRotation = DDRotation(DDName(DDSplit(childRotationName).first, DDSplit(childRotationName).second));
    // due to conversion to ROOT::Math::Rotation3D -- Michael Case
    DD3Vector x, y, z;
    childRotation.rotation()->GetComponents(x, y, z); // these are the orthonormal columns.
    CLHEP::HepRep3x3 tr(x.X(), y.X(), z.X(), x.Y(), y.Y(), z.Y(), x.Z(), y.Z(), z.Z());
    childRotMatrix = CLHEP::HepRotation(tr);
  } else if (childName == "pixfwdNipple:PixelForwardNippleZPlus") {
    childRotMatrix = *nippleRotationZPlus;
  } else if (childName == "pixfwdNipple:PixelForwardNippleZMinus") {
    childRotMatrix = *nippleRotationZMinus;
  }
  
  CLHEP::Hep3Vector childTranslation;
  if (childName == "pixfwdNipple:PixelForwardNippleZPlus") {
    childTranslation = CLHEP::Hep3Vector(nippleTranslationX, nippleTranslationY, nippleTranslationZ);
  } else if (childName == "pixfwdNipple:PixelForwardNippleZMinus") {
    childTranslation = CLHEP::Hep3Vector(-nippleTranslationX, nippleTranslationY, nippleTranslationZ);
  } else {
    childTranslation = CLHEP::Hep3Vector(childTranslationVector[0],childTranslationVector[1],childTranslationVector[2]);
  }
  
  // Create a matrix for rotation around blade axis (to "blade frame") :
  
  CLHEP::HepRotation bladeRotMatrix(CLHEP::Hep3Vector(0.,1.,0.),effBladeAngle);
  
  // Cycle over Phi positions, placing copies of the child volume :

  double deltaPhi = (360./nBlades)*CLHEP::deg;
  int nQuarter = nBlades/4;
  double zShiftMax = effBladeZShift*((nQuarter-1)/2.);

  for (int iBlade=0; iBlade < nBlades; iBlade++) {
    
    // check if this blade position should be skipped :
        
    if (flagString[iBlade] != flagSelector[0]) continue;
    int copy = issueCopyNumber();
    
    // calculate Phi and Z shift for this blade :

    double phi = (iBlade + 0.5) * deltaPhi - 90.*CLHEP::deg;
    int iQuarter = iBlade % nQuarter;
    double zShift = - zShiftMax + iQuarter * effBladeZShift;
    
    // compute rotation matrix from mother to blade frame :
    
    CLHEP::HepRotation rotMatrix(CLHEP::Hep3Vector(0.,0.,1.), phi);
    rotMatrix *= bladeRotMatrix;

    // convert translation vector from blade frame to mother frame, and add Z shift :
    
    CLHEP::Hep3Vector translation = rotMatrix(childTranslation + CLHEP::Hep3Vector(0., ancorRadius, 0.));
    translation += CLHEP::Hep3Vector(0., 0., zShift + zPlane);
    
    // create DDRotation for placing the child if not already existent :

    DDRotation rotation;   
    std::string rotstr = DDSplit(childName).first + int_to_string(copy);
    rotation = DDRotation(DDName(rotstr, idNameSpace));

    if (!rotation) {
      rotMatrix *= childRotMatrix;
      DDRotationMatrix* temp = new DDRotationMatrix(rotMatrix.xx(), rotMatrix.xy(), rotMatrix.xz(),
                                                    rotMatrix.yx(), rotMatrix.yy(), rotMatrix.yz(),
                                                    rotMatrix.zx(), rotMatrix.zy(), rotMatrix.zz() );
      rotation = DDrot(DDName(rotstr, idNameSpace), temp);
    }
    // position the child :

    DDTranslation ddtran(translation.x(), translation.y(), translation.z());
    cpv.position(child, mother, copy, ddtran, rotation);
    // LogDebug("PixelGeom") << "DDPixFwdBlades: " << child << " Copy " << copy << " positioned in " << mother << " at " << translation << " with rotation " << rotation;
  }

  // End of cycle over Phi positions

}
void DDPixFwdBlades::initialize ( const DDNumericArguments nArgs,
const DDVectorArguments vArgs,
const DDMapArguments mArgs,
const DDStringArguments sArgs,
const DDStringVectorArguments vsArgs 
)

Definition at line 63 of file DDPixFwdBlades.cc.

References childName, childRotationName, childTranslationVector, endcap, flagSelector, flagString, idNameSpace, and DDCurrentNamespace::ns().

                                                                  {
                                        
  if ( nArgs.find("Endcap") != nArgs.end() ) {
    endcap = nArgs["Endcap"];
  } else {
    endcap = 1.;
  }

  if ( sArgs.find("FlagString") != sArgs.end() ) {
    flagString = sArgs["FlagString"];
    flagSelector = sArgs["FlagSelector"];
  } else {
    flagString = "YYYYYYYYYYYYYYYYYYYYYYYY";
    flagSelector = "Y";
  }

  if ( sArgs.find("Child") != sArgs.end() ) {
    childName   = sArgs["Child"];
  } else {
    childName   = "";
  }

  if ( vArgs.find("ChildTranslation") != vArgs.end() ) {
    childTranslationVector = vArgs["ChildTranslation"];
  } else {
    childTranslationVector = std::vector<double>(3, 0.);
  }

  if ( sArgs.find("ChildRotation") != sArgs.end() ) {
    childRotationName = sArgs["ChildRotation"];
  } else {
    childRotationName = "";
  }

  idNameSpace = DDCurrentNamespace::ns();
}
int DDPixFwdBlades::issueCopyNumber ( ) [private]

Definition at line 210 of file DDPixFwdBlades.cc.

References childName, and copyNumbers.

Referenced by execute().

                                    {
  if (copyNumbers.count(childName) == 0) copyNumbers[childName] = 0;
  return ++copyNumbers[childName];
}

Member Data Documentation

const double DDPixFwdBlades::ancorRadius = 54.631*CLHEP::mm [static, private]

Definition at line 94 of file DDPixFwdBlades.h.

Referenced by computeNippleParameters(), and execute().

const double DDPixFwdBlades::bladeAngle = 20.*CLHEP::deg [static, private]

Definition at line 90 of file DDPixFwdBlades.h.

Referenced by computeNippleParameters(), and execute().

const double DDPixFwdBlades::bladeZShift = 6.*CLHEP::mm [static, private]

Definition at line 92 of file DDPixFwdBlades.h.

Referenced by computeNippleParameters(), and execute().

std::string DDPixFwdBlades::childName [private]

Definition at line 112 of file DDPixFwdBlades.h.

Referenced by execute(), initialize(), and issueCopyNumber().

std::string DDPixFwdBlades::childRotationName [private]

Definition at line 115 of file DDPixFwdBlades.h.

Referenced by execute(), and initialize().

std::vector<double> DDPixFwdBlades::childTranslationVector [private]

Definition at line 114 of file DDPixFwdBlades.h.

Referenced by execute(), and initialize().

std::map< std::string, int > DDPixFwdBlades::copyNumbers [static, private]

Definition at line 121 of file DDPixFwdBlades.h.

Referenced by issueCopyNumber().

double DDPixFwdBlades::endcap [private]

Definition at line 107 of file DDPixFwdBlades.h.

Referenced by execute(), and initialize().

std::string DDPixFwdBlades::flagSelector [private]

Definition at line 110 of file DDPixFwdBlades.h.

Referenced by execute(), and initialize().

std::string DDPixFwdBlades::flagString [private]

Definition at line 109 of file DDPixFwdBlades.h.

Referenced by execute(), and initialize().

std::string DDPixFwdBlades::idNameSpace [private]

Definition at line 119 of file DDPixFwdBlades.h.

Referenced by execute(), and initialize().

const double DDPixFwdBlades::jX = -16.25*CLHEP::mm [static, private]

Definition at line 98 of file DDPixFwdBlades.h.

Referenced by computeNippleParameters().

const double DDPixFwdBlades::jY = 96.50*CLHEP::mm [static, private]

Definition at line 99 of file DDPixFwdBlades.h.

Referenced by computeNippleParameters().

const double DDPixFwdBlades::jZ = 1.25*CLHEP::mm [static, private]

Definition at line 100 of file DDPixFwdBlades.h.

Referenced by computeNippleParameters().

const double DDPixFwdBlades::kX = 16.25*CLHEP::mm [static, private]

Definition at line 101 of file DDPixFwdBlades.h.

Referenced by computeNippleParameters().

const double DDPixFwdBlades::kY = 96.50*CLHEP::mm [static, private]

Definition at line 102 of file DDPixFwdBlades.h.

Referenced by computeNippleParameters().

const double DDPixFwdBlades::kZ = -1.25*CLHEP::mm [static, private]

Definition at line 103 of file DDPixFwdBlades.h.

Referenced by computeNippleParameters().

const int DDPixFwdBlades::nBlades = 24 [static, private]

Definition at line 89 of file DDPixFwdBlades.h.

Referenced by computeNippleParameters(), and execute().

CLHEP::HepRotation * DDPixFwdBlades::nippleRotationZMinus = 0 [static, private]

Definition at line 124 of file DDPixFwdBlades.h.

Referenced by computeNippleParameters(), and execute().

CLHEP::HepRotation * DDPixFwdBlades::nippleRotationZPlus = 0 [static, private]

Definition at line 123 of file DDPixFwdBlades.h.

Referenced by computeNippleParameters(), and execute().

double DDPixFwdBlades::nippleTranslationX = 0. [static, private]

Definition at line 125 of file DDPixFwdBlades.h.

Referenced by computeNippleParameters(), and execute().

double DDPixFwdBlades::nippleTranslationY = 0. [private]

Definition at line 125 of file DDPixFwdBlades.h.

Referenced by computeNippleParameters(), and execute().

double DDPixFwdBlades::nippleTranslationZ = 0. [private]

Definition at line 125 of file DDPixFwdBlades.h.

Referenced by computeNippleParameters(), and execute().

const double DDPixFwdBlades::zPlane = 0. [static, private]

Definition at line 91 of file DDPixFwdBlades.h.

Referenced by execute().