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