CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
FWGEMSegmentProxyBuilder.cc
Go to the documentation of this file.
1 #include "TEveGeoNode.h"
2 #include "TEveGeoShape.h"
3 #include "TEveStraightLineSet.h"
4 #include "TGeoArb8.h"
5 
10 
12 
14 public:
17 
18  bool haveSingleProduct() const override { return false; }
19 
21 
24 
25 private:
27  void buildViewType(const GEMSegment& iData,
28  unsigned int iIndex,
29  TEveElement& oItemHolder,
31  const FWViewContext*) override;
32 };
33 
35  unsigned int iIndex,
36  TEveElement& oItemHolder,
38  const FWViewContext*) {
39  const FWGeometry* geom = item()->getGeom();
40  unsigned int rawid = iData.gemDetId().rawId();
41 
42  if (!geom->contains(rawid)) {
43  fwLog(fwlog::kError) << "failed to get geometry of GEM chamber with rawid: " << rawid << std::endl;
44  return;
45  }
46 
47  TEveStraightLineSet* segmentSet = new TEveStraightLineSet();
48  // FIXME: This should be set elsewhere.
49  segmentSet->SetLineWidth(3);
50  segmentSet->SetMarkerColor(item()->defaultDisplayProperties().color());
51  segmentSet->SetMarkerSize(0.5);
52  setupAddElement(segmentSet, &oItemHolder);
53  TEveGeoShape* shape = geom->getEveShape(rawid);
54  if (shape) {
55  if (TGeoTrap* box = dynamic_cast<TGeoTrap*>(shape->GetShape())) // Trapezoidal
56  {
57  shape->SetMainTransparency(75);
58  shape->SetMainColor(item()->defaultDisplayProperties().color());
59  segmentSet->AddElement(shape);
60 
61  LocalPoint pos = iData.localPosition();
62  LocalVector dir = iData.localDirection();
63  LocalVector unit = dir.unit();
64 
65  double localPosition[3] = {pos.x(), pos.y(), pos.z()};
66  double localDirectionIn[3] = {dir.x(), dir.y(), dir.z()};
67  double localDirectionOut[3] = {-dir.x(), -dir.y(), -dir.z()};
68 
69  Double_t distIn = box->DistFromInside(localPosition, localDirectionIn);
70  Double_t distOut = box->DistFromInside(localPosition, localDirectionOut);
71  LocalVector vIn = unit * distIn;
72  LocalVector vOut = -unit * distOut;
73  float localSegmentInnerPoint[3] = {static_cast<float>(localPosition[0] + vIn.x()),
74  static_cast<float>(localPosition[1] + vIn.y()),
75  static_cast<float>(localPosition[2] + vIn.z())};
76 
77  float localSegmentOuterPoint[3] = {static_cast<float>(localPosition[0] + vOut.x()),
78  static_cast<float>(localPosition[1] + vOut.y()),
79  static_cast<float>(localPosition[2] + vOut.z())};
80 
81  float globalSegmentInnerPoint[3];
82  float globalSegmentOuterPoint[3];
83 
84  geom->localToGlobal(
85  rawid, localSegmentInnerPoint, globalSegmentInnerPoint, localSegmentOuterPoint, globalSegmentOuterPoint);
86  if (type == FWViewType::kRhoPhi && std::abs(dir.x()) < 0.1) {
87  segmentSet->AddMarker(globalSegmentInnerPoint[0], globalSegmentInnerPoint[1], globalSegmentInnerPoint[2]);
88  } else
89  segmentSet->AddLine(globalSegmentInnerPoint[0],
90  globalSegmentInnerPoint[1],
91  globalSegmentInnerPoint[2],
92  globalSegmentOuterPoint[0],
93  globalSegmentOuterPoint[1],
94  globalSegmentOuterPoint[2]);
95  }
96  }
97 }
98 
100  GEMSegment,
101  "GEM Segment",
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:67
LocalPoint localPosition() const override
Definition: GEMSegment.h:52
GEMDetId gemDetId() const
Definition: GEMSegment.h:83
LocalVector localDirection() const override
Local direction.
Definition: GEMSegment.h:55
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
const FWGEMSegmentProxyBuilder & operator=(const FWGEMSegmentProxyBuilder &)=delete
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
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool contains(unsigned int id) const
Definition: FWGeometry.h:139
bool haveSingleProduct() const override
void buildViewType(const GEMSegment &iData, unsigned int iIndex, TEveElement &oItemHolder, FWViewType::EType type, const FWViewContext *) override
Vector3DBase unit() const
Definition: Vector3DBase.h:54
#define fwLog(_level_)
Definition: fwLog.h:45
T x() const
Definition: PV3DBase.h:59
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:548
Basic3DVector unit() const