CMS 3D CMS Logo

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 
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 }
AlCaHLTBitMon_QueryRunRegistry.comp
string comp
Definition: AlCaHLTBitMon_QueryRunRegistry.py:249
mps_fire.i
i
Definition: mps_fire.py:428
funct::false
false
Definition: Factorize.h:29
FWPFLegoRecHit::buildTower
void buildTower(const std::vector< TEveVector > &corners, const FWViewContext *vc)
Definition: FWPFLegoRecHit.cc:35
L1EGammaCrystalsEmulatorProducer_cfi.scale
scale
Definition: L1EGammaCrystalsEmulatorProducer_cfi.py:10
FWPFLegoRecHit::m_energy
float m_energy
Definition: FWPFLegoRecHit.h:72
FWPFLegoRecHit::m_et
float m_et
Definition: FWPFLegoRecHit.h:73
testProducerWithPsetDescEmpty_cfi.x2
x2
Definition: testProducerWithPsetDescEmpty_cfi.py:28
FWPFLegoRecHit.h
FWProxyBuilderBase.h
FWPFLegoRecHit::addLine
void addLine(float x1, float y1, float z1, float x2, float y2, float z2)
Definition: FWPFLegoRecHit.cc:141
FWViewEnergyScale::getPlotEt
bool getPlotEt() const
Definition: FWViewEnergyScale.h:47
FWPFLegoRecHit::setupEveBox
void setupEveBox(std::vector< TEveVector > &corners, float scale)
Definition: FWPFLegoRecHit.cc:20
FWPFLegoRecHit::m_isTallest
bool m_isTallest
Definition: FWPFLegoRecHit.h:74
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
testProducerWithPsetDescEmpty_cfi.z2
z2
Definition: testProducerWithPsetDescEmpty_cfi.py:41
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
FWPFLegoRecHit::updateScale
void updateScale(const FWViewContext *vc, float maxLogVal)
Definition: FWPFLegoRecHit.cc:67
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:78
DDAxes::z
FWPFLegoRecHit::setIsTallest
void setIsTallest(bool b)
Definition: FWPFLegoRecHit.cc:130
b
double b
Definition: hdecay.h:118
FWViewEnergyScale::getScaleFactorLego
float getScaleFactorLego() const
Definition: FWViewEnergyScale.h:45
testProducerWithPsetDescEmpty_cfi.y2
y2
Definition: testProducerWithPsetDescEmpty_cfi.py:30
FWProxyBuilderBase::setupAddElement
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
Definition: FWProxyBuilderBase.cc:350
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
FWViewContext
Definition: FWViewContext.h:32
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
FWPFLegoRecHit::buildLineSet
void buildLineSet(const std::vector< TEveVector > &corners, const FWViewContext *vc)
Definition: FWPFLegoRecHit.cc:49
FWPFLegoRecHit::setLine
void setLine(int idx, float x1, float y1, float z1, float x2, float y2, float z2)
Definition: FWPFLegoRecHit.cc:115
heppy_batch.val
val
Definition: heppy_batch.py:351
FWProxyBuilderBase
Definition: FWProxyBuilderBase.h:46
FWPFLegoRecHit::m_ls
TEveStraightLineSet * m_ls
Definition: FWPFLegoRecHit.h:71
FWViewEnergyScale
Definition: FWViewEnergyScale.h:34
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
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
FWViewContext::getEnergyScale
FWViewEnergyScale * getEnergyScale() const
Definition: FWViewContext.cc:25
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
FWPFLegoRecHit::m_tower
TEveBox * m_tower
Definition: FWPFLegoRecHit.h:70
FWPFLegoRecHit::FWPFLegoRecHit
FWPFLegoRecHit(const std::vector< TEveVector > &corners, TEveElement *comp, FWProxyBuilderBase *pb, const FWViewContext *vc, float e, float et)
Definition: FWPFLegoRecHit.cc:5