CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
FWDTRecHitProxyBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Muons
4 // Class : FWDTRecHitProxyBuilder
5 //
6 //
7 
8 #include "TEvePointSet.h"
9 #include "TEveStraightLineSet.h"
10 
15 
18 
19 using namespace DTEnums;
20 
21 class FWDTRecHitProxyBuilder : public FWSimpleProxyBuilderTemplate<DTRecHit1DPair> {
22 public:
24  ~FWDTRecHitProxyBuilder(void) override {}
25 
26  bool haveSingleProduct() const override { return false; }
27 
29 
30  // Disable default copy constructor
32  // Disable default assignment operator
33  const FWDTRecHitProxyBuilder& operator=(const FWDTRecHitProxyBuilder&) = delete;
34 
35 private:
37  void buildViewType(const DTRecHit1DPair& iData,
38  unsigned int iIndex,
39  TEveElement& oItemHolder,
41  const FWViewContext*) override;
42 };
43 
45  unsigned int iIndex,
46  TEveElement& oItemHolder,
48  const FWViewContext*) {
49  const DTLayerId& layerId = iData.wireId().layerId();
50  int superLayer = layerId.superlayerId().superLayer();
51 
52  const FWGeometry* geom = item()->getGeom();
53 
54  if (!geom->contains(layerId)) {
55  fwLog(fwlog::kError) << "failed get geometry of DT layer with detid: " << layerId << std::endl;
56  return;
57  }
58 
59  TEveStraightLineSet* recHitSet = new TEveStraightLineSet;
60  setupAddElement(recHitSet, &oItemHolder);
61 
62  TEvePointSet* pointSet = new TEvePointSet;
63  setupAddElement(pointSet, &oItemHolder);
64 
65  const DTRecHit1D* leftRecHit = iData.componentRecHit(Left);
66  const DTRecHit1D* rightRecHit = iData.componentRecHit(Right);
67  float lLocalPos[3] = {leftRecHit->localPosition().x(), 0.0, 0.0};
68  float rLocalPos[3] = {rightRecHit->localPosition().x(), 0.0, 0.0};
69 
70  if (((type == FWViewType::kRhoPhi || type == FWViewType::kRhoPhiPF) && superLayer != 2) ||
71  (type == FWViewType::kRhoZ && superLayer == 2) || type == FWViewType::k3D || type == FWViewType::kISpy) {
72  float leftGlobalPoint[3];
73  float rightGlobalPoint[3];
74 
75  geom->localToGlobal(layerId, lLocalPos, leftGlobalPoint, rLocalPos, rightGlobalPoint);
76 
77  pointSet->SetNextPoint(leftGlobalPoint[0], leftGlobalPoint[1], leftGlobalPoint[2]);
78  pointSet->SetNextPoint(rightGlobalPoint[0], rightGlobalPoint[1], rightGlobalPoint[2]);
79 
80  recHitSet->AddLine(leftGlobalPoint[0],
81  leftGlobalPoint[1],
82  leftGlobalPoint[2],
83  rightGlobalPoint[0],
84  rightGlobalPoint[1],
85  rightGlobalPoint[2]);
86  }
87 }
88 
91  "DT RecHits",
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:67
bool haveSingleProduct() const override
void buildViewType(const DTRecHit1DPair &iData, unsigned int iIndex, TEveElement &oItemHolder, FWViewType::EType type, const FWViewContext *) override
const DTRecHit1D * componentRecHit(DTEnums::DTCellSide lrSide) const
Return the left/right DTRecHit1D.
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:45
static const int kAll3DBits
Definition: FWViewType.h:68
void localToGlobal(unsigned int id, const float *local, float *global, bool translatep=true) const
Definition: FWGeometry.cc:494
int superLayer() const
Return the superlayer number.
bool contains(unsigned int id) const
Definition: FWGeometry.h:139
#define fwLog(_level_)
Definition: fwLog.h:45
DTLayerId layerId() const
Return the corresponding LayerId.
Definition: DTWireId.h:45
~FWDTRecHitProxyBuilder(void) override
DTWireId wireId() const
T x() const
Definition: PV3DBase.h:59
LocalPoint localPosition() const override
Return the 3-dimensional local position.
Definition: DTRecHit1D.h:47
void setupAddElement(TEveElement *el, TEveElement *parent, const FWEventItem *item, bool master, bool color)
Definition: TrackUtils.cc:299