CMS 3D CMS Logo

FWDTDigiProxyBuilder.cc
Go to the documentation of this file.
1 /*
2  * FWDTDigiProxyBuilder.cc
3  * FWorks
4  *
5  * Created by Ianna Osborne on 6/7/10.
6  *
7  */
8 
9 #include "TEveGeoNode.h"
10 #include "TEvePointSet.h"
11 #include "TEveCompound.h"
12 #include "TGeoArb8.h"
13 #include "TEveBox.h"
14 
19 
21 
22 namespace {
23  void addTube(TEveBox* shape, const FWGeometry::GeomDetInfo& info, float localPos[3], const float* pars) {
24  const Float_t width = pars[0] / 2.;
25  const Float_t thickness = pars[1] / 2.;
26  const Float_t length = pars[2] / 2.;
27 
28  const Float_t vtx[24] = {localPos[0] - width, -length, -thickness, localPos[0] - width, length, -thickness,
29  localPos[0] + width, length, -thickness, localPos[0] + width, -length, -thickness,
30  localPos[0] - width, -length, thickness, localPos[0] - width, length, thickness,
31  localPos[0] + width, length, thickness, localPos[0] + width, -length, thickness};
32 
33  double array[16] = {info.matrix[0],
34  info.matrix[3],
35  info.matrix[6],
36  0.,
37  info.matrix[1],
38  info.matrix[4],
39  info.matrix[7],
40  0.,
41  info.matrix[2],
42  info.matrix[5],
43  info.matrix[8],
44  0.,
45  info.translation[0],
46  info.translation[1],
47  info.translation[2],
48  1.};
49 
50  shape->SetVertices(vtx);
51  shape->SetTransMatrix(array);
52  shape->SetDrawFrame(false);
53  shape->SetMainTransparency(75);
54  }
55 } // namespace
56 
58 public:
60  ~FWDTDigiProxyBuilder(void) override {}
61 
62  bool haveSingleProduct(void) const override { return false; }
63 
65 
66 private:
67  // Disable default copy constructor
69  // Disable default assignment operator
70  const FWDTDigiProxyBuilder& operator=(const FWDTDigiProxyBuilder&) = delete;
71 
73  void buildViewType(const FWEventItem* iItem,
74  TEveElementList* product,
76  const FWViewContext*) override;
77 };
78 
80  TEveElementList* product,
82  const FWViewContext*) {
83  const DTDigiCollection* digis = nullptr;
84  iItem->get(digis);
85 
86  if (!digis) {
87  return;
88  }
89  const FWGeometry* geom = iItem->getGeom();
90 
91  for (DTDigiCollection::DigiRangeIterator dri = digis->begin(), dre = digis->end(); dri != dre; ++dri) {
92  const DTLayerId& layerId = (*dri).first;
93  unsigned int rawid = layerId.rawId();
94  const DTDigiCollection::Range& range = (*dri).second;
95 
96  if (!geom->contains(rawid)) {
97  fwLog(fwlog::kWarning) << "failed to get geometry of DT with detid: " << rawid << std::endl;
98 
99  TEveCompound* compound = createCompound();
100  setupAddElement(compound, product);
101 
102  continue;
103  }
104 
105  const float* pars = geom->getParameters(rawid);
106  FWGeometry::IdToInfoItr det = geom->find(rawid);
107 
108  int superLayer = layerId.superlayerId().superLayer();
109 
110  float localPos[3] = {0.0, 0.0, 0.0};
111 
112  // Loop over the digis of this DetUnit
113  for (DTDigiCollection::const_iterator it = range.first; it != range.second; ++it) {
114  // The x wire position in the layer, starting from its wire number.
115  float firstChannel = pars[3];
116  float nChannels = pars[5];
117  localPos[0] = ((*it).wire() - (firstChannel - 1) - 0.5) * pars[0] - nChannels / 2.0 * pars[0];
118 
120  TEveBox* box = new TEveBox;
121  setupAddElement(box, product);
122  ::addTube(box, *det, localPos, pars);
123  } else if (((type == FWViewType::kRhoPhi || type == FWViewType::kRhoPhiPF) && superLayer != 2) ||
124  (type == FWViewType::kRhoZ && superLayer == 2)) {
125  TEvePointSet* pointSet = new TEvePointSet;
126  pointSet->SetMarkerStyle(24);
127  setupAddElement(pointSet, product);
128 
129  float globalPos[3];
130  geom->localToGlobal(*det, localPos, globalPos);
131  pointSet->SetNextPoint(globalPos[0], globalPos[1], globalPos[2]);
132 
133  TEveBox* box = new TEveBox;
134  setupAddElement(box, product);
135  ::addTube(box, *det, localPos, pars);
136  } else {
137  TEveCompound* compound = createCompound();
138  setupAddElement(compound, product);
139  }
140  }
141  }
142 }
143 
146  "DT Digis",
FWGeometry::GeomDetInfo
Definition: FWGeometry.h:119
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
ApeEstimator_cff.width
width
Definition: ApeEstimator_cff.py:24
fwLog
#define fwLog(_level_)
Definition: fwLog.h:45
FWGeometry
Definition: FWGeometry.h:27
FWDTDigiProxyBuilder::buildViewType
void buildViewType(const FWEventItem *iItem, TEveElementList *product, FWViewType::EType, const FWViewContext *) override
Definition: FWDTDigiProxyBuilder.cc:79
FWViewType::EType
EType
Definition: FWViewType.h:31
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
FWViewType::kRhoZ
Definition: FWViewType.h:33
FWProxyBuilderBase.h
ecaldqm::nChannels
Definition: EcalDQMCommonUtils.h:113
REGISTER_PROXYBUILDER_METHODS
#define REGISTER_PROXYBUILDER_METHODS()
Definition: register_dataproxybuilder_macro.h:28
FWGeometry::IdToInfoItr
std::vector< FWGeometry::GeomDetInfo >::const_iterator IdToInfoItr
Definition: FWGeometry.h:137
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
mps_check.array
array
Definition: mps_check.py:216
DTSuperLayerId::superLayer
int superLayer() const
Return the superlayer number.
Definition: DTSuperLayerId.h:39
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
FWViewType::kAll3DBits
static const int kAll3DBits
Definition: FWViewType.h:68
FWDTDigiProxyBuilder
Definition: FWDTDigiProxyBuilder.cc:57
Calorimetry_cff.thickness
thickness
Definition: Calorimetry_cff.py:115
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
FWProxyBuilderBase::buildViewType
virtual void buildViewType(const FWEventItem *iItem, TEveElementList *, FWViewType::EType, const FWViewContext *)
Definition: FWProxyBuilderBase.cc:333
DTLayerId
Definition: DTLayerId.h:12
FWGeometry.h
FWDTDigiProxyBuilder::FWDTDigiProxyBuilder
FWDTDigiProxyBuilder(void)
Definition: FWDTDigiProxyBuilder.cc:59
FWDTDigiProxyBuilder::~FWDTDigiProxyBuilder
~FWDTDigiProxyBuilder(void) override
Definition: FWDTDigiProxyBuilder.cc:60
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
DTDigiCollection
FWProxyBuilderBase::setupAddElement
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
Definition: FWProxyBuilderBase.cc:350
fwlog::kWarning
Definition: fwLog.h:35
fwLog.h
FWEventItem.h
FWViewContext
Definition: FWViewContext.h:32
FWEventItem::getGeom
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:548
FWEventItem
Definition: FWEventItem.h:56
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
extraflags_cff.vtx
vtx
Definition: extraflags_cff.py:18
FWViewType::kISpy
Definition: FWViewType.h:35
FWProxyBuilderBase
Definition: FWProxyBuilderBase.h:46
FWDTDigiProxyBuilder::haveSingleProduct
bool haveSingleProduct(void) const override
Definition: FWDTDigiProxyBuilder.cc:62
DTLayerId::superlayerId
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:45
FWViewType::k3D
Definition: FWViewType.h:34
MuonDigiCollection::Range
std::pair< const_iterator, const_iterator > Range
Definition: MuonDigiCollection.h:95
FWDTDigiProxyBuilder::operator=
const FWDTDigiProxyBuilder & operator=(const FWDTDigiProxyBuilder &)=delete
DTDigiCollection.h
FWViewType::kRhoPhiPF
Definition: FWViewType.h:42
DigiContainerIterator
Definition: MuonDigiCollection.h:30
FWViewType::kRhoPhi
Definition: FWViewType.h:32