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 "TEveGeoShape.h"
15 #include "TEveStraightLineSet.h"
16 #include "TGeoArb8.h"
17 
22 
24 
26 public:
28  ~FWCSCSegmentProxyBuilder(void) override {}
29 
31 
32 private:
35 
37  void build(const CSCSegment& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) override;
38 };
39 
41  unsigned int iIndex,
42  TEveElement& oItemHolder,
43  const FWViewContext*) {
44  const FWGeometry* geom = item()->getGeom();
45  unsigned int rawid = iData.cscDetId().rawId();
46 
47  if (!geom->contains(rawid)) {
48  fwLog(fwlog::kError) << "failed to get geometry of CSC chamber with rawid: " << rawid << std::endl;
49  return;
50  }
51 
52  TEveStraightLineSet* segmentSet = new TEveStraightLineSet();
53  // FIXME: This should be set elsewhere.
54  segmentSet->SetLineWidth(3);
55  setupAddElement(segmentSet, &oItemHolder);
56 
57  TEveGeoShape* shape = item()->getGeom()->getEveShape(rawid);
58  if (TGeoTrap* trap = dynamic_cast<TGeoTrap*>(shape->GetShape())) // Trapezoidal
59  {
60  LocalPoint pos = iData.localPosition();
61  LocalVector dir = iData.localDirection();
62  LocalVector unit = dir.unit();
63 
64  Double_t localPosition[3] = {pos.x(), pos.y(), pos.z()};
65  Double_t localDirectionIn[3] = {dir.x(), dir.y(), dir.z()};
66  Double_t localDirectionOut[3] = {-dir.x(), -dir.y(), -dir.z()};
67 
68  float distIn = trap->DistFromInside(localPosition, localDirectionIn);
69  float distOut = trap->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 
86  segmentSet->AddLine(globalSegmentInnerPoint[0],
87  globalSegmentInnerPoint[1],
88  globalSegmentInnerPoint[2],
89  globalSegmentOuterPoint[0],
90  globalSegmentOuterPoint[1],
91  globalSegmentOuterPoint[2]);
92  }
93 }
94 
96  CSCSegment,
97  "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:28
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:25
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:27
CSCSegment::localPosition
LocalPoint localPosition() const override
Definition: CSCSegment.h:39
FWGeometry::getEveShape
TEveGeoShape * getEveShape(unsigned int id) const
Definition: FWGeometry.cc:324
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
CSCSegmentCollection.h