CMS 3D CMS Logo

FWGEMSegmentProxyBuilder.cc
Go to the documentation of this file.
1 #include "TEveGeoNode.h"
2 #include "TEveStraightLineSet.h"
3 #include "TGeoArb8.h"
4 
9 
11 
13 public:
16 
17  bool haveSingleProduct() const override { return false; }
18 
20 
21 private:
24 
26  void buildViewType(const GEMSegment& iData,
27  unsigned int iIndex,
28  TEveElement& oItemHolder,
30  const FWViewContext*) override;
31 };
32 
34  unsigned int iIndex,
35  TEveElement& oItemHolder,
37  const FWViewContext*) {
38  const FWGeometry* geom = item()->getGeom();
39  unsigned int rawid = iData.gemDetId().rawId();
40 
41  if (!geom->contains(rawid)) {
42  fwLog(fwlog::kError) << "failed to get geometry of GEM chamber with rawid: " << rawid << std::endl;
43  return;
44  }
45 
46  TEveStraightLineSet* segmentSet = new TEveStraightLineSet();
47  // FIXME: This should be set elsewhere.
48  segmentSet->SetLineWidth(3);
49  segmentSet->SetMarkerColor(item()->defaultDisplayProperties().color());
50  segmentSet->SetMarkerSize(0.5);
51  setupAddElement(segmentSet, &oItemHolder);
52  TEveGeoShape* shape = geom->getEveShape(rawid);
53  if (shape) {
54  if (TGeoTrap* box = dynamic_cast<TGeoTrap*>(shape->GetShape())) // Trapezoidal
55  {
56  shape->SetMainTransparency(75);
57  shape->SetMainColor(item()->defaultDisplayProperties().color());
58  segmentSet->AddElement(shape);
59 
60  LocalPoint pos = iData.localPosition();
61  LocalVector dir = iData.localDirection();
62  LocalVector unit = dir.unit();
63 
64  double localPosition[3] = {pos.x(), pos.y(), pos.z()};
65  double localDirectionIn[3] = {dir.x(), dir.y(), dir.z()};
66  double localDirectionOut[3] = {-dir.x(), -dir.y(), -dir.z()};
67 
68  Double_t distIn = box->DistFromInside(localPosition, localDirectionIn);
69  Double_t distOut = box->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  if (type == FWViewType::kRhoPhi && std::abs(dir.x()) < 0.1) {
86  segmentSet->AddMarker(globalSegmentInnerPoint[0], globalSegmentInnerPoint[1], globalSegmentInnerPoint[2]);
87  } else
88  segmentSet->AddLine(globalSegmentInnerPoint[0],
89  globalSegmentInnerPoint[1],
90  globalSegmentInnerPoint[2],
91  globalSegmentOuterPoint[0],
92  globalSegmentOuterPoint[1],
93  globalSegmentOuterPoint[2]);
94  }
95  }
96 }
97 
99  GEMSegment,
100  "GEM Segment",
Vector3DBase< float, LocalTag >
FWGEMSegmentProxyBuilder
Definition: FWGEMSegmentProxyBuilder.cc:12
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:33
FWGEMSegmentProxyBuilder::operator=
const FWGEMSegmentProxyBuilder & operator=(const FWGEMSegmentProxyBuilder &)=delete
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
Point3DBase< float, LocalTag >
FWGEMSegmentProxyBuilder::FWGEMSegmentProxyBuilder
FWGEMSegmentProxyBuilder()
Definition: FWGEMSegmentProxyBuilder.cc:14
FWGeometry.h
FWGEMSegmentProxyBuilder::~FWGEMSegmentProxyBuilder
~FWGEMSegmentProxyBuilder() override
Definition: FWGEMSegmentProxyBuilder.cc:15
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
type
type
Definition: HCALResponse.h:21
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:17
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