CMS 3D CMS Logo

FWTrackTrackingRecHitProxyBuilder.cc
Go to the documentation of this file.
1 #include "TEvePointSet.h"
2 
7 
12 
14 public:
17 
19 
20 private:
22  void build(const reco::Track& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) override;
23 
24 public:
27 };
28 
30  unsigned int iIndex,
31  TEveElement& oItemHolder,
32  const FWViewContext*) {
33  const FWGeometry* geom = item()->getGeom();
34 
35  for (trackingRecHit_iterator it = iData.recHitsBegin(), itEnd = iData.recHitsEnd(); it != itEnd; ++it) {
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  unsigned int rawid = rechit->geographicalId().rawId();
44 
45  if (!geom->contains(rawid)) {
46  fwLog(fwlog::kError) << "failed get geometry for detid: " << rawid << std::endl;
47  }
48 
49  LocalPoint pos(0.0, 0.0, 0.0);
50  if (const SiStripRecHit2D* hit = dynamic_cast<const SiStripRecHit2D*>(rechit)) {
51  if (hit->hasPositionAndError()) {
52  pos = rechit->localPosition();
53  }
54  } else if (const SiStripRecHit1D* hit = dynamic_cast<const SiStripRecHit1D*>(rechit)) {
55  if (hit->hasPositionAndError()) {
56  pos = rechit->localPosition();
57  }
58  }
59 
60  float localPos[3] = {pos.x(), pos.y(), pos.z()};
61  float globalPos[3];
62  geom->localToGlobal(rawid, localPos, globalPos);
63  pointSet->SetNextPoint(globalPos[0], globalPos[1], globalPos[2]);
64  }
65  }
66 }
67 
70  "Track Tracking RecHits",
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:57
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
static const int kAll3DBits
Definition: FWViewType.h:58
bool isValid() const
const FWTrackTrackingRecHitProxyBuilder & operator=(const FWTrackTrackingRecHitProxyBuilder &)=delete
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:91
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:88
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:548
DetId geographicalId() const
#define fwLog(_level_)
Definition: fwLog.h:45
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
virtual LocalPoint localPosition() const =0
const FWEventItem * item() const