CMS 3D CMS Logo

FWCSCSegmentProxyBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Muons
4 // Class : FWCSCSegmentProxyBuilder
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author:
10 // Created: Sun Jan 6 23:57:00 EST 2008
11 //
12 
13 #include "TEveGeoNode.h"
14 #include "TEveStraightLineSet.h"
15 #include "TGeoArb8.h"
16 
21 
23 
25 public:
27  ~FWCSCSegmentProxyBuilder(void) override {}
28 
30 
31 private:
34 
36  void build(const CSCSegment& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) override;
37 };
38 
40  unsigned int iIndex,
41  TEveElement& oItemHolder,
42  const FWViewContext*) {
43  const FWGeometry* geom = item()->getGeom();
44  unsigned int rawid = iData.cscDetId().rawId();
45 
46  if (!geom->contains(rawid)) {
47  fwLog(fwlog::kError) << "failed to get geometry of CSC chamber with rawid: " << rawid << std::endl;
48  return;
49  }
50 
51  TEveStraightLineSet* segmentSet = new TEveStraightLineSet();
52  // FIXME: This should be set elsewhere.
53  segmentSet->SetLineWidth(3);
54  setupAddElement(segmentSet, &oItemHolder);
55 
56  TEveGeoShape* shape = item()->getGeom()->getEveShape(rawid);
57  if (TGeoTrap* trap = dynamic_cast<TGeoTrap*>(shape->GetShape())) // Trapezoidal
58  {
59  LocalPoint pos = iData.localPosition();
60  LocalVector dir = iData.localDirection();
61  LocalVector unit = dir.unit();
62 
63  Double_t localPosition[3] = {pos.x(), pos.y(), pos.z()};
64  Double_t localDirectionIn[3] = {dir.x(), dir.y(), dir.z()};
65  Double_t localDirectionOut[3] = {-dir.x(), -dir.y(), -dir.z()};
66 
67  float distIn = trap->DistFromInside(localPosition, localDirectionIn);
68  float distOut = trap->DistFromInside(localPosition, localDirectionOut);
69  LocalVector vIn = unit * distIn;
70  LocalVector vOut = -unit * distOut;
71  float localSegmentInnerPoint[3] = {static_cast<float>(localPosition[0] + vIn.x()),
72  static_cast<float>(localPosition[1] + vIn.y()),
73  static_cast<float>(localPosition[2] + vIn.z())};
74 
75  float localSegmentOuterPoint[3] = {static_cast<float>(localPosition[0] + vOut.x()),
76  static_cast<float>(localPosition[1] + vOut.y()),
77  static_cast<float>(localPosition[2] + vOut.z())};
78 
79  float globalSegmentInnerPoint[3];
80  float globalSegmentOuterPoint[3];
81 
82  geom->localToGlobal(
83  rawid, localSegmentInnerPoint, globalSegmentInnerPoint, localSegmentOuterPoint, globalSegmentOuterPoint);
84 
85  segmentSet->AddLine(globalSegmentInnerPoint[0],
86  globalSegmentInnerPoint[1],
87  globalSegmentInnerPoint[2],
88  globalSegmentOuterPoint[0],
89  globalSegmentOuterPoint[1],
90  globalSegmentOuterPoint[2]);
91  }
92 }
93 
95  CSCSegment,
96  "CSC-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
REGISTER_FWPROXYBUILDER
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
Definition: FWProxyBuilderFactory.h:33
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
FWCSCSegmentProxyBuilder::operator=
const FWCSCSegmentProxyBuilder & operator=(const FWCSCSegmentProxyBuilder &)=delete
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
FWCSCSegmentProxyBuilder::~FWCSCSegmentProxyBuilder
~FWCSCSegmentProxyBuilder(void) override
Definition: FWCSCSegmentProxyBuilder.cc:27
Point3DBase< float, LocalTag >
CSCSegment
Definition: CSCSegment.h:21
FWGeometry.h
CSCSegment::localDirection
LocalVector localDirection() const override
Local direction.
Definition: CSCSegment.h:42
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
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
FWCSCSegmentProxyBuilder
Definition: FWCSCSegmentProxyBuilder.cc:24
CSCSegment::cscDetId
CSCDetId cscDetId() const
Definition: CSCSegment.h:70
fwlog::kError
Definition: fwLog.h:35
FWSimpleProxyBuilderTemplate
Definition: FWSimpleProxyBuilderTemplate.h:30
FWCSCSegmentProxyBuilder::FWCSCSegmentProxyBuilder
FWCSCSegmentProxyBuilder(void)
Definition: FWCSCSegmentProxyBuilder.cc:26
CSCSegment::localPosition
LocalPoint localPosition() const override
Definition: CSCSegment.h:39
FWGeometry::getEveShape
TEveGeoShape * getEveShape(unsigned int id) const
Definition: FWGeometry.cc:321
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
CSCSegmentCollection.h