CMS 3D CMS Logo

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