CMS 3D CMS Logo

FWME0SegmentProxyBuilder.cc
Go to the documentation of this file.
1 #include "TEveGeoNode.h"
2 #include "TEveStraightLineSet.h"
3 #include "TGeoArb8.h"
4 #include "TEvePointSet.h"
5 
10 
12 
14 public:
16  ~FWME0SegmentProxyBuilder(void) override {}
17 
19 
20 private:
23 
24  void build(const ME0Segment& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) override;
25 };
26 
28  unsigned int iIndex,
29  TEveElement& oItemHolder,
30  const FWViewContext*) {
31  const FWGeometry* geom = item()->getGeom();
32  unsigned int rawid = iData.me0DetId().rawId();
33 
34  if (!geom->contains(rawid)) {
35  fwLog(fwlog::kError) << "failed to get geometry of ME0 chamber with rawid: " << rawid << std::endl;
36  return;
37  }
38 
39  TEveStraightLineSet* segmentSet = new TEveStraightLineSet();
40  // FIXME: This should be set elsewhere.
41  segmentSet->SetLineWidth(5);
42  setupAddElement(segmentSet, &oItemHolder);
43 
44  TEveGeoShape* shape = item()->getGeom()->getEveShape(rawid);
45  if (shape) {
46  if (TGeoBBox* box = dynamic_cast<TGeoBBox*>(shape->GetShape())) {
47  LocalPoint pos = iData.localPosition();
48  LocalVector dir = iData.localDirection();
49  LocalVector unit = dir.unit();
50 
51  double localPosition[3] = {pos.x(), pos.y(), pos.z()};
52  double localDirectionIn[3] = {dir.x(), dir.y(), dir.z()};
53  double localDirectionOut[3] = {-dir.x(), -dir.y(), -dir.z()};
54 
55  Double_t distIn = box->DistFromInside(localPosition, localDirectionIn);
56  Double_t distOut = box->DistFromInside(localPosition, localDirectionOut);
57  LocalVector vIn = unit * distIn;
58  LocalVector vOut = -unit * distOut;
59  float localSegmentInnerPoint[3] = {static_cast<float>(localPosition[0] + vIn.x()),
60  static_cast<float>(localPosition[1] + vIn.y()),
61  static_cast<float>(localPosition[2] + vIn.z())};
62 
63  float localSegmentOuterPoint[3] = {static_cast<float>(localPosition[0] + vOut.x()),
64  static_cast<float>(localPosition[1] + vOut.y()),
65  static_cast<float>(localPosition[2] + vOut.z())};
66 
67  float globalSegmentInnerPoint[3];
68  float globalSegmentOuterPoint[3];
69 
70  geom->localToGlobal(
71  rawid, localSegmentInnerPoint, globalSegmentInnerPoint, localSegmentOuterPoint, globalSegmentOuterPoint);
72 
73  segmentSet->AddLine(globalSegmentInnerPoint[0],
74  globalSegmentInnerPoint[1],
75  globalSegmentInnerPoint[2],
76  globalSegmentOuterPoint[0],
77  globalSegmentOuterPoint[1],
78  globalSegmentOuterPoint[2]);
79 
80  // Draw hits included in the segment
81  TEvePointSet* pointSet = new TEvePointSet;
82  // FIXME: This should be set elsewhere.
83  pointSet->SetMarkerSize(0.5);
84  pointSet->SetMarkerColor(1);
85  setupAddElement(pointSet, &oItemHolder);
86  auto recHits = iData.specificRecHits();
87  for (auto rh = recHits.begin(); rh != recHits.end(); rh++) {
88  auto me0id = rh->me0Id();
89  LocalPoint hpos = rh->localPosition();
90  float hitLocalPos[3] = {hpos.x(), hpos.y(), hpos.z()};
91  float hitGlobalPoint[3];
92  geom->localToGlobal(me0id, hitLocalPos, hitGlobalPoint);
93  pointSet->SetNextPoint(hitGlobalPoint[0], hitGlobalPoint[1], hitGlobalPoint[2]);
94  }
95  }
96  }
97 }
98 
100  ME0Segment,
101  "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:15
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:16
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:13
fwlog::kError
Definition: fwLog.h:35
FWSimpleProxyBuilderTemplate
Definition: FWSimpleProxyBuilderTemplate.h:30
FWGeometry::getEveShape
TEveGeoShape * getEveShape(unsigned int id) const
Definition: FWGeometry.cc:321
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23