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",
FWGeometry::GeomDetInfo
Definition: FWGeometry.h:119
mps_fire.i
i
Definition: mps_fire.py:355
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:497
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:231
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:152
mps_check.array
array
Definition: mps_check.py:216
FWSiStripClusterProxyBuilder
Definition: FWSiStripClusterProxyBuilder.cc:17
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:475
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:49
FWSiStripClusterProxyBuilder::FWSiStripClusterProxyBuilder
FWSiStripClusterProxyBuilder(void)
Definition: FWSiStripClusterProxyBuilder.cc:42
bsc_activity_cfg.clusters
clusters
Definition: bsc_activity_cfg.py:36
FWSiStripClusterProxyBuilder::~FWSiStripClusterProxyBuilder
~FWSiStripClusterProxyBuilder(void) override
Definition: FWSiStripClusterProxyBuilder.cc:47
FWGeometry.h
SiStripCluster.h
FWSiStripClusterProxyBuilder::m_shapeList
TEveElementList * m_shapeList
Definition: FWSiStripClusterProxyBuilder.cc:39
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:140
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:290
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:517