CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 {
27 public:
30 
32 
33 private:
34  virtual 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
45 FWCSCWireDigiProxyBuilder::getYOfFirstWire(const int station, const int ring, const double length)
46 {
47  double yAlignmentFrame = 3.49;
48  double alignmentPinToFirstWire;
49 
50  if ( station == 1 )
51  {
52  if ( ring == 1 || ring == 4 )
53  {
54  alignmentPinToFirstWire = 1.065;
55  yAlignmentFrame = 0.0;
56  }
57 
58  else // ME12, ME 13
59  alignmentPinToFirstWire = 2.85;
60  }
61 
62  else if ( station == 4 && ring == 1 )
63  alignmentPinToFirstWire = 3.04;
64 
65  else if ( station == 3 && ring == 1 )
66  alignmentPinToFirstWire = 2.84;
67 
68  else // ME21, ME22, ME32, ME42
69  alignmentPinToFirstWire = 2.87;
70 
71  return (yAlignmentFrame-length) + alignmentPinToFirstWire;
72 }
73 
74 double
76 {
77  // return radialExtentOfTheWirePlane / numOfWireGroups
78  // These numbers come from cscSpec.xml
79 
80  if ( ring == 2 )
81  {
82  if ( station == 1 )
83  return 174.81/64;
84  else
85  return 323.38/64;
86  }
87 
88  if ( station == 1 && (ring == 1 || ring == 4))
89  return 150.5/48;
90  if ( station == 1 && ring == 3 )
91  return 164.47/32;
92  if ( station == 2 && ring == 1 )
93  return 189.97/112;
94  if ( station == 3 && ring == 1 )
95  return 170.01/96;
96  if ( station == 4 && ring == 1 )
97  return 149.73/96;
98 
99  return 0.0;
100 }
101 
102 void
103 FWCSCWireDigiProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*)
104 {
105  const CSCWireDigiCollection* digis = 0;
106 
107  iItem->get(digis);
108 
109  if ( ! digis )
110  {
111  fwLog( fwlog::kWarning ) << "Failed to get CSCWireDigis" << std::endl;
112  return;
113  }
114  const FWGeometry *geom = iItem->getGeom();
115 
116  for ( CSCWireDigiCollection::DigiRangeIterator dri = digis->begin(), driEnd = digis->end();
117  dri != driEnd; ++dri )
118  {
119  const CSCDetId& cscDetId = (*dri).first;
120  unsigned int rawid = cscDetId.rawId();
121  const CSCWireDigiCollection::Range& range = (*dri).second;
122 
123  if( ! geom->contains( rawid ))
124  {
125  fwLog( fwlog::kWarning ) << "Failed to get geometry of CSC chamber with detid: "
126  << rawid << std::endl;
127 
128  TEveCompound* compound = createCompound();
129  setupAddElement( compound, product );
130 
131  continue;
132  }
133 
134  const float* shape = geom->getShapePars( rawid );
135 
136  float length = shape[4];
137  float topWidth = shape[2];
138  float bottomWidth = shape[1];
139 
140  // NOTE: do not use parameters right now: need to sort out what is finally needed
141  //const float* parameters = iItem->getGeom()->getParameters( rawid );
142  //float wireSpacing = parameters[6];
143  double wireSpacing = getAverageWireSpacing(cscDetId.station(), cscDetId.ring());
144  //float wireAngle = parameters[7];
145  //float cosWireAngle = cos(wireAngle);
146 
147  double yOfFirstWire = getYOfFirstWire( cscDetId.station(), cscDetId.ring(), length );
148 
149  for ( CSCWireDigiCollection::const_iterator dit = range.first;
150  dit != range.second; ++dit )
151  {
152  TEveStraightLineSet* wireDigiSet = new TEveStraightLineSet();
153  wireDigiSet->SetLineWidth(3);
154  setupAddElement(wireDigiSet, product);
155 
156  int wireGroup = (*dit).getWireGroup();
157  float yOfWire = yOfFirstWire + ((wireGroup-1)*wireSpacing);
158  float wireLength = yOfWire*(topWidth-bottomWidth) / length;
159  wireLength += bottomWidth*2.0;
160 
161  float localPointLeft[3] =
162  {
163  static_cast<float>(-wireLength*0.5), yOfWire, static_cast<float>(0.0)
164  };
165 
166  // NOTE: This is only an approximation for slanted wires.
167  // Need to improve the determination of the x coordinate.
168  float localPointRight[3] =
169  {
170  static_cast<float>(wireLength*0.5), yOfWire, static_cast<float>(0.0)
171  //wireLength*0.5, yOfWire + wireLength*tan(wireAngle), 0.0
172  };
173 
174  float globalPointLeft[3];
175  float globalPointRight[3];
176 
177  geom->localToGlobal( rawid, localPointLeft, globalPointLeft, localPointRight, globalPointRight );
178 
179  wireDigiSet->AddLine( globalPointLeft[0], globalPointLeft[1], globalPointLeft[2],
180  globalPointRight[0], globalPointRight[1], globalPointRight[2] );
181  }
182  }
183 }
184 
187 
188 
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:58
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
void get(const T *&oData) const
Definition: FWEventItem.h:84
double getAverageWireSpacing(const int station, const int ring)
static const int kAll3DBits
Definition: FWViewType.h:59
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
const float * getShapePars(unsigned int id) const
Definition: FWGeometry.cc:309
void localToGlobal(unsigned int id, const float *local, float *global, bool translatep=true) const
Definition: FWGeometry.cc:325
bool contains(unsigned int id) const
Definition: FWGeometry.h:98
int ring() const
Definition: CSCDetId.h:77
#define fwLog(_level_)
Definition: fwLog.h:50
std::vector< CSCWireDigi >::const_iterator const_iterator
TEveCompound * createCompound(bool set_color=true, bool propagate_color_to_all_children=false) const
const FWCSCWireDigiProxyBuilder & operator=(const FWCSCWireDigiProxyBuilder &)
int station() const
Definition: CSCDetId.h:88
std::pair< const_iterator, const_iterator > Range
double getYOfFirstWire(const int station, const int ring, const double length)
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:681