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 "TEveLine.h"
6 #include "TEveCompound.h"
7 
13 
16 
18 {
19 public:
21  virtual ~FWSiStripClusterProxyBuilder( void );
22 
24 
25  // virtual void cleanLocal();
26  virtual void itemBeingDestroyed(const FWEventItem*);
27 
28 protected:
30  virtual void build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) override;
31  virtual 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  m_shapeList = new TEveElementList("shapePool");
43  m_shapeList->IncDenyDestroy();
44 }
45 
47 {
48  m_shapeList->DecDenyDestroy();
49 }
50 
51 void
53 {
54  m_shapeList->DestroyElements();
56 }
57 
58 void
59 FWSiStripClusterProxyBuilder::build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext* )
60 {
61  const edmNew::DetSetVector<SiStripCluster>* clusters = 0;
62  iItem->get( clusters );
63  if( 0 == clusters ) return;
64  int cntEl = 0;
65 
66  for (TEveElement::List_i ei = product->BeginChildren(); ei != product->EndChildren(); ++ei) {
67  TEveElement* holder = *ei;
68  if (holder->HasChildren()) {
69  holder->SetRnrSelfChildren(false, false);
70  holder->RemoveElement(holder->LastChild());
71  }
72  }
73 
74  // check if need to create more shapes
75  int sdiff = clusters->size() - m_shapeList->NumChildren();
76  for (int i = 0; i <= sdiff; ++i)
77  m_shapeList->AddElement(new TEveGeoShape("Det"));
78 
79  TEveElement::List_i shapeIt = m_shapeList->BeginChildren();
80  for( edmNew::DetSetVector<SiStripCluster>::const_iterator set = clusters->begin(), setEnd = clusters->end();
81  set != setEnd; ++set) {
82 
83  unsigned int id = set->detId();
84  const FWGeometry::GeomDetInfo& info = *iItem->getGeom()->find( id );
85 
86  double array[16] = { info.matrix[0], info.matrix[3], info.matrix[6], 0.,
87  info.matrix[1], info.matrix[4], info.matrix[7], 0.,
88  info.matrix[2], info.matrix[5], info.matrix[8], 0.,
89  info.translation[0], info.translation[1], info.translation[2], 1.
90  };
91 
92 
93  // note TEveGeoShape owns shape
94  TEveGeoShape* shape = (TEveGeoShape*)(*shapeIt);
95  shape->SetShape(iItem->getGeom()->getShape(info));
96  shape->SetTransMatrix(array);
97  shape->SetRnrSelf(true);
98  shapeIt++;
99 
100  for( edmNew::DetSet<SiStripCluster>::const_iterator ic = set->begin (), icEnd = set->end (); ic != icEnd; ++ic )
101  {
102  TEveCompound* itemHolder = 0;
103  TEveLine* line = 0;
104 
105  if (cntEl < product->NumChildren())
106  {
107  TEveElement::List_i pit = product->BeginChildren();
108  std::advance(pit, cntEl);
109  itemHolder = (TEveCompound*)*pit;
110  itemHolder->SetRnrSelfChildren(true, true);
111 
112  line = (TEveLine*) (itemHolder->FirstChild());
113  setupAddElement( shape, itemHolder );
114  }
115  else {
116  itemHolder = createCompound();
117  setupAddElement( itemHolder, product );
118  line = new TEveLine("line");
119  setupAddElement( line, itemHolder );
120  setupAddElement( shape, itemHolder );
121  }
122  shape->SetMainTransparency(75);
123 
124  // setup line pnts
125  float localTop[3] = { 0.0, 0.0, 0.0 };
126  float localBottom[3] = { 0.0, 0.0, 0.0 };
127  fireworks::localSiStrip( (*ic).firstStrip(), localTop, localBottom, iItem->getGeom()->getParameters( id ), id );
128  float globalTop[3];
129  float globalBottom[3];
130  iItem->getGeom()->localToGlobal( id, localTop, globalTop, localBottom, globalBottom );
131  line->SetPoint(0, globalTop[0], globalTop[1], globalTop[2]);
132  line->SetPoint(1, globalBottom[0], globalBottom[1], globalBottom[2]);
133 
134  cntEl++;
135  }
136  }
137 }
138 void
139 FWSiStripClusterProxyBuilder::localModelChanges( const FWModelId& iId, TEveElement* iCompound,
140  FWViewType::EType viewType, const FWViewContext* vc )
141 {
142  increaseComponentTransparency( iId.index(), iCompound, "Det", 60 );
143 }
144 
int i
Definition: DBlmapReader.cc:9
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_)
virtual 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:358
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
TGeoShape * getShape(unsigned int id) const
Definition: FWGeometry.cc:212
data_type const * const_iterator
Definition: DetSetNew.h:30
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
void localToGlobal(unsigned int id, const float *local, float *global, bool translatep=true) const
Definition: FWGeometry.cc:328
virtual void itemBeingDestroyed(const FWEventItem *)
size_type size() const
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