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