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