CMS 3D CMS Logo

FWSiStripClusterProxyBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 #include <vector>
4 #include "TEveGeoNode.h"
5 #include "TEveLine.h"
6 #include "TEveCompound.h"
7 
13 
16 
18 {
19 public:
21  ~FWSiStripClusterProxyBuilder( void ) override;
22 
24 
25  // virtual void cleanLocal();
26  void itemBeingDestroyed(const FWEventItem*) override;
27 
28 protected:
30  void build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) override;
31  void localModelChanges( const FWModelId& iId, TEveElement* iCompound,
32  FWViewType::EType viewType, const FWViewContext* vc ) override;
33 private:
36 
37  TEveElementList* m_shapeList;
38 };
39 
41 {
42 
43  m_shapeList = new TEveElementList("shapePool");
44  m_shapeList->IncDenyDestroy();
45 }
46 
48 {
49  m_shapeList->DecDenyDestroy();
50 }
51 
52 void
54 {
55  m_shapeList->DestroyElements();
57 }
58 
59 void
60 FWSiStripClusterProxyBuilder::build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext* )
61 {
63  iItem->get( clusters );
64  if( nullptr == clusters ) return;
65  int cntEl = 0;
66 
67  for (TEveElement::List_i ei = product->BeginChildren(); ei != product->EndChildren(); ++ei) {
68  TEveElement* holder = *ei;
69  if (holder->HasChildren()) {
70  holder->SetRnrSelfChildren(false, false);
71  holder->RemoveElement(holder->LastChild());
72  }
73  }
74 
75  // check if need to create more shapes
76  int sdiff = clusters->size() - m_shapeList->NumChildren();
77  for (int i = 0; i <= sdiff; ++i)
78  m_shapeList->AddElement(new TEveGeoShape("Det"));
79 
80  TEveElement::List_i shapeIt = m_shapeList->BeginChildren();
81  for( edmNew::DetSetVector<SiStripCluster>::const_iterator set = clusters->begin(), setEnd = clusters->end();
82  set != setEnd; ++set) {
83 
84  unsigned int id = set->detId();
85  const FWGeometry::GeomDetInfo& info = *iItem->getGeom()->find( id );
86 
87  double array[16] = { info.matrix[0], info.matrix[3], info.matrix[6], 0.,
88  info.matrix[1], info.matrix[4], info.matrix[7], 0.,
89  info.matrix[2], info.matrix[5], info.matrix[8], 0.,
90  info.translation[0], info.translation[1], info.translation[2], 1.
91  };
92 
93 
94  // note TEveGeoShape owns shape
95  TEveGeoShape* shape = (TEveGeoShape*)(*shapeIt);
96  shape->SetShape(iItem->getGeom()->getShape(info));
97  shape->SetTransMatrix(array);
98  shape->SetRnrSelf(true);
99  shapeIt++;
100 
101  for( edmNew::DetSet<SiStripCluster>::const_iterator ic = set->begin (), icEnd = set->end (); ic != icEnd; ++ic )
102  {
103  TEveCompound* itemHolder = nullptr;
104  TEveLine* line = nullptr;
105 
106  if (cntEl < product->NumChildren())
107  {
108  TEveElement::List_i pit = product->BeginChildren();
109  std::advance(pit, cntEl);
110  itemHolder = (TEveCompound*)*pit;
111  itemHolder->SetRnrSelfChildren(true, true);
112 
113  line = (TEveLine*) (itemHolder->FirstChild());
114  setupAddElement( shape, itemHolder );
115  }
116  else {
117  itemHolder = createCompound();
118  setupAddElement( itemHolder, product );
119  line = new TEveLine("line");
120  setupAddElement( line, itemHolder );
121  setupAddElement( shape, itemHolder );
122  }
123  shape->SetMainTransparency(75);
124 
125  // setup line pnts
126  float localTop[3] = { 0.0, 0.0, 0.0 };
127  float localBottom[3] = { 0.0, 0.0, 0.0 };
128  fireworks::localSiStrip( (*ic).firstStrip(), localTop, localBottom, iItem->getGeom()->getParameters( id ), id );
129  float globalTop[3];
130  float globalBottom[3];
131  iItem->getGeom()->localToGlobal( id, localTop, globalTop, localBottom, globalBottom );
132  line->SetPoint(0, globalTop[0], globalTop[1], globalTop[2]);
133  line->SetPoint(1, globalBottom[0], globalBottom[1], globalBottom[2]);
134 
135  cntEl++;
136  }
137  }
138 }
139 void
140 FWSiStripClusterProxyBuilder::localModelChanges( const FWModelId& iId, TEveElement* iCompound,
141  FWViewType::EType viewType, const FWViewContext* vc )
142 {
143  increaseComponentTransparency( iId.index(), iCompound, "Det", 60 );
144 }
145 
void itemBeingDestroyed(const FWEventItem *) override
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
#define REGISTER_PROXYBUILDER_METHODS()
const_iterator end(bool update=false) const
static const TGPicture * info(bool iBackgroundIsBlack)
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
void localModelChanges(const FWModelId &iId, TEveElement *iCompound, FWViewType::EType viewType, const FWViewContext *vc) override
static const int kAllRPZBits
Definition: FWViewType.h:58
virtual void itemBeingDestroyed(const FWEventItem *)
IdToInfoItr find(unsigned int) const
Definition: FWGeometry.cc:508
const float * getParameters(unsigned int id) const
Definition: FWGeometry.cc:446
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
void get(const T *&oData) const
Definition: FWEventItem.h:85
TGeoShape * getShape(unsigned int id) const
Definition: FWGeometry.cc:257
data_type const * const_iterator
Definition: DetSetNew.h:30
#define nullptr
static const int kAll3DBits
Definition: FWViewType.h:59
void localSiStrip(short strip, float *localTop, float *localBottom, const float *pars, unsigned int id)
Definition: TrackUtils.cc:262
int index() const
Definition: FWModelId.h:49
void localToGlobal(unsigned int id, const float *local, float *global, bool translatep=true) const
Definition: FWGeometry.cc:478
size_type size() const
TEveCompound * createCompound(bool set_color=true, bool propagate_color_to_all_children=false) const
const FWSiStripClusterProxyBuilder & operator=(const FWSiStripClusterProxyBuilder &)=delete
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:683
void increaseComponentTransparency(unsigned int index, TEveElement *holder, const std::string &name, Char_t transpOffset)
const_iterator begin(bool update=false) const