CMS 3D CMS Logo

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 }
FWBoxRecHit::setLine
void setLine(int idx, float x1, float y1, float z1, float x2, float y2, float z2)
Definition: FWBoxRecHit.cc:137
mps_fire.i
i
Definition: mps_fire.py:428
funct::false
false
Definition: Factorize.h:29
L1EGammaCrystalsEmulatorProducer_cfi.scale
scale
Definition: L1EGammaCrystalsEmulatorProducer_cfi.py:10
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
testProducerWithPsetDescEmpty_cfi.x2
x2
Definition: testProducerWithPsetDescEmpty_cfi.py:28
FWBoxRecHit::m_energy
float m_energy
Definition: FWBoxRecHit.h:67
FWBoxRecHit::buildTower
void buildTower(const std::vector< TEveVector > &corners)
Definition: FWBoxRecHit.cc:47
FWBoxRecHit::buildLineSet
void buildLineSet(const std::vector< TEveVector > &corners)
Definition: FWBoxRecHit.cc:62
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
testProducerWithPsetDescEmpty_cfi.z2
z2
Definition: testProducerWithPsetDescEmpty_cfi.py:41
FWBoxRecHit.h
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
alignCSCRings.s
s
Definition: alignCSCRings.py:92
testProducerWithPsetDescEmpty_cfi.y1
y1
Definition: testProducerWithPsetDescEmpty_cfi.py:29
FWBoxRecHit::updateScale
void updateScale(float scale, float maxLogVal, bool plotEt)
Definition: FWBoxRecHit.cc:85
FWBoxRecHit::addLine
void addLine(float x1, float y1, float z1, float x2, float y2, float z2)
Definition: FWBoxRecHit.cc:155
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
DDAxes::z
FWBoxRecHit::m_ls
TEveStraightLineSet * m_ls
Definition: FWBoxRecHit.h:66
h
FWBoxRecHit::m_tower
TEveBox * m_tower
Definition: FWBoxRecHit.h:65
testProducerWithPsetDescEmpty_cfi.y2
y2
Definition: testProducerWithPsetDescEmpty_cfi.py:30
FWBoxRecHit::setIsTallest
void setIsTallest()
Definition: FWBoxRecHit.cc:152
FWBoxRecHit::m_et
float m_et
Definition: FWBoxRecHit.h:68
FWBoxRecHit::m_isTallest
bool m_isTallest
Definition: FWBoxRecHit.h:69
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
CmsShowCommon.h
FWBoxRecHit::FWBoxRecHit
FWBoxRecHit(const std::vector< TEveVector > &corners, TEveElement *comp, float e, float et)
Definition: FWBoxRecHit.cc:9
heppy_batch.val
val
Definition: heppy_batch.py:351
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
ztail.d
d
Definition: ztail.py:151
FWViewEnergyScale.h
FWBoxRecHit::setupEveBox
void setupEveBox(std::vector< TEveVector > &corners, float scale)
Definition: FWBoxRecHit.cc:31
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
Context.h
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37