Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-03 04:09:57

0001 #ifndef _FWCANDIDATELEGOPROXYBUILDER_H_
0002 #define _FWCANDIDATELEGOPROXYBUILDER_H_
0003 
0004 // -*- C++ -*-
0005 //
0006 // Package:     Candidates
0007 // Class  :     FWCandidateLegoProxyBuilder
0008 //
0009 // Implementation:
0010 //     <Notes on implementation>
0011 //
0012 // Original Author:  Simon Harris
0013 //       Created:    24/06/2011
0014 //
0015 
0016 // User include files
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 // FWCandidateLegoProxyBuilder
0026 //-----------------------------------------------------------------------------
0027 class FWCandidateLegoProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::Candidate> {
0028 public:
0029   // ---------------- Constructor(s)/Destructor ----------------------
0030   FWCandidateLegoProxyBuilder() {}
0031   ~FWCandidateLegoProxyBuilder() override {}
0032 
0033   // --------------------- Member Functions --------------------------
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   // ----------------------- Data Members ----------------------------
0041   FWCandidateLegoProxyBuilder(const FWCandidateLegoProxyBuilder &) = delete;
0042   const FWCandidateLegoProxyBuilder &operator=(const FWCandidateLegoProxyBuilder &) = delete;
0043 
0044 private:
0045   // --------------------- Member Functions --------------------------
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();  // There is only one child
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   // Line set marker is nto the same color as line, have to fix it here
0071   if ((parent)->HasChildren()) {
0072     TEveElement *el = (parent)->FirstChild();  // There is only one child
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);