CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 public:
27 
29 
30 private:
32  void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) override;
33 
34 public:
37 };
38 
39 void FWCSCStripDigiProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) {
40  const CSCStripDigiCollection* digis = nullptr;
41 
42  iItem->get(digis);
43 
44  if (!digis) {
45  fwLog(fwlog::kWarning) << "failed to get CSCStripDigis" << std::endl;
46  return;
47  }
48  const FWGeometry* geom = iItem->getGeom();
49 
50  int thresholdOffset = 9;
51 
52  for (CSCStripDigiCollection::DigiRangeIterator dri = digis->begin(), driEnd = digis->end(); dri != driEnd; ++dri) {
53  unsigned int rawid = (*dri).first.rawId();
54  const CSCStripDigiCollection::Range& range = (*dri).second;
55 
56  if (!geom->contains(rawid)) {
57  fwLog(fwlog::kWarning) << "failed to get geometry of CSC with detid: " << rawid << std::endl;
58 
59  TEveCompound* compound = createCompound();
60  setupAddElement(compound, product);
61 
62  continue;
63  }
64 
65  const float* shape = geom->getShapePars(rawid);
66  float length = shape[4];
67 
68  const float* parameters = geom->getParameters(rawid);
69 
70  float yAxisOrientation = parameters[0];
71  float centreToIntersection = parameters[1];
72  float yCentre = parameters[2];
73  float phiOfOneEdge = parameters[3];
74  float stripOffset = parameters[4];
75  float angularWidth = parameters[5];
76 
77  for (CSCStripDigiCollection::const_iterator dit = range.first; dit != range.second; ++dit) {
78  std::vector<int> adcCounts = (*dit).getADCCounts();
79 
80  int signalThreshold = (adcCounts[0] + adcCounts[1]) / 2 + thresholdOffset;
81 
82  TEveStraightLineSet* stripDigiSet = new TEveStraightLineSet();
83  setupAddElement(stripDigiSet, product);
84 
85  if (std::find_if(adcCounts.begin(), adcCounts.end(), [&](auto c) { return c > signalThreshold; }) !=
86  adcCounts.end()) {
87  stripDigiSet->SetLineWidth(3);
88  int stripId = (*dit).getStrip();
89 
90  float yOrigin = centreToIntersection - yCentre;
91  float stripAngle = phiOfOneEdge + yAxisOrientation * (stripId - (0.5 - stripOffset)) * angularWidth;
92  float tanStripAngle = tan(stripAngle);
93  //float xOfStrip = yAxisOrientation*yOrigin*tanStripAngle; this is x of strip at origin
94 
95  float localPointTop[3] = {yAxisOrientation * (yOrigin + length) * tanStripAngle, length, 0.0};
96 
97  float localPointBottom[3] = {yAxisOrientation * (yOrigin - length) * tanStripAngle, -length, 0.0};
98 
99  float globalPointTop[3];
100  float globalPointBottom[3];
101 
102  geom->localToGlobal(rawid, localPointTop, globalPointTop, localPointBottom, globalPointBottom);
103 
104  stripDigiSet->AddLine(globalPointBottom[0],
105  globalPointBottom[1],
106  globalPointBottom[2],
107  globalPointTop[0],
108  globalPointTop[1],
109  globalPointTop[2]);
110  }
111  }
112  }
113 }
114 
117  "CSCStripDigi",
#define REGISTER_PROXYBUILDER_METHODS()
const edm::EventSetup & c
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:67
const float * getParameters(unsigned int id) const
Definition: FWGeometry.cc:472
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
void get(const T *&oData) const
Definition: FWEventItem.h:78
static const int kAll3DBits
Definition: FWViewType.h:68
const uint16_t range(const Frame &aFrame)
const float * getShapePars(unsigned int id) const
Definition: FWGeometry.cc:483
void localToGlobal(unsigned int id, const float *local, float *global, bool translatep=true) const
Definition: FWGeometry.cc:494
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
bool contains(unsigned int id) const
Definition: FWGeometry.h:139
const FWCSCStripDigiProxyBuilder & operator=(const FWCSCStripDigiProxyBuilder &)=delete
#define fwLog(_level_)
Definition: fwLog.h:45
std::pair< const_iterator, const_iterator > Range
std::vector< DigiType >::const_iterator const_iterator
TEveCompound * createCompound(bool set_color=true, bool propagate_color_to_all_children=false) const
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:548