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  // Disable default copy constructor
68  // Disable default assignment operator
69  const FWDTDigiProxyBuilder& operator=(const FWDTDigiProxyBuilder&) = delete;
70 
71 private:
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",
bool haveSingleProduct(void) const override
virtual void buildViewType(const FWEventItem *iItem, TEveElementList *, FWViewType::EType, const FWViewContext *)
void buildViewType(const FWEventItem *iItem, TEveElementList *product, FWViewType::EType, const FWViewContext *) override
#define REGISTER_PROXYBUILDER_METHODS()
static const TGPicture * info(bool iBackgroundIsBlack)
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
int superLayer() const
Return the superlayer number.
static const int kAllRPZBits
Definition: FWViewType.h:67
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
~FWDTDigiProxyBuilder(void) override
const FWDTDigiProxyBuilder & operator=(const FWDTDigiProxyBuilder &)=delete
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:548
#define fwLog(_level_)
Definition: fwLog.h:45
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
TEveCompound * createCompound(bool set_color=true, bool propagate_color_to_all_children=false) const
std::pair< const_iterator, const_iterator > Range
std::vector< DigiType >::const_iterator const_iterator
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:45
std::vector< FWGeometry::GeomDetInfo >::const_iterator IdToInfoItr
Definition: FWGeometry.h:138