CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/Fireworks/ParticleFlow/plugins/FWPFClusterLegoProxyBuilder.cc

Go to the documentation of this file.
00001 #include "FWPFClusterLegoProxyBuilder.h"
00002 #include "Fireworks/Candidates/interface/FWLegoCandidate.h"
00003 
00004 //______________________________________________________________________________
00005 void
00006 FWPFClusterLegoProxyBuilder::localModelChanges( const FWModelId &iId, TEveElement *parent, FWViewType::EType viewType, const FWViewContext *vc )
00007 {
00008     // Line set marker is not the same colour as line, fixed here
00009     if( ( parent )->HasChildren() )
00010     {
00011         for( TEveElement::List_i j = parent->BeginChildren(); j != parent->EndChildren(); j++ )
00012         {
00013             FWLegoCandidate *cluster = dynamic_cast<FWLegoCandidate*>( *j );
00014             const FWDisplayProperties &dp = FWProxyBuilderBase::item()->modelInfo( iId.index() ).displayProperties();
00015             cluster->SetMarkerColor( dp.color() );
00016             cluster->ElementChanged();
00017         }
00018     }
00019 }
00020 
00021 //______________________________________________________________________________
00022 void
00023 FWPFClusterLegoProxyBuilder::scaleProduct( TEveElementList* parent, FWViewType::EType type, const FWViewContext* vc )
00024 {
00025    for (TEveElement::List_i i = parent->BeginChildren(); i!= parent->EndChildren(); ++i)
00026    {
00027       if ((*i)->HasChildren())
00028       {
00029          TEveElement* el = (*i)->FirstChild();  // there is only one child added in this proxy builder
00030          FWLegoCandidate *cluster = dynamic_cast<FWLegoCandidate*>( el );
00031          cluster->updateScale(vc, context());
00032       }
00033    }
00034 }
00035 
00036 //______________________________________________________________________________
00037 void
00038 FWPFClusterLegoProxyBuilder::sharedBuild( const reco::PFCluster &iData, TEveElement &oItemHolder, const FWViewContext *vc )
00039 {
00040    TEveVector centre = TEveVector( iData.x(), iData.y(), iData.z() );
00041    float energy = iData.energy();
00042    float et = FWPFMaths::calculateEt( centre, energy );
00043    float pt = et;
00044    float eta = iData.eta();
00045    float phi = iData.phi();
00046 
00047    context().voteMaxEtAndEnergy( et, energy );
00048 
00049    FWLegoCandidate *cluster = new FWLegoCandidate( vc, FWProxyBuilderBase::context(), energy, et, pt, eta, phi );
00050    cluster->SetMarkerColor( FWProxyBuilderBase::item()->defaultDisplayProperties().color() );
00051    setupAddElement( cluster, &oItemHolder );
00052 }
00053 
00054 //______________________________ECAL____________________________________________
00055 void
00056 FWPFEcalClusterLegoProxyBuilder::build( const reco::PFCluster &iData, unsigned int iIndex, TEveElement &oItemHolder, const FWViewContext *vc )
00057 {
00058    PFLayer::Layer layer = iData.layer();
00059    if( layer < 0 )
00060       sharedBuild( iData, oItemHolder, vc ); 
00061 }
00062 
00063 //______________________________HCAL____________________________________________
00064 void
00065 FWPFHcalClusterLegoProxyBuilder::build( const reco::PFCluster &iData, unsigned int iIndex, TEveElement &oItemHolder, const FWViewContext *vc )
00066 {
00067    PFLayer::Layer layer = iData.layer();
00068    if( layer > 0 )
00069       sharedBuild( iData, oItemHolder, vc );
00070 }
00071 
00072 //______________________________________________________________________________
00073 REGISTER_FWPROXYBUILDER( FWPFEcalClusterLegoProxyBuilder, reco::PFCluster, "PF Cluster", FWViewType::kLegoPFECALBit );
00074 REGISTER_FWPROXYBUILDER( FWPFHcalClusterLegoProxyBuilder, reco::PFCluster, "PF Cluster", FWViewType::kLegoBit );