CMS 3D CMS Logo

VisTrackingGeometry Class Reference

#include <VisReco/VisRecoGeometry/interface/VisTrackingGeometry.h>

Inheritance diagram for VisTrackingGeometry:

VisCuTrackerCluster VisCuTrackerDigi VisCuTrackerRecHit VisCuTrackerSimHit VisTkSimHitTwig VisTkSimTrackTwig

List of all members.

Public Types

enum  DetectorRep {
  FullDet, RZDet, RPhiDet, CSCME1,
  CSCME2, CSCME3, CSCME4
}

Static Public Member Functions

static void addBoxWafer (SoSeparator *separator, const GeomDetUnit *det)
 Transform and add the DetUnit to the scene graph.
static void addWafer (SoSeparator *separator, const GeomDetUnit *det, DetectorRep type)
 Transform and add the DetUnit to the scene graph.
static SoSeparator * buildDet (DetectorRep type, std::vector< const GeomDetUnit * > &)
static SoSeparator * buildDet (DetectorRep type, edm::ESHandle< TrackerGeometry > &pDD, int subDetector)
static SoAnnotation * buildDet_anno (DetectorRep type, std::vector< const GeomDetUnit * > &)
static void createRotation (const GeomDetUnit *det, SbVec3f &axis, float &angle)
 Get rotation of a DetUnit.
static int subDetector (const std::string &key)
static bool visible (const GlobalPoint &point, DetectorRep type, int subDetector)


Detailed Description

Definition at line 25 of file VisTrackingGeometry.h.


Member Enumeration Documentation

enum VisTrackingGeometry::DetectorRep

Enumerator:
FullDet 
RZDet 
RPhiDet 
CSCME1 
CSCME2 
CSCME3 
CSCME4 

Definition at line 32 of file VisTrackingGeometry.h.

00032                      { FullDet, RZDet, RPhiDet, 
00033                        CSCME1, CSCME2, CSCME3, CSCME4};


Member Function Documentation

void VisTrackingGeometry::addBoxWafer ( SoSeparator *  separator,
const GeomDetUnit det 
) [static]

Transform and add the DetUnit to the scene graph.

Definition at line 268 of file VisTrackingGeometry.cc.

References BoundSurface::bounds(), f, Bounds::length(), GloballyPositioned< T >::position(), GloballyPositioned< T >::rotation(), GeomDet::surface(), Bounds::thickness(), Bounds::width(), Basic3DVector< T >::x(), x, Basic3DVector< T >::y(), y, Basic3DVector< T >::z(), and z.

00269 {    
00270     const int NVERT = 8;
00271 
00272     Basic3DVector< float > nx (1., 0., 0.); // x basis vector
00273     Basic3DVector< float > ny (0., 1., 0.); // y basis vector
00274     Basic3DVector< float > nz (0., 0., 1.); // z basis vector
00275 
00276     float posx = 0.;
00277     float posy = 0.;
00278     float posz = 0.;
00279     float x = 0.;
00280     float y = 0.;
00281     float z = 0.;
00282 
00283     static int faceIndices[] = 
00284         {0, 4, 3, 7, 2, 6, 1, 5, 0, 4, SO_END_FACE_INDEX,
00285          1, 0, 2, 3, SO_END_FACE_INDEX,
00286          6, 7, 5, 4, SO_END_FACE_INDEX
00287         };     
00288 
00289     static SoIndexedTriangleStripSet *detFaceSet = 0;
00290     if (detFaceSet == 0)
00291     {
00292         detFaceSet = new SoIndexedTriangleStripSet;
00293         detFaceSet->coordIndex.setValues(0, sizeof (faceIndices)/sizeof (int), faceIndices);
00294     }
00295     
00296     TkRotation< float > detRot = det->surface ().rotation ();
00297     Basic3DVector< float > px = detRot * nx; // Rxx Ryx Rzx
00298     Basic3DVector< float > py = detRot * ny; // Rxy Ryy Rzy
00299     Basic3DVector< float > pz = detRot * nz; // Rxz Ryz Rzz
00300 
00301     // set the rotation matrix
00302     SbMatrix rotMatrix (px.x (), py.x (), pz.x (), 0,
00303                         px.y (), py.y (), pz.y (), 0,
00304                         px.z (), py.z (), pz.z (), 0,
00305                         0, 0, 0, 1);
00306 
00307     // position of the wafer's center
00308     posx = det->surface ().position ().x () / 100.0;  // cm -> m
00309     posy = det->surface ().position ().y () / 100.0;  // cm -> m
00310     posz = det->surface ().position ().z () / 100.0;  // cm -> m
00311 
00312     x = det->surface ().bounds ().width () / 100.0;   // cm -> m
00313     y = det->surface ().bounds ().length () / 100.0; // cm -> m
00314     z = det->surface ().bounds ().thickness () / 100.0;  // cm -> m
00315                 
00316     SbVec3f points [NVERT] = {
00317         SbVec3f ( 0.5f, -0.5f, -0.5f),      // Origin (0, 0, 0) in the center of the cube:
00318         SbVec3f ( 0.5f,  0.5f, -0.5f),      //   7------6      Z
00319         SbVec3f ( 0.5f,  0.5f,  0.5f),      //  /|     /|      |
00320         SbVec3f ( 0.5f, -0.5f,  0.5f),      // 3------2 |      |
00321         SbVec3f (-0.5f, -0.5f, -0.5f),      // | 4----|-5     /--->Y
00322         SbVec3f (-0.5f,  0.5f, -0.5f),      // |/     |/     /
00323         SbVec3f (-0.5f,  0.5f,  0.5f),      // 0------1     X
00324         SbVec3f (-0.5f, -0.5f,  0.5f)       // 
00325     };
00326     
00327     SoMFVec3f vertexData;
00328     vertexData.setValues (0, NVERT, points);
00329 
00330     SoCoordinate3 *detCoords = new SoCoordinate3;
00331     detCoords->point = vertexData;
00332     
00333     SoTransform *detTransform = new SoTransform;
00334     detTransform->translation.setValue (posx, posy, posz);
00335     detTransform->rotation = SbRotation (rotMatrix);
00336     detTransform->scaleFactor.setValue (x, y, z);
00337 
00338     // Create the separator for the faces.
00339     SoSeparator *facesNode = new SoSeparator;
00340     facesNode->addChild (detTransform);
00341     facesNode->addChild (detCoords);
00342     facesNode->addChild (detFaceSet);
00343 
00344     separator->addChild (facesNode);
00345 }

void VisTrackingGeometry::addWafer ( SoSeparator *  separator,
const GeomDetUnit det,
DetectorRep  type 
) [static]

Transform and add the DetUnit to the scene graph.

Definition at line 164 of file VisTrackingGeometry.cc.

References IgSoG4Trap::alp1, IgSoG4Trap::alp2, angle(), b, b2, BoundSurface::bounds(), createRotation(), IgSoG4Trap::dx1, IgSoG4Trap::dx2, IgSoG4Trap::dx3, IgSoG4Trap::dx4, IgSoG4Trap::dy1, IgSoG4Trap::dy2, IgSoG4Trap::dz, GeomDet::geographicalId(), Bounds::length(), TrapezoidalPlaneBounds::parameters(), GloballyPositioned< T >::position(), RZDet, funct::sqrt(), DetId::subdetId(), GeomDet::surface(), Bounds::thickness(), Bounds::width(), and width.

Referenced by buildDet(), VisCuTracker::buildDet(), and buildDet_anno().

00165 {    
00166     // position of the wafer's center
00167     float posx = det->surface ().position ().x () / 100.0;  // cm -> m
00168     float posy = det->surface ().position ().y () / 100.0;  // cm -> m
00169     float posz = det->surface ().position ().z () / 100.0;  // cm -> m
00170     if(type==RZDet) {posx=0;posy=sqrt(det->surface ().position ().x ()*det->surface ().position ().x ()+det->surface ().position ().y ()*det->surface ().position ().y ()) / 100.0; if (det->surface ().position ().y () < 0.0)posy = - posy;}
00171     float angle;
00172     SbVec3f axis;
00173     createRotation (det, axis, angle);
00174     SoTransform *transform = new SoTransform;
00175     transform->translation.setValue (posx, posy, posz);
00176     if(type==RZDet){
00177      int subdet = det->geographicalId().subdetId(); 
00178      if(subdet==1 || subdet==3 || subdet==5)//barrel
00179       {
00180           SbMatrix sbm (1, 0, 0, 0,
00181                         0, 0, -1, 0,
00182                         0, 1, 0, 0,
00183                         0, 0, 0, 1);
00184     SbRotation sbr (sbm);
00185     sbr.getValue (axis, angle);
00186            transform->rotation.setValue (axis, angle);
00187         }  else transform->rotation.setValue (axis, angle);
00188         }  else transform->rotation.setValue (axis, angle);
00189 
00190     // Trapezoidal
00191     const Bounds *b = &((det->surface ()).bounds ());
00192     if (dynamic_cast<const TrapezoidalPlaneBounds *> (b))
00193     {
00194         const TrapezoidalPlaneBounds *b2 = dynamic_cast<const TrapezoidalPlaneBounds *> (b);
00195         std::vector< float > par = b2->parameters ();
00196         
00197         // these parameters are half-lengths, as in CMSIM/GEANT3
00198         float hBottomEdge = par [0];
00199         float hTopEdge    = par [1];
00200         float thickness   = par [2];
00201         float apothem     = par [3];
00202 
00203         IgSoG4Trap *g4Trap = new IgSoG4Trap ();
00204         g4Trap->dz = thickness / 100.; 
00205         g4Trap->dy1 = apothem / 100.;
00206         g4Trap->dy2 = apothem / 100.;
00207         g4Trap->dx1 = hBottomEdge / 100.;
00208         g4Trap->dx2 = hTopEdge / 100.;
00209         g4Trap->dx3 = hBottomEdge / 100.;
00210         g4Trap->dx4 = hTopEdge / 100.;
00211         g4Trap->alp1 = 0.0;
00212         g4Trap->alp2 = 0.0;
00213         separator->addChild (transform);
00214         separator->addChild (g4Trap);
00215     }
00216     if (dynamic_cast<const RectangularPlaneBounds *> (b))
00217     {
00218         IgSoCube *cube = new IgSoCube ();
00219             
00220         // Rectangular
00221         float length = det->surface ().bounds ().length () / 100.0; // cm -> m
00222         float width = det->surface ().bounds ().width () / 100.0;   // cm -> m
00223         float thickness = det->surface ().bounds ().thickness () / 100.0;  // cm -> m
00224         
00225         transform->scaleFactor.setValue (width, length, thickness);
00226         separator->addChild (transform);
00227         separator->addChild (cube);
00228     }
00229 }

SoSeparator * VisTrackingGeometry::buildDet ( DetectorRep  type,
std::vector< const GeomDetUnit * > &  detUnits 
) [static]

Definition at line 64 of file VisTrackingGeometry.cc.

References addWafer(), and visible().

00065 {
00066     SoSeparator *sep = new SoSeparator;    
00067  
00068     SoMaterial *mat = new SoMaterial;
00069     mat->ambientColor.setValue (0.88445997, 0.840042, 0.53582799);
00070     mat->diffuseColor.setValue (0.66334498, 0.630032, 0.401871);
00071     mat->specularColor.setValue (0.49999201, 0.49999201, 0.49999201);
00072     mat->emissiveColor.setValue (0, 0, 0);
00073     mat->shininess = 0.1;
00074     mat->transparency = 0;
00075     sep->addChild (mat);
00076     for (std::vector<const GeomDetUnit *>::const_iterator idet = detUnits.begin (); idet != detUnits.end (); idet++)    
00077     {
00078 
00079             if (visible ( (*idet)->surface ().position (), type, (**idet).type ().subDetector ()))
00080             {
00081                 SoSeparator* separator = new SoSeparator;
00082                 addWafer (separator, *idet,type);
00083                 sep->addChild (separator);
00084             }
00085     }
00086     return sep;
00087 }

SoSeparator * VisTrackingGeometry::buildDet ( DetectorRep  type,
edm::ESHandle< TrackerGeometry > &  pDD,
int  subDetector 
) [static]

Definition at line 35 of file VisTrackingGeometry.cc.

References addWafer(), and visible().

00036 {
00037     SoSeparator *sep = new SoSeparator;    
00038  
00039     SoMaterial *mat = new SoMaterial;
00040     mat->ambientColor.setValue (0.88445997, 0.840042, 0.53582799);
00041     mat->diffuseColor.setValue (0.66334498, 0.630032, 0.401871);
00042     mat->specularColor.setValue (0.49999201, 0.49999201, 0.49999201);
00043     mat->emissiveColor.setValue (0, 0, 0);
00044     mat->shininess = 0.1;
00045     mat->transparency = 0;
00046     sep->addChild (mat);
00047 
00048     for (TrackingGeometry::DetUnitContainer::const_iterator idet = pDD->detUnits ().begin (); idet != pDD->detUnits ().end (); idet++)    
00049     {
00050         if ((**idet).type ().subDetector () == subDetector)
00051         {
00052             if (visible ((*idet)->surface ().position (), type, subDetector))
00053             {
00054                 SoSeparator* separator = new SoSeparator;
00055                 addWafer (separator, *idet,type);
00056                 sep->addChild (separator);
00057             }
00058         } 
00059     }
00060     return sep;
00061 }

SoAnnotation * VisTrackingGeometry::buildDet_anno ( DetectorRep  type,
std::vector< const GeomDetUnit * > &  detUnits 
) [static]

Definition at line 90 of file VisTrackingGeometry.cc.

References addWafer().

00091 {
00092     SoAnnotation *sep = new SoAnnotation;
00093 
00094     SoMaterial *mat = new SoMaterial;
00095     mat->ambientColor.setValue (0.88445997, 0.840042, 0.53582799);
00096     mat->diffuseColor.setValue (0.66334498, 0.630032, 0.401871);
00097     mat->specularColor.setValue (0.49999201, 0.49999201, 0.49999201);
00098     mat->emissiveColor.setValue (0, 0, 0);
00099     mat->shininess = 0.1;
00100     mat->transparency = 0;
00101     sep->addChild (mat);
00102     for (std::vector<const GeomDetUnit *>::const_iterator idet = detUnits.begin (); idet != detUnits.end (); idet++)
00103     {
00104         SoAnnotation* separator = new SoAnnotation;
00105         addWafer (separator, *idet, type);
00106         sep->addChild (separator);
00107     }
00108     return sep;
00109 }

void VisTrackingGeometry::createRotation ( const GeomDetUnit det,
SbVec3f &  axis,
float &  angle 
) [static]

Get rotation of a DetUnit.

Definition at line 233 of file VisTrackingGeometry.cc.

References rot, GloballyPositioned< T >::rotation(), GeomDet::surface(), Basic3DVector< T >::x(), x, Basic3DVector< T >::y(), y, Basic3DVector< T >::z(), and z.

Referenced by VisDTDigiTwig::addDescription(), addWafer(), VisDTDigiTwig::addWire(), and VisDTRecHitsTwig::addWire().

00234 {    
00235     // Extract the coeff of the rotation matrix
00236     // with a projection on the basis vectors
00237     TkRotation< float > rot = det->surface ().rotation ();
00238     Basic3DVector< float > nx (1., 0., 0.); // x basis vector
00239     Basic3DVector< float > ny (0., 1., 0.); // y basis vector
00240     Basic3DVector< float > nz (0., 0., 1.); // z basis vector
00241     Basic3DVector< float > px = rot * nx; // Rxx Ryx Rzx
00242     Basic3DVector< float > py = rot * ny; // Rxy Ryy Rzy
00243     Basic3DVector< float > pz = rot * nz; // Rxz Ryz Rzz
00244     /* the rotation matrix is
00245      *  Rxx Rxy Rxz
00246      *  Ryx Ryy Ryz
00247      *  Rzx Rzy Rzz
00248      */
00249     // SbMatrix in row major order.
00250     // The 4th dimension is set empiricly set to
00251     // the identity
00252     SbMatrix sbm (px.x (), py.x (), pz.x (), 0,
00253                   px.y (), py.y (), pz.y (), 0,
00254                   px.z (), py.z (), pz.z (), 0,
00255                   0, 0, 0, 1);
00256     SbRotation sbr (sbm);
00257 
00258     float x;
00259     float y;
00260     float z;
00261 
00262     sbr.getValue (axis, angle);
00263     axis.getValue (x, y, z);
00264 }

int VisTrackingGeometry::subDetector ( const std::string &  key  )  [static]

Definition at line 348 of file VisTrackingGeometry.cc.

References GeomDetEnumerators::CSC, GeomDetEnumerators::PixelBarrel, GeomDetEnumerators::PixelEndcap, GeomDetEnumerators::TEC, GeomDetEnumerators::TIB, GeomDetEnumerators::TID, and GeomDetEnumerators::TOB.

00349 { 
00350     std::map<std::string, GeomDetEnumerators::SubDetector> type; 
00351 
00352     type ["PixelBarrel"] = GeomDetEnumerators::PixelBarrel;
00353     type ["TIB"] = GeomDetEnumerators::TIB;
00354     type ["TOB"] = GeomDetEnumerators::TOB;
00355     type ["PixelEndcap"] = GeomDetEnumerators::PixelEndcap;
00356     type ["TID"] = GeomDetEnumerators::TID;
00357     type ["TEC"] = GeomDetEnumerators::TEC;
00358     type ["CSC"] = GeomDetEnumerators::CSC;
00359 
00360     return type [key]; 
00361 }

bool VisTrackingGeometry::visible ( const GlobalPoint point,
DetectorRep  type,
int  subDetector 
) [static]

Definition at line 112 of file VisTrackingGeometry.cc.

References GeomDetEnumerators::CSC, CSCME1, CSCME2, CSCME3, CSCME4, FullDet, GeomDetEnumerators::PixelEndcap, RPhiDet, RZDet, GeomDetEnumerators::TEC, GeomDetEnumerators::TIB, GeomDetEnumerators::TID, GeomDetEnumerators::TOB, true, width, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by buildDet().

00113 {
00114     bool visible = false;
00115     double width = 1.0;
00116     double length = 10.0;
00117     if (subDetector == GeomDetEnumerators::TOB) width = 10.0;
00118     if (subDetector == GeomDetEnumerators::TIB) width = 5.5;
00119     if (subDetector == GeomDetEnumerators::TID) width = 15.0;
00120     if (subDetector == GeomDetEnumerators::TEC) width = 30.0;
00121     if (subDetector == GeomDetEnumerators::CSC) width = 55.0;
00122 
00123 
00124     switch (type)
00125     {
00126     case FullDet:
00127         visible = true;
00128         //point.z () > 0. ? visible = true : visible = false;
00129         //visible = false;
00130         break;
00131     case RZDet:
00132         if (subDetector == GeomDetEnumerators::TID || subDetector == GeomDetEnumerators::TEC) point.x () < width ? visible = true : visible = false; 
00133      else {
00134             if(subDetector == GeomDetEnumerators::PixelEndcap)visible = true ; else fabs (point.x ()) < width ? visible = true : visible = false;
00135             }
00136         break;
00137     case RPhiDet:
00138         fabs (point.z ()) < length ? visible = true : visible = false;
00139         break;
00140     case CSCME1:
00141         fabs( point.z ()) < 800. ? visible = true : visible = false;
00142         break; 
00143     case CSCME2:
00144         fabs( point.z ()) > 800. && fabs( point.z ()) < 900. ? 
00145             visible = true : visible = false;
00146         break;
00147     case CSCME3:
00148         fabs( point.z ()) > 900. && fabs( point.z ()) < 1000. ? 
00149             visible = true : visible = false;
00150         break;
00151         //     visible = false;
00152     case CSCME4:
00153         fabs( point.z ()) > 1000. ? visible = true : visible = false;
00154         break;
00155     default:
00156         break;
00157     }
00158     
00159     return visible;
00160 }


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