CMS 3D CMS Logo

FWGEMRecHitProxyBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Muons
4 // Class : FWGEMRecHitProxyBuilder
5 //
6 //
7 // Original Author:
8 // Created: Sun Jan 6 23:42:33 EST 2008
9 // $Id: FWRPCRecHitProxyBuilder.cc,v 1.16 2010/11/11 20:25:28 amraktad Exp $
10 // $Id: FWGEMRecHitProxyBuilder.cc,v 1.17 2013/10/10 21:57:00 Yusang Kim $
11 //
12 
13 #include "TEveGeoNode.h"
14 #include "TEveGeoShape.h"
15 #include "TEveStraightLineSet.h"
16 
21 
23 
25 public:
28 
29  bool haveSingleProduct() const override { return false; }
30 
32 
35 
36 private:
38  void buildViewType(const GEMRecHit& iData,
39  unsigned int iIndex,
40  TEveElement& oItemHolder,
42  const FWViewContext*) override;
43 };
44 
46  unsigned int iIndex,
47  TEveElement& oItemHolder,
49  const FWViewContext*) {
50  GEMDetId gemId = iData.gemId();
51  unsigned int rawid = gemId.rawId();
52 
53  const FWGeometry* geom = item()->getGeom();
54 
55  if (!geom->contains(rawid)) {
56  fwLog(fwlog::kError) << "failed to get geometry of GEM roll with detid: " << rawid << std::endl;
57  return;
58  }
59 
60  TEveStraightLineSet* recHitSet = new TEveStraightLineSet;
61  recHitSet->SetLineWidth(3);
62 
64  TEveGeoShape* shape = geom->getEveShape(rawid);
65  shape->SetMainTransparency(75);
66  shape->SetMainColor(item()->defaultDisplayProperties().color());
67  recHitSet->AddElement(shape);
68  }
69 
70  float localX = iData.localPosition().x();
71  float localY = iData.localPosition().y();
72  float localZ = iData.localPosition().z();
73 
74  float localXerr = sqrt(iData.localPositionError().xx());
75  float localYerr = sqrt(iData.localPositionError().yy());
76 
77  float localU1[3] = {localX - localXerr, localY, localZ};
78 
79  float localU2[3] = {localX + localXerr, localY, localZ};
80 
81  float localV1[3] = {localX, localY - localYerr, localZ};
82 
83  float localV2[3] = {localX, localY + localYerr, localZ};
84 
85  float globalU1[3];
86  float globalU2[3];
87  float globalV1[3];
88  float globalV2[3];
89 
90  FWGeometry::IdToInfoItr det = geom->find(rawid);
91 
92  geom->localToGlobal(*det, localU1, globalU1);
93  geom->localToGlobal(*det, localU2, globalU2);
94  geom->localToGlobal(*det, localV1, globalV1);
95  geom->localToGlobal(*det, localV2, globalV2);
96 
97  recHitSet->AddLine(globalU1[0], globalU1[1], globalU1[2], globalU2[0], globalU2[1], globalU2[2]);
98 
99  recHitSet->AddLine(globalV1[0], globalV1[1], globalV1[2], globalV2[0], globalV2[1], globalV2[2]);
100 
101  setupAddElement(recHitSet, &oItemHolder);
102 }
103 
105  GEMRecHit,
106  "GEM RecHits",
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
bool haveSingleProduct() const override
static const int kAllRPZBits
Definition: FWViewType.h:67
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
LocalPoint localPosition() const override
Return the 3-dimensional local position.
Definition: GEMRecHit.h:37
static const int kAll3DBits
Definition: FWViewType.h:68
const FWGEMRecHitProxyBuilder & operator=(const FWGEMRecHitProxyBuilder &)=delete
float yy() const
Definition: LocalError.h:24
T sqrt(T t)
Definition: SSEVec.h:19
LocalError localPositionError() const override
Return the 3-dimensional error on the local position.
Definition: GEMRecHit.h:40
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:548
GEMDetId gemId() const
Return the gemId.
Definition: GEMRecHit.h:65
#define fwLog(_level_)
Definition: fwLog.h:45
constexpr uint16_t localX(uint16_t px)
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
constexpr uint16_t localY(uint16_t py, uint16_t n)
const FWEventItem * item() const
std::vector< FWGeometry::GeomDetInfo >::const_iterator IdToInfoItr
Definition: FWGeometry.h:137
float xx() const
Definition: LocalError.h:22
void buildViewType(const GEMRecHit &iData, unsigned int iIndex, TEveElement &oItemHolder, FWViewType::EType type, const FWViewContext *) override