CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWDTSegmentProxyBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Muons
4 // Class : FWDTSegmentProxyBuilder
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author:
10 // Created: Sun Jan 6 23:57:00 EST 2008
11 // $Id: FWDTSegmentProxyBuilder.cc,v 1.14 2010/11/11 20:25:28 amraktad Exp $
12 //
13 
14 #include "TEveGeoNode.h"
15 #include "TEveStraightLineSet.h"
16 #include "TGeoArb8.h"
17 
22 
24 
26 {
27 public:
29  virtual ~FWDTSegmentProxyBuilder( void ) {}
30 
32 
33 private:
36 
37  void build( const DTRecSegment4D& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* );
38 };
39 
40 void
42  unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* )
43 {
44  unsigned int rawid = iData.chamberId().rawId();
45  const FWGeometry *geom = item()->getGeom();
46 
47  if( ! geom->contains( rawid ))
48  {
49  fwLog( fwlog::kError ) << "failed to get geometry of DT chamber with detid: "
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  TEveGeoShape* shape = item()->getGeom()->getEveShape( rawid );
60  if( shape )
61  {
62  if( TGeoBBox* box = dynamic_cast<TGeoBBox*>( shape->GetShape()))
63  {
64  LocalPoint pos = iData.localPosition();
65  LocalVector dir = iData.localDirection();
66  LocalVector unit = dir.unit();
67 
68  double localPosition[3] = { pos.x(), pos.y(), pos.z() };
69  double localDirectionIn[3] = { dir.x(), dir.y(), dir.z() };
70  double localDirectionOut[3] = { -dir.x(), -dir.y(), -dir.z() };
71 
72  Double_t distIn = box->DistFromInside( localPosition, localDirectionIn );
73  Double_t distOut = box->DistFromInside( localPosition, localDirectionOut );
74  LocalVector vIn = unit * distIn;
75  LocalVector vOut = -unit * distOut;
76  float localSegmentInnerPoint[3] = { static_cast<float>(localPosition[0] + vIn.x()),
77  static_cast<float>(localPosition[1] + vIn.y()),
78  static_cast<float>(localPosition[2] + vIn.z())
79  };
80 
81  float localSegmentOuterPoint[3] = { static_cast<float>(localPosition[0] + vOut.x()),
82  static_cast<float>(localPosition[1] + vOut.y()),
83  static_cast<float>(localPosition[2] + vOut.z())
84  };
85 
86  float globalSegmentInnerPoint[3];
87  float globalSegmentOuterPoint[3];
88 
89  geom->localToGlobal( rawid, localSegmentInnerPoint, globalSegmentInnerPoint, localSegmentOuterPoint, globalSegmentOuterPoint );
90 
91  segmentSet->AddLine( globalSegmentInnerPoint[0], globalSegmentInnerPoint[1], globalSegmentInnerPoint[2],
92  globalSegmentOuterPoint[0], globalSegmentOuterPoint[1], globalSegmentOuterPoint[2] );
93  }
94  }
95 }
96 
98 
99 
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:59
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
T y() const
Definition: PV3DBase.h:63
virtual DTChamberId chamberId() const
The (specific) DetId of the chamber on which the segment resides.
void localToGlobal(unsigned int id, const float *local, float *global) const
Definition: FWGeometry.cc:325
const FWEventItem * item() const
static const int kAll3DBits
Definition: FWViewType.h:60
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
virtual LocalVector localDirection() const
Local direction in Chamber frame.
TEveGeoShape * getEveShape(unsigned int id) const
Definition: FWGeometry.cc:250
string unit
Definition: csvLumiCalc.py:46
T z() const
Definition: PV3DBase.h:64
bool contains(unsigned int id) const
Definition: FWGeometry.h:98
const FWDTSegmentProxyBuilder & operator=(const FWDTSegmentProxyBuilder &)
virtual LocalPoint localPosition() const
Local position in Chamber frame.
Vector3DBase unit() const
Definition: Vector3DBase.h:57
#define fwLog(_level_)
Definition: fwLog.h:51
dbl *** dir
Definition: mlp_gen.cc:35
T x() const
Definition: PV3DBase.h:62
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:682