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 public:
21  ~FWCSCRecHitProxyBuilder(void) override {}
22 
24 
27 
28 private:
30  void build(const CSCRecHit2D& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) override;
31 };
32 
34  unsigned int iIndex,
35  TEveElement& oItemHolder,
36  const FWViewContext*) {
37  const FWGeometry* geom = item()->getGeom();
38  unsigned int rawid = iData.cscDetId().rawId();
39 
40  if (!geom->contains(rawid)) {
41  fwLog(fwlog::kError) << "failed to get geometry of CSC layer with detid: " << rawid << std::endl;
42  return;
43  }
44  FWGeometry::IdToInfoItr det = geom->find(rawid);
45 
46  TEveStraightLineSet* recHitSet = new TEveStraightLineSet;
47  setupAddElement(recHitSet, &oItemHolder);
48 
49  TEvePointSet* pointSet = new TEvePointSet;
50  setupAddElement(pointSet, &oItemHolder);
51 
52  float localPositionX = iData.localPosition().x();
53  float localPositionY = iData.localPosition().y();
54 
55  float localPositionXX = sqrt(iData.localPositionError().xx());
56  float localPositionYY = sqrt(iData.localPositionError().yy());
57 
58  float localU1Point[3] = {localPositionX - localPositionXX, localPositionY, 0.0};
59 
60  float localU2Point[3] = {localPositionX + localPositionXX, localPositionY, 0.0};
61 
62  float localV1Point[3] = {localPositionX, localPositionY - localPositionYY, 0.0};
63 
64  float localV2Point[3] = {localPositionX, localPositionY + localPositionYY, 0.0};
65 
66  float globalU1Point[3];
67  float globalU2Point[3];
68  float globalV1Point[3];
69  float globalV2Point[3];
70 
71  geom->localToGlobal(*det, localU1Point, globalU1Point);
72  geom->localToGlobal(*det, localU2Point, globalU2Point);
73  geom->localToGlobal(*det, localV1Point, globalV1Point);
74  geom->localToGlobal(*det, localV2Point, globalV2Point);
75 
76  pointSet->SetNextPoint(globalU1Point[0], globalU1Point[1], globalU1Point[2]);
77  pointSet->SetNextPoint(globalU2Point[0], globalU2Point[1], globalU2Point[2]);
78  pointSet->SetNextPoint(globalV1Point[0], globalV1Point[1], globalV1Point[2]);
79  pointSet->SetNextPoint(globalV2Point[0], globalV2Point[1], globalV2Point[2]);
80 
81  recHitSet->AddLine(
82  globalU1Point[0], globalU1Point[1], globalU1Point[2], globalU2Point[0], globalU2Point[1], globalU2Point[2]);
83 
84  recHitSet->AddLine(
85  globalV1Point[0], globalV1Point[1], globalV1Point[2], globalV2Point[0], globalV2Point[1], globalV2Point[2]);
86 }
87 
90  "CSC RecHits",
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:67
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
CSCDetId cscDetId() const
Definition: CSCRecHit2D.h:58
static const int kAll3DBits
Definition: FWViewType.h:68
float yy() const
Definition: LocalError.h:24
T sqrt(T t)
Definition: SSEVec.h:19
LocalError localPositionError() const override
Definition: CSCRecHit2D.h:57
LocalPoint localPosition() const override
Definition: CSCRecHit2D.h:56
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:548
#define fwLog(_level_)
Definition: fwLog.h:45
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
const FWCSCRecHitProxyBuilder & operator=(const FWCSCRecHitProxyBuilder &)=delete
const FWEventItem * item() const
std::vector< FWGeometry::GeomDetInfo >::const_iterator IdToInfoItr
Definition: FWGeometry.h:138
float xx() const
Definition: LocalError.h:22