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 public:
32  ~FWGEMDigiProxyBuilder() override {}
33 
35 
36 private:
38  void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) override;
41 };
42 
43 void FWGEMDigiProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) {
44  const GEMDigiCollection* digis = nullptr;
45 
46  iItem->get(digis);
47 
48  if (!digis) {
49  fwLog(fwlog::kWarning) << "Failed to get GEMDigis" << std::endl;
50  return;
51  }
52  const FWGeometry* geom = iItem->getGeom();
53 
54  for (GEMDigiCollection::DigiRangeIterator dri = digis->begin(), driEnd = digis->end(); dri != driEnd; ++dri) {
55  unsigned int rawid = (*dri).first.rawId();
56  const GEMDigiCollection::Range& range = (*dri).second;
57 
58  if (!geom->contains(rawid)) {
59  fwLog(fwlog::kWarning) << "Failed to get geometry of GEM roll with detid: " << rawid << std::endl;
60 
61  TEveCompound* compound = createCompound();
62  setupAddElement(compound, product);
63 
64  continue;
65  }
66 
67  const float* parameters = geom->getParameters(rawid);
68  float nStrips = parameters[0];
69  float halfStripLength = parameters[1] * 0.5;
70  float topPitch = parameters[3];
71  float bottomPitch = parameters[4];
72 
73  for (GEMDigiCollection::const_iterator dit = range.first; dit != range.second; ++dit) {
74  TEveStraightLineSet* stripDigiSet = new TEveStraightLineSet;
75  stripDigiSet->SetLineWidth(3);
76  setupAddElement(stripDigiSet, product);
77 
78  int strip = (*dit).strip();
79  float topOfStrip = (strip - 0.5) * topPitch - 0.5 * nStrips * topPitch;
80  float bottomOfStrip = (strip - 0.5) * bottomPitch - 0.5 * nStrips * bottomPitch;
81 
82  float localPointTop[3] = {topOfStrip, halfStripLength, 0.0};
83 
84  float localPointBottom[3] = {bottomOfStrip, -halfStripLength, 0.0};
85 
86  float globalPointTop[3];
87  float globalPointBottom[3];
88 
89  geom->localToGlobal(rawid, localPointTop, globalPointTop, localPointBottom, globalPointBottom);
90 
91  stripDigiSet->AddLine(globalPointTop[0],
92  globalPointTop[1],
93  globalPointTop[2],
94  globalPointBottom[0],
95  globalPointBottom[1],
96  globalPointBottom[2]);
97  }
98  }
99 }
100 
103  "GEMDigi",
105 
107 public:
110 
112 
113 private:
114  void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) override;
117 };
118 
119 void FWGEMPadDigiProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) {
120  const GEMPadDigiCollection* digis = nullptr;
121 
122  iItem->get(digis);
123 
124  if (!digis) {
125  fwLog(fwlog::kWarning) << "Failed to get GEMPadDigis" << std::endl;
126  return;
127  }
128  const FWGeometry* geom = iItem->getGeom();
129 
130  for (GEMPadDigiCollection::DigiRangeIterator dri = digis->begin(), driEnd = digis->end(); dri != driEnd; ++dri) {
131  unsigned int rawid = (*dri).first.rawId();
132  const GEMPadDigiCollection::Range& range = (*dri).second;
133 
134  if (!geom->contains(rawid)) {
135  fwLog(fwlog::kWarning) << "Failed to get geometry of GEM roll with detid: " << rawid << std::endl;
136 
137  TEveCompound* compound = createCompound();
138  setupAddElement(compound, product);
139 
140  continue;
141  }
142 
143  const float* parameters = geom->getParameters(rawid);
144  float nStrips = parameters[0];
145  float halfStripLength = parameters[1] * 0.5;
146  float nPads = parameters[5];
147  float topPitch = parameters[3] * nStrips / nPads;
148  float bottomPitch = parameters[4] * nStrips / nPads;
149 
150  for (GEMPadDigiCollection::const_iterator dit = range.first; dit != range.second; ++dit) {
151  TEveStraightLineSet* stripDigiSet = new TEveStraightLineSet;
152  stripDigiSet->SetLineWidth(3 * nStrips / nPads);
153  setupAddElement(stripDigiSet, product);
154 
155  int pad = (*dit).pad();
156  float topOfStrip = (pad - 0.5) * topPitch - 0.5 * topPitch * nPads;
157  float bottomOfStrip = (pad - 0.5) * bottomPitch - 0.5 * bottomPitch * nPads;
158 
159  float localPointTop[3] = {topOfStrip, halfStripLength, 0.0};
160 
161  float localPointBottom[3] = {bottomOfStrip, -halfStripLength, 0.0};
162 
163  float globalPointTop[3];
164  float globalPointBottom[3];
165 
166  geom->localToGlobal(rawid, localPointTop, globalPointTop, localPointBottom, globalPointBottom);
167 
168  stripDigiSet->AddLine(globalPointTop[0],
169  globalPointTop[1],
170  globalPointTop[2],
171  globalPointBottom[0],
172  globalPointBottom[1],
173  globalPointBottom[2]);
174  }
175  }
176 }
177 
180  "GEMPadDigi",
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
BeamSpotPI::parameters
parameters
Definition: BeamSpotPayloadInspectorHelper.h:30
fwLog
#define fwLog(_level_)
Definition: fwLog.h:45
FWGeometry
Definition: FWGeometry.h:27
FWViewType::kAllRPZBits
static const int kAllRPZBits
Definition: FWViewType.h:67
REGISTER_FWPROXYBUILDER
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
Definition: FWProxyBuilderFactory.h:33
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
FWEventItem::get
void get(const T *&oData) const
Definition: FWEventItem.h:78
FWProxyBuilderBase.h
REGISTER_PROXYBUILDER_METHODS
#define REGISTER_PROXYBUILDER_METHODS()
Definition: register_dataproxybuilder_macro.h:28
FWGEMDigiProxyBuilder::~FWGEMDigiProxyBuilder
~FWGEMDigiProxyBuilder() override
Definition: FWGEMDigiProxyBuilder.cc:32
FWProxyBuilderBase::createCompound
TEveCompound * createCompound(bool set_color=true, bool propagate_color_to_all_children=false) const
Definition: FWProxyBuilderBase.cc:374
MuonDigiCollection::const_iterator
std::vector< DigiType >::const_iterator const_iterator
Definition: MuonDigiCollection.h:94
FWViewType::kAll3DBits
static const int kAll3DBits
Definition: FWViewType.h:68
FWGEMPadDigiProxyBuilder::operator=
const FWGEMPadDigiProxyBuilder & operator=(const FWGEMPadDigiProxyBuilder &)=delete
FWGEMPadDigiProxyBuilder
Definition: FWGEMDigiProxyBuilder.cc:106
GEMEtaPartition.h
FWGEMDigiProxyBuilder
Definition: FWGEMDigiProxyBuilder.cc:29
GEMPadDigiCollection
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
FWGEMDigiProxyBuilder::FWGEMDigiProxyBuilder
FWGEMDigiProxyBuilder()
Definition: FWGEMDigiProxyBuilder.cc:31
FWGeometry.h
FWProxyBuilderBase::setupAddElement
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
Definition: FWProxyBuilderBase.cc:350
fwlog::kWarning
Definition: fwLog.h:35
fwLog.h
FWProxyBuilderBase::build
void build()
Definition: FWProxyBuilderBase.cc:110
FWEventItem.h
FWViewContext
Definition: FWViewContext.h:32
me0TriggerPseudoDigis_cff.nStrips
nStrips
1.2 is to make the matching window safely the two nearest strips 0.35 is the size of an ME0 chamber i...
Definition: me0TriggerPseudoDigis_cff.py:26
FWGEMPadDigiProxyBuilder::~FWGEMPadDigiProxyBuilder
~FWGEMPadDigiProxyBuilder() override
Definition: FWGEMDigiProxyBuilder.cc:109
FWEventItem::getGeom
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:548
FWEventItem
Definition: FWEventItem.h:56
GEMGeometry.h
FWGEMDigiProxyBuilder::operator=
const FWGEMDigiProxyBuilder & operator=(const FWGEMDigiProxyBuilder &)=delete
FWProxyBuilderBase
Definition: FWProxyBuilderBase.h:46
FWGEMPadDigiProxyBuilder::FWGEMPadDigiProxyBuilder
FWGEMPadDigiProxyBuilder()
Definition: FWGEMDigiProxyBuilder.cc:108
GEMDigiCollection
GEMPadDigiCollection.h
MuonDigiCollection::Range
std::pair< const_iterator, const_iterator > Range
Definition: MuonDigiCollection.h:95
GEMDigiCollection.h
DigiContainerIterator
Definition: MuonDigiCollection.h:30