CMS 3D CMS Logo

FWEtlRecHitsProxyBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: MTD
4 // Class : FWEtlRecHitProxyBuilder
5 //
6 //
7 // Original Author:
8 // Created: Tue Dec 6 17:00:00 CET 2022
9 //
10 
11 #include "TEvePointSet.h"
12 #include "TEveCompound.h"
13 
18 
20 
22 public:
24  ~FWEtlRecHitProxyBuilder(void) override {}
25 
27 
28  // Disable default copy constructor
30  // Disable default assignment operator
32 
33 private:
35  void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) override;
36 };
37 
38 void FWEtlRecHitProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) {
39  const FTLRecHitCollection* recHits = nullptr;
40 
41  iItem->get(recHits);
42 
43  if (!recHits) {
44  fwLog(fwlog::kWarning) << "failed to get the ETL RecHit Collection" << std::endl;
45  return;
46  }
47 
48  const FWGeometry* geom = iItem->getGeom();
49 
50  for (const auto& hit : *recHits) {
51  unsigned int id = hit.id().rawId();
52 
53  if (!geom->contains(id)) {
54  fwLog(fwlog::kWarning) << "failed to get ETL geometry element with detid: " << id << std::endl;
55  continue;
56  }
57 
58  TEvePointSet* pointSet = new TEvePointSet();
59 
60  TEveElement* itemHolder = createCompound();
61  product->AddElement(itemHolder);
62 
63  const float* pars = geom->getParameters(id);
64 
65  // --- Get the ETL RecHit local position:
66  float x_local = (hit.row() + 0.5f) * pars[0] + pars[2];
67  float y_local = (hit.column() + 0.5f) * pars[1] + pars[3];
68 
69  const float localPoint[3] = {x_local, y_local, 0.0};
70 
71  float globalPoint[3];
72  geom->localToGlobal(id, localPoint, globalPoint);
73 
74  pointSet->SetNextPoint(globalPoint[0], globalPoint[1], globalPoint[2]);
75 
76  setupAddElement(pointSet, itemHolder);
77 
78  } // recHits loop
79 }
80 
83  "ETLrechits",
const FWEtlRecHitProxyBuilder & operator=(const FWEtlRecHitProxyBuilder &)=delete
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:57
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:58
unsigned int id
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:548
#define fwLog(_level_)
Definition: fwLog.h:45
TEveCompound * createCompound(bool set_color=true, bool propagate_color_to_all_children=false) const