CMS 3D CMS Logo

FWEtlClusterProxyBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: MTD
4 // Class : FWEtlClusterProxyBuilder
5 //
6 //
7 // Original Author:
8 // Created: Thu Nov 28 10:00:00 CET 2022
9 //
10 
11 #include "TEvePointSet.h"
12 #include "TEveCompound.h"
13 
18 
20 
22 public:
24  ~FWEtlClusterProxyBuilder(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 FWEtlClusterProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) {
39  const FTLClusterCollection* clusters = nullptr;
40 
41  iItem->get(clusters);
42 
43  if (!clusters) {
44  fwLog(fwlog::kWarning) << "failed to get the ETL Cluster Collection" << std::endl;
45  return;
46  }
47 
48  const FWGeometry* geom = iItem->getGeom();
49 
50  TEvePointSet* pointSet = new TEvePointSet();
51  TEveElement* itemHolder = createCompound();
52  product->AddElement(itemHolder);
53 
54  for (const auto& detSet : *clusters) {
55  unsigned int id = detSet.detId();
56 
57  if (!geom->contains(id)) {
58  fwLog(fwlog::kWarning) << "failed to get ETL geometry element with detid: " << id << std::endl;
59  continue;
60  }
61 
62  const float* pars = geom->getParameters(id);
63 
64  for (const auto& cluster : detSet) {
65  // --- Get the ETL cluster local position:
66  float x_local = (cluster.x() + 0.5f) * pars[0] + pars[2];
67  float y_local = (cluster.y() + 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  } // cluster loop
77 
78  } // detSet loop
79 
80  setupAddElement(pointSet, itemHolder);
81 }
82 
85  "ETLclusters",
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
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
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:548
#define fwLog(_level_)
Definition: fwLog.h:45
const FWEtlClusterProxyBuilder & operator=(const FWEtlClusterProxyBuilder &)=delete
TEveCompound * createCompound(bool set_color=true, bool propagate_color_to_all_children=false) const