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