CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWHBHERecHitProxyBuilder.cc
Go to the documentation of this file.
1 #include "TEveCompound.h"
2 #include "TEveBoxSet.h"
3 
11 
13 {
14 public:
16  : m_maxEnergy( 0.85 ), m_plotEt(true)
17  {}
18 
19  virtual ~FWHBHERecHitProxyBuilder( void )
20  {}
21 
22  virtual bool havePerViewProduct(FWViewType::EType) const { return true; }
23  virtual void scaleProduct(TEveElementList* parent, FWViewType::EType, const FWViewContext* vc);
24 
26 
27 private:
28  virtual void build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext* );
29 
30  Float_t m_maxEnergy;
31  bool m_plotEt;
32 
35 };
36 
37 void
39 {
40  if (m_plotEt != vc->getEnergyScale()->getPlotEt() )
41  {
42  m_plotEt = !m_plotEt;
43 
45  item()->get( collection );
46  if (! collection)
47  return;
48 
49  int index = 0;
50  std::vector<float> scaledCorners(24);
51  for (std::vector<HBHERecHit>::const_iterator it = collection->begin() ; it != collection->end(); ++it, ++index)
52  {
53  const float* corners = item()->getGeom()->getCorners((*it).detid());
54  if (corners == 0)
55  continue;
57 
58  /*
59  printf("--------------------scale product \n");
60  for (int i = 0; i < 8 ; ++i)
61  printf("[%f %f %f ]\n",b->fVertices[i][0], b->fVertices[i][1],b->fVertices[i][2] );
62  */
63 
64  if (m_plotEt)
65  fireworks::etScaledBox3DCorners(corners, (*it).energy(), m_maxEnergy, scaledCorners, true);
66  else
67  fireworks::energyScaledBox3DCorners(corners, (*it).energy() / m_maxEnergy, scaledCorners, true);
68 
69  /*
70  printf("after \n");
71  for (int i = 0; i < 8 ; ++i)
72  printf("[%f %f %f ]\n",b->fVertices[i][0], b->fVertices[i][1],b->fVertices[i][2] );
73  */
74  memcpy(b->fVertices, &scaledCorners[0], sizeof(b->fVertices));
75 
76  }
77  getBoxSet()->ElementChanged();
78  }
79 }
80 
81 //______________________________________________________________________________
82 
83 void
84 FWHBHERecHitProxyBuilder::build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext* vc)
85 {
87 
89  iItem->get( collection );
90 
91  if( 0 == collection )
92  {
93  return;
94  }
95  std::vector<HBHERecHit>::const_iterator it = collection->begin();
96  std::vector<HBHERecHit>::const_iterator itEnd = collection->end();
97  std::vector<float> scaledCorners(24);
98 
99  for( ; it != itEnd; ++it )
100  {
101  if(( *it ).energy() > m_maxEnergy )
102  m_maxEnergy = ( *it ).energy();
103  }
104 
105  TEveBoxSet* boxSet = addBoxSetToProduct(product);
106  int index = 0;
107  for (std::vector<HBHERecHit>::const_iterator it = collection->begin() ; it != collection->end(); ++it)
108  {
109  const float* corners = context().getGeom()->getCorners((*it).detid());
110  if (corners)
111  {
112  if (m_plotEt)
113  fireworks::etScaledBox3DCorners(corners, (*it).energy(), m_maxEnergy, scaledCorners, true);
114  else
115  fireworks::energyScaledBox3DCorners(corners, (*it).energy() / m_maxEnergy, scaledCorners, true);
116  }
117  addBox(boxSet, &scaledCorners[0], iItem->modelInfo(index++).displayProperties());
118  }
119 }
120 
type
Definition: HCALResponse.h:22
const fireworks::Context & context() const
const FWDisplayProperties & displayProperties() const
Definition: FWEventItem.h:67
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
list parent
Definition: dbtoconf.py:74
virtual void scaleProduct(TEveElementList *parent, FWViewType::EType, const FWViewContext *vc)
const FWGeometry * getGeom() const
Definition: Context.h:84
void get(const T *&oData) const
Definition: FWEventItem.h:84
FWViewEnergyScale * getEnergyScale() const
TEveBoxSet * getBoxSet() const
const FWEventItem * item() const
virtual bool havePerViewProduct(FWViewType::EType) const
const FWHBHERecHitProxyBuilder & operator=(const FWHBHERecHitProxyBuilder &)
const_iterator end() const
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:278
void energyScaledBox3DCorners(const float *corners, float scale, std::vector< float > &, bool invert=false)
double b
Definition: hdecay.h:120
TEveBoxSet * addBoxSetToProduct(TEveElementList *product)
void etScaledBox3DCorners(const float *corners, float energy, float maxEnergy, std::vector< float > &scaledCorners, bool reflect=false)
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:536
void addBox(TEveBoxSet *set, const float *pnts, const FWDisplayProperties &dp)
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:688
const_iterator begin() const
bool getPlotEt() const