CMS 3D CMS Logo

FWPFRhoPhiRecHit.cc
Go to the documentation of this file.
2 
3 //______________________________________________________________________________
5  TEveElement *iH,
6  const FWViewContext *vc,
7  float E,
8  float et,
9  double lPhi,
10  double rPhi,
11  std::vector<TEveVector> &bCorners)
12  : m_hasChild(false), m_energy(E), m_et(et), m_lPhi(lPhi), m_rPhi(rPhi), m_child(nullptr) {
13  buildRecHit(pb, iH, vc, bCorners);
14 }
15 
16 //______________________________________________________________________________
18 
19 //______________________________________________________________________________
21  FWViewEnergyScale *caloScale = vc->getEnergyScale();
22  float value = caloScale->getPlotEt() ? m_et : m_energy;
23  Double_t scale = caloScale->getScaleFactor3D() * value;
24  unsigned int a = 0;
25 
26  if (scale < 0.f)
27  scale *= -1.f;
28 
29  // Scale centres
30  TEveVector sc1 = m_corners[1];
31  TEveVector sc2 = m_corners[0];
32 
33  // Used to store normalized vectors
34  TEveVector v1 = sc1; // Bottom right corner
35  TEveVector v2 = sc2; // Bottom left corner
36 
37  v1.Normalize();
38  v2.Normalize();
39 
40  v1 *= scale; // Now at new height
41  v2 *= scale;
42 
43  // Get line parameters and scale coordinates
44  TEveChunkManager::iterator li(m_ls->GetLinePlex());
45  while (li.next()) {
46  TEveStraightLineSet::Line_t &l = *(TEveStraightLineSet::Line_t *)li();
47  switch (a) {
48  case 0:
49  // Left side of tower first
50  l.fV1[0] = sc2.fX;
51  l.fV1[1] = sc2.fY;
52  l.fV2[0] = sc2.fX + v2.fX;
53  l.fV2[1] = sc2.fY + v2.fY;
54  break;
55 
56  case 1:
57  // Top of tower
58  l.fV1[0] = sc2.fX + v2.fX;
59  l.fV1[1] = sc2.fY + v2.fY;
60  l.fV2[0] = sc1.fX + v1.fX;
61  l.fV2[1] = sc1.fY + v1.fY;
62  break;
63 
64  case 2:
65  // Right hand side of tower
66  l.fV1[0] = sc1.fX + v1.fX;
67  l.fV1[1] = sc1.fY + v1.fY;
68  l.fV2[0] = sc1.fX;
69  l.fV2[1] = sc1.fY;
70  break;
71 
72  case 3:
73  // Bottom of tower
74  l.fV1[0] = sc1.fX;
75  l.fV1[1] = sc1.fY;
76  l.fV2[0] = sc2.fX;
77  l.fV2[1] = sc2.fY;
78  break;
79  }
80  a++;
81  }
82  TEveProjected *proj = *(m_ls)->BeginProjecteds();
83  proj->UpdateProjection();
84 
85  m_corners[2] = sc2 + v2; // New top left of tower
86  m_corners[3] = sc1 + v1; // New top right of tower
87 
88  if (m_hasChild) {
90  m_child->setCorners(1, m_corners[3]); // Base of child is now top of parent
91  m_child->updateScale(vc);
92  }
93 }
94 
95 //______________________________________________________________________________
97  m_corners.clear();
98  if (m_hasChild)
99  m_child->clean();
100 
101  delete this;
102 }
103 
104 //______________________________________________________________________________
106  FWProxyBuilderBase *pb, TEveElement *itemHolder, const FWViewContext *vc, float E, float et) {
107  if (m_hasChild) // Already has a child stacked on top so move on to child
108  m_child->addChild(pb, itemHolder, vc, E, et);
109  else {
110  std::vector<TEveVector> corners(2);
111  corners[0] = m_corners[2]; // Top left of current tower
112  corners[1] = m_corners[3]; // Top right of current tower
113  m_child = new FWPFRhoPhiRecHit(pb, itemHolder, vc, E, et, m_lPhi, m_rPhi, corners);
114  m_hasChild = true;
115  }
116 }
117 
118 //______________________________________________________________________________
120  TEveElement *itemHolder,
121  const FWViewContext *vc,
122  std::vector<TEveVector> &bCorners) {
123  float scale = 0;
124  float value = 0;
125  TEveVector v1, v2, v3, v4;
126  TEveVector vec;
127 
128  FWViewEnergyScale *caloScale = vc->getEnergyScale();
129  value = caloScale->getPlotEt() ? m_et : m_energy;
130  scale = caloScale->getScaleFactor3D() * value;
131 
132  v1 = bCorners[0]; // Bottom left
133  v2 = bCorners[1]; // Bottom right
134 
135  v3 = v1;
136  vec = v3;
137  vec.Normalize();
138  v3 = v3 + (vec * scale);
139 
140  v4 = v2;
141  vec = v4;
142  vec.Normalize();
143  v4 = v4 + (vec * scale);
144 
145  m_ls = new TEveScalableStraightLineSet("rhophiRecHit");
146  m_ls->AddLine(v1.fX, v1.fY, 0, v3.fX, v3.fY, 0); // Bottom left - Top left
147  m_ls->AddLine(v3.fX, v3.fY, 0, v4.fX, v4.fY, 0); // Top left - Top right
148  m_ls->AddLine(v4.fX, v4.fY, 0, v2.fX, v2.fY, 0); // Top right - Bottom right
149  m_ls->AddLine(v2.fX, v2.fY, 0, v1.fX, v1.fY, 0); // Bottom right - Bottom left
150 
151  m_corners.push_back(v1);
152  m_corners.push_back(v2);
153  m_corners.push_back(v3);
154  m_corners.push_back(v4);
155 
156  pb->setupAddElement(m_ls, itemHolder);
157 }
std::vector< TEveVector > m_corners
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
bool getPlotEt() const
FWViewEnergyScale * getEnergyScale() const
FWPFRhoPhiRecHit(FWProxyBuilderBase *pb, TEveElement *iH, const FWViewContext *vc, float E, float et, double lPhi, double rPhi, std::vector< TEveVector > &bCorners)
double f[11][100]
Definition: value.py:1
void addChild(FWProxyBuilderBase *pb, TEveElement *itemHolder, const FWViewContext *vc, float E, float et)
void updateScale(TEveScalableStraightLineSet *ls, Double_t scale, unsigned int i)
float getScaleFactor3D() const
void buildRecHit(FWProxyBuilderBase *pb, TEveElement *itemHolder, const FWViewContext *vc, std::vector< TEveVector > &bCorners)
virtual ~FWPFRhoPhiRecHit()
double a
Definition: hdecay.h:121
void setCorners(int i, TEveVector vec)
TEveScalableStraightLineSet * m_ls
FWPFRhoPhiRecHit * m_child