CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWTrackTrackingRecHitProxyBuilder.cc
Go to the documentation of this file.
1 #include "TEvePointSet.h"
2 
7 
12 
14 {
15 public:
18 
20 
21 private:
22  void build( const reco::Track& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* );
23 
26 };
27 
28 void
29 FWTrackTrackingRecHitProxyBuilder::build( const reco::Track& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* )
30 {
31  const FWGeometry *geom = item()->getGeom();
32 
33  for( trackingRecHit_iterator it = iData.recHitsBegin(), itEnd = iData.recHitsEnd(); it != itEnd; ++it )
34  {
35  TEvePointSet* pointSet = new TEvePointSet;
36  setupAddElement( pointSet, &oItemHolder );
37 
38  TrackingRecHitRef rechitRef = *it;
39  const TrackingRecHit *rechit = &( *rechitRef );
40 
41  if( rechit->isValid())
42  {
43  unsigned int rawid = rechit->geographicalId().rawId();
44 
45  if(! geom->contains( rawid ))
46  {
48  << "failed get geometry for detid: "
49  << rawid << std::endl;
50  }
51 
52  LocalPoint pos( 0.0, 0.0, 0.0 );
53  if( const SiStripRecHit2D* hit = dynamic_cast<const SiStripRecHit2D*>( rechit ))
54  {
55  if( hit->hasPositionAndError())
56  {
57  pos = rechit->localPosition();
58  }
59  }
60  else if( const SiStripRecHit1D* hit = dynamic_cast<const SiStripRecHit1D*>( rechit ))
61  {
62  if( hit->hasPositionAndError())
63  {
64  pos = rechit->localPosition();
65  }
66  }
67 
68  float localPos[3] = { pos.x(), pos.y(), pos.z() };
69  float globalPos[3];
70  geom->localToGlobal( rawid, localPos, globalPos );
71  pointSet->SetNextPoint( globalPos[0], globalPos[1], globalPos[2] );
72  }
73  }
74 }
75 
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:59
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
T y() const
Definition: PV3DBase.h:62
void localToGlobal(unsigned int id, const float *local, float *global) const
Definition: FWGeometry.cc:325
const FWEventItem * item() const
static const int kAll3DBits
Definition: FWViewType.h:60
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
T z() const
Definition: PV3DBase.h:63
bool contains(unsigned int id) const
Definition: FWGeometry.h:98
const FWTrackTrackingRecHitProxyBuilder & operator=(const FWTrackTrackingRecHitProxyBuilder &)
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:63
#define fwLog(_level_)
Definition: fwLog.h:51
bool isValid() const
DetId geographicalId() const
T x() const
Definition: PV3DBase.h:61
virtual LocalPoint localPosition() const =0
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:681
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:65