CMS 3D CMS Logo

FWCaloRecHitDigitSetProxyBuilder.cc
Go to the documentation of this file.
2 #include "TEveBoxSet.h"
10 
12 
14  : m_invertBox(false), m_ignoreGeoShapeSize(false), m_enlarge(1.0) {}
15 
16 //______________________________________________________________________________
17 
20  if (iItem) {
21  iItem->getConfig()->assertParam("Enlarge", 1.0, 1.0, 5.0);
22  // iItem->getConfig()->assertParam( "IgnoreShapeSize", false);
23  }
24 }
25 //______________________________________________________________________________
26 
28  const float* corners, float scale, bool plotEt, std::vector<float>& scaledCorners, const CaloRecHit*) {
29  scale *= m_enlarge;
31  // Same functionality as fireworks::energyTower3DCorners()
32 
33  for (int i = 0; i < 24; ++i)
34  scaledCorners[i] = corners[i];
35 
36  // Coordinates of a front face scaled
37  if (m_invertBox) {
38  // We know, that an ES rechit geometry in -Z needs correction.
39  // The back face is actually its front face.
40  for (unsigned int i = 0; i < 12; i += 3) {
41  m_vector.Set(corners[i] - corners[i + 12], corners[i + 1] - corners[i + 13], corners[i + 2] - corners[i + 14]);
42  m_vector.Normalize();
43  m_vector *= scale;
44 
45  scaledCorners[i] = corners[i] + m_vector.fX;
46  scaledCorners[i + 1] = corners[i + 1] + m_vector.fY;
47  scaledCorners[i + 2] = corners[i + 2] + m_vector.fZ;
48  }
49  } else {
50  for (unsigned int i = 0; i < 12; i += 3) {
51  m_vector.Set(corners[i + 12] - corners[i], corners[i + 13] - corners[i + 1], corners[i + 14] - corners[i + 2]);
52  m_vector.Normalize();
53  m_vector *= scale;
54 
55  scaledCorners[i] = corners[i + 12];
56  scaledCorners[i + 1] = corners[i + 13];
57  scaledCorners[i + 2] = corners[i + 14];
58 
59  scaledCorners[i + 12] = corners[i + 12] + m_vector.fX;
60  scaledCorners[i + 13] = corners[i + 13] + m_vector.fY;
61  scaledCorners[i + 14] = corners[i + 14] + m_vector.fZ;
62  }
63  }
64  } else {
65  // Same functionality as fireworks::energyScaledBox3DCorners().
66 
67  m_vector.Set(0.f, 0.f, 0.f);
68  for (unsigned int i = 0; i < 24; i += 3) {
69  m_vector[0] += corners[i];
70  m_vector[1] += corners[i + 1];
71  m_vector[2] += corners[i + 2];
72  }
73  m_vector *= 1.f / 8.f;
74 
75  if (plotEt) {
76  scale *= m_vector.Perp() / m_vector.Mag();
77  }
78 
79  // Coordinates for a scaled version of the original box
80  for (unsigned int i = 0; i < 24; i += 3) {
81  scaledCorners[i] = m_vector[0] + (corners[i] - m_vector[0]) * scale;
82  scaledCorners[i + 1] = m_vector[1] + (corners[i + 1] - m_vector[1]) * scale;
83  scaledCorners[i + 2] = m_vector[2] + (corners[i + 2] - m_vector[2]) * scale;
84  }
85 
86  if (m_invertBox)
87  fireworks::invertBox(scaledCorners);
88  }
89 }
90 //_____________________________________________________________________________
91 
93  // printf("scale face %f \n", vc->getEnergyScale()->getScaleFactor3D());
94  return vc->getEnergyScale()->getScaleFactor3D() / 50;
95 }
96 
97 //______________________________________________________________________________
98 
101  const FWViewContext* vc) {
102  size_t size = item()->size();
103  if (!size)
104  return;
105 
106  std::vector<float> scaledCorners(24);
107  float scale = scaleFactor(vc);
108 
109  assert(parent->NumChildren() == 1);
110  TEveBoxSet* boxSet = static_cast<TEveBoxSet*>(*parent->BeginChildren());
111 
112  for (int index = 0; index < static_cast<int>(size); ++index) {
113  const CaloRecHit* hit = (const CaloRecHit*)item()->modelData(index);
114  const float* corners = item()->getGeom()->getCorners(hit->detid());
115  if (corners == nullptr)
116  continue;
117 
119 
120  viewContextBoxScale(corners, hit->energy() * scale, vc->getEnergyScale()->getPlotEt(), scaledCorners, hit);
121  memcpy(b->fVertices, &scaledCorners[0], sizeof(b->fVertices));
122  }
123  boxSet->ElementChanged();
124 }
125 //______________________________________________________________________________
126 
128  TEveElementList* product,
129  const FWViewContext* vc) {
130  size_t size = iItem->size();
131  if (!size)
132  return;
133 
134  // m_ignoreGeoShapeSize = item()->getConfig()->value<bool>("IgnoreShapeSize");
135  m_enlarge = item()->getConfig()->value<double>("Enlarge");
136 
137  std::vector<float> scaledCorners(24);
138 
139  float scale = scaleFactor(vc);
140 
141  TEveBoxSet* boxSet = addBoxSetToProduct(product);
142  boxSet->SetAntiFlick(kTRUE);
143  for (int index = 0; index < static_cast<int>(size); ++index) {
144  const CaloRecHit* hit = (const CaloRecHit*)item()->modelData(index);
145 
146  const float* corners = context().getGeom()->getCorners(hit->detid());
147  if (corners) {
148  m_vector.Set(0.f, 0.f, 0.f);
149  for (unsigned int i = 0; i < 24; i += 3) {
150  m_vector[0] += corners[i];
151  m_vector[1] += corners[i + 1];
152  m_vector[2] += corners[i + 2];
153  }
154  m_vector.Normalize();
155  context().voteMaxEtAndEnergy(m_vector.Perp() * hit->energy(), hit->energy());
156  viewContextBoxScale(corners, hit->energy() * scale, vc->getEnergyScale()->getPlotEt(), scaledCorners, hit);
157  }
158 
159  addBox(boxSet, &scaledCorners[0], iItem->modelInfo(index).displayProperties());
160  }
161 }
size
Write out results.
size_t size() const
Definition: FWEventItem.cc:457
const void * modelData(int iIndex) const
Definition: FWEventItem.cc:466
FWProxyBuilderConfiguration * getConfig() const
Definition: FWEventItem.h:150
virtual void viewContextBoxScale(const float *corners, float scale, bool plotEt, std::vector< float > &scaledCorners, const CaloRecHit *)
assert(be >=bs)
const FWDisplayProperties & displayProperties() const
Definition: FWEventItem.h:64
const fireworks::Context & context() const
bool getPlotEt() const
FWViewEnergyScale * getEnergyScale() const
void setItem(const FWEventItem *iItem) override
FWGeometry * getGeom() const
Definition: Context.h:72
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:439
void scaleProduct(TEveElementList *parent, FWViewType::EType, const FWViewContext *vc) override
virtual void setItem(const FWEventItem *iItem)
void voteMaxEtAndEnergy(float Et, float energy) const
Definition: Context.cc:162
void invertBox(std::vector< float > &corners)
double f[11][100]
virtual float scaleFactor(const FWViewContext *vc)
FWGenericParameter< T > * assertParam(const std::string &name, T def)
float getScaleFactor3D() const
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:548
double b
Definition: hdecay.h:118
TEveBoxSet * addBoxSetToProduct(TEveElementList *product)
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:446
void addBox(TEveBoxSet *set, const float *pnts, const FWDisplayProperties &dp)
const FWEventItem * item() const