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 // $Id: FWCSCStripDigiProxyBuilder.cc,v 1.14 2010/09/07 15:46:48 yana Exp $
12 //
13 
14 #include "TEveStraightLineSet.h"
15 #include "TEveCompound.h"
16 
21 
23 
25 {
26 public:
29 
31 
32 private:
33  virtual void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*);
36 };
37 
38 void
39 FWCSCStripDigiProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*)
40 {
41  const CSCStripDigiCollection* digis = 0;
42 
43  iItem->get(digis);
44 
45  if( ! digis )
46  {
47  fwLog( fwlog::kWarning ) << "failed to get CSCStripDigis"<<std::endl;
48  return;
49  }
50  const FWGeometry *geom = iItem->getGeom();
51 
52  int thresholdOffset = 9;
53 
54  for ( CSCStripDigiCollection::DigiRangeIterator dri = digis->begin(), driEnd = digis->end();
55  dri != driEnd; ++dri )
56  {
57  unsigned int rawid = (*dri).first.rawId();
58  const CSCStripDigiCollection::Range& range = (*dri).second;
59 
60  if( ! geom->contains( rawid ))
61  {
62  fwLog( fwlog::kWarning ) << "failed to get geometry of CSC with detid: "
63  << rawid << std::endl;
64 
65  TEveCompound* compound = createCompound();
66  setupAddElement( compound, product );
67 
68  continue;
69  }
70 
71  const float* shape = geom->getShapePars( rawid );
72  float length = shape[4];
73 
74  const float* parameters = geom->getParameters( rawid );
75 
76  float yAxisOrientation = parameters[0];
77  float centreToIntersection = parameters[1];
78  float yCentre = parameters[2];
79  float phiOfOneEdge = parameters[3];
80  float stripOffset = parameters[4];
81  float angularWidth = parameters[5];
82 
83  for( CSCStripDigiCollection::const_iterator dit = range.first;
84  dit != range.second; ++dit )
85  {
86  std::vector<int> adcCounts = (*dit).getADCCounts();
87 
88  int signalThreshold = (adcCounts[0] + adcCounts[1])/2 + thresholdOffset;
89 
90  TEveStraightLineSet* stripDigiSet = new TEveStraightLineSet();
91  setupAddElement(stripDigiSet, product);
92 
93  if( std::find_if( adcCounts.begin(), adcCounts.end(), bind2nd( std::greater<int>(), signalThreshold )) != adcCounts.end())
94  {
95  stripDigiSet->SetLineWidth(3);
96  int stripId = (*dit).getStrip();
97 
98  float yOrigin = centreToIntersection-yCentre;
99  float stripAngle = phiOfOneEdge + yAxisOrientation*(stripId-(0.5-stripOffset))*angularWidth;
100  float tanStripAngle = tan(stripAngle);
101  //float xOfStrip = yAxisOrientation*yOrigin*tanStripAngle; this is x of strip at origin
102 
103  float localPointTop[3] =
104  {
105  yAxisOrientation*(yOrigin+length)*tanStripAngle, length, 0.0
106  };
107 
108  float localPointBottom[3] =
109  {
110  yAxisOrientation*(yOrigin-length)*tanStripAngle, -length, 0.0
111  };
112 
113  float globalPointTop[3];
114  float globalPointBottom[3];
115 
116  geom->localToGlobal( rawid, localPointTop, globalPointTop, localPointBottom, globalPointBottom);
117 
118  stripDigiSet->AddLine( globalPointBottom[0], globalPointBottom[1], globalPointBottom[2],
119  globalPointTop[0], globalPointTop[1], globalPointTop[2] );
120  }
121  }
122  }
123 }
124 
127 
dictionary parameters
Definition: Parameters.py:2
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:59
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:85
void localToGlobal(unsigned int id, const float *local, float *global) const
Definition: FWGeometry.cc:325
static const int kAll3DBits
Definition: FWViewType.h:60
const float * getShapePars(unsigned int id) const
Definition: FWGeometry.cc:309
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:51
std::vector< DigiType >::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:682