CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWSiStripClusterProxyBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 #include <vector>
4 #include "TEveGeoNode.h"
5 #include "TEveStraightLineSet.h"
6 #include "TEveCompound.h"
7 
13 
16 
18 {
19 public:
21  virtual ~FWSiStripClusterProxyBuilder( void ) {}
22 
24 
25  virtual void clean() override;
26  virtual void cleanLocal() override;
27 
28 
29 protected:
31  virtual void build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) override;
32  virtual void localModelChanges( const FWModelId& iId, TEveElement* iCompound,
33  FWViewType::EType viewType, const FWViewContext* vc ) override;
34 private:
37 
38  std::vector<TEveGeoShape*> m_shapeMap;
39 };
40 
41 
42 void
44 {
45  // keep itemholders to restore configuration
46 
47  for (FWProxyBuilderBase::Product_it i = m_products.begin(); i != m_products.end(); ++i)
48  {
49  if ((*i)->m_elements)
50  {
51  TEveElement* elms = (*i)->m_elements;
52  for (TEveElement::List_i it = elms->BeginChildren(); it != elms->EndChildren(); ++it)
53  (*it)->DestroyElements();
54  }
55  }
56 
57  cleanLocal();
58 }
59 
60 
61 
62 void
64 {
65  for (TEveGeoShape* i : m_shapeMap)
66  i->Destroy();
67 
68  m_shapeMap.clear();
69 }
70 
71 void
72 FWSiStripClusterProxyBuilder::build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext* )
73 {
74  const edmNew::DetSetVector<SiStripCluster>* clusters = 0;
75  iItem->get( clusters );
76  if( 0 == clusters ) return;
77  int cnt = 0;
78 
79  for( edmNew::DetSetVector<SiStripCluster>::const_iterator set = clusters->begin(), setEnd = clusters->end();
80  set != setEnd; ++set) {
81  unsigned int id = set->detId();
82 
83  TEveGeoShape* shape = item()->getGeom()->getEveShape( id );
84  if (shape)
85  {
86  shape->SetMainTransparency( 75 );
87  shape->SetElementName( "Det" );
88  m_shapeMap.push_back(shape);
89  }
90  else
91  {
93  << "failed to get shape of SiStripCluster with detid: "
94  << id << std::endl;
95  }
96 
97 
98  for( edmNew::DetSet<SiStripCluster>::const_iterator ic = set->begin (), icEnd = set->end (); ic != icEnd; ++ic )
99  {
100  TEveCompound* itemHolder = 0;
101  if (cnt < product->NumChildren())
102  {
103  TEveElement::List_i pit = product->BeginChildren();
104  std::advance(pit, cnt);
105  itemHolder = (TEveCompound*)*pit;
106  itemHolder->SetRnrSelfChildren(true, true);
107  }
108  else {
109  itemHolder = createCompound();
110  setupAddElement( itemHolder, product );
111  }
112 
113  // add common shape
114  if (shape)
115  {
116  setupAddElement( shape, itemHolder );
117  increaseComponentTransparency( cnt, itemHolder, "Det", 60 );
118  }
119 
120  // add line
121  if( ! item()->getGeom()->contains( id ))
122  {
124  << "failed to geometry of SiStripCluster with detid: "
125  << id << std::endl;
126  continue;
127  }
128 
129 
130 
131  TEveStraightLineSet *lineSet = new TEveStraightLineSet( "strip" );
132  setupAddElement( lineSet, itemHolder );
133  float localTop[3] = { 0.0, 0.0, 0.0 };
134  float localBottom[3] = { 0.0, 0.0, 0.0 };
135 
136  fireworks::localSiStrip( (*ic).firstStrip(), localTop, localBottom, iItem->getGeom()->getParameters( id ), id );
137 
138  float globalTop[3];
139  float globalBottom[3];
140  iItem->getGeom()->localToGlobal( id, localTop, globalTop, localBottom, globalBottom );
141 
142  lineSet->AddLine( globalTop[0], globalTop[1], globalTop[2],
143  globalBottom[0], globalBottom[1], globalBottom[2] );
144 
145  cnt++;
146  }
147  }
148 }
149 void
150 FWSiStripClusterProxyBuilder::localModelChanges( const FWModelId& iId, TEveElement* iCompound,
151  FWViewType::EType viewType, const FWViewContext* vc )
152 {
153  increaseComponentTransparency( iId.index(), iCompound, "Det", 60 );
154 }
155 
int i
Definition: DBlmapReader.cc:9
std::vector< Product * >::iterator Product_it
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
#define REGISTER_PROXYBUILDER_METHODS()
const_iterator end(bool update=false) const
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
std::vector< Product * > m_products
bool contains(EventRange const &lh, EventID const &rh)
Definition: EventRange.cc:38
virtual void localModelChanges(const FWModelId &iId, TEveElement *iCompound, FWViewType::EType viewType, const FWViewContext *vc) override
static const int kAllRPZBits
Definition: FWViewType.h:58
const float * getParameters(unsigned int id) const
Definition: FWGeometry.cc:296
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
void get(const T *&oData) const
Definition: FWEventItem.h:84
data_type const * const_iterator
Definition: DetSetNew.h:30
const FWEventItem * item() const
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:291
const FWSiStripClusterProxyBuilder & operator=(const FWSiStripClusterProxyBuilder &)
int index() const
Definition: FWModelId.h:49
TEveGeoShape * getEveShape(unsigned int id) const
Definition: FWGeometry.cc:253
void localToGlobal(unsigned int id, const float *local, float *global, bool translatep=true) const
Definition: FWGeometry.cc:328
#define fwLog(_level_)
Definition: fwLog.h:50
std::vector< TEveGeoShape * > m_shapeMap
TEveCompound * createCompound(bool set_color=true, bool propagate_color_to_all_children=false) const
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:681
void increaseComponentTransparency(unsigned int index, TEveElement *holder, const std::string &name, Char_t transpOffset)
const_iterator begin(bool update=false) const