CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
FWGEMDigiProxyBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Muon
4 // Class : FWGEMDigiProxyBuilder
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: mccauley
10 // Created: Sun Jan 6 23:57:00 EST 2008
11 // $Id: FWRPCDigiProxyBuilder.cc,v 1.14 2010/09/07 15:46:48 yana Exp $
12 // $Id: FWGEMDigiProxyBuilder.cc,v 1.15 2013/10/10 22:06:00 YusangKim$
13 //
14 
15 #include "TEveStraightLineSet.h"
16 #include "TEveCompound.h"
17 #include "TEveGeoNode.h"
18 
23 
28 
30 public:
32  ~FWGEMDigiProxyBuilder() override {}
33 
35 
36 private:
38  void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) override;
39 
40 public:
43 };
44 
45 void FWGEMDigiProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) {
46  const GEMDigiCollection* digis = nullptr;
47 
48  iItem->get(digis);
49 
50  if (!digis) {
51  fwLog(fwlog::kWarning) << "Failed to get GEMDigis" << std::endl;
52  return;
53  }
54  const FWGeometry* geom = iItem->getGeom();
55 
56  for (GEMDigiCollection::DigiRangeIterator dri = digis->begin(), driEnd = digis->end(); dri != driEnd; ++dri) {
57  unsigned int rawid = (*dri).first.rawId();
58  const GEMDigiCollection::Range& range = (*dri).second;
59 
60  if (!geom->contains(rawid)) {
61  fwLog(fwlog::kWarning) << "Failed to get geometry of GEM roll with detid: " << rawid << std::endl;
62 
63  TEveCompound* compound = createCompound();
64  setupAddElement(compound, product);
65 
66  continue;
67  }
68 
69  const float* parameters = geom->getParameters(rawid);
70  float nStrips = parameters[0];
71  float halfStripLength = parameters[1] * 0.5;
72  float topPitch = parameters[3];
73  float bottomPitch = parameters[4];
74 
75  for (GEMDigiCollection::const_iterator dit = range.first; dit != range.second; ++dit) {
76  TEveStraightLineSet* stripDigiSet = new TEveStraightLineSet;
77  stripDigiSet->SetLineWidth(3);
78  setupAddElement(stripDigiSet, product);
79 
80  int strip = (*dit).strip();
81  float topOfStrip = (strip - 0.5) * topPitch - 0.5 * nStrips * topPitch;
82  float bottomOfStrip = (strip - 0.5) * bottomPitch - 0.5 * nStrips * bottomPitch;
83 
84  float localPointTop[3] = {topOfStrip, halfStripLength, 0.0};
85 
86  float localPointBottom[3] = {bottomOfStrip, -halfStripLength, 0.0};
87 
88  float globalPointTop[3];
89  float globalPointBottom[3];
90 
91  geom->localToGlobal(rawid, localPointTop, globalPointTop, localPointBottom, globalPointBottom);
92 
93  stripDigiSet->AddLine(globalPointTop[0],
94  globalPointTop[1],
95  globalPointTop[2],
96  globalPointBottom[0],
97  globalPointBottom[1],
98  globalPointBottom[2]);
99  }
100  }
101 }
102 
105  "GEMDigi",
107 
109 public:
112 
114 
115 public:
118 
119 private:
120  void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) override;
121 };
122 
123 void FWGEMPadDigiProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) {
124  const GEMPadDigiCollection* digis = nullptr;
125 
126  iItem->get(digis);
127 
128  if (!digis) {
129  fwLog(fwlog::kWarning) << "Failed to get GEMPadDigis" << std::endl;
130  return;
131  }
132  const FWGeometry* geom = iItem->getGeom();
133 
134  for (GEMPadDigiCollection::DigiRangeIterator dri = digis->begin(), driEnd = digis->end(); dri != driEnd; ++dri) {
135  unsigned int rawid = (*dri).first.rawId();
136  const GEMPadDigiCollection::Range& range = (*dri).second;
137 
138  if (!geom->contains(rawid)) {
139  fwLog(fwlog::kWarning) << "Failed to get geometry of GEM roll with detid: " << rawid << std::endl;
140 
141  TEveCompound* compound = createCompound();
142  setupAddElement(compound, product);
143 
144  continue;
145  }
146 
147  const float* parameters = geom->getParameters(rawid);
148  float nStrips = parameters[0];
149  float halfStripLength = parameters[1] * 0.5;
150  float nPads = parameters[5];
151  float topPitch = parameters[3] * nStrips / nPads;
152  float bottomPitch = parameters[4] * nStrips / nPads;
153 
154  for (GEMPadDigiCollection::const_iterator dit = range.first; dit != range.second; ++dit) {
155  TEveStraightLineSet* stripDigiSet = new TEveStraightLineSet;
156  stripDigiSet->SetLineWidth(3 * nStrips / nPads);
157  setupAddElement(stripDigiSet, product);
158 
159  int pad = (*dit).pad();
160  float topOfStrip = (pad - 0.5) * topPitch - 0.5 * topPitch * nPads;
161  float bottomOfStrip = (pad - 0.5) * bottomPitch - 0.5 * bottomPitch * nPads;
162 
163  float localPointTop[3] = {topOfStrip, halfStripLength, 0.0};
164 
165  float localPointBottom[3] = {bottomOfStrip, -halfStripLength, 0.0};
166 
167  float globalPointTop[3];
168  float globalPointBottom[3];
169 
170  geom->localToGlobal(rawid, localPointTop, globalPointTop, localPointBottom, globalPointBottom);
171 
172  stripDigiSet->AddLine(globalPointTop[0],
173  globalPointTop[1],
174  globalPointTop[2],
175  globalPointBottom[0],
176  globalPointBottom[1],
177  globalPointBottom[2]);
178  }
179  }
180 }
181 
184  "GEMPadDigi",
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:67
const float * getParameters(unsigned int id) const
Definition: FWGeometry.cc:472
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
void get(const T *&oData) const
Definition: FWEventItem.h:78
const FWGEMPadDigiProxyBuilder & operator=(const FWGEMPadDigiProxyBuilder &)=delete
tuple nStrips
1.2 is to make the matching window safely the two nearest strips 0.35 is the size of an ME0 chamber i...
static const int kAll3DBits
Definition: FWViewType.h:68
const uint16_t range(const Frame &aFrame)
const FWGEMDigiProxyBuilder & operator=(const FWGEMDigiProxyBuilder &)=delete
void localToGlobal(unsigned int id, const float *local, float *global, bool translatep=true) const
Definition: FWGeometry.cc:494
bool contains(unsigned int id) const
Definition: FWGeometry.h:139
#define fwLog(_level_)
Definition: fwLog.h:45
std::pair< const_iterator, const_iterator > Range
std::vector< DigiType >::const_iterator const_iterator
TEveCompound * createCompound(bool set_color=true, bool propagate_color_to_all_children=false) const
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:548