CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 "TEveGeoShape.h"
15 #include "TEveStraightLineSet.h"
16 #include "TGeoArb8.h"
17 
22 
24 
26 public:
28  ~FWCSCSegmentProxyBuilder(void) override {}
29 
31 
34 
35 private:
37  void build(const CSCSegment& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) override;
38 };
39 
41  unsigned int iIndex,
42  TEveElement& oItemHolder,
43  const FWViewContext*) {
44  const FWGeometry* geom = item()->getGeom();
45  unsigned int rawid = iData.cscDetId().rawId();
46 
47  if (!geom->contains(rawid)) {
48  fwLog(fwlog::kError) << "failed to get geometry of CSC chamber with rawid: " << rawid << std::endl;
49  return;
50  }
51 
52  TEveStraightLineSet* segmentSet = new TEveStraightLineSet();
53  // FIXME: This should be set elsewhere.
54  segmentSet->SetLineWidth(3);
55  setupAddElement(segmentSet, &oItemHolder);
56 
57  TEveGeoShape* shape = item()->getGeom()->getEveShape(rawid);
58  if (TGeoTrap* trap = dynamic_cast<TGeoTrap*>(shape->GetShape())) // Trapezoidal
59  {
60  LocalPoint pos = iData.localPosition();
61  LocalVector dir = iData.localDirection();
62  LocalVector unit = dir.unit();
63 
64  Double_t localPosition[3] = {pos.x(), pos.y(), pos.z()};
65  Double_t localDirectionIn[3] = {dir.x(), dir.y(), dir.z()};
66  Double_t localDirectionOut[3] = {-dir.x(), -dir.y(), -dir.z()};
67 
68  float distIn = trap->DistFromInside(localPosition, localDirectionIn);
69  float distOut = trap->DistFromInside(localPosition, localDirectionOut);
70  LocalVector vIn = unit * distIn;
71  LocalVector vOut = -unit * distOut;
72  float localSegmentInnerPoint[3] = {static_cast<float>(localPosition[0] + vIn.x()),
73  static_cast<float>(localPosition[1] + vIn.y()),
74  static_cast<float>(localPosition[2] + vIn.z())};
75 
76  float localSegmentOuterPoint[3] = {static_cast<float>(localPosition[0] + vOut.x()),
77  static_cast<float>(localPosition[1] + vOut.y()),
78  static_cast<float>(localPosition[2] + vOut.z())};
79 
80  float globalSegmentInnerPoint[3];
81  float globalSegmentOuterPoint[3];
82 
83  geom->localToGlobal(
84  rawid, localSegmentInnerPoint, globalSegmentInnerPoint, localSegmentOuterPoint, globalSegmentOuterPoint);
85 
86  segmentSet->AddLine(globalSegmentInnerPoint[0],
87  globalSegmentInnerPoint[1],
88  globalSegmentInnerPoint[2],
89  globalSegmentOuterPoint[0],
90  globalSegmentOuterPoint[1],
91  globalSegmentOuterPoint[2]);
92  }
93 }
94 
96  CSCSegment,
97  "CSC-segments",
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
LocalPoint localPosition() const override
Definition: CSCSegment.h:39
CSCDetId cscDetId() const
Definition: CSCSegment.h:70
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
LocalVector localDirection() const override
Local direction.
Definition: CSCSegment.h:42
TEveGeoShape * getEveShape(unsigned int id) const
Definition: FWGeometry.cc:318
T z() const
Definition: PV3DBase.h:61
void localToGlobal(unsigned int id, const float *local, float *global, bool translatep=true) const
Definition: FWGeometry.cc:494
bool contains(unsigned int id) const
Definition: FWGeometry.h:139
Vector3DBase unit() const
Definition: Vector3DBase.h:54
#define fwLog(_level_)
Definition: fwLog.h:45
const FWCSCSegmentProxyBuilder & operator=(const FWCSCSegmentProxyBuilder &)=delete
T x() const
Definition: PV3DBase.h:59
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:548
Basic3DVector unit() const