Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-03 04:10:03

0001 // -*- C++ -*-
0002 //
0003 // Package:     ParticleFlow
0004 // Class  :     FWCandidatesLegoProxyBuilder
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:  Colin Bernet
0010 //         Created:  Fri May 28 14:54:19 CEST 2010
0011 // Edited:           sharris, Wed 10 Feb 2011, 13:00
0012 //
0013 
0014 // User include files
0015 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
0016 #include "Fireworks/Core/interface/Context.h"
0017 #include "Fireworks/Core/interface/FWEventItem.h"
0018 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
0019 #include "Fireworks/Candidates/interface/FWLegoCandidate.h"
0020 #include "Fireworks/ParticleFlow/interface/setTrackTypePF.h"  // NB: This has to come after FWLegoCandidate include
0021 
0022 //-----------------------------------------------------------------------------
0023 // FWCandidate3DProxyBuilder
0024 //-----------------------------------------------------------------------------
0025 
0026 class FWPFCandidatesLegoProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::PFCandidate> {
0027 public:
0028   FWPFCandidatesLegoProxyBuilder();
0029   ~FWPFCandidatesLegoProxyBuilder() override;
0030 
0031   // --------------------- Member Functions --------------------------
0032   bool havePerViewProduct(FWViewType::EType) const override { return true; }
0033   void scaleProduct(TEveElementList* parent, FWViewType::EType, const FWViewContext* vc) override;
0034   void localModelChanges(const FWModelId& iId,
0035                          TEveElement* iCompound,
0036                          FWViewType::EType viewType,
0037                          const FWViewContext* vc) override;
0038 
0039   REGISTER_PROXYBUILDER_METHODS();
0040 
0041   FWPFCandidatesLegoProxyBuilder(const FWPFCandidatesLegoProxyBuilder&) = delete;                   // stop default
0042   const FWPFCandidatesLegoProxyBuilder& operator=(const FWPFCandidatesLegoProxyBuilder&) = delete;  // stop default
0043 
0044 private:
0045   // --------------------- Member Functions --------------------------
0046   using FWSimpleProxyBuilderTemplate<reco::PFCandidate>::build;
0047   void build(const reco::PFCandidate&, unsigned int, TEveElement&, const FWViewContext*) override;
0048 };
0049 //=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_
0050 
0051 //
0052 // constructors and destructor
0053 //
0054 //______________________________________________________________________________
0055 FWPFCandidatesLegoProxyBuilder::FWPFCandidatesLegoProxyBuilder() {}
0056 FWPFCandidatesLegoProxyBuilder::~FWPFCandidatesLegoProxyBuilder() {}
0057 
0058 //
0059 // member functions
0060 //
0061 //______________________________________________________________________________
0062 void FWPFCandidatesLegoProxyBuilder::build(const reco::PFCandidate& iData,
0063                                            unsigned int iIndex,
0064                                            TEveElement& oItemHolder,
0065                                            const FWViewContext* vc) {
0066   FWLegoCandidate* candidate =
0067       new FWLegoCandidate(vc, context(), iData.energy(), iData.et(), iData.pt(), iData.eta(), iData.phi());
0068   candidate->SetMarkerColor(item()->defaultDisplayProperties().color());
0069   fireworks::setTrackTypePF(iData, candidate);
0070 
0071   context().voteMaxEtAndEnergy(iData.et(), iData.et());
0072 
0073   setupAddElement(candidate, &oItemHolder);
0074 }
0075 
0076 //______________________________________________________________________________
0077 void FWPFCandidatesLegoProxyBuilder::scaleProduct(TEveElementList* parent,
0078                                                   FWViewType::EType type,
0079                                                   const FWViewContext* vc) {
0080   for (TEveElement::List_i i = parent->BeginChildren(); i != parent->EndChildren(); ++i) {
0081     if ((*i)->HasChildren()) {
0082       TEveElement* el = (*i)->FirstChild();  // there is only one child added in this proxy builder
0083       FWLegoCandidate* candidate = dynamic_cast<FWLegoCandidate*>(el);
0084       candidate->updateScale(vc, context());
0085     }
0086   }
0087 }
0088 
0089 //______________________________________________________________________________
0090 void FWPFCandidatesLegoProxyBuilder::localModelChanges(const FWModelId& iId,
0091                                                        TEveElement* parent,
0092                                                        FWViewType::EType viewType,
0093                                                        const FWViewContext* vc) {
0094   // line set marker is not same color as line, have to fix it here
0095   if ((parent)->HasChildren()) {
0096     TEveElement* el = (parent)->FirstChild();  // we know there is only one child added in this proxy builder
0097     FWLegoCandidate* candidate = dynamic_cast<FWLegoCandidate*>(el);
0098     candidate->SetMarkerColor(item()->modelInfo(iId.index()).displayProperties().color());
0099     candidate->ElementChanged();
0100   }
0101 }
0102 
0103 //______________________________________________________________________________
0104 REGISTER_FWPROXYBUILDER(FWPFCandidatesLegoProxyBuilder,
0105                         reco::PFCandidate,
0106                         "PF Candidates",
0107                         FWViewType::kLegoPFECALBit | FWViewType::kLegoBit);