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