CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
FWBoxRecHit.cc
Go to the documentation of this file.
1 #include "TEveCompound.h"
2 
7 
8 //______________________________________________________________________________
9 FWBoxRecHit::FWBoxRecHit(const std::vector<TEveVector> &corners, TEveElement *list, float e, float et)
10  : m_tower(nullptr), m_ls(nullptr), m_energy(e), m_et(et), m_isTallest(false) {
11  buildTower(corners);
12  buildLineSet(corners);
13 
14  TEveCompound *h = new TEveCompound("rechit box", "tower");
15  list->AddElement(h);
16  h->CSCApplyMainColorToAllChildren();
17  h->AddElement(m_tower);
18  h->AddElement(m_ls);
19 }
20 
21 //______________________________________________________________________________
22 /*
23  FWViewEnergyScale*
24  FWBoxRecHit::getEnergyScale() const
25  {
26  return fireworks::Context::getInstance()->commonPrefs()->getEnergyScale();
27  }
28 */
29 
30 //______________________________________________________________________________
31 void FWBoxRecHit::setupEveBox(std::vector<TEveVector> &corners, float scale) {
32  // printf("---\n");
33  // TEveVector z(0.f, 0.f, 0.f);
34  for (size_t i = 0; i < 4; ++i) {
35  int j = i + 4;
36  corners[i + 4].fZ = scale;
37  m_tower->SetVertex(i, corners[i]);
38  m_tower->SetVertex(j, corners[j]);
39  // printf("%ld -> %f, %f , height=%f \n",i, corners[i].fX, corners[i].fY, scale);
40  }
41 
42  m_tower->SetLineWidth(1.0);
43  m_tower->SetLineColor(kBlack);
44 }
45 
46 //______________________________________________________________________________
47 void FWBoxRecHit::buildTower(const std::vector<TEveVector> &corners) {
48  m_tower = new TEveBox("EcalRecHitTower");
49  std::vector<TEveVector> towerCorners = corners;
50  /*
51  FWViewEnergyScale *caloScale = 1;//getEnergyScale();
52  float val = caloScale->getPlotEt() ? m_et : m_energy;
53  float scale = caloScale->getScaleFactorLego() * val;
54 
55  if( scale < 0 )
56  scale *= -1;
57  */
58  setupEveBox(towerCorners, 0.01f);
59 }
60 
61 //______________________________________________________________________________
62 void FWBoxRecHit::buildLineSet(const std::vector<TEveVector> &corners) {
63  m_ls = new TEveStraightLineSet("EcalRecHitLineSet");
64 
65  const float *data;
66  TEveVector c;
67  for (unsigned int i = 0; i < 4; ++i) {
68  data = m_tower->GetVertex(i);
69  c.fX += data[0];
70  c.fY += data[1];
71  m_ls->AddLine(data[0], data[1], 0, data[0], data[1], 0);
72  }
73  c *= 0.25;
74 
75  // last line is trick to add a marker in line set
76  m_ls->SetMarkerStyle(1);
77  m_ls->AddLine(c.fX, c.fY, c.fZ, c.fX, c.fY, c.fZ);
78  m_ls->AddMarker(0, 0.);
79 
80  m_ls->ResetBBox();
81  m_ls->ComputeBBox();
82 }
83 
84 //______________________________________________________________________________
85 void FWBoxRecHit::updateScale(float scaleFac, float maxLogVal, bool plotEt) {
86  // FWViewEnergyScale *caloScale = getEnergyScale();
87  //
88  //float scale = caloScale->getScaleFactorLego() * val;
89 
90  // printf("scale %f %f\n", caloScale->getValToHeight(), val);
91  float val = plotEt ? m_et : m_energy;
92  float scale = scaleFac * val;
93  // Reposition top points of tower
94  const float *data;
95  TEveVector c;
96  for (unsigned int i = 0; i < 4; ++i) {
97  data = m_tower->GetVertex(i);
98  c.fX += data[0];
99  c.fY += data[1];
100  m_tower->SetVertex(i, data[0], data[1], 0);
101  m_tower->SetVertex(i + 4, data[0], data[1], scale);
102  }
103  c *= 0.25;
104  if (false)
105  c.Dump();
106 
107  // Scale lineset
108  float s = log(1 + val) / maxLogVal;
109  float d = 0.5 * (m_tower->GetVertex(1)[0] - m_tower->GetVertex(0)[0]);
110  d *= s;
111  float z = scale * 1.001;
112  setLine(0, c.fX - d, c.fY - d, z, c.fX + d, c.fY - d, z);
113  setLine(1, c.fX + d, c.fY - d, z, c.fX + d, c.fY + d, z);
114  setLine(2, c.fX + d, c.fY + d, z, c.fX - d, c.fY + d, z);
115  setLine(3, c.fX - d, c.fY + d, z, c.fX - d, c.fY - d, z);
116 
117  if (m_isTallest) {
118  m_ls->AddLine(c.fX - d, c.fY - d, z, c.fX + d, c.fY + d, z);
119  m_ls->AddLine(c.fX - d, c.fY + d, z, c.fX + d, c.fY - d, z);
120  m_ls->GetMarkerPlex().Refit();
121  }
122 
123  TEveStraightLineSet::Marker_t *m = ((TEveStraightLineSet::Marker_t *)(m_ls->GetMarkerPlex().Atom(0)));
124  m->fV[0] = c.fX;
125  m->fV[1] = c.fY;
126  m->fV[2] = z;
127 
128  // stamp changed elements
129 
130  m_ls->ComputeBBox();
131  // float* bb = m_ls->GetBBox();
132  m_tower->StampTransBBox();
133  m_ls->StampTransBBox();
134 }
135 
136 //______________________________________________________________________________
137 void FWBoxRecHit::setLine(int idx, float x1, float y1, float z1, float x2, float y2, float z2) {
138  // AMT: this func should go in TEveStraightLineSet class
139 
140  TEveStraightLineSet::Line_t *l = ((TEveStraightLineSet::Line_t *)(m_ls->GetLinePlex().Atom(idx)));
141 
142  l->fV1[0] = x1;
143  l->fV1[1] = y1;
144  l->fV1[2] = z1;
145 
146  l->fV2[0] = x2;
147  l->fV2[1] = y2;
148  l->fV2[2] = z2;
149 }
150 
151 //______________________________________________________________________________
153 
154 //______________________________________________________________________________
155 void FWBoxRecHit::addLine(float x1, float y1, float z1, float x2, float y2, float z2) {
156  m_ls->AddLine(x1, y1, z1, x2, y2, z2);
157 }
158 
159 //______________________________________________________________________________
160 void FWBoxRecHit::addLine(const TEveVector &v1, const TEveVector &v2) {
161  m_ls->AddLine(v1.fX, v1.fY, v1.fZ, v2.fX, v2.fY, v2.fZ);
162 }
void setupEveBox(std::vector< TEveVector > &corners, float scale)
Definition: FWBoxRecHit.cc:31
static std::vector< std::string > checklist log
const edm::EventSetup & c
float m_energy
Definition: FWBoxRecHit.h:67
void buildTower(const std::vector< TEveVector > &corners)
Definition: FWBoxRecHit.cc:47
TEveStraightLineSet * m_ls
Definition: FWBoxRecHit.h:66
void updateScale(float scale, float maxLogVal, bool plotEt)
Definition: FWBoxRecHit.cc:85
void addLine(float x1, float y1, float z1, float x2, float y2, float z2)
Definition: FWBoxRecHit.cc:155
void buildLineSet(const std::vector< TEveVector > &corners)
Definition: FWBoxRecHit.cc:62
tuple d
Definition: ztail.py:151
void setIsTallest()
Definition: FWBoxRecHit.cc:152
TEveBox * m_tower
Definition: FWBoxRecHit.h:65
bool m_isTallest
Definition: FWBoxRecHit.h:69
float m_et
Definition: FWBoxRecHit.h:68
FWBoxRecHit(const std::vector< TEveVector > &corners, TEveElement *comp, float e, float et)
Definition: FWBoxRecHit.cc:9
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
void setLine(int idx, float x1, float y1, float z1, float x2, float y2, float z2)
Definition: FWBoxRecHit.cc:137
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4