test
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:
35  virtual void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) override;
38 
39  // NOTE: these parameters are not available via a public interface
40  // from the geometry or topology so must be hard-coded.
41  double getYOfFirstWire(const int station, const int ring, const double length);
42  double getAverageWireSpacing(const int station, const int ring);
43 };
44 
45 double
46 FWCSCWireDigiProxyBuilder::getYOfFirstWire(const int station, const int ring, const double length)
47 {
48  double yAlignmentFrame = 3.49;
49  double alignmentPinToFirstWire;
50 
51  if ( station == 1 )
52  {
53  if ( ring == 1 || ring == 4 )
54  {
55  alignmentPinToFirstWire = 1.065;
56  yAlignmentFrame = 0.0;
57  }
58 
59  else // ME12, ME 13
60  alignmentPinToFirstWire = 2.85;
61  }
62 
63  else if ( station == 4 && ring == 1 )
64  alignmentPinToFirstWire = 3.04;
65 
66  else if ( station == 3 && ring == 1 )
67  alignmentPinToFirstWire = 2.84;
68 
69  else // ME21, ME22, ME32, ME42
70  alignmentPinToFirstWire = 2.87;
71 
72  return (yAlignmentFrame-length) + alignmentPinToFirstWire;
73 }
74 
75 double
77 {
78  // return radialExtentOfTheWirePlane / numOfWireGroups
79  // These numbers come from cscSpec.xml
80 
81  if ( ring == 2 )
82  {
83  if ( station == 1 )
84  return 174.81/64;
85  else
86  return 323.38/64;
87  }
88 
89  if ( station == 1 && (ring == 1 || ring == 4))
90  return 150.5/48;
91  if ( station == 1 && ring == 3 )
92  return 164.47/32;
93  if ( station == 2 && ring == 1 )
94  return 189.97/112;
95  if ( station == 3 && ring == 1 )
96  return 170.01/96;
97  if ( station == 4 && ring == 1 )
98  return 149.73/96;
99 
100  return 0.0;
101 }
102 
103 void
104 FWCSCWireDigiProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*)
105 {
106  const CSCWireDigiCollection* digis = 0;
107 
108  iItem->get(digis);
109 
110  if ( ! digis )
111  {
112  fwLog( fwlog::kWarning ) << "Failed to get CSCWireDigis" << std::endl;
113  return;
114  }
115  const FWGeometry *geom = iItem->getGeom();
116 
117  for ( CSCWireDigiCollection::DigiRangeIterator dri = digis->begin(), driEnd = digis->end();
118  dri != driEnd; ++dri )
119  {
120  const CSCDetId& cscDetId = (*dri).first;
121  unsigned int rawid = cscDetId.rawId();
122  const CSCWireDigiCollection::Range& range = (*dri).second;
123 
124  if( ! geom->contains( rawid ))
125  {
126  fwLog( fwlog::kWarning ) << "Failed to get geometry of CSC chamber with detid: "
127  << rawid << std::endl;
128 
129  TEveCompound* compound = createCompound();
130  setupAddElement( compound, product );
131 
132  continue;
133  }
134 
135  const float* shape = geom->getShapePars( rawid );
136 
137  float length = shape[4];
138  float topWidth = shape[2];
139  float bottomWidth = shape[1];
140 
141  // NOTE: do not use parameters right now: need to sort out what is finally needed
142  //const float* parameters = iItem->getGeom()->getParameters( rawid );
143  //float wireSpacing = parameters[6];
144  double wireSpacing = getAverageWireSpacing(cscDetId.station(), cscDetId.ring());
145  //float wireAngle = parameters[7];
146  //float cosWireAngle = cos(wireAngle);
147 
148  double yOfFirstWire = getYOfFirstWire( cscDetId.station(), cscDetId.ring(), length );
149 
150  for ( CSCWireDigiCollection::const_iterator dit = range.first;
151  dit != range.second; ++dit )
152  {
153  TEveStraightLineSet* wireDigiSet = new TEveStraightLineSet();
154  wireDigiSet->SetLineWidth(3);
155  setupAddElement(wireDigiSet, product);
156 
157  int wireGroup = (*dit).getWireGroup();
158  float yOfWire = yOfFirstWire + ((wireGroup-1)*wireSpacing);
159  float wireLength = yOfWire*(topWidth-bottomWidth) / length;
160  wireLength += bottomWidth*2.0;
161 
162  float localPointLeft[3] =
163  {
164  static_cast<float>(-wireLength*0.5), yOfWire, static_cast<float>(0.0)
165  };
166 
167  // NOTE: This is only an approximation for slanted wires.
168  // Need to improve the determination of the x coordinate.
169  float localPointRight[3] =
170  {
171  static_cast<float>(wireLength*0.5), yOfWire, static_cast<float>(0.0)
172  //wireLength*0.5, yOfWire + wireLength*tan(wireAngle), 0.0
173  };
174 
175  float globalPointLeft[3];
176  float globalPointRight[3];
177 
178  geom->localToGlobal( rawid, localPointLeft, globalPointLeft, localPointRight, globalPointRight );
179 
180  wireDigiSet->AddLine( globalPointLeft[0], globalPointLeft[1], globalPointLeft[2],
181  globalPointRight[0], globalPointRight[1], globalPointRight[2] );
182  }
183  }
184 }
185 
188 
189 
#define REGISTER_PROXYBUILDER_METHODS()
#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:85
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:312
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
int ring() const
Definition: CSCDetId.h:75
#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:86
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:683