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