CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 
26 
28 {
29 public:
32 
34 
35 private:
37  virtual void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*);
40 };
41 
42 void
43 FWGEMDigiProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*)
44 {
45  const GEMDigiCollection* digis = 0;
46 
47  iItem->get(digis);
48 
49  if ( ! digis )
50  {
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();
57  dri != driEnd; ++dri )
58  {
59  unsigned int rawid = (*dri).first.rawId();
60  const GEMDigiCollection::Range& range = (*dri).second;
61 
62  if( ! geom->contains( rawid ))
63  {
64  fwLog( fwlog::kWarning ) << "Failed to get geometry of GEM roll with detid: "
65  << rawid << std::endl;
66 
67  TEveCompound* compound = createCompound();
68  setupAddElement( compound, product );
69 
70  continue;
71  }
72 
73  const float* parameters = geom->getParameters( rawid );
74  float nStrips = parameters[0];
75  float halfStripLength = parameters[1]*0.5;
76  float topPitch = parameters[3];
77  float bottomPitch = parameters[4];
78 
79  for( GEMDigiCollection::const_iterator dit = range.first;
80  dit != range.second; ++dit )
81  {
82  TEveStraightLineSet* stripDigiSet = new TEveStraightLineSet;
83  stripDigiSet->SetLineWidth(3);
84  setupAddElement( stripDigiSet, product );
85 
86  int strip = (*dit).strip();
87  float topOfStrip = (strip-0.5)*topPitch - 0.5*nStrips*topPitch;
88  float bottomOfStrip = (strip-0.5)*bottomPitch - 0.5*nStrips*bottomPitch;
89 
90  float localPointTop[3] =
91  {
92  topOfStrip, halfStripLength, 0.0
93  };
94 
95  float localPointBottom[3] =
96  {
97  bottomOfStrip, -halfStripLength, 0.0
98  };
99 
100  float globalPointTop[3];
101  float globalPointBottom[3];
102 
103  geom->localToGlobal( rawid, localPointTop, globalPointTop, localPointBottom, globalPointBottom );
104 
105  stripDigiSet->AddLine(globalPointTop[0], globalPointTop[1], globalPointTop[2],
106  globalPointBottom[0], globalPointBottom[1], globalPointBottom[2]);
107  }
108  }
109 }
110 
113 
114 
116 {
117 public:
120 
122 
123 private:
124  virtual void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*);
127 };
128 
129 void
130 FWGEMPadDigiProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*)
131 {
132  const GEMPadDigiCollection* digis = 0;
133 
134  iItem->get(digis);
135 
136  if ( ! digis )
137  {
138  fwLog(fwlog::kWarning)<<"Failed to get GEMPadDigis"<<std::endl;
139  return;
140  }
141  const FWGeometry *geom = iItem->getGeom();
142 
143  for ( GEMPadDigiCollection::DigiRangeIterator dri = digis->begin(), driEnd = digis->end();
144  dri != driEnd; ++dri )
145  {
146  unsigned int rawid = (*dri).first.rawId();
147  const GEMPadDigiCollection::Range& range = (*dri).second;
148 
149  if( ! geom->contains( rawid ))
150  {
151  fwLog( fwlog::kWarning ) << "Failed to get geometry of GEM roll with detid: "
152  << rawid << std::endl;
153 
154  TEveCompound* compound = createCompound();
155  setupAddElement( compound, product );
156 
157  continue;
158  }
159 
160  const float* parameters = geom->getParameters( rawid );
161  float nStrips = parameters[0];
162  float halfStripLength = parameters[1]*0.5;
163  float nPads = parameters[5];
164  float topPitch = parameters[3]*nStrips/nPads;
165  float bottomPitch = parameters[4]*nStrips/nPads;
166 
167  for( GEMPadDigiCollection::const_iterator dit = range.first;
168  dit != range.second; ++dit )
169  {
170  TEveStraightLineSet* stripDigiSet = new TEveStraightLineSet;
171  stripDigiSet->SetLineWidth(3*nStrips/nPads);
172  setupAddElement( stripDigiSet, product );
173 
174  int pad = (*dit).pad();
175  float topOfStrip = (pad-0.5)*topPitch - 0.5*topPitch*nPads;
176  float bottomOfStrip = (pad-0.5)*bottomPitch - 0.5*bottomPitch*nPads;
177 
178  float localPointTop[3] =
179  {
180  topOfStrip, halfStripLength, 0.0
181  };
182 
183  float localPointBottom[3] =
184  {
185  bottomOfStrip, -halfStripLength, 0.0
186  };
187 
188  float globalPointTop[3];
189  float globalPointBottom[3];
190 
191  geom->localToGlobal( rawid, localPointTop, globalPointTop, localPointBottom, globalPointBottom );
192 
193  stripDigiSet->AddLine(globalPointTop[0], globalPointTop[1], globalPointTop[2],
194  globalPointBottom[0], globalPointBottom[1], globalPointBottom[2]);
195  }
196  }
197 }
198 
201 
dictionary parameters
Definition: Parameters.py:2
#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:296
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
void get(const T *&oData) const
Definition: FWEventItem.h:84
const FWGEMPadDigiProxyBuilder & operator=(const FWGEMPadDigiProxyBuilder &)
static const int kAll3DBits
Definition: FWViewType.h:59
const FWGEMDigiProxyBuilder & operator=(const FWGEMDigiProxyBuilder &)
void localToGlobal(unsigned int id, const float *local, float *global, bool translatep=true) const
Definition: FWGeometry.cc:328
bool contains(unsigned int id) const
Definition: FWGeometry.h:109
#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:681