CMS 3D CMS Logo

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 
22 private:
25 
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",
Vector3DBase< float, LocalTag >
FWGEMSegmentProxyBuilder
Definition: FWGEMSegmentProxyBuilder.cc:13
fwLog
#define fwLog(_level_)
Definition: fwLog.h:45
FWGeometry
Definition: FWGeometry.h:27
FWSimpleProxyBuilderTemplate.h
FWViewType::EType
EType
Definition: FWViewType.h:31
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
FWViewType::kAllRPZBits
static const int kAllRPZBits
Definition: FWViewType.h:67
REGISTER_FWPROXYBUILDER
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
Definition: FWProxyBuilderFactory.h:33
GEMSegment::localPosition
LocalPoint localPosition() const override
Definition: GEMSegment.h:52
pos
Definition: PixelAliasList.h:18
REGISTER_PROXYBUILDER_METHODS
#define REGISTER_PROXYBUILDER_METHODS()
Definition: register_dataproxybuilder_macro.h:28
FWViewType::kAll3DBits
static const int kAll3DBits
Definition: FWViewType.h:68
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
FWGEMSegmentProxyBuilder::buildViewType
void buildViewType(const GEMSegment &iData, unsigned int iIndex, TEveElement &oItemHolder, FWViewType::EType type, const FWViewContext *) override
Definition: FWGEMSegmentProxyBuilder.cc:34
FWGEMSegmentProxyBuilder::operator=
const FWGEMSegmentProxyBuilder & operator=(const FWGEMSegmentProxyBuilder &)=delete
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
Point3DBase< float, LocalTag >
FWGEMSegmentProxyBuilder::FWGEMSegmentProxyBuilder
FWGEMSegmentProxyBuilder()
Definition: FWGEMSegmentProxyBuilder.cc:15
FWGeometry.h
FWGEMSegmentProxyBuilder::~FWGEMSegmentProxyBuilder
~FWGEMSegmentProxyBuilder() override
Definition: FWGEMSegmentProxyBuilder.cc:16
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
FWProxyBuilderBase::setupAddElement
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
Definition: FWProxyBuilderBase.cc:350
fwLog.h
FWEventItem.h
GEMSegment
Definition: GEMSegment.h:19
FWViewContext
Definition: FWViewContext.h:32
unit
Basic3DVector unit() const
Definition: Basic3DVectorLD.h:162
FWEventItem::getGeom
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:548
FWProxyBuilderBase::item
const FWEventItem * item() const
Definition: FWProxyBuilderBase.h:64
GEMSegment::gemDetId
GEMDetId gemDetId() const
Definition: GEMSegment.h:83
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
GEMSegmentCollection.h
FWGEMSegmentProxyBuilder::haveSingleProduct
bool haveSingleProduct() const override
Definition: FWGEMSegmentProxyBuilder.cc:18
GEMSegment::localDirection
LocalVector localDirection() const override
Local direction.
Definition: GEMSegment.h:55
fwlog::kError
Definition: fwLog.h:35
FWSimpleProxyBuilderTemplate
Definition: FWSimpleProxyBuilderTemplate.h:30
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
FWViewType::kRhoPhi
Definition: FWViewType.h:32
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23