CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWCSCRecHitProxyBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Muons
4 // Class : FWCSCRecHitProxyBuilder
5 //
6 //
7 
8 #include "TEvePointSet.h"
9 #include "TEveStraightLineSet.h"
10 
15 
17 
19 {
20 public:
22  virtual ~FWCSCRecHitProxyBuilder( void ) {}
23 
25 
26 private:
29 
31  void build( const CSCRecHit2D& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* ) override;
32 };
33 
34 void
36  unsigned int iIndex, TEveElement& oItemHolder,
37  const FWViewContext* )
38 {
39  const FWGeometry *geom = item()->getGeom();
40  unsigned int rawid = iData.cscDetId().rawId();
41 
42  if( ! geom->contains( rawid ))
43  {
44  fwLog( fwlog::kError ) << "failed to get geometry of CSC layer with detid: "
45  << rawid <<std::endl;
46  return;
47  }
48  FWGeometry::IdToInfoItr det = geom->find( rawid );
49 
50  TEveStraightLineSet* recHitSet = new TEveStraightLineSet;
51  setupAddElement( recHitSet, &oItemHolder );
52 
53  TEvePointSet* pointSet = new TEvePointSet;
54  setupAddElement( pointSet, &oItemHolder );
55 
56  float localPositionX = iData.localPosition().x();
57  float localPositionY = iData.localPosition().y();
58 
59  float localPositionXX = sqrt( iData.localPositionError().xx());
60  float localPositionYY = sqrt( iData.localPositionError().yy());
61 
62  float localU1Point[3] =
63  {
64  localPositionX - localPositionXX, localPositionY, 0.0
65  };
66 
67  float localU2Point[3] =
68  {
69  localPositionX + localPositionXX, localPositionY, 0.0
70  };
71 
72  float localV1Point[3] =
73  {
74  localPositionX, localPositionY - localPositionYY, 0.0
75  };
76 
77  float localV2Point[3] =
78  {
79  localPositionX, localPositionY + localPositionYY, 0.0
80  };
81 
82  float globalU1Point[3];
83  float globalU2Point[3];
84  float globalV1Point[3];
85  float globalV2Point[3];
86 
87  geom->localToGlobal( *det, localU1Point, globalU1Point );
88  geom->localToGlobal( *det, localU2Point, globalU2Point );
89  geom->localToGlobal( *det, localV1Point, globalV1Point );
90  geom->localToGlobal( *det, localV2Point, globalV2Point );
91 
92  pointSet->SetNextPoint( globalU1Point[0], globalU1Point[1], globalU1Point[2] );
93  pointSet->SetNextPoint( globalU2Point[0], globalU2Point[1], globalU2Point[2] );
94  pointSet->SetNextPoint( globalV1Point[0], globalV1Point[1], globalV1Point[2] );
95  pointSet->SetNextPoint( globalV2Point[0], globalV2Point[1], globalV2Point[2] );
96 
97  recHitSet->AddLine( globalU1Point[0], globalU1Point[1], globalU1Point[2],
98  globalU2Point[0], globalU2Point[1], globalU2Point[2] );
99 
100  recHitSet->AddLine( globalV1Point[0], globalV1Point[1], globalV1Point[2],
101  globalV2Point[0], globalV2Point[1], globalV2Point[2] );
102 }
103 
105 
106 
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:58
IdToInfoItr find(unsigned int) const
Definition: FWGeometry.cc:355
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
const FWEventItem * item() const
static const int kAll3DBits
Definition: FWViewType.h:59
const FWCSCRecHitProxyBuilder & operator=(const FWCSCRecHitProxyBuilder &)
T sqrt(T t)
Definition: SSEVec.h:48
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:109
#define fwLog(_level_)
Definition: fwLog.h:50
std::vector< FWGeometry::GeomDetInfo >::const_iterator IdToInfoItr
Definition: FWGeometry.h:107
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:681