CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Fireworks/ParticleFlow/plugins/FWPFCandidatesLegoProxyBuilder.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     ParticleFlow
00004 // Class  :     FWCandidatesLegoProxyBuilder
00005 // 
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Colin Bernet
00010 //         Created:  Fri May 28 14:54:19 CEST 2010
00011 // Edited:           sharris, Wed 10 Feb 2011, 13:00
00012 //
00013 
00014 // User include files
00015 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
00016 #include "Fireworks/Core/interface/Context.h"
00017 #include "Fireworks/Core/interface/FWEventItem.h"
00018 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
00019 #include "Fireworks/ParticleFlow/interface/FWPFLegoCandidate.h"
00020 #include "Fireworks/ParticleFlow/interface/setTrackTypePF.h"   // NB: This has to come after FWPFLegoCandidate include
00021 
00022 //-----------------------------------------------------------------------------
00023 // FWCandidate3DProxyBuilder
00024 //-----------------------------------------------------------------------------
00025 
00026 class FWPFCandidatesLegoProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::PFCandidate> 
00027 {
00028    public:
00029       FWPFCandidatesLegoProxyBuilder();
00030       virtual ~FWPFCandidatesLegoProxyBuilder();
00031 
00032    // --------------------- Member Functions --------------------------
00033       virtual bool havePerViewProduct(FWViewType::EType) const { return true; }
00034       virtual void scaleProduct(TEveElementList* parent, FWViewType::EType, const FWViewContext* vc);
00035       virtual void localModelChanges(const FWModelId& iId, TEveElement* iCompound,
00036                                      FWViewType::EType viewType, const FWViewContext* vc);
00037 
00038       REGISTER_PROXYBUILDER_METHODS();
00039 
00040    private:
00041       FWPFCandidatesLegoProxyBuilder(const FWPFCandidatesLegoProxyBuilder&); // stop default
00042       const FWPFCandidatesLegoProxyBuilder& operator=(const FWPFCandidatesLegoProxyBuilder&); // stop default
00043       
00044    // --------------------- Member Functions --------------------------
00045       void build(const reco::PFCandidate&, unsigned int, TEveElement&, const FWViewContext*);
00046 };
00047 //=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_
00048 
00049 
00050 //
00051 // constructors and destructor
00052 //
00053 //______________________________________________________________________________
00054 FWPFCandidatesLegoProxyBuilder::FWPFCandidatesLegoProxyBuilder(){}
00055 FWPFCandidatesLegoProxyBuilder::~FWPFCandidatesLegoProxyBuilder(){}
00056 
00057 //
00058 // member functions
00059 //
00060 //______________________________________________________________________________
00061 void 
00062 FWPFCandidatesLegoProxyBuilder::build(const reco::PFCandidate &iData, unsigned int iIndex, TEveElement &oItemHolder, const FWViewContext *vc)
00063 {
00064    FWPFLegoCandidate *candidate = new FWPFLegoCandidate( vc, context(), iData.energy(), iData.et(), iData.pt(),
00065                                                          iData.eta(), iData.phi() );
00066    candidate->SetMarkerColor( item()->defaultDisplayProperties().color() );
00067    fireworks::setTrackTypePF( iData, candidate );
00068 
00069    context().voteMaxEtAndEnergy( iData.et(), iData.et() );
00070 
00071    setupAddElement( candidate, &oItemHolder );
00072 }
00073 
00074 //______________________________________________________________________________
00075 void
00076 FWPFCandidatesLegoProxyBuilder::scaleProduct(TEveElementList* parent, FWViewType::EType type, const FWViewContext* vc)
00077 {
00078    for (TEveElement::List_i i = parent->BeginChildren(); i!= parent->EndChildren(); ++i)
00079    {
00080       if ((*i)->HasChildren())
00081       {
00082          TEveElement* el = (*i)->FirstChild();  // there is only one child added in this proxy builder
00083          FWPFLegoCandidate *candidate = dynamic_cast<FWPFLegoCandidate*> (el);
00084          candidate->updateScale(vc, context());
00085       }
00086    }
00087 }
00088 
00089 //______________________________________________________________________________
00090 void
00091 FWPFCandidatesLegoProxyBuilder::localModelChanges(const FWModelId& iId, TEveElement* parent,
00092                                                   FWViewType::EType viewType, const FWViewContext* vc)
00093 {
00094    // line set marker is not same color as line, have to fix it here
00095    if ((parent)->HasChildren())
00096    {
00097       TEveElement* el = (parent)->FirstChild();  // we know there is only one child added in this proxy builder
00098       FWPFLegoCandidate *candidate = dynamic_cast<FWPFLegoCandidate*> (el);
00099       const FWDisplayProperties& dp = item()->modelInfo(iId.index()).displayProperties();
00100       candidate->SetMarkerColor( dp.color());
00101       candidate->ElementChanged();
00102    }  
00103 }
00104 
00105 //______________________________________________________________________________
00106 REGISTER_FWPROXYBUILDER(FWPFCandidatesLegoProxyBuilder, reco::PFCandidate, "PF Candidates", FWViewType::kLegoPFECALBit | FWViewType::kLegoBit );