File indexing completed on 2024-06-04 04:34:51
0001 #ifndef _FWCANDIDATEHGCALLEGOPROXYBUILDER_H_
0002 #define _FWCANDIDATEHGCALLEGOPROXYBUILDER_H_
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
0013 #include "Fireworks/Core/interface/Context.h"
0014 #include "Fireworks/Core/interface/FWEventItem.h"
0015 #include "DataFormats/ParticleFlowReco/interface/HGCalMultiCluster.h"
0016
0017 #include "Fireworks/Candidates/interface/FWLegoCandidate.h"
0018
0019 #include <cmath>
0020
0021
0022
0023
0024 class FWCandidateHGCalLegoProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::HGCalMultiCluster> {
0025 public:
0026
0027 FWCandidateHGCalLegoProxyBuilder() {}
0028 ~FWCandidateHGCalLegoProxyBuilder() override {}
0029
0030
0031 bool havePerViewProduct(FWViewType::EType) const override { return true; }
0032 void scaleProduct(TEveElementList *, FWViewType::EType, const FWViewContext *) override;
0033 void localModelChanges(const FWModelId &, TEveElement *, FWViewType::EType, const FWViewContext *) override;
0034
0035 REGISTER_PROXYBUILDER_METHODS();
0036
0037
0038 FWCandidateHGCalLegoProxyBuilder(const FWCandidateHGCalLegoProxyBuilder &) = delete;
0039 const FWCandidateHGCalLegoProxyBuilder &operator=(const FWCandidateHGCalLegoProxyBuilder &) = delete;
0040
0041 private:
0042
0043 using FWSimpleProxyBuilderTemplate<reco::HGCalMultiCluster>::build;
0044 void build(const reco::HGCalMultiCluster &, unsigned int, TEveElement &, const FWViewContext *) override;
0045 };
0046 #endif
0047
0048
0049
0050 void FWCandidateHGCalLegoProxyBuilder::scaleProduct(TEveElementList *parent,
0051 FWViewType::EType type,
0052 const FWViewContext *vc) {
0053 for (TEveElement::List_i i = parent->BeginChildren(); i != parent->EndChildren(); ++i) {
0054 if ((*i)->HasChildren()) {
0055 TEveElement *el = (*i)->FirstChild();
0056 FWLegoCandidate *candidate = dynamic_cast<FWLegoCandidate *>(el);
0057 candidate->updateScale(vc, context());
0058 }
0059 }
0060 }
0061
0062
0063 void FWCandidateHGCalLegoProxyBuilder::localModelChanges(const FWModelId &iId,
0064 TEveElement *parent,
0065 FWViewType::EType type,
0066 const FWViewContext *vc) {
0067
0068 if ((parent)->HasChildren()) {
0069 TEveElement *el = (parent)->FirstChild();
0070 FWLegoCandidate *candidate = dynamic_cast<FWLegoCandidate *>(el);
0071 candidate->SetMarkerColor(item()->modelInfo(iId.index()).displayProperties().color());
0072 candidate->ElementChanged();
0073 }
0074 }
0075
0076
0077 void FWCandidateHGCalLegoProxyBuilder::build(const reco::HGCalMultiCluster &iData,
0078 unsigned int iIndex,
0079 TEveElement &oItemHolder,
0080 const FWViewContext *vc) {
0081 const auto &clusters = iData.clusters();
0082
0083 for (const auto &c : clusters) {
0084 auto pt = c->energy() / std::cosh(c->eta());
0085 FWLegoCandidate *candidate = new FWLegoCandidate(vc, context(), c->energy(), pt, pt, c->eta(), c->phi());
0086
0087 candidate->SetMarkerColor(item()->defaultDisplayProperties().color());
0088 context().voteMaxEtAndEnergy(pt, c->energy());
0089 setupAddElement(candidate, &oItemHolder);
0090 }
0091 }
0092
0093
0094 REGISTER_FWPROXYBUILDER(FWCandidateHGCalLegoProxyBuilder,
0095 reco::HGCalMultiCluster,
0096 "HGCal Multiclusters Lego",
0097 FWViewType::kLegoBit | FWViewType::kLegoHFBit);