CMS 3D CMS Logo

FWCSCWireDigiProxyBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Muon
4 // Class : FWCSCWireDigiProxyBuilder
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: mccauley
10 // Created: Sun Jan 6 23:57:00 EST 2008
11 //
12 
13 #include "TEveStraightLineSet.h"
14 #include "TEveCompound.h"
15 
20 
22 
23 #include <cmath>
24 
26 public:
29 
31 
32 private:
34  void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) override;
37 
38  // NOTE: these parameters are not available via a public interface
39  // from the geometry or topology so must be hard-coded.
40  double getYOfFirstWire(const int station, const int ring, const double length);
41  double getAverageWireSpacing(const int station, const int ring);
42 };
43 
44 double FWCSCWireDigiProxyBuilder::getYOfFirstWire(const int station, const int ring, const double length) {
45  double yAlignmentFrame = 3.49;
46  double alignmentPinToFirstWire;
47 
48  if (station == 1) {
49  if (ring == 1 || ring == 4) {
50  alignmentPinToFirstWire = 1.065;
51  yAlignmentFrame = 0.0;
52  }
53 
54  else // ME12, ME 13
55  alignmentPinToFirstWire = 2.85;
56  }
57 
58  else if (station == 4 && ring == 1)
59  alignmentPinToFirstWire = 3.04;
60 
61  else if (station == 3 && ring == 1)
62  alignmentPinToFirstWire = 2.84;
63 
64  else // ME21, ME22, ME32, ME42
65  alignmentPinToFirstWire = 2.87;
66 
67  return (yAlignmentFrame - length) + alignmentPinToFirstWire;
68 }
69 
71  // return radialExtentOfTheWirePlane / numOfWireGroups
72  // These numbers come from cscSpec.xml
73 
74  if (ring == 2) {
75  if (station == 1)
76  return 174.81 / 64;
77  else
78  return 323.38 / 64;
79  }
80 
81  if (station == 1 && (ring == 1 || ring == 4))
82  return 150.5 / 48;
83  if (station == 1 && ring == 3)
84  return 164.47 / 32;
85  if (station == 2 && ring == 1)
86  return 189.97 / 112;
87  if (station == 3 && ring == 1)
88  return 170.01 / 96;
89  if (station == 4 && ring == 1)
90  return 149.73 / 96;
91 
92  return 0.0;
93 }
94 
95 void FWCSCWireDigiProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) {
96  const CSCWireDigiCollection* digis = nullptr;
97 
98  iItem->get(digis);
99 
100  if (!digis) {
101  fwLog(fwlog::kWarning) << "Failed to get CSCWireDigis" << std::endl;
102  return;
103  }
104  const FWGeometry* geom = iItem->getGeom();
105 
106  for (CSCWireDigiCollection::DigiRangeIterator dri = digis->begin(), driEnd = digis->end(); dri != driEnd; ++dri) {
107  const CSCDetId& cscDetId = (*dri).first;
108  unsigned int rawid = cscDetId.rawId();
109  const CSCWireDigiCollection::Range& range = (*dri).second;
110 
111  if (!geom->contains(rawid)) {
112  fwLog(fwlog::kWarning) << "Failed to get geometry of CSC chamber with detid: " << rawid << std::endl;
113 
114  TEveCompound* compound = createCompound();
115  setupAddElement(compound, product);
116 
117  continue;
118  }
119 
120  const float* shape = geom->getShapePars(rawid);
121 
122  float length = shape[4];
123  float topWidth = shape[2];
124  float bottomWidth = shape[1];
125 
126  // NOTE: do not use parameters right now: need to sort out what is finally needed
127  //const float* parameters = iItem->getGeom()->getParameters( rawid );
128  //float wireSpacing = parameters[6];
129  double wireSpacing = getAverageWireSpacing(cscDetId.station(), cscDetId.ring());
130  //float wireAngle = parameters[7];
131  //float cosWireAngle = cos(wireAngle);
132 
133  double yOfFirstWire = getYOfFirstWire(cscDetId.station(), cscDetId.ring(), length);
134 
135  for (CSCWireDigiCollection::const_iterator dit = range.first; dit != range.second; ++dit) {
136  TEveStraightLineSet* wireDigiSet = new TEveStraightLineSet();
137  wireDigiSet->SetLineWidth(3);
138  setupAddElement(wireDigiSet, product);
139 
140  int wireGroup = (*dit).getWireGroup();
141  float yOfWire = yOfFirstWire + ((wireGroup - 1) * wireSpacing);
142  float wireLength = yOfWire * (topWidth - bottomWidth) / length;
143  wireLength += bottomWidth * 2.0;
144 
145  float localPointLeft[3] = {static_cast<float>(-wireLength * 0.5), yOfWire, static_cast<float>(0.0)};
146 
147  // NOTE: This is only an approximation for slanted wires.
148  // Need to improve the determination of the x coordinate.
149  float localPointRight[3] = {
150  static_cast<float>(wireLength * 0.5), yOfWire, static_cast<float>(0.0)
151  //wireLength*0.5, yOfWire + wireLength*tan(wireAngle), 0.0
152  };
153 
154  float globalPointLeft[3];
155  float globalPointRight[3];
156 
157  geom->localToGlobal(rawid, localPointLeft, globalPointLeft, localPointRight, globalPointRight);
158 
159  wireDigiSet->AddLine(globalPointLeft[0],
160  globalPointLeft[1],
161  globalPointLeft[2],
162  globalPointRight[0],
163  globalPointRight[1],
164  globalPointRight[2]);
165  }
166  }
167 }
168 
171  "CSCWireDigi",
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
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
relativeConstraints.station
station
Definition: relativeConstraints.py:67
CSCDetId::ring
int ring() const
Definition: CSCDetId.h:68
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:27
FWCSCWireDigiProxyBuilder::operator=
const FWCSCWireDigiProxyBuilder & operator=(const FWCSCWireDigiProxyBuilder &)=delete
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
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
FWCSCWireDigiProxyBuilder::getAverageWireSpacing
double getAverageWireSpacing(const int station, const int ring)
Definition: FWCSCWireDigiProxyBuilder.cc:70
FWCSCWireDigiProxyBuilder::~FWCSCWireDigiProxyBuilder
~FWCSCWireDigiProxyBuilder() override
Definition: FWCSCWireDigiProxyBuilder.cc:28
FWGeometry.h
FWCSCWireDigiProxyBuilder::getYOfFirstWire
double getYOfFirstWire(const int station, const int ring, const double length)
Definition: FWCSCWireDigiProxyBuilder.cc:44
FWCSCWireDigiProxyBuilder
Definition: FWCSCWireDigiProxyBuilder.cc:25
CSCDetId
Definition: CSCDetId.h:26
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
FWCSCWireDigiProxyBuilder::FWCSCWireDigiProxyBuilder
FWCSCWireDigiProxyBuilder()
Definition: FWCSCWireDigiProxyBuilder.cc:27
FWEventItem::getGeom
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:548
FWEventItem
Definition: FWEventItem.h:56
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
CSCWireDigiCollection
FWProxyBuilderBase
Definition: FWProxyBuilderBase.h:46
relativeConstraints.ring
ring
Definition: relativeConstraints.py:68
MuonDigiCollection::Range
std::pair< const_iterator, const_iterator > Range
Definition: MuonDigiCollection.h:95
CSCWireDigiCollection.h
CSCDetId::station
int station() const
Definition: CSCDetId.h:79
DigiContainerIterator
Definition: MuonDigiCollection.h:30