CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWHFRecHitProxyBuilder.cc
Go to the documentation of this file.
8 #include "TEveCompound.h"
9 
11 {
12 public:
14  : m_maxEnergy( 5.0 )
15  {}
16 
17  virtual ~FWHFRecHitProxyBuilder( void )
18  {}
19 
21 
22 private:
23  virtual void build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext* );
24 
25  Float_t m_maxEnergy;
26 
29 };
30 
31 void
32 FWHFRecHitProxyBuilder::build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext* )
33 {
34  const HFRecHitCollection* collection = 0;
35  iItem->get( collection );
36 
37  if( 0 == collection )
38  {
39  return;
40  }
41 
42  std::vector<HFRecHit>::const_iterator it = collection->begin();
43  std::vector<HFRecHit>::const_iterator itEnd = collection->end();
44  for( ; it != itEnd; ++it )
45  {
46  if(( *it ).energy() > m_maxEnergy )
47  m_maxEnergy = ( *it ).energy();
48  }
49 
50  TEveBoxSet* boxSet = addBoxSetToProduct(product);
51  int index = 0;
52  for (std::vector<HFRecHit>::const_iterator it = collection->begin() ; it != collection->end(); ++it)
53  {
54  unsigned int rawid = ( *it ).detid().rawId();
55  if( ! context().getGeom()->contains( rawid ))
56  {
57  fwLog( fwlog::kInfo ) << "FWHFRecHitProxyBuilder cannot get geometry for DetId: "
58  << rawid << ". Ignored.\n";
59  }
60  const float* corners = context().getGeom()->getCorners( rawid );
61 
62  std::vector<float> scaledCorners(24);
63  if (corners)
64  fireworks::energyScaledBox3DCorners(corners, (*it).energy() / m_maxEnergy, scaledCorners, true);
65 
66  addBox(boxSet, &scaledCorners[0], iItem->modelInfo(index++).displayProperties());
67  }
68 }
69 
const fireworks::Context & context() const
const FWDisplayProperties & displayProperties() const
Definition: FWEventItem.h:67
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
bool contains(EventRange const &lh, EventID const &rh)
Definition: EventRange.cc:38
const FWGeometry * getGeom() const
Definition: Context.h:84
void get(const T *&oData) const
Definition: FWEventItem.h:84
const FWHFRecHitProxyBuilder & operator=(const FWHFRecHitProxyBuilder &)
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)
#define fwLog(_level_)
Definition: fwLog.h:51
TEveBoxSet * addBoxSetToProduct(TEveElementList *product)
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:535
void addBox(TEveBoxSet *set, const float *pnts, const FWDisplayProperties &dp)
const_iterator begin() const