00001
00002 #include "VisReco/VisMuonCSC/interface/VisCSCChamberDrawer.h"
00003
00004 #include "Geometry/CommonDetUnit/interface/GeomDetType.h"
00005 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
00006 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00007 #include "Geometry/CSCGeometry/interface/CSCLayer.h"
00008 #include "Geometry/CSCGeometry/interface/CSCLayerGeometry.h"
00009 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00010 #include <Inventor/nodes/SoDrawStyle.h>
00011 #include <Inventor/nodes/SoMaterial.h>
00012 #include <Inventor/nodes/SoSeparator.h>
00013 #include <Inventor/nodes/SoLineSet.h>
00014 #include <Inventor/nodes/SoCoordinate3.h>
00015
00016
00017
00018 VisCSCChamberDrawer::VisCSCChamberDrawer(void) : m_lineColor(0x59595900), m_lineThickness(2.0F), m_chamberFlag(true)
00019 {
00020 }
00021
00022 bool VisCSCChamberDrawer::getOutline(SoSeparator *sep, const edm::ESHandle<CSCGeometry> pGeom, const CSCDetId id)
00023 {
00024 if (!pGeom.isValid() || !m_chamberFlag) return false;
00025
00026 SbColor lineColor;
00027 float transparency = 0.0f;
00028 lineColor.setPackedValue(static_cast<uint32_t>(m_lineColor), transparency);
00029 SoMaterial *mat = new SoMaterial;
00030 mat->diffuseColor.setValue (lineColor);
00031 SoDrawStyle *drawStyle = new SoDrawStyle;
00032 if (m_lineThickness != 0.F) drawStyle->lineWidth = m_lineThickness;
00033
00034
00035 sep->addChild(mat);
00036 sep->addChild(drawStyle);
00037
00038 const CSCLayer *pLayer = pGeom->layer (id);
00039 if (!pLayer)
00040 {
00041 pLayer = pGeom->layer(4);
00042
00043 }
00044 const CSCLayerGeometry *layerGeom = pLayer->geometry ();
00045
00046 const std::vector<float> trapezBounds = layerGeom->parameters ();
00047 const GeomDet *det = pGeom->idToDet(id);
00048 std::vector<Surface::GlobalPoint> crossPoint;
00049
00050 crossPoint.push_back (det->surface ().toGlobal
00051 (LocalPoint (-trapezBounds [0], -trapezBounds [3], 0.0)));
00052 crossPoint.push_back (det->surface ().toGlobal
00053 (LocalPoint ( trapezBounds [0], -trapezBounds [3], 0.0)));
00054 crossPoint.push_back (det->surface ().toGlobal
00055 (LocalPoint ( trapezBounds [1], trapezBounds [3], 0.0)));
00056 crossPoint.push_back (det->surface ().toGlobal
00057 (LocalPoint (-trapezBounds [1], trapezBounds [3], 0.0)));
00058 crossPoint.push_back(crossPoint.front());
00059 std::vector<SbVec3f> pts(5);
00060 for (int i=0; i < 5; i++)
00061 {
00062 pts[i] = SbVec3f(crossPoint[i].x(), crossPoint[i].y(), crossPoint[i].z())*0.01F;
00063 }
00064 SoCoordinate3 *vert = new SoCoordinate3;
00065 vert->point.setValues(0, 5, &pts[0]);
00066
00067 sep->addChild(vert);
00068 SoLineSet *trapez = new SoLineSet;
00069 sep->addChild (trapez);
00070
00071 return true;
00072 }
00073