Go to the documentation of this file.00001 #include "TEvePointSet.h"
00002
00003 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
00004 #include "Fireworks/Core/interface/FWGeometry.h"
00005 #include "Fireworks/Core/interface/FWEventItem.h"
00006 #include "Fireworks/Core/interface/fwLog.h"
00007
00008 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2D.h"
00009 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit1D.h"
00010 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
00011 #include "DataFormats/TrackReco/interface/Track.h"
00012
00013 class FWTrackTrackingRecHitProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::Track>
00014 {
00015 public:
00016 FWTrackTrackingRecHitProxyBuilder( void ) {}
00017 virtual ~FWTrackTrackingRecHitProxyBuilder( void ) {}
00018
00019 REGISTER_PROXYBUILDER_METHODS();
00020
00021 private:
00022 void build( const reco::Track& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* );
00023
00024 FWTrackTrackingRecHitProxyBuilder( const FWTrackTrackingRecHitProxyBuilder& );
00025 const FWTrackTrackingRecHitProxyBuilder& operator=( const FWTrackTrackingRecHitProxyBuilder& );
00026 };
00027
00028 void
00029 FWTrackTrackingRecHitProxyBuilder::build( const reco::Track& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* )
00030 {
00031 const FWGeometry *geom = item()->getGeom();
00032
00033 for( trackingRecHit_iterator it = iData.recHitsBegin(), itEnd = iData.recHitsEnd(); it != itEnd; ++it )
00034 {
00035 TEvePointSet* pointSet = new TEvePointSet;
00036 setupAddElement( pointSet, &oItemHolder );
00037
00038 TrackingRecHitRef rechitRef = *it;
00039 const TrackingRecHit *rechit = &( *rechitRef );
00040
00041 if( rechit->isValid())
00042 {
00043 unsigned int rawid = rechit->geographicalId().rawId();
00044
00045 if(! geom->contains( rawid ))
00046 {
00047 fwLog( fwlog::kError )
00048 << "failed get geometry for detid: "
00049 << rawid << std::endl;
00050 }
00051
00052 LocalPoint pos( 0.0, 0.0, 0.0 );
00053 if( const SiStripRecHit2D* hit = dynamic_cast<const SiStripRecHit2D*>( rechit ))
00054 {
00055 if( hit->hasPositionAndError())
00056 {
00057 pos = rechit->localPosition();
00058 }
00059 }
00060 else if( const SiStripRecHit1D* hit = dynamic_cast<const SiStripRecHit1D*>( rechit ))
00061 {
00062 if( hit->hasPositionAndError())
00063 {
00064 pos = rechit->localPosition();
00065 }
00066 }
00067
00068 float localPos[3] = { pos.x(), pos.y(), pos.z() };
00069 float globalPos[3];
00070 geom->localToGlobal( rawid, localPos, globalPos );
00071 pointSet->SetNextPoint( globalPos[0], globalPos[1], globalPos[2] );
00072 }
00073 }
00074 }
00075
00076 REGISTER_FWPROXYBUILDER( FWTrackTrackingRecHitProxyBuilder, reco::Track, "Track Tracking RecHits", FWViewType::kAll3DBits | FWViewType::kAllRPZBits );