CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
FWPFLegoRecHit.cc
Go to the documentation of this file.
3 
4 //______________________________________________________________________________
5 FWPFLegoRecHit::FWPFLegoRecHit(const std::vector<TEveVector> &corners,
6  TEveElement *comp,
8  const FWViewContext *vc,
9  float e,
10  float et)
11  : m_energy(e), m_et(et), m_isTallest(false) {
12  buildTower(corners, vc);
13  buildLineSet(corners, vc);
14 
15  pb->setupAddElement(m_tower, comp);
16  pb->setupAddElement(m_ls, comp);
17 }
18 
19 //______________________________________________________________________________
20 void FWPFLegoRecHit::setupEveBox(std::vector<TEveVector> &corners, float scale) {
21  for (size_t i = 0; i < 4; ++i) {
22  int j = i + 4;
23  corners[i + 4].fZ = corners[i].fZ + scale;
24  m_tower->SetVertex(i, corners[i]);
25  m_tower->SetVertex(j, corners[j]);
26  }
27 
28  m_tower->SetPickable(true);
29  m_tower->SetDrawFrame(false);
30  m_tower->SetLineWidth(1.0);
31  m_tower->SetLineColor(kBlack);
32 }
33 
34 //______________________________________________________________________________
35 void FWPFLegoRecHit::buildTower(const std::vector<TEveVector> &corners, const FWViewContext *vc) {
36  m_tower = new TEveBox("EcalRecHitTower");
37  std::vector<TEveVector> towerCorners = corners;
38  FWViewEnergyScale *caloScale = vc->getEnergyScale();
39  float val = caloScale->getPlotEt() ? m_et : m_energy;
40  float scale = caloScale->getScaleFactorLego() * val;
41 
42  if (scale < 0)
43  scale *= -1;
44 
45  setupEveBox(towerCorners, scale);
46 }
47 
48 //______________________________________________________________________________
49 void FWPFLegoRecHit::buildLineSet(const std::vector<TEveVector> &corners, const FWViewContext *vc) {
50  m_ls = new TEveStraightLineSet("EcalRecHitLineSet");
51 
52  // no need to set anything, all is re-set in updateScales()
53  // reserve space for square outline
54  TEveVector c;
55  m_ls->AddLine(c.fX, c.fY, c.fZ, c.fX, c.fY, c.fZ);
56  m_ls->AddLine(c.fX, c.fY, c.fZ, c.fX, c.fY, c.fZ);
57  m_ls->AddLine(c.fX, c.fY, c.fZ, c.fX, c.fY, c.fZ);
58  m_ls->AddLine(c.fX, c.fY, c.fZ, c.fX, c.fY, c.fZ);
59 
60  // last line is trick to add a marker in line set
61  m_ls->SetMarkerStyle(1);
62  m_ls->AddLine(c.fX, c.fY, c.fZ, c.fX, c.fY, c.fZ);
63  m_ls->AddMarker(0, 0.);
64 }
65 
66 //______________________________________________________________________________
67 void FWPFLegoRecHit::updateScale(const FWViewContext *vc, float maxLogVal) {
68  FWViewEnergyScale *caloScale = vc->getEnergyScale();
69  float val = caloScale->getPlotEt() ? m_et : m_energy;
70  float scale = caloScale->getScaleFactorLego() * val;
71 
72  // printf("scale %f %f\n", caloScale->getValToHeight(), val);
73 
74  if (scale < 0)
75  scale *= -1;
76 
77  // Reposition top points of tower
78  const float *data;
79  TEveVector c;
80  for (unsigned int i = 0; i < 4; ++i) {
81  data = m_tower->GetVertex(i);
82  c.fX += data[0];
83  c.fY += data[1];
84  m_tower->SetVertex(i, data[0], data[1], 0);
85  m_tower->SetVertex(i + 4, data[0], data[1], scale);
86  }
87  c *= 0.25;
88  // Scale lineset
89  float s = log(1 + val) / maxLogVal;
90  float d = 0.5 * (m_tower->GetVertex(1)[0] - m_tower->GetVertex(0)[0]);
91  d *= s;
92  float z = scale * 1.001;
93  setLine(0, c.fX - d, c.fY - d, z, c.fX + d, c.fY - d, z);
94  setLine(1, c.fX + d, c.fY - d, z, c.fX + d, c.fY + d, z);
95  setLine(2, c.fX + d, c.fY + d, z, c.fX - d, c.fY + d, z);
96  setLine(3, c.fX - d, c.fY + d, z, c.fX - d, c.fY - d, z);
97 
98  if (m_isTallest) {
99  // This is the tallest tower and hence two additional lines needs scaling
100  setLine(4, c.fX - d, c.fY - d, z, c.fX + d, c.fY + d, z);
101  setLine(5, c.fX - d, c.fY + d, z, c.fX + d, c.fY - d, z);
102  }
103 
104  TEveStraightLineSet::Marker_t *m = ((TEveStraightLineSet::Marker_t *)(m_ls->GetMarkerPlex().Atom(0)));
105  m->fV[0] = c.fX;
106  m->fV[1] = c.fY;
107  m->fV[2] = z;
108 
109  // stamp changed elements
110  m_tower->StampTransBBox();
111  m_ls->StampTransBBox();
112 }
113 
114 //______________________________________________________________________________
115 void FWPFLegoRecHit::setLine(int idx, float x1, float y1, float z1, float x2, float y2, float z2) {
116  // AMT: this func should go in TEveStraightLineSet class
117 
118  TEveStraightLineSet::Line_t *l = ((TEveStraightLineSet::Line_t *)(m_ls->GetLinePlex().Atom(idx)));
119 
120  l->fV1[0] = x1;
121  l->fV1[1] = y1;
122  l->fV1[2] = z1;
123 
124  l->fV2[0] = x2;
125  l->fV2[1] = y2;
126  l->fV2[2] = z2;
127 }
128 
129 //______________________________________________________________________________
131  m_isTallest = b;
132 
133  if (m_isTallest) {
134  TEveVector vec;
135  addLine(vec, vec);
136  addLine(vec, vec);
137  }
138 }
139 
140 //______________________________________________________________________________
141 void FWPFLegoRecHit::addLine(float x1, float y1, float z1, float x2, float y2, float z2) {
142  m_ls->AddLine(x1, y1, z1, x2, y2, z2);
143 }
144 
145 //______________________________________________________________________________
146 void FWPFLegoRecHit::addLine(const TEveVector &v1, const TEveVector &v2) {
147  m_ls->AddLine(v1.fX, v1.fY, v1.fZ, v2.fX, v2.fY, v2.fZ);
148 }
static std::vector< std::string > checklist log
const edm::EventSetup & c
void setLine(int idx, float x1, float y1, float z1, float x2, float y2, float z2)
void addLine(float x1, float y1, float z1, float x2, float y2, float z2)
void buildTower(const std::vector< TEveVector > &corners, const FWViewContext *vc)
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
FWViewEnergyScale * getEnergyScale() const
void setupEveBox(std::vector< TEveVector > &corners, float scale)
TEveBox * m_tower
tuple d
Definition: ztail.py:151
float getScaleFactorLego() const
FWPFLegoRecHit(const std::vector< TEveVector > &corners, TEveElement *comp, FWProxyBuilderBase *pb, const FWViewContext *vc, float e, float et)
double b
Definition: hdecay.h:118
void setIsTallest(bool b)
void buildLineSet(const std::vector< TEveVector > &corners, const FWViewContext *vc)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
void updateScale(const FWViewContext *vc, float maxLogVal)
TEveStraightLineSet * m_ls
bool getPlotEt() const