CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/Fireworks/Candidates/plugins/FWCandidateLegoProxyBuilder.cc

Go to the documentation of this file.
00001 #ifndef _FWCANDIDATELEGOPROXYBUILDER_H_
00002 #define _FWCANDIDATELEGOPROXYBUILDER_H_
00003 
00004 // -*- C++ -*-
00005 //
00006 // Package:     Candidates
00007 // Class  :     FWCandidateLegoProxyBuilder
00008 //
00009 // Implementation:
00010 //     <Notes on implementation>
00011 //
00012 // Original Author:  Simon Harris
00013 //       Created:    24/06/2011
00014 //
00015 
00016 // User include files
00017 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
00018 #include "Fireworks/Core/interface/Context.h"
00019 #include "Fireworks/Core/interface/FWEventItem.h"
00020 #include "DataFormats/Candidate/interface/Candidate.h"
00021 
00022 #include "Fireworks/Candidates/interface/FWLegoCandidate.h"
00023 
00024 //-----------------------------------------------------------------------------
00025 // FWCandidateLegoProxyBuilder
00026 //-----------------------------------------------------------------------------
00027 class FWCandidateLegoProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::Candidate>
00028 {
00029    public:
00030    // ---------------- Constructor(s)/Destructor ----------------------
00031       FWCandidateLegoProxyBuilder(){}
00032       virtual ~FWCandidateLegoProxyBuilder(){}
00033 
00034    // --------------------- Member Functions --------------------------
00035       virtual bool havePerViewProduct( FWViewType::EType ) const { return true; }
00036       virtual void scaleProduct( TEveElementList*, FWViewType::EType, const FWViewContext* );
00037       virtual void localModelChanges( const FWModelId&, TEveElement*, FWViewType::EType,
00038                                  const FWViewContext* );
00039 
00040       REGISTER_PROXYBUILDER_METHODS();
00041 
00042    private:
00043    // ----------------------- Data Members ----------------------------
00044       FWCandidateLegoProxyBuilder( const FWCandidateLegoProxyBuilder& );
00045       const FWCandidateLegoProxyBuilder& operator=( const FWCandidateLegoProxyBuilder& );
00046 
00047    // --------------------- Member Functions --------------------------
00048       void build( const reco::Candidate&, unsigned int, TEveElement&, const FWViewContext* );
00049 };
00050 #endif
00051 //=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_=_
00052 
00053 
00054 //______________________________________________________________________________
00055 void
00056 FWCandidateLegoProxyBuilder::scaleProduct( TEveElementList *parent, FWViewType::EType type,
00057                                            const FWViewContext *vc )
00058 {
00059    for( TEveElement::List_i i = parent->BeginChildren(); i != parent->EndChildren(); ++i )
00060    {
00061       if( (*i)->HasChildren() )
00062       {
00063          TEveElement *el = (*i)->FirstChild();  // There is only one child
00064          FWLegoCandidate *candidate = dynamic_cast<FWLegoCandidate*> (el);
00065          candidate->updateScale( vc, context() );
00066       }
00067    }
00068 }
00069 
00070 //______________________________________________________________________________
00071 void
00072 FWCandidateLegoProxyBuilder::localModelChanges( const FWModelId &iId, TEveElement *parent,
00073                                        FWViewType::EType type, const FWViewContext *vc )
00074 {
00075    // Line set marker is nto the same color as line, have to fix it here
00076    if( (parent)->HasChildren() )
00077    {
00078       TEveElement *el = (parent)->FirstChild();       // There is only one child
00079       FWLegoCandidate *candidate = dynamic_cast<FWLegoCandidate*> (el);
00080       const FWDisplayProperties &dp = item()->modelInfo( iId.index() ).displayProperties();
00081       candidate->SetMarkerColor( dp.color() );
00082       candidate->ElementChanged();
00083    }
00084 }
00085 
00086 //______________________________________________________________________________
00087 void
00088 FWCandidateLegoProxyBuilder::build( const reco::Candidate &iData, unsigned int iIndex,
00089                               TEveElement &oItemHolder, const FWViewContext *vc )
00090 {
00091    FWLegoCandidate *candidate = new FWLegoCandidate( vc, context(), iData.energy(),
00092                                                          iData.et(), iData.pt(),
00093                                                          iData.eta(), iData.phi() );
00094 
00095    candidate->SetMarkerColor( item()->defaultDisplayProperties().color() );
00096    context().voteMaxEtAndEnergy( iData.et(), iData.energy() );
00097 
00098    setupAddElement( candidate, &oItemHolder );
00099 }
00100 
00101 //______________________________________________________________________________
00102 REGISTER_FWPROXYBUILDER( FWCandidateLegoProxyBuilder, reco::Candidate, "Candidates",
00103                          FWViewType::kLegoBit | FWViewType::kLegoPFECALBit );