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 }
FWEventItem::modelInfo
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:446
mps_fire.i
i
Definition: mps_fire.py:428
FWCaloRecHitDigitSetProxyBuilder::m_ignoreGeoShapeSize
bool m_ignoreGeoShapeSize
Definition: FWCaloRecHitDigitSetProxyBuilder.h:30
funct::false
false
Definition: Factorize.h:29
FWDigitSetProxyBuilder::addBoxSetToProduct
TEveBoxSet * addBoxSetToProduct(TEveElementList *product)
Definition: FWDigitSetProxyBuilder.cc:73
FWGeometry::getCorners
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:467
L1EGammaCrystalsEmulatorProducer_cfi.scale
scale
Definition: L1EGammaCrystalsEmulatorProducer_cfi.py:10
FWViewType::EType
EType
Definition: FWViewType.h:31
FWEventItem::getConfig
FWProxyBuilderConfiguration * getConfig() const
Definition: FWEventItem.h:150
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
cms::cuda::assert
assert(be >=bs)
FWEventItem::modelData
const void * modelData(int iIndex) const
Definition: FWEventItem.cc:466
FWViewEnergyScale::getPlotEt
bool getPlotEt() const
Definition: FWViewEnergyScale.h:47
BuilderUtils.h
CaloRecHit
Definition: CaloRecHit.h:23
FWDigitSetProxyBuilder::addBox
void addBox(TEveBoxSet *set, const float *pnts, const FWDisplayProperties &dp)
Definition: FWDigitSetProxyBuilder.cc:94
CaloRecHit.h
FWCaloRecHitDigitSetProxyBuilder::m_enlarge
double m_enlarge
Definition: FWCaloRecHitDigitSetProxyBuilder.h:31
FWCaloRecHitDigitSetProxyBuilder::setItem
void setItem(const FWEventItem *iItem) override
Definition: FWCaloRecHitDigitSetProxyBuilder.cc:18
fireworks::Context::voteMaxEtAndEnergy
void voteMaxEtAndEnergy(float Et, float energy) const
Definition: Context.cc:162
FWDigitSetProxyBuilder.h
b
double b
Definition: hdecay.h:118
FWProxyBuilderConfiguration::assertParam
FWGenericParameter< T > * assertParam(const std::string &name, T def)
Definition: FWProxyBuilderConfiguration.cc:83
FWGeometry.h
FWCaloRecHitDigitSetProxyBuilder::scaleProduct
void scaleProduct(TEveElementList *parent, FWViewType::EType, const FWViewContext *vc) override
Definition: FWCaloRecHitDigitSetProxyBuilder.cc:99
FWCaloRecHitDigitSetProxyBuilder.h
FWCaloRecHitDigitSetProxyBuilder::m_invertBox
bool m_invertBox
Definition: FWCaloRecHitDigitSetProxyBuilder.h:29
type
type
Definition: SiPixelVCal_PayloadInspector.cc:39
FWProxyBuilderConfiguration.h
fireworks::Context::getGeom
FWGeometry * getGeom() const
Definition: Context.h:72
FWCaloRecHitDigitSetProxyBuilder::m_vector
TEveVector m_vector
Definition: FWCaloRecHitDigitSetProxyBuilder.h:32
FWDigitSetProxyBuilder::BFreeBox_t
Definition: FWDigitSetProxyBuilder.h:47
FWProxyBuilderBase::build
void build()
Definition: FWProxyBuilderBase.cc:110
FWEventItem.h
FWEventItem::ModelInfo::displayProperties
const FWDisplayProperties & displayProperties() const
Definition: FWEventItem.h:64
FWViewContext
Definition: FWViewContext.h:32
FWEventItem::getGeom
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:548
FWProxyBuilderBase::item
const FWEventItem * item() const
Definition: FWProxyBuilderBase.h:64
FWViewEnergyScale::getScaleFactor3D
float getScaleFactor3D() const
Definition: FWViewEnergyScale.h:44
FWEventItem
Definition: FWEventItem.h:56
FWCaloRecHitDigitSetProxyBuilder::scaleFactor
virtual float scaleFactor(const FWViewContext *vc)
Definition: FWCaloRecHitDigitSetProxyBuilder.cc:92
FWProxyBuilderConfiguration::value
T value(const std::string &name)
Definition: FWProxyBuilderConfiguration.cc:123
fireworks::invertBox
void invertBox(std::vector< float > &corners)
Definition: BuilderUtils.cc:134
FWCaloRecHitDigitSetProxyBuilder::viewContextBoxScale
virtual void viewContextBoxScale(const float *corners, float scale, bool plotEt, std::vector< float > &scaledCorners, const CaloRecHit *)
Definition: FWCaloRecHitDigitSetProxyBuilder.cc:27
FWProxyBuilderBase::context
const fireworks::Context & context() const
Definition: FWProxyBuilderBase.cc:412
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
FWViewEnergyScale.h
FWCaloRecHitDigitSetProxyBuilder::FWCaloRecHitDigitSetProxyBuilder
FWCaloRecHitDigitSetProxyBuilder()
Definition: FWCaloRecHitDigitSetProxyBuilder.cc:13
FWProxyBuilderBase::setItem
virtual void setItem(const FWEventItem *iItem)
Definition: FWProxyBuilderBase.cc:83
FWViewContext::getEnergyScale
FWViewEnergyScale * getEnergyScale() const
Definition: FWViewContext.cc:25
class-composition.parent
parent
Definition: class-composition.py:98
hit
Definition: SiStripHitEffFromCalibTree.cc:88
FWEventItem::size
size_t size() const
Definition: FWEventItem.cc:457
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443