CMS 3D CMS Logo

FWTrajectorySeedProxyBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: TrajectorySeeds
4 // Class : FWTrajectorySeedProxyBuilder
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Tue Nov 25 14:42:13 EST 2008
11 //
12 
13 // system include files
14 #include "TEveStraightLineSet.h"
15 #include "TEvePointSet.h"
16 #include "TEveLine.h"
17 
18 // user include files
26 
30 
32 public:
35 
37 
38  FWTrajectorySeedProxyBuilder(const FWTrajectorySeedProxyBuilder&) = delete; // stop default
39 
40  const FWTrajectorySeedProxyBuilder& operator=(const FWTrajectorySeedProxyBuilder&) = delete; // stop default
41 
42 private:
44  void build(const TrajectorySeed& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) override;
45 };
46 
48 
50 
52  unsigned int iIndex,
53  TEveElement& itemHolder,
54  const FWViewContext*) {
55  // LocalPoint pnt = iData.startingState().parameters().position();
56  // std::cout << pnt << std::endl;
57  // std::cout << dynamic_cast<const SiPixelRecHit *>(&(*iData.recHits().first)) << std::endl;
58  // TEveVector startPos(pnt.x(), pnt.y(), pnt.z());
59 
60  TEvePointSet* pointSet = new TEvePointSet;
61  TEveLine* line = new TEveLine;
62  TEveStraightLineSet* lineSet = new TEveStraightLineSet;
63 
64  for (auto const& hit : iData.recHits()) {
65  unsigned int id = hit.geographicalId();
66  const FWGeometry* geom = item()->getGeom();
67  const float* pars = geom->getParameters(id);
68  const SiPixelRecHit* rh = dynamic_cast<const SiPixelRecHit*>(&hit);
69  // std::cout << id << "id "<< std::endl;
70  if (rh) {
71  const SiPixelCluster* itc = rh->cluster().get();
72  if (!geom->contains(id)) {
73  fwLog(fwlog::kWarning) << "failed get geometry of SiPixelCluster with detid: " << id << std::endl;
74  continue;
75  }
76 
77  float localPoint[3] = {
78  fireworks::pixelLocalX((*itc).minPixelRow(), pars), fireworks::pixelLocalY((*itc).minPixelCol(), pars), 0.0};
79 
80  float globalPoint[3];
81  geom->localToGlobal(id, localPoint, globalPoint);
82 
83  pointSet->SetNextPoint(globalPoint[0], globalPoint[1], globalPoint[2]);
84  line->SetNextPoint(globalPoint[0], globalPoint[1], globalPoint[2]);
85 
86  }
87 
88  else {
90 
91  if (cluster) {
92  short firststrip = cluster->firstStrip();
93  float localTop[3] = {0.0, 0.0, 0.0};
94  float localBottom[3] = {0.0, 0.0, 0.0};
95 
96  fireworks::localSiStrip(firststrip, localTop, localBottom, pars, id);
97 
98  float globalTop[3];
99  float globalBottom[3];
100  geom->localToGlobal(id, localTop, globalTop, localBottom, globalBottom);
101 
102  lineSet->AddLine(globalTop[0], globalTop[1], globalTop[2], globalBottom[0], globalBottom[1], globalBottom[2]);
103  }
104  }
105  }
106 
107  setupAddElement(pointSet, &itemHolder);
108  setupAddElement(line, &itemHolder);
109  setupAddElement(lineSet, &itemHolder);
110 }
111 
112 //
113 // static member functions
114 //
117  "TrajectorySeeds",
ClusterRef cluster() const
Definition: SiPixelRecHit.h:47
const FWTrajectorySeedProxyBuilder & operator=(const FWTrajectorySeedProxyBuilder &)=delete
#define REGISTER_PROXYBUILDER_METHODS()
uint16_t firstStrip() const
#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
RecHitRange recHits() const
static const int kAll3DBits
Definition: FWViewType.h:58
void localSiStrip(short strip, float *localTop, float *localBottom, const float *pars, unsigned int id)
Definition: TrackUtils.cc:263
const SiStripCluster * extractClusterFromTrackingRecHit(const TrackingRecHit *rh)
Definition: TrackUtils.cc:318
float pixelLocalX(const double mpx, const float *)
Definition: TrackUtils.cc:159
float pixelLocalY(const double mpy, const float *)
Definition: TrackUtils.cc:209
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:548
#define fwLog(_level_)
Definition: fwLog.h:45
Pixel cluster – collection of neighboring pixels above threshold.
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
const FWEventItem * item() const
Our base class.
Definition: SiPixelRecHit.h:23