CMS 3D CMS Logo

FWHGCalMultiClusterProxyBuilder.cc
Go to the documentation of this file.
1 #include "TEveBoxSet.h"
7 
8 class FWHGCalMultiClusterProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::HGCalMultiCluster>
9 {
10 public:
13 
15 
16 private:
17  FWHGCalMultiClusterProxyBuilder( const FWHGCalMultiClusterProxyBuilder& ) = delete; // stop default
18  const FWHGCalMultiClusterProxyBuilder& operator=( const FWHGCalMultiClusterProxyBuilder& ) = delete; // stop default
19 
21  void build( const reco::HGCalMultiCluster& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* ) override;
22 };
23 
24 void
25 FWHGCalMultiClusterProxyBuilder::build( const reco::HGCalMultiCluster& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* )
26 {
27  const auto & clusters = iData.clusters();
28 
29  TEveBoxSet* boxset = new TEveBoxSet();
30  boxset->Reset(TEveBoxSet::kBT_FreeBox, true, 64);
31  boxset->UseSingleColor();
32  boxset->SetPickable(true);
33  for (const auto & c : clusters)
34  {
35  std::vector<std::pair<DetId, float> > clusterDetIds = c->hitsAndFractions();
36 
37 
38  for( std::vector<std::pair<DetId, float> >::iterator it = clusterDetIds.begin(), itEnd = clusterDetIds.end();
39  it != itEnd; ++it )
40  {
41  const float* corners = item()->getGeom()->getCorners( it->first );
42  const float* parameters = item()->getGeom()->getParameters( it->first );
43  const float* shapes = item()->getGeom()->getShapePars(it->first);
44 
45  if( corners == nullptr || parameters == nullptr || shapes == nullptr ) {
46  continue;
47  }
48 
49 #if 0
50  const int total_points = parameters[0];
51  const int total_vertices = 3*total_points;
52 #else // using broken boxes(half hexagon) until there's support for hexagons in TEveBoxSet
53  const int total_points = 4;
54  const int total_vertices = 3*total_points;
55 
56  const float thickness = shapes[3];
57 
58  std::vector<float> pnts(24);
59  for(int i = 0; i < total_points; ++i){
60  pnts[i*3+0] = corners[i*3];
61  pnts[i*3+1] = corners[i*3+1];
62  pnts[i*3+2] = corners[i*3+2];
63 
64  pnts[(i*3+0)+total_vertices] = corners[i*3];
65  pnts[(i*3+1)+total_vertices] = corners[i*3+1];
66  pnts[(i*3+2)+total_vertices] = corners[i*3+2]+thickness;
67  }
68  boxset->AddBox( &pnts[0]);
69 #endif
70  }
71  }
72  boxset->RefitPlex();
73  setupAddElement(boxset, &oItemHolder);
74 }
75 
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
const float * getParameters(unsigned int id) const
Definition: FWGeometry.cc:446
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
const FWEventItem * item() const
const float * getShapePars(unsigned int id) const
Definition: FWGeometry.cc:462
const edm::PtrVector< reco::BasicCluster > & clusters() const
const FWHGCalMultiClusterProxyBuilder & operator=(const FWHGCalMultiClusterProxyBuilder &)=delete
const float * getCorners(unsigned int id) const
Definition: FWGeometry.cc:430
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:683