00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "TEvePointSet.h"
00010 #include "TEveStraightLineSet.h"
00011
00012 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
00013 #include "Fireworks/Core/interface/FWEventItem.h"
00014 #include "Fireworks/Core/interface/FWGeometry.h"
00015 #include "Fireworks/Core/interface/fwLog.h"
00016
00017 #include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h"
00018
00019 class FWCSCRecHitProxyBuilder : public FWSimpleProxyBuilderTemplate<CSCRecHit2D>
00020 {
00021 public:
00022 FWCSCRecHitProxyBuilder( void ) {}
00023 virtual ~FWCSCRecHitProxyBuilder( void ) {}
00024
00025 REGISTER_PROXYBUILDER_METHODS();
00026
00027 private:
00028 FWCSCRecHitProxyBuilder( const FWCSCRecHitProxyBuilder& );
00029 const FWCSCRecHitProxyBuilder& operator=( const FWCSCRecHitProxyBuilder& );
00030
00031 void build( const CSCRecHit2D& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* );
00032 };
00033
00034 void
00035 FWCSCRecHitProxyBuilder::build( const CSCRecHit2D& iData,
00036 unsigned int iIndex, TEveElement& oItemHolder,
00037 const FWViewContext* )
00038 {
00039 const FWGeometry *geom = item()->getGeom();
00040 unsigned int rawid = iData.cscDetId().rawId();
00041
00042 if( ! geom->contains( rawid ))
00043 {
00044 fwLog( fwlog::kError ) << "failed to get geometry of CSC layer with detid: "
00045 << rawid <<std::endl;
00046 return;
00047 }
00048 FWGeometry::IdToInfoItr det = geom->find( rawid );
00049
00050 TEveStraightLineSet* recHitSet = new TEveStraightLineSet;
00051 setupAddElement( recHitSet, &oItemHolder );
00052
00053 TEvePointSet* pointSet = new TEvePointSet;
00054 setupAddElement( pointSet, &oItemHolder );
00055
00056 float localPositionX = iData.localPosition().x();
00057 float localPositionY = iData.localPosition().y();
00058
00059 float localPositionXX = sqrt( iData.localPositionError().xx());
00060 float localPositionYY = sqrt( iData.localPositionError().yy());
00061
00062 float localU1Point[3] =
00063 {
00064 localPositionX - localPositionXX, localPositionY, 0.0
00065 };
00066
00067 float localU2Point[3] =
00068 {
00069 localPositionX + localPositionXX, localPositionY, 0.0
00070 };
00071
00072 float localV1Point[3] =
00073 {
00074 localPositionX, localPositionY - localPositionYY, 0.0
00075 };
00076
00077 float localV2Point[3] =
00078 {
00079 localPositionX, localPositionY + localPositionYY, 0.0
00080 };
00081
00082 float globalU1Point[3];
00083 float globalU2Point[3];
00084 float globalV1Point[3];
00085 float globalV2Point[3];
00086
00087 geom->localToGlobal( *det, localU1Point, globalU1Point );
00088 geom->localToGlobal( *det, localU2Point, globalU2Point );
00089 geom->localToGlobal( *det, localV1Point, globalV1Point );
00090 geom->localToGlobal( *det, localV2Point, globalV2Point );
00091
00092 pointSet->SetNextPoint( globalU1Point[0], globalU1Point[1], globalU1Point[2] );
00093 pointSet->SetNextPoint( globalU2Point[0], globalU2Point[1], globalU2Point[2] );
00094 pointSet->SetNextPoint( globalV1Point[0], globalV1Point[1], globalV1Point[2] );
00095 pointSet->SetNextPoint( globalV2Point[0], globalV2Point[1], globalV2Point[2] );
00096
00097 recHitSet->AddLine( globalU1Point[0], globalU1Point[1], globalU1Point[2],
00098 globalU2Point[0], globalU2Point[1], globalU2Point[2] );
00099
00100 recHitSet->AddLine( globalV1Point[0], globalV1Point[1], globalV1Point[2],
00101 globalV2Point[0], globalV2Point[1], globalV2Point[2] );
00102 }
00103
00104 REGISTER_FWPROXYBUILDER( FWCSCRecHitProxyBuilder, CSCRecHit2D, "CSC RecHits", FWViewType::kAll3DBits | FWViewType::kAllRPZBits );
00105
00106