CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWCSCStripDigiProxyBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Muon
4 // Class : FWCSCStripDigiProxyBuilder
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 
24 {
25 public:
28 
30 
31 private:
32  virtual void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) override;
35 };
36 
37 void
38 FWCSCStripDigiProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*)
39 {
40  const CSCStripDigiCollection* digis = 0;
41 
42  iItem->get(digis);
43 
44  if( ! digis )
45  {
46  fwLog( fwlog::kWarning ) << "failed to get CSCStripDigis"<<std::endl;
47  return;
48  }
49  const FWGeometry *geom = iItem->getGeom();
50 
51  int thresholdOffset = 9;
52 
53  for ( CSCStripDigiCollection::DigiRangeIterator dri = digis->begin(), driEnd = digis->end();
54  dri != driEnd; ++dri )
55  {
56  unsigned int rawid = (*dri).first.rawId();
57  const CSCStripDigiCollection::Range& range = (*dri).second;
58 
59  if( ! geom->contains( rawid ))
60  {
61  fwLog( fwlog::kWarning ) << "failed to get geometry of CSC with detid: "
62  << rawid << std::endl;
63 
64  TEveCompound* compound = createCompound();
65  setupAddElement( compound, product );
66 
67  continue;
68  }
69 
70  const float* shape = geom->getShapePars( rawid );
71  float length = shape[4];
72 
73  const float* parameters = geom->getParameters( rawid );
74 
75  float yAxisOrientation = parameters[0];
76  float centreToIntersection = parameters[1];
77  float yCentre = parameters[2];
78  float phiOfOneEdge = parameters[3];
79  float stripOffset = parameters[4];
80  float angularWidth = parameters[5];
81 
82  for( CSCStripDigiCollection::const_iterator dit = range.first;
83  dit != range.second; ++dit )
84  {
85  std::vector<int> adcCounts = (*dit).getADCCounts();
86 
87  int signalThreshold = (adcCounts[0] + adcCounts[1])/2 + thresholdOffset;
88 
89  TEveStraightLineSet* stripDigiSet = new TEveStraightLineSet();
90  setupAddElement(stripDigiSet, product);
91 
92  if( std::find_if( adcCounts.begin(), adcCounts.end(), bind2nd( std::greater<int>(), signalThreshold )) != adcCounts.end())
93  {
94  stripDigiSet->SetLineWidth(3);
95  int stripId = (*dit).getStrip();
96 
97  float yOrigin = centreToIntersection-yCentre;
98  float stripAngle = phiOfOneEdge + yAxisOrientation*(stripId-(0.5-stripOffset))*angularWidth;
99  float tanStripAngle = tan(stripAngle);
100  //float xOfStrip = yAxisOrientation*yOrigin*tanStripAngle; this is x of strip at origin
101 
102  float localPointTop[3] =
103  {
104  yAxisOrientation*(yOrigin+length)*tanStripAngle, length, 0.0
105  };
106 
107  float localPointBottom[3] =
108  {
109  yAxisOrientation*(yOrigin-length)*tanStripAngle, -length, 0.0
110  };
111 
112  float globalPointTop[3];
113  float globalPointBottom[3];
114 
115  geom->localToGlobal( rawid, localPointTop, globalPointTop, localPointBottom, globalPointBottom);
116 
117  stripDigiSet->AddLine( globalPointBottom[0], globalPointBottom[1], globalPointBottom[2],
118  globalPointTop[0], globalPointTop[1], globalPointTop[2] );
119  }
120  }
121  }
122 }
123 
126 
dictionary parameters
Definition: Parameters.py:2
#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:293
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
void get(const T *&oData) const
Definition: FWEventItem.h:84
static const int kAll3DBits
Definition: FWViewType.h:59
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
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
bool contains(unsigned int id) const
Definition: FWGeometry.h:98
#define fwLog(_level_)
Definition: fwLog.h:50
std::vector< CSCStripDigi >::const_iterator const_iterator
const FWCSCStripDigiProxyBuilder & operator=(const FWCSCStripDigiProxyBuilder &)
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