CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 {
26 public:
28  virtual ~FWCSCSegmentProxyBuilder( void ) {}
29 
31 
32 private:
35 
36  void build( const CSCSegment& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* ) override;
37 };
38 
39 void
41  unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* )
42 {
43  const FWGeometry *geom = item()->getGeom();
44  unsigned int rawid = iData.cscDetId().rawId();
45 
46  if( ! geom->contains( rawid ))
47  {
48  fwLog(fwlog::kError) << "failed to get geometry of CSC chamber with rawid: "
49  << rawid << std::endl;
50  return;
51  }
52 
53  TEveStraightLineSet* segmentSet = new TEveStraightLineSet();
54  // FIXME: This should be set elsewhere.
55  segmentSet->SetLineWidth( 3 );
56  setupAddElement( segmentSet, &oItemHolder );
57 
58  TEveGeoShape* shape = item()->getGeom()->getEveShape( rawid );
59  if( TGeoTrap* trap = dynamic_cast<TGeoTrap*>( shape->GetShape())) // Trapezoidal
60  {
61  LocalPoint pos = iData.localPosition();
62  LocalVector dir = iData.localDirection();
63  LocalVector unit = dir.unit();
64 
65  Double_t localPosition[3] = { pos.x(), pos.y(), pos.z() };
66  Double_t localDirectionIn[3] = { dir.x(), dir.y(), dir.z() };
67  Double_t localDirectionOut[3] = { -dir.x(), -dir.y(), -dir.z() };
68 
69  float distIn = trap->DistFromInside( localPosition, localDirectionIn );
70  float distOut = trap->DistFromInside( localPosition, localDirectionOut );
71  LocalVector vIn = unit * distIn;
72  LocalVector vOut = -unit * distOut;
73  float localSegmentInnerPoint[3] = { static_cast<float>(localPosition[0] + vIn.x()),
74  static_cast<float>(localPosition[1] + vIn.y()),
75  static_cast<float>(localPosition[2] + vIn.z())
76  };
77 
78  float localSegmentOuterPoint[3] = { static_cast<float>(localPosition[0] + vOut.x()),
79  static_cast<float>(localPosition[1] + vOut.y()),
80  static_cast<float>(localPosition[2] + vOut.z())
81  };
82 
83  float globalSegmentInnerPoint[3];
84  float globalSegmentOuterPoint[3];
85 
86  geom->localToGlobal( rawid, localSegmentInnerPoint, globalSegmentInnerPoint, localSegmentOuterPoint, globalSegmentOuterPoint );
87 
88  segmentSet->AddLine( globalSegmentInnerPoint[0], globalSegmentInnerPoint[1], globalSegmentInnerPoint[2],
89  globalSegmentOuterPoint[0], globalSegmentOuterPoint[1], globalSegmentOuterPoint[2] );
90  }
91 }
92 
94 
95 
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:58
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
T y() const
Definition: PV3DBase.h:63
const FWEventItem * item() const
static const int kAll3DBits
Definition: FWViewType.h:59
TEveGeoShape * getEveShape(unsigned int id) const
Definition: FWGeometry.cc:250
string unit
Definition: csvLumiCalc.py:46
T z() const
Definition: PV3DBase.h:64
void localToGlobal(unsigned int id, const float *local, float *global, bool translatep=true) const
Definition: FWGeometry.cc:325
bool contains(unsigned int id) const
Definition: FWGeometry.h:98
Vector3DBase unit() const
Definition: Vector3DBase.h:57
const FWCSCSegmentProxyBuilder & operator=(const FWCSCSegmentProxyBuilder &)
#define fwLog(_level_)
Definition: fwLog.h:50
dbl *** dir
Definition: mlp_gen.cc:35
T x() const
Definition: PV3DBase.h:62
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:681