CMS 3D CMS Logo

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 {
31 public:
33  ~FWGEMDigiProxyBuilder() override {}
34 
36 
37 private:
39  void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) override;
42 };
43 
44 void
45 FWGEMDigiProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*)
46 {
47  const GEMDigiCollection* digis = nullptr;
48 
49  iItem->get(digis);
50 
51  if ( ! digis )
52  {
53  fwLog(fwlog::kWarning)<<"Failed to get GEMDigis"<<std::endl;
54  return;
55  }
56  const FWGeometry *geom = iItem->getGeom();
57 
58  for ( GEMDigiCollection::DigiRangeIterator dri = digis->begin(), driEnd = digis->end();
59  dri != driEnd; ++dri )
60  {
61  unsigned int rawid = (*dri).first.rawId();
62  const GEMDigiCollection::Range& range = (*dri).second;
63 
64  if( ! geom->contains( rawid ))
65  {
66  fwLog( fwlog::kWarning ) << "Failed to get geometry of GEM roll with detid: "
67  << rawid << std::endl;
68 
69  TEveCompound* compound = createCompound();
70  setupAddElement( compound, product );
71 
72  continue;
73  }
74 
75  const float* parameters = geom->getParameters( rawid );
76  float nStrips = parameters[0];
77  float halfStripLength = parameters[1]*0.5;
78  float topPitch = parameters[3];
79  float bottomPitch = parameters[4];
80 
81  for( GEMDigiCollection::const_iterator dit = range.first;
82  dit != range.second; ++dit )
83  {
84  TEveStraightLineSet* stripDigiSet = new TEveStraightLineSet;
85  stripDigiSet->SetLineWidth(3);
86  setupAddElement( stripDigiSet, product );
87 
88  int strip = (*dit).strip();
89  float topOfStrip = (strip-0.5)*topPitch - 0.5*nStrips*topPitch;
90  float bottomOfStrip = (strip-0.5)*bottomPitch - 0.5*nStrips*bottomPitch;
91 
92  float localPointTop[3] =
93  {
94  topOfStrip, halfStripLength, 0.0
95  };
96 
97  float localPointBottom[3] =
98  {
99  bottomOfStrip, -halfStripLength, 0.0
100  };
101 
102  float globalPointTop[3];
103  float globalPointBottom[3];
104 
105  geom->localToGlobal( rawid, localPointTop, globalPointTop, localPointBottom, globalPointBottom );
106 
107  stripDigiSet->AddLine(globalPointTop[0], globalPointTop[1], globalPointTop[2],
108  globalPointBottom[0], globalPointBottom[1], globalPointBottom[2]);
109  }
110  }
111 }
112 
115 
116 
118 {
119 public:
122 
124 
125 private:
126  void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) override;
129 };
130 
131 void
132 FWGEMPadDigiProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*)
133 {
134  const GEMPadDigiCollection* digis = nullptr;
135 
136  iItem->get(digis);
137 
138  if ( ! digis )
139  {
140  fwLog(fwlog::kWarning)<<"Failed to get GEMPadDigis"<<std::endl;
141  return;
142  }
143  const FWGeometry *geom = iItem->getGeom();
144 
145  for ( GEMPadDigiCollection::DigiRangeIterator dri = digis->begin(), driEnd = digis->end();
146  dri != driEnd; ++dri )
147  {
148  unsigned int rawid = (*dri).first.rawId();
149  const GEMPadDigiCollection::Range& range = (*dri).second;
150 
151  if( ! geom->contains( rawid ))
152  {
153  fwLog( fwlog::kWarning ) << "Failed to get geometry of GEM roll with detid: "
154  << rawid << std::endl;
155 
156  TEveCompound* compound = createCompound();
157  setupAddElement( compound, product );
158 
159  continue;
160  }
161 
162  const float* parameters = geom->getParameters( rawid );
163  float nStrips = parameters[0];
164  float halfStripLength = parameters[1]*0.5;
165  float nPads = parameters[5];
166  float topPitch = parameters[3]*nStrips/nPads;
167  float bottomPitch = parameters[4]*nStrips/nPads;
168 
169  for( GEMPadDigiCollection::const_iterator dit = range.first;
170  dit != range.second; ++dit )
171  {
172  TEveStraightLineSet* stripDigiSet = new TEveStraightLineSet;
173  stripDigiSet->SetLineWidth(3*nStrips/nPads);
174  setupAddElement( stripDigiSet, product );
175 
176  int pad = (*dit).pad();
177  float topOfStrip = (pad-0.5)*topPitch - 0.5*topPitch*nPads;
178  float bottomOfStrip = (pad-0.5)*bottomPitch - 0.5*bottomPitch*nPads;
179 
180  float localPointTop[3] =
181  {
182  topOfStrip, halfStripLength, 0.0
183  };
184 
185  float localPointBottom[3] =
186  {
187  bottomOfStrip, -halfStripLength, 0.0
188  };
189 
190  float globalPointTop[3];
191  float globalPointBottom[3];
192 
193  geom->localToGlobal( rawid, localPointTop, globalPointTop, localPointBottom, globalPointBottom );
194 
195  stripDigiSet->AddLine(globalPointTop[0], globalPointTop[1], globalPointTop[2],
196  globalPointBottom[0], globalPointBottom[1], globalPointBottom[2]);
197  }
198  }
199 }
200 
203 
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:58
const float * getParameters(unsigned int id) const
Definition: FWGeometry.cc:302
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
void get(const T *&oData) const
Definition: FWEventItem.h:85
static const int kAll3DBits
Definition: FWViewType.h:59
const FWGEMDigiProxyBuilder & operator=(const FWGEMDigiProxyBuilder &)=delete
void localToGlobal(unsigned int id, const float *local, float *global, bool translatep=true) const
Definition: FWGeometry.cc:334
bool contains(unsigned int id) const
Definition: FWGeometry.h:110
#define fwLog(_level_)
Definition: fwLog.h:50
std::vector< GEMDigi >::const_iterator const_iterator
TEveCompound * createCompound(bool set_color=true, bool propagate_color_to_all_children=false) const
std::pair< const_iterator, const_iterator > Range
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:683