Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-06-04 04:34:51

0001 #ifndef _FWCANDIDATEHGCALLEGOPROXYBUILDER_H_
0002 #define _FWCANDIDATEHGCALLEGOPROXYBUILDER_H_
0003 
0004 // -*- C++ -*-
0005 //
0006 // Package:     Candidates
0007 // Class  :     FWCandidateHGCalLegoProxyBuilder
0008 //
0009 //
0010 
0011 // User include files
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 // FWCandidateHGCalLegoProxyBuilder
0023 //-----------------------------------------------------------------------------
0024 class FWCandidateHGCalLegoProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::HGCalMultiCluster> {
0025 public:
0026   // ---------------- Constructor(s)/Destructor ----------------------
0027   FWCandidateHGCalLegoProxyBuilder() {}
0028   ~FWCandidateHGCalLegoProxyBuilder() override {}
0029 
0030   // --------------------- Member Functions --------------------------
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   // ----------------------- Data Members ----------------------------
0038   FWCandidateHGCalLegoProxyBuilder(const FWCandidateHGCalLegoProxyBuilder &) = delete;
0039   const FWCandidateHGCalLegoProxyBuilder &operator=(const FWCandidateHGCalLegoProxyBuilder &) = delete;
0040 
0041 private:
0042   // --------------------- Member Functions --------------------------
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();  // There is only one child
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   // Line set marker is nto the same color as line, have to fix it here
0068   if ((parent)->HasChildren()) {
0069     TEveElement *el = (parent)->FirstChild();  // There is only one child
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);