CMS 3D CMS Logo

FWGEMSegmentProxyBuilder.cc
Go to the documentation of this file.
1 #include "TEveGeoNode.h"
2 #include "TEveStraightLineSet.h"
3 #include "TGeoArb8.h"
4 
9 
11 
13 {
14 public:
17 
18  virtual bool haveSingleProduct() const { return false; }
19 
21 
22 private:
25 
27  virtual void buildViewType(const GEMSegment& iData,
28  unsigned int iIndex,
29  TEveElement& oItemHolder,
31  const FWViewContext*);
32 };
33 
34 
35 void
37  unsigned int iIndex,
38  TEveElement& oItemHolder,
40  const FWViewContext*)
41 {
42 
43  const FWGeometry *geom = item()->getGeom();
44  unsigned int rawid = iData.gemDetId().rawId();
45 
46  if( !geom->contains( rawid )){
47  fwLog(fwlog::kError) << "failed to get geometry of GEM chamber with rawid: "
48  << rawid << std::endl;
49  return;
50  }
51 
52  TEveStraightLineSet* segmentSet = new TEveStraightLineSet();
53  // FIXME: This should be set elsewhere.
54  segmentSet->SetLineWidth( 3 );
55  segmentSet->SetMarkerColor(item()->defaultDisplayProperties().color());
56  segmentSet->SetMarkerSize(0.5);
57  setupAddElement( segmentSet, &oItemHolder );
58  TEveGeoShape* shape = geom->getEveShape( rawid );
59  if( shape )
60  {
61  if( TGeoTrap* box = dynamic_cast<TGeoTrap*>( shape->GetShape())) // Trapezoidal
62  {
63  shape->SetMainTransparency( 75 );
64  shape->SetMainColor( item()->defaultDisplayProperties().color());
65  segmentSet->AddElement( shape );
66 
67  LocalPoint pos = iData.localPosition();
68  LocalVector dir = iData.localDirection();
69  LocalVector unit = dir.unit();
70 
71  double localPosition[3] = { pos.x(), pos.y(), pos.z() };
72  double localDirectionIn[3] = { dir.x(), dir.y(), dir.z() };
73  double localDirectionOut[3] = { -dir.x(), -dir.y(), -dir.z() };
74 
75  Double_t distIn = box->DistFromInside( localPosition, localDirectionIn );
76  Double_t distOut = box->DistFromInside( localPosition, localDirectionOut );
77  LocalVector vIn = unit * distIn;
78  LocalVector vOut = -unit * distOut;
79  float localSegmentInnerPoint[3] = { static_cast<float>(localPosition[0] + vIn.x()),
80  static_cast<float>(localPosition[1] + vIn.y()),
81  static_cast<float>(localPosition[2] + vIn.z())
82  };
83 
84  float localSegmentOuterPoint[3] = { static_cast<float>(localPosition[0] + vOut.x()),
85  static_cast<float>(localPosition[1] + vOut.y()),
86  static_cast<float>(localPosition[2] + vOut.z())
87  };
88 
89  float globalSegmentInnerPoint[3];
90  float globalSegmentOuterPoint[3];
91 
92  geom->localToGlobal( rawid, localSegmentInnerPoint, globalSegmentInnerPoint, localSegmentOuterPoint, globalSegmentOuterPoint );
93  if (type == FWViewType::kRhoPhi && std::abs(dir.x()) < 0.1){
94  segmentSet->AddMarker( globalSegmentInnerPoint[0], globalSegmentInnerPoint[1], globalSegmentInnerPoint[2] );
95  }
96  else
97  segmentSet->AddLine( globalSegmentInnerPoint[0], globalSegmentInnerPoint[1], globalSegmentInnerPoint[2],
98  globalSegmentOuterPoint[0], globalSegmentOuterPoint[1], globalSegmentOuterPoint[2] );
99 
100  }
101  }
102 
103 }
104 
type
Definition: HCALResponse.h:21
#define REGISTER_PROXYBUILDER_METHODS()
const FWGEMSegmentProxyBuilder & operator=(const FWGEMSegmentProxyBuilder &)
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
virtual bool haveSingleProduct() const
static const int kAllRPZBits
Definition: FWViewType.h:58
GEMDetId gemDetId() const
Definition: GEMSegment.h:73
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
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
TEveGeoShape * getEveShape(unsigned int id) const
Definition: FWGeometry.cc:259
LocalPoint localPosition() const
Definition: GEMSegment.h:42
T z() const
Definition: PV3DBase.h:64
void localToGlobal(unsigned int id, const float *local, float *global, bool translatep=true) const
Definition: FWGeometry.cc:334
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool contains(unsigned int id) const
Definition: FWGeometry.h:110
Vector3DBase unit() const
Definition: Vector3DBase.h:57
#define fwLog(_level_)
Definition: fwLog.h:50
virtual void buildViewType(const GEMSegment &iData, unsigned int iIndex, TEveElement &oItemHolder, FWViewType::EType type, const FWViewContext *)
LocalVector localDirection() const
Local direction.
Definition: GEMSegment.h:45
dbl *** dir
Definition: mlp_gen.cc:35
T x() const
Definition: PV3DBase.h:62
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:683