Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TEveGeoNode.h"
00015 #include "TEveStraightLineSet.h"
00016 #include "TGeoArb8.h"
00017
00018 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
00019 #include "Fireworks/Core/interface/FWEventItem.h"
00020 #include "Fireworks/Core/interface/FWGeometry.h"
00021 #include "Fireworks/Core/interface/fwLog.h"
00022
00023 #include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h"
00024
00025 class FWCSCSegmentProxyBuilder : public FWSimpleProxyBuilderTemplate<CSCSegment>
00026 {
00027 public:
00028 FWCSCSegmentProxyBuilder( void ) {}
00029 virtual ~FWCSCSegmentProxyBuilder( void ) {}
00030
00031 REGISTER_PROXYBUILDER_METHODS();
00032
00033 private:
00034 FWCSCSegmentProxyBuilder( const FWCSCSegmentProxyBuilder& );
00035 const FWCSCSegmentProxyBuilder& operator=( const FWCSCSegmentProxyBuilder& );
00036
00037 void build( const CSCSegment& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* );
00038 };
00039
00040 void
00041 FWCSCSegmentProxyBuilder::build( const CSCSegment& iData,
00042 unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* )
00043 {
00044 const FWGeometry *geom = item()->getGeom();
00045 unsigned int rawid = iData.cscDetId().rawId();
00046
00047 if( ! geom->contains( rawid ))
00048 {
00049 fwLog(fwlog::kError) << "failed to get geometry of CSC chamber with rawid: "
00050 << rawid << std::endl;
00051 return;
00052 }
00053
00054 TEveStraightLineSet* segmentSet = new TEveStraightLineSet();
00055
00056 segmentSet->SetLineWidth( 3 );
00057 setupAddElement( segmentSet, &oItemHolder );
00058
00059 TEveGeoShape* shape = item()->getGeom()->getEveShape( rawid );
00060 if( TGeoTrap* trap = dynamic_cast<TGeoTrap*>( shape->GetShape()))
00061 {
00062 LocalPoint pos = iData.localPosition();
00063 LocalVector dir = iData.localDirection();
00064 LocalVector unit = dir.unit();
00065
00066 Double_t localPosition[3] = { pos.x(), pos.y(), pos.z() };
00067 Double_t localDirectionIn[3] = { dir.x(), dir.y(), dir.z() };
00068 Double_t localDirectionOut[3] = { -dir.x(), -dir.y(), -dir.z() };
00069
00070 float distIn = trap->DistFromInside( localPosition, localDirectionIn );
00071 float distOut = trap->DistFromInside( localPosition, localDirectionOut );
00072 LocalVector vIn = unit * distIn;
00073 LocalVector vOut = -unit * distOut;
00074 float localSegmentInnerPoint[3] = { static_cast<float>(localPosition[0] + vIn.x()),
00075 static_cast<float>(localPosition[1] + vIn.y()),
00076 static_cast<float>(localPosition[2] + vIn.z())
00077 };
00078
00079 float localSegmentOuterPoint[3] = { static_cast<float>(localPosition[0] + vOut.x()),
00080 static_cast<float>(localPosition[1] + vOut.y()),
00081 static_cast<float>(localPosition[2] + vOut.z())
00082 };
00083
00084 float globalSegmentInnerPoint[3];
00085 float globalSegmentOuterPoint[3];
00086
00087 geom->localToGlobal( rawid, localSegmentInnerPoint, globalSegmentInnerPoint, localSegmentOuterPoint, globalSegmentOuterPoint );
00088
00089 segmentSet->AddLine( globalSegmentInnerPoint[0], globalSegmentInnerPoint[1], globalSegmentInnerPoint[2],
00090 globalSegmentOuterPoint[0], globalSegmentOuterPoint[1], globalSegmentOuterPoint[2] );
00091 }
00092 }
00093
00094 REGISTER_FWPROXYBUILDER( FWCSCSegmentProxyBuilder, CSCSegment, "CSC-segments", FWViewType::kAll3DBits | FWViewType::kAllRPZBits );
00095
00096