CMS 3D CMS Logo

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  ~FWCSCRecHitProxyBuilder( void ) override {}
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 
float xx() const
Definition: LocalError.h:24
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
CSCDetId cscDetId() const
Definition: CSCRecHit2D.h:52
static const int kAllRPZBits
Definition: FWViewType.h:58
IdToInfoItr find(unsigned int) const
Definition: FWGeometry.cc:375
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
LocalPoint localPosition() const override
Definition: CSCRecHit2D.h:50
const FWEventItem * item() const
static const int kAll3DBits
Definition: FWViewType.h:59
float yy() const
Definition: LocalError.h:26
T sqrt(T t)
Definition: SSEVec.h:18
void localToGlobal(unsigned int id, const float *local, float *global, bool translatep=true) const
Definition: FWGeometry.cc:345
bool contains(unsigned int id) const
Definition: FWGeometry.h:113
#define fwLog(_level_)
Definition: fwLog.h:50
LocalError localPositionError() const override
Definition: CSCRecHit2D.h:51
const FWCSCRecHitProxyBuilder & operator=(const FWCSCRecHitProxyBuilder &)=delete
std::vector< FWGeometry::GeomDetInfo >::const_iterator IdToInfoItr
Definition: FWGeometry.h:110
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:683