CMS 3D CMS Logo

FWBtlClusterProxyBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: MTD
4 // Class : FWBtlClusterProxyBuilder
5 //
6 //
7 // Original Author:
8 // Created: Thu Nov 24 10:00:00 CET 2022
9 //
10 
11 #include "TEvePointSet.h"
12 #include "TEveCompound.h"
13 
18 
20 
22 public:
24  ~FWBtlClusterProxyBuilder(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 FWBtlClusterProxyBuilder::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 BTL 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 BTL 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 BTL cluster local position:
66  float x_local =
67  (cluster.getClusterErrorX() < 0. ? (cluster.x() + 0.5f) * pars[0] + pars[2] : cluster.getClusterPosX());
68  float y_local = (cluster.y() + 0.5f) * pars[1] + pars[3];
69 
70  const float localPoint[3] = {x_local, y_local, 0.0};
71 
72  float globalPoint[3];
73  geom->localToGlobal(id, localPoint, globalPoint);
74 
75  pointSet->SetNextPoint(globalPoint[0], globalPoint[1], globalPoint[2]);
76 
77  } // cluster loop
78 
79  } // detSet loop
80 
81  setupAddElement(pointSet, itemHolder);
82 }
83 
86  "BTLclusters",
#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
const FWBtlClusterProxyBuilder & operator=(const FWBtlClusterProxyBuilder &)=delete
static const int kAll3DBits
Definition: FWViewType.h:68
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