CMS 3D CMS Logo

FWCSCSegmentProxyBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Muons
4 // Class : FWCSCSegmentProxyBuilder
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author:
10 // Created: Sun Jan 6 23:57:00 EST 2008
11 //
12 
13 #include "TEveGeoNode.h"
14 #include "TEveStraightLineSet.h"
15 #include "TGeoArb8.h"
16 
21 
23 
25 public:
27  ~FWCSCSegmentProxyBuilder(void) override {}
28 
30 
31 private:
34 
36  void build(const CSCSegment& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) override;
37 };
38 
40  unsigned int iIndex,
41  TEveElement& oItemHolder,
42  const FWViewContext*) {
43  const FWGeometry* geom = item()->getGeom();
44  unsigned int rawid = iData.cscDetId().rawId();
45 
46  if (!geom->contains(rawid)) {
47  fwLog(fwlog::kError) << "failed to get geometry of CSC chamber with rawid: " << rawid << std::endl;
48  return;
49  }
50 
51  TEveStraightLineSet* segmentSet = new TEveStraightLineSet();
52  // FIXME: This should be set elsewhere.
53  segmentSet->SetLineWidth(3);
54  setupAddElement(segmentSet, &oItemHolder);
55 
56  TEveGeoShape* shape = item()->getGeom()->getEveShape(rawid);
57  if (TGeoTrap* trap = dynamic_cast<TGeoTrap*>(shape->GetShape())) // Trapezoidal
58  {
59  LocalPoint pos = iData.localPosition();
60  LocalVector dir = iData.localDirection();
61  LocalVector unit = dir.unit();
62 
63  Double_t localPosition[3] = {pos.x(), pos.y(), pos.z()};
64  Double_t localDirectionIn[3] = {dir.x(), dir.y(), dir.z()};
65  Double_t localDirectionOut[3] = {-dir.x(), -dir.y(), -dir.z()};
66 
67  float distIn = trap->DistFromInside(localPosition, localDirectionIn);
68  float distOut = trap->DistFromInside(localPosition, localDirectionOut);
69  LocalVector vIn = unit * distIn;
70  LocalVector vOut = -unit * distOut;
71  float localSegmentInnerPoint[3] = {static_cast<float>(localPosition[0] + vIn.x()),
72  static_cast<float>(localPosition[1] + vIn.y()),
73  static_cast<float>(localPosition[2] + vIn.z())};
74 
75  float localSegmentOuterPoint[3] = {static_cast<float>(localPosition[0] + vOut.x()),
76  static_cast<float>(localPosition[1] + vOut.y()),
77  static_cast<float>(localPosition[2] + vOut.z())};
78 
79  float globalSegmentInnerPoint[3];
80  float globalSegmentOuterPoint[3];
81 
82  geom->localToGlobal(
83  rawid, localSegmentInnerPoint, globalSegmentInnerPoint, localSegmentOuterPoint, globalSegmentOuterPoint);
84 
85  segmentSet->AddLine(globalSegmentInnerPoint[0],
86  globalSegmentInnerPoint[1],
87  globalSegmentInnerPoint[2],
88  globalSegmentOuterPoint[0],
89  globalSegmentOuterPoint[1],
90  globalSegmentOuterPoint[2]);
91  }
92 }
93 
95  CSCSegment,
96  "CSC-segments",
CSCDetId cscDetId() const
Definition: CSCSegment.h:70
LocalVector localDirection() const override
Local direction.
Definition: CSCSegment.h:42
static const int kAllRPZBits
Definition: FWViewType.h:67
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
T y() const
Definition: PV3DBase.h:60
const FWEventItem * item() const
static const int kAll3DBits
Definition: FWViewType.h:68
TEveGeoShape * getEveShape(unsigned int id) const
Definition: FWGeometry.cc:262
T z() const
Definition: PV3DBase.h:61
void localToGlobal(unsigned int id, const float *local, float *global, bool translatep=true) const
Definition: FWGeometry.cc:438
LocalPoint localPosition() const override
Definition: CSCSegment.h:39
bool contains(unsigned int id) const
Definition: FWGeometry.h:139
Vector3DBase unit() const
Definition: Vector3DBase.h:54
#define fwLog(_level_)
Definition: fwLog.h:45
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
const FWCSCSegmentProxyBuilder & operator=(const FWCSCSegmentProxyBuilder &)=delete
T x() const
Definition: PV3DBase.h:59
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:548
Basic3DVector unit() const