CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWCaloRecHitDigitSetProxyBuilder.cc
Go to the documentation of this file.
2 #include "TEveBoxSet.h"
10 
12 
14  : m_invertBox(false), m_ignoreGeoShapeSize(false)
15 {}
16 
17 //______________________________________________________________________________
18 
20 {
22  // if (iItem) iItem->getConfig()->assertParam( "IgnoreShapeSize", false);
23 }
24 //______________________________________________________________________________
25 
26 void FWCaloRecHitDigitSetProxyBuilder::viewContextBoxScale( const float* corners, float scale, bool plotEt, std::vector<float>& scaledCorners, const CaloRecHit*)
27 {
29  {
30  // Same functionality as fireworks::energyTower3DCorners()
31 
32  for( int i = 0; i < 24; ++i )
33  scaledCorners[i] = corners[i];
34 
35  // Coordinates of a front face scaled
36  if( m_invertBox )
37  {
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  {
42  m_vector.Set( corners[i] - corners[i + 12], corners[i + 1] - corners[i + 13], corners[i + 2] - corners[i + 14] );
43  m_vector.Normalize();
44  m_vector *= scale;
45 
46  scaledCorners[i] = corners[i] + m_vector.fX;
47  scaledCorners[i + 1] = corners[i + 1] + m_vector.fY;
48  scaledCorners[i + 2] = corners[i + 2] + m_vector.fZ;
49  }
50  }
51  else
52  {
53  for( unsigned int i = 0; i < 12; i += 3 )
54  {
55  m_vector.Set( corners[i + 12] - corners[i], corners[i + 13] - corners[i + 1], corners[i + 14] - corners[i + 2] );
56  m_vector.Normalize();
57  m_vector *= scale;
58 
59  scaledCorners[i] = corners[i + 12];
60  scaledCorners[i + 1] = corners[i + 13];
61  scaledCorners[i + 2] = corners[i + 14];
62 
63  scaledCorners[i + 12] = corners[i + 12] + m_vector.fX;
64  scaledCorners[i + 13] = corners[i + 13] + m_vector.fY;
65  scaledCorners[i + 14] = corners[i + 14] + m_vector.fZ;
66  }
67  }
68  }
69  else {
70 
71  // Same functionality as fireworks::energyScaledBox3DCorners().
72 
73  m_vector.Set(0.f, 0.f, 0.f);
74  for( unsigned int i = 0; i < 24; i += 3 )
75  {
76  m_vector[0] += corners[i];
77  m_vector[1] += corners[i + 1];
78  m_vector[2] += corners[i + 2];
79  }
80  m_vector *= 1.f/8.f;
81 
82  if (plotEt)
83  {
84  scale *= m_vector.Perp()/m_vector.Mag();
85  }
86 
87  // Coordinates for a scaled version of the original box
88  for( unsigned int i = 0; i < 24; i += 3 )
89  {
90  scaledCorners[i] = m_vector[0] + ( corners[i] - m_vector[0] ) * scale;
91  scaledCorners[i + 1] = m_vector[1] + ( corners[i + 1] - m_vector[1] ) * scale;
92  scaledCorners[i + 2] = m_vector[2] + ( corners[i + 2] - m_vector[2] ) * scale;
93  }
94 
95  if( m_invertBox )
96  fireworks::invertBox( scaledCorners );
97  }
98 }
99 //_____________________________________________________________________________
100 
102 {
103  // printf("scale face %f \n", vc->getEnergyScale()->getScaleFactor3D());
104  return vc->getEnergyScale()->getScaleFactor3D()/50;
105 }
106 
107 //______________________________________________________________________________
108 
109 void
111 {
112  size_t size = item()->size();
113  if (!size) return;
114 
115 
116  std::vector<float> scaledCorners(24);
117  float scale = scaleFactor(vc);
118 
119  assert(parent->NumChildren() == 1);
120  TEveBoxSet* boxSet = static_cast<TEveBoxSet*>(*parent->BeginChildren());
121 
122  for (int index = 0; index < static_cast<int>(size); ++index)
123  {
124  const CaloRecHit* hit = (const CaloRecHit*)item()->modelData(index);
125  const float* corners = item()->getGeom()->getCorners(hit->detid());
126  if (corners == 0) continue;
127 
129 
130  viewContextBoxScale(corners, hit->energy()*scale, vc->getEnergyScale()->getPlotEt(), scaledCorners, hit);
131  memcpy(b->fVertices, &scaledCorners[0], sizeof(b->fVertices));
132  }
133  boxSet->ElementChanged();
134 }
135 //______________________________________________________________________________
136 
137 void
138 FWCaloRecHitDigitSetProxyBuilder::build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext* vc)
139 {
140  size_t size = iItem->size();
141  if (!size) return;
142 
143  // m_ignoreGeoShapeSize = item()->getConfig()->value<bool>("IgnoreShapeSize");
144 
145  std::vector<float> scaledCorners(24);
146 
147  float scale = scaleFactor(vc);
148 
149  TEveBoxSet* boxSet = addBoxSetToProduct(product);
150  boxSet->SetAntiFlick(kTRUE);
151  for (int index = 0; index < static_cast<int>(size); ++index)
152  {
153  const CaloRecHit* hit = (const CaloRecHit*)item()->modelData(index);
154 
155  const float* corners = context().getGeom()->getCorners(hit->detid());
156  if (corners)
157  {
158  m_vector.Set(0.f, 0.f, 0.f);
159  for( unsigned int i = 0; i < 24; i += 3 )
160  {
161  m_vector[0] += corners[i];
162  m_vector[1] += corners[i + 1];
163  m_vector[2] += corners[i + 2];
164  }
165  m_vector.Normalize();
166  context().voteMaxEtAndEnergy( m_vector.Perp() *hit->energy(), hit->energy());
167  viewContextBoxScale( corners, hit->energy()*scale, vc->getEnergyScale()->getPlotEt(), scaledCorners, hit);
168  }
169 
170  addBox(boxSet, &scaledCorners[0], iItem->modelInfo(index).displayProperties());
171  }
172 }
173 
174 
type
Definition: HCALResponse.h:22
const fireworks::Context & context() const
float getScaleFactor3D() const
int i
Definition: DBlmapReader.cc:9
const FWDisplayProperties & displayProperties() const
Definition: FWEventItem.h:68
list parent
Definition: dbtoconf.py:74
virtual void scaleProduct(TEveElementList *parent, FWViewType::EType, const FWViewContext *vc)
const DetId & detid() const
Definition: CaloRecHit.h:22
const FWGeometry * getGeom() const
Definition: Context.h:84
void voteMaxEtAndEnergy(float Et, float energy) const
Definition: Context.cc:185
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:19
virtual void setItem(const FWEventItem *iItem)
void invertBox(std::vector< float > &corners)
double f[11][100]
virtual float scaleFactor(const FWViewContext *vc)
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:277
size_t size() const
Definition: FWEventItem.cc:548
double b
Definition: hdecay.h:120
TEveBoxSet * addBoxSetToProduct(TEveElementList *product)
const void * modelData(int iIndex) const
Definition: FWEventItem.cc:567
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:535
void addBox(TEveBoxSet *set, const float *pnts, const FWDisplayProperties &dp)
tuple size
Write out results.
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:681
bool getPlotEt() const