CMS 3D CMS Logo

FWME0SegmentProxyBuilder.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 #include "TEvePointSet.h"
6 
11 
13 
15 public:
17  ~FWME0SegmentProxyBuilder(void) override {}
18 
20 
21 private:
24 
25  void build(const ME0Segment& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) override;
26 };
27 
29  unsigned int iIndex,
30  TEveElement& oItemHolder,
31  const FWViewContext*) {
32  const FWGeometry* geom = item()->getGeom();
33  unsigned int rawid = iData.me0DetId().rawId();
34 
35  if (!geom->contains(rawid)) {
36  fwLog(fwlog::kError) << "failed to get geometry of ME0 chamber with rawid: " << rawid << std::endl;
37  return;
38  }
39 
40  TEveStraightLineSet* segmentSet = new TEveStraightLineSet();
41  // FIXME: This should be set elsewhere.
42  segmentSet->SetLineWidth(5);
43  setupAddElement(segmentSet, &oItemHolder);
44 
45  TEveGeoShape* shape = item()->getGeom()->getEveShape(rawid);
46  if (shape) {
47  if (TGeoBBox* box = dynamic_cast<TGeoBBox*>(shape->GetShape())) {
48  LocalPoint pos = iData.localPosition();
49  LocalVector dir = iData.localDirection();
50  LocalVector unit = dir.unit();
51 
52  double localPosition[3] = {pos.x(), pos.y(), pos.z()};
53  double localDirectionIn[3] = {dir.x(), dir.y(), dir.z()};
54  double localDirectionOut[3] = {-dir.x(), -dir.y(), -dir.z()};
55 
56  Double_t distIn = box->DistFromInside(localPosition, localDirectionIn);
57  Double_t distOut = box->DistFromInside(localPosition, localDirectionOut);
58  LocalVector vIn = unit * distIn;
59  LocalVector vOut = -unit * distOut;
60  float localSegmentInnerPoint[3] = {static_cast<float>(localPosition[0] + vIn.x()),
61  static_cast<float>(localPosition[1] + vIn.y()),
62  static_cast<float>(localPosition[2] + vIn.z())};
63 
64  float localSegmentOuterPoint[3] = {static_cast<float>(localPosition[0] + vOut.x()),
65  static_cast<float>(localPosition[1] + vOut.y()),
66  static_cast<float>(localPosition[2] + vOut.z())};
67 
68  float globalSegmentInnerPoint[3];
69  float globalSegmentOuterPoint[3];
70 
71  geom->localToGlobal(
72  rawid, localSegmentInnerPoint, globalSegmentInnerPoint, localSegmentOuterPoint, globalSegmentOuterPoint);
73 
74  segmentSet->AddLine(globalSegmentInnerPoint[0],
75  globalSegmentInnerPoint[1],
76  globalSegmentInnerPoint[2],
77  globalSegmentOuterPoint[0],
78  globalSegmentOuterPoint[1],
79  globalSegmentOuterPoint[2]);
80 
81  // Draw hits included in the segment
82  TEvePointSet* pointSet = new TEvePointSet;
83  // FIXME: This should be set elsewhere.
84  pointSet->SetMarkerSize(0.5);
85  pointSet->SetMarkerColor(1);
86  setupAddElement(pointSet, &oItemHolder);
87  auto recHits = iData.specificRecHits();
88  for (auto rh = recHits.begin(); rh != recHits.end(); rh++) {
89  auto me0id = rh->me0Id();
90  LocalPoint hpos = rh->localPosition();
91  float hitLocalPos[3] = {hpos.x(), hpos.y(), hpos.z()};
92  float hitGlobalPoint[3];
93  geom->localToGlobal(me0id, hitLocalPos, hitGlobalPoint);
94  pointSet->SetNextPoint(hitGlobalPoint[0], hitGlobalPoint[1], hitGlobalPoint[2]);
95  }
96  }
97  }
98 }
99 
101  ME0Segment,
102  "ME0-segments",
Vector3DBase< float, LocalTag >
fwLog
#define fwLog(_level_)
Definition: fwLog.h:45
FWGeometry
Definition: FWGeometry.h:27
FWSimpleProxyBuilderTemplate.h
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
FWViewType::kAllRPZBits
static const int kAllRPZBits
Definition: FWViewType.h:67
FWME0SegmentProxyBuilder::operator=
const FWME0SegmentProxyBuilder & operator=(const FWME0SegmentProxyBuilder &)=delete
ME0Segment::specificRecHits
const std::vector< ME0RecHit > & specificRecHits() const
Definition: ME0Segment.h:74
REGISTER_FWPROXYBUILDER
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
Definition: FWProxyBuilderFactory.h:33
pos
Definition: PixelAliasList.h:18
ME0SegmentCollection.h
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
FWME0SegmentProxyBuilder::FWME0SegmentProxyBuilder
FWME0SegmentProxyBuilder(void)
Definition: FWME0SegmentProxyBuilder.cc:16
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
Point3DBase< float, LocalTag >
ME0Segment::localDirection
LocalVector localDirection() const override
Local direction.
Definition: ME0Segment.h:50
FWME0SegmentProxyBuilder::~FWME0SegmentProxyBuilder
~FWME0SegmentProxyBuilder(void) override
Definition: FWME0SegmentProxyBuilder.cc:17
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
FWGeometry.h
ME0Segment
Definition: ME0Segment.h:20
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
ME0Segment::me0DetId
ME0DetId me0DetId() const
Definition: ME0Segment.h:78
FWProxyBuilderBase::setupAddElement
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
Definition: FWProxyBuilderBase.cc:350
ME0Segment::localPosition
LocalPoint localPosition() const override
Definition: ME0Segment.h:47
fwLog.h
FWProxyBuilderBase::build
void build()
Definition: FWProxyBuilderBase.cc:110
FWEventItem.h
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
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
FWME0SegmentProxyBuilder
Definition: FWME0SegmentProxyBuilder.cc:14
fwlog::kError
Definition: fwLog.h:35
FWSimpleProxyBuilderTemplate
Definition: FWSimpleProxyBuilderTemplate.h:30
FWGeometry::getEveShape
TEveGeoShape * getEveShape(unsigned int id) const
Definition: FWGeometry.cc:324
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23