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 
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 
27 protected:
28  virtual void build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) override;
29  virtual void localModelChanges( const FWModelId& iId, TEveElement* iCompound,
30  FWViewType::EType viewType, const FWViewContext* vc ) override;
31 private:
34 };
35 
36 
37 void
39 {
40  // keep itemholders to restore configuration
41 
42  for (FWProxyBuilderBase::Product_it i = m_products.begin(); i != m_products.end(); ++i)
43  {
44  if ((*i)->m_elements)
45  {
46  TEveElement* elms = (*i)->m_elements;
47  for (TEveElement::List_i it = elms->BeginChildren(); it != elms->EndChildren(); ++it)
48  (*it)->DestroyElements();
49  }
50  }
51 
52  cleanLocal();
53 }
54 void
55 FWSiStripClusterProxyBuilder::build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext* )
56 {
57  const edmNew::DetSetVector<SiStripCluster>* clusters = 0;
58  iItem->get( clusters );
59  if( 0 == clusters ) return;
60  int cnt = 0;
61 
62  for( edmNew::DetSetVector<SiStripCluster>::const_iterator set = clusters->begin(), setEnd = clusters->end();
63  set != setEnd; ++set) {
64  unsigned int id = set->detId();
65 
66 
67  TEveGeoShape* shape = item()->getGeom()->getEveShape( id );
68  if (shape)
69  {
70  shape->SetMainTransparency( 75 );
71  shape->SetElementName( "Det" );
72  }
73  else
74  {
76  << "failed to get shape of SiStripCluster with detid: "
77  << id << std::endl;
78  }
79 
80  for( edmNew::DetSet<SiStripCluster>::const_iterator ic = set->begin (), icEnd = set->end (); ic != icEnd; ++ic )
81  {
82  TEveCompound* itemHolder = 0;
83  if (cnt < product->NumChildren())
84  {
85  TEveElement::List_i pit = product->BeginChildren();
86  std::advance(pit, cnt);
87  itemHolder = (TEveCompound*)*pit;
88  itemHolder->SetRnrSelfChildren(true, true);
89  }
90  else {
91  itemHolder = createCompound();
92  setupAddElement( itemHolder, product );
93  }
94 
95  // add common shape
96  if (shape)
97  {
98  setupAddElement( shape, itemHolder );
99  increaseComponentTransparency( cnt, itemHolder, "Det", 60 );
100  }
101 
102  // add line
103  if( ! item()->getGeom()->contains( id ))
104  {
106  << "failed to geometry of SiStripCluster with detid: "
107  << id << std::endl;
108  continue;
109  }
110 
111  TEveStraightLineSet *lineSet = new TEveStraightLineSet( "strip" );
112  setupAddElement( lineSet, itemHolder );
113  float localTop[3] = { 0.0, 0.0, 0.0 };
114  float localBottom[3] = { 0.0, 0.0, 0.0 };
115 
116  fireworks::localSiStrip( (*ic).firstStrip(), localTop, localBottom, iItem->getGeom()->getParameters( id ), id );
117 
118  float globalTop[3];
119  float globalBottom[3];
120  iItem->getGeom()->localToGlobal( id, localTop, globalTop, localBottom, globalBottom );
121 
122  lineSet->AddLine( globalTop[0], globalTop[1], globalTop[2],
123  globalBottom[0], globalBottom[1], globalBottom[2] );
124 
125  cnt++;
126  }
127  }
128 }
129 void
130 FWSiStripClusterProxyBuilder::localModelChanges( const FWModelId& iId, TEveElement* iCompound,
131  FWViewType::EType viewType, const FWViewContext* vc )
132 {
133  increaseComponentTransparency( iId.index(), iCompound, "Det", 60 );
134 }
135 
int i
Definition: DBlmapReader.cc:9
std::vector< Product * >::iterator Product_it
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
#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:293
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
virtual void cleanLocal()
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:250
void localToGlobal(unsigned int id, const float *local, float *global, bool translatep=true) const
Definition: FWGeometry.cc:325
#define fwLog(_level_)
Definition: fwLog.h:50
const_iterator end(bool update=true) const
TEveCompound * createCompound(bool set_color=true, bool propagate_color_to_all_children=false) const
const_iterator begin(bool update=true) const
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:681
void increaseComponentTransparency(unsigned int index, TEveElement *holder, const std::string &name, Char_t transpOffset)