CMS 3D CMS Logo

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

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