CMS 3D CMS Logo

FWCandidateHGCalLegoProxyBuilder.cc
Go to the documentation of this file.
1 #ifndef _FWCANDIDATEHGCALLEGOPROXYBUILDER_H_
2 #define _FWCANDIDATEHGCALLEGOPROXYBUILDER_H_
3 
4 // -*- C++ -*-
5 //
6 // Package: Candidates
7 // Class : FWCandidateHGCalLegoProxyBuilder
8 //
9 //
10 
11 // User include files
16 
18 
19 #include <cmath>
20 
21 //-----------------------------------------------------------------------------
22 // FWCandidateHGCalLegoProxyBuilder
23 //-----------------------------------------------------------------------------
24 class FWCandidateHGCalLegoProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::HGCalMultiCluster> {
25 public:
26  // ---------------- Constructor(s)/Destructor ----------------------
29 
30  // --------------------- Member Functions --------------------------
31  bool havePerViewProduct(FWViewType::EType) const override { return true; }
32  void scaleProduct(TEveElementList *, FWViewType::EType, const FWViewContext *) override;
33  void localModelChanges(const FWModelId &, TEveElement *, FWViewType::EType, const FWViewContext *) override;
34 
36 
37  // ----------------------- Data Members ----------------------------
40 
41 private:
42  // --------------------- Member Functions --------------------------
44  void build(const reco::HGCalMultiCluster &, unsigned int, TEveElement &, const FWViewContext *) override;
45 };
46 #endif
47 //=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_
48 
49 //______________________________________________________________________________
52  const FWViewContext *vc) {
53  for (TEveElement::List_i i = parent->BeginChildren(); i != parent->EndChildren(); ++i) {
54  if ((*i)->HasChildren()) {
55  TEveElement *el = (*i)->FirstChild(); // There is only one child
56  FWLegoCandidate *candidate = dynamic_cast<FWLegoCandidate *>(el);
57  candidate->updateScale(vc, context());
58  }
59  }
60 }
61 
62 //______________________________________________________________________________
64  TEveElement *parent,
66  const FWViewContext *vc) {
67  // Line set marker is nto the same color as line, have to fix it here
68  if ((parent)->HasChildren()) {
69  TEveElement *el = (parent)->FirstChild(); // There is only one child
70  FWLegoCandidate *candidate = dynamic_cast<FWLegoCandidate *>(el);
71  candidate->SetMarkerColor(item()->modelInfo(iId.index()).displayProperties().color());
72  candidate->ElementChanged();
73  }
74 }
75 
76 //______________________________________________________________________________
78  unsigned int iIndex,
79  TEveElement &oItemHolder,
80  const FWViewContext *vc) {
81  const auto &clusters = iData.clusters();
82 
83  for (const auto &c : clusters) {
84  auto pt = c->energy() / std::cosh(c->eta());
85  FWLegoCandidate *candidate = new FWLegoCandidate(vc, context(), c->energy(), pt, pt, c->eta(), c->phi());
86 
87  candidate->SetMarkerColor(item()->defaultDisplayProperties().color());
88  context().voteMaxEtAndEnergy(pt, c->energy());
89  setupAddElement(candidate, &oItemHolder);
90  }
91 }
92 
93 //______________________________________________________________________________
96  "HGCal Multiclusters Lego",
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
int index() const
Definition: FWModelId.h:41
const edm::PtrVector< reco::BasicCluster > & clusters() const
const fireworks::Context & context() const
const FWCandidateHGCalLegoProxyBuilder & operator=(const FWCandidateHGCalLegoProxyBuilder &)=delete
void voteMaxEtAndEnergy(float Et, float energy) const
Definition: Context.cc:169
void localModelChanges(const FWModelId &, TEveElement *, FWViewType::EType, const FWViewContext *) override
bool havePerViewProduct(FWViewType::EType) const override
void updateScale(const FWViewContext *vc, const fireworks::Context &)
static constexpr unsigned int kLegoBit
Definition: FWViewType.h:50
void scaleProduct(TEveElementList *, FWViewType::EType, const FWViewContext *) override
static constexpr unsigned int kLegoHFBit
Definition: FWViewType.h:51
const FWEventItem * item() const