CMS 3D CMS Logo

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