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 // $Id: FWCSCSegmentProxyBuilder.cc,v 1.17 2010/09/07 15:46:48 yana Exp $
12 //
13 
14 #include "TEveGeoNode.h"
15 #include "TEveStraightLineSet.h"
16 #include "TGeoArb8.h"
17 
22 
24 
26 {
27 public:
29  virtual ~FWCSCSegmentProxyBuilder( void ) {}
30 
32 
33 private:
36 
37  void build( const CSCSegment& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* );
38 };
39 
40 void
42  unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* )
43 {
44  const FWGeometry *geom = item()->getGeom();
45  unsigned int rawid = iData.cscDetId().rawId();
46 
47  if( ! geom->contains( rawid ))
48  {
49  fwLog(fwlog::kError) << "failed to get geometry of CSC chamber with rawid: "
50  << rawid << std::endl;
51  return;
52  }
53 
54  TEveStraightLineSet* segmentSet = new TEveStraightLineSet();
55  // FIXME: This should be set elsewhere.
56  segmentSet->SetLineWidth( 3 );
57  setupAddElement( segmentSet, &oItemHolder );
58 
59  float length = 0.0;
60  float thickness = 0.0;
61 
62  TEveGeoShape* shape = item()->getGeom()->getEveShape( rawid );
63  if( TGeoTrap* trap = dynamic_cast<TGeoTrap*>( shape->GetShape())) // Trapezoidal
64  {
65  length = trap->GetDz();
66  thickness = trap->GetH1();
67 
68  LocalPoint pos = iData.localPosition();
69  LocalVector dir = iData.localDirection();
70  LocalVector unit = dir.unit();
71 
72  Double_t localPosition[3] = { pos.x(), pos.y(), pos.z() };
73  Double_t localDirectionIn[3] = { dir.x(), dir.y(), dir.z() };
74  Double_t localDirectionOut[3] = { -dir.x(), -dir.y(), -dir.z() };
75 
76  float distIn = trap->DistFromInside( localPosition, localDirectionIn );
77  float distOut = trap->DistFromInside( localPosition, localDirectionOut );
78  LocalVector vIn = unit * distIn;
79  LocalVector vOut = -unit * distOut;
80  float localSegmentInnerPoint[3] = { static_cast<float>(localPosition[0] + vIn.x()),
81  static_cast<float>(localPosition[1] + vIn.y()),
82  static_cast<float>(localPosition[2] + vIn.z())
83  };
84 
85  float localSegmentOuterPoint[3] = { static_cast<float>(localPosition[0] + vOut.x()),
86  static_cast<float>(localPosition[1] + vOut.y()),
87  static_cast<float>(localPosition[2] + vOut.z())
88  };
89 
90  float globalSegmentInnerPoint[3];
91  float globalSegmentOuterPoint[3];
92 
93  geom->localToGlobal( rawid, localSegmentInnerPoint, globalSegmentInnerPoint, localSegmentOuterPoint, globalSegmentOuterPoint );
94 
95  segmentSet->AddLine( globalSegmentInnerPoint[0], globalSegmentInnerPoint[1], globalSegmentInnerPoint[2],
96  globalSegmentOuterPoint[0], globalSegmentOuterPoint[1], globalSegmentOuterPoint[2] );
97  }
98 }
99 
101 
102 
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
CSCDetId cscDetId() const
Definition: CSCSegment.h:70
static const int kAllRPZBits
Definition: FWViewType.h:56
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
T y() const
Definition: PV3DBase.h:57
void localToGlobal(unsigned int id, const float *local, float *global) const
Definition: FWGeometry.cc:326
const FWEventItem * item() const
static const int kAll3DBits
Definition: FWViewType.h:57
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
LocalPoint localPosition() const
Definition: CSCSegment.h:39
LocalVector localDirection() const
Local direction.
Definition: CSCSegment.h:42
TEveGeoShape * getEveShape(unsigned int id) const
Definition: FWGeometry.cc:251
string unit
Definition: csvLumiCalc.py:46
T z() const
Definition: PV3DBase.h:58
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:51
dbl *** dir
Definition: mlp_gen.cc:35
T x() const
Definition: PV3DBase.h:56
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:688