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 
30  void build( const CSCRecHit2D& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* ) override;
31 };
32 
33 void
35  unsigned int iIndex, TEveElement& oItemHolder,
36  const FWViewContext* )
37 {
38  const FWGeometry *geom = item()->getGeom();
39  unsigned int rawid = iData.cscDetId().rawId();
40 
41  if( ! geom->contains( rawid ))
42  {
43  fwLog( fwlog::kError ) << "failed to get geometry of CSC layer with detid: "
44  << rawid <<std::endl;
45  return;
46  }
47  FWGeometry::IdToInfoItr det = geom->find( rawid );
48 
49  TEveStraightLineSet* recHitSet = new TEveStraightLineSet;
50  setupAddElement( recHitSet, &oItemHolder );
51 
52  TEvePointSet* pointSet = new TEvePointSet;
53  setupAddElement( pointSet, &oItemHolder );
54 
55  float localPositionX = iData.localPosition().x();
56  float localPositionY = iData.localPosition().y();
57 
58  float localPositionXX = sqrt( iData.localPositionError().xx());
59  float localPositionYY = sqrt( iData.localPositionError().yy());
60 
61  float localU1Point[3] =
62  {
63  localPositionX - localPositionXX, localPositionY, 0.0
64  };
65 
66  float localU2Point[3] =
67  {
68  localPositionX + localPositionXX, localPositionY, 0.0
69  };
70 
71  float localV1Point[3] =
72  {
73  localPositionX, localPositionY - localPositionYY, 0.0
74  };
75 
76  float localV2Point[3] =
77  {
78  localPositionX, localPositionY + localPositionYY, 0.0
79  };
80 
81  float globalU1Point[3];
82  float globalU2Point[3];
83  float globalV1Point[3];
84  float globalV2Point[3];
85 
86  geom->localToGlobal( *det, localU1Point, globalU1Point );
87  geom->localToGlobal( *det, localU2Point, globalU2Point );
88  geom->localToGlobal( *det, localV1Point, globalV1Point );
89  geom->localToGlobal( *det, localV2Point, globalV2Point );
90 
91  pointSet->SetNextPoint( globalU1Point[0], globalU1Point[1], globalU1Point[2] );
92  pointSet->SetNextPoint( globalU2Point[0], globalU2Point[1], globalU2Point[2] );
93  pointSet->SetNextPoint( globalV1Point[0], globalV1Point[1], globalV1Point[2] );
94  pointSet->SetNextPoint( globalV2Point[0], globalV2Point[1], globalV2Point[2] );
95 
96  recHitSet->AddLine( globalU1Point[0], globalU1Point[1], globalU1Point[2],
97  globalU2Point[0], globalU2Point[1], globalU2Point[2] );
98 
99  recHitSet->AddLine( globalV1Point[0], globalV1Point[1], globalV1Point[2],
100  globalV2Point[0], globalV2Point[1], globalV2Point[2] );
101 }
102 
104 
105 
#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:98
#define fwLog(_level_)
Definition: fwLog.h:50
std::vector< FWGeometry::GeomDetInfo >::const_iterator IdToInfoItr
Definition: FWGeometry.h:96
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:681