CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/Fireworks/ParticleFlow/plugins/FWPFBlockProxyBuilder.cc

Go to the documentation of this file.
00001 #include "FWPFBlockProxyBuilder.h"
00002 
00003 //______________________________________________________________________________
00004 float
00005 FWPFBlockProxyBuilder::calculateEt( const TEveVector &centre, float e )
00006 {
00007    TEveVector vec = centre;
00008    float et;
00009 
00010    vec.Normalize();
00011    vec *= e;
00012    et = vec.Perp();
00013 
00014    return et;
00015 }
00016 
00017 //______________________________________________________________________________
00018 void
00019 FWPFBlockProxyBuilder::scaleProduct( TEveElementList *parent, FWViewType::EType viewType, const FWViewContext *vc )
00020 {
00021    typedef std::vector<ScalableLines> Lines_t;
00022    FWViewEnergyScale *caloScale = vc->getEnergyScale();
00023 
00024    if( viewType == FWViewType::kRhoPhiPF || viewType == FWViewType::kRhoZ )
00025    {  /* Handle the rhophi and rhoz cluster scaling */
00026       for( Lines_t::iterator i = m_clusters.begin(); i != m_clusters.end(); ++i )
00027       {
00028          if( vc == (*i).m_vc )
00029          {
00030             float value = caloScale->getPlotEt() ? (*i).m_et : (*i).m_energy;
00031             (*i).m_ls->SetScale( caloScale->getScaleFactor3D() * value );
00032             TEveProjected *proj = *(*i).m_ls->BeginProjecteds();
00033             proj->UpdateProjection();
00034          }
00035       }
00036    }
00037 }
00038 
00039 //______________________________________________________________________________
00040 void
00041 FWPFBlockProxyBuilder::setupTrackElement( const reco::PFBlockElement &blockElement, 
00042                                               TEveElement &oItemHolder, const FWViewContext *vc, FWViewType::EType viewType )
00043 {
00044    if( blockElement.trackType( reco::PFBlockElement::DEFAULT ) )
00045    {
00046       reco::Track track = *blockElement.trackRef();
00047       FWPFTrackUtils *trackUtils = new FWPFTrackUtils();
00048 
00049       if( viewType == FWViewType::kLego || viewType == FWViewType::kLegoPFECAL )       // Lego views
00050       {
00051          TEveStraightLineSet *legoTrack = trackUtils->setupLegoTrack( track );
00052          legoTrack->SetRnrMarkers( true );
00053          setupAddElement( legoTrack, &oItemHolder );
00054       }
00055       else if( viewType == FWViewType::kRhoPhiPF || viewType == FWViewType::kRhoZ )   // Projected views
00056       {
00057          TEveTrack *trk = trackUtils->setupRPZTrack( track );
00058          TEvePointSet *ps = trackUtils->getCollisionMarkers( trk );
00059          setupAddElement( trk, &oItemHolder );
00060          if( ps->GetN() != 0 )
00061             setupAddElement( ps, &oItemHolder );
00062          else
00063             delete ps;
00064       }
00065    }
00066 }
00067 
00068 //______________________________________________________________________________
00069 void
00070 FWPFBlockProxyBuilder::setupClusterElement( const reco::PFBlockElement &blockElement, TEveElement &oItemHolder, 
00071                                                 const FWViewContext *vc, FWViewType::EType viewType, float r )
00072 {
00073    // Get reference to PFCluster
00074    reco::PFCluster cluster = *blockElement.clusterRef();
00075    TEveVector centre = TEveVector( cluster.x(), cluster.y(), cluster.z() );
00076    float energy = cluster.energy();
00077    float et = calculateEt( centre, energy );
00078    float pt = et;
00079    float eta = cluster.eta();
00080    float phi = cluster.phi();
00081 
00082    FWProxyBuilderBase::context().voteMaxEtAndEnergy( et, energy );
00083 
00084    if( viewType == FWViewType::kLego || viewType == FWViewType::kLegoPFECAL )
00085    {
00086       FWPFLegoCandidate *legoCluster = new FWPFLegoCandidate( vc, FWProxyBuilderBase::context(), energy, et, pt, eta, phi );
00087       legoCluster->SetMarkerColor( FWProxyBuilderBase::item()->defaultDisplayProperties().color() );
00088       setupAddElement( legoCluster, &oItemHolder );
00089    }
00090    if( viewType == FWViewType::kRhoPhiPF )
00091    {
00092       const FWDisplayProperties &dp = item()->defaultDisplayProperties();
00093       FWPFClusterRPZUtils *clusterUtils = new FWPFClusterRPZUtils();
00094       TEveScalableStraightLineSet *rpCluster = clusterUtils->buildRhoPhiClusterLineSet( cluster, vc, energy, et, r );
00095       rpCluster->SetLineColor( dp.color() );
00096       m_clusters.push_back( ScalableLines( rpCluster, et, energy, vc ) );
00097       setupAddElement( rpCluster, &oItemHolder );
00098       delete clusterUtils;
00099    }
00100    else if( viewType == FWViewType::kRhoZ )
00101    {
00102       const FWDisplayProperties &dp = item()->defaultDisplayProperties();
00103       FWPFClusterRPZUtils *clusterUtils = new FWPFClusterRPZUtils();
00104       TEveScalableStraightLineSet *rzCluster = clusterUtils->buildRhoZClusterLineSet( cluster, vc, context().caloTransAngle(),
00105                                                                                       energy, et, r, context().caloZ1() );
00106       rzCluster->SetLineColor( dp.color() );
00107       m_clusters.push_back( ScalableLines( rzCluster, et, energy, vc ) );
00108       setupAddElement( rzCluster, &oItemHolder );
00109       delete clusterUtils;
00110    }
00111 }
00112 
00113 //______________________________________________________________________________
00114 void
00115 FWPFBlockProxyBuilder::buildViewType( const reco::PFBlock &iData, unsigned int iIndex, TEveElement &oItemHolder, 
00116                                   FWViewType::EType viewType, const FWViewContext *vc )
00117 {
00118    const edm::OwnVector<reco::PFBlockElement> &elements = iData.elements();
00119    
00120    for( unsigned int i = 0; i < elements.size(); ++i )
00121    {
00122       reco::PFBlockElement::Type type = elements[i].type();
00123       switch( type )
00124       {
00125          case 1:  // TRACK
00126             if( e_builderType == BASE )
00127                setupTrackElement( elements[i], oItemHolder, vc, viewType );
00128          break;
00129 
00130          case 4:  // ECAL
00131             if( e_builderType == ECAL )
00132                setupClusterElement( elements[i], oItemHolder, vc, viewType, context().caloR1() );
00133          break;
00134 
00135          case 5:  // HCAL
00136             if( e_builderType == HCAL )
00137             {
00138                if( viewType == FWViewType::kRhoPhiPF )
00139                   setupClusterElement( elements[i], oItemHolder, vc, viewType, 177.7 );
00140                else  // RhoZ
00141                   setupClusterElement( elements[i], oItemHolder, vc, viewType, context().caloR1() );
00142             }
00143          break;
00144 
00145          default: // Ignore anything that isn't wanted
00146          break;
00147       }
00148    }
00149 }
00150 
00151 //______________________________________________________________________________
00152 REGISTER_FWPROXYBUILDER( FWPFBlockProxyBuilder, reco::PFBlock, "PF Block", FWViewType::kRhoPhiPFBit | FWViewType::kLegoBit |
00153                                                                                FWViewType::kRhoZBit | FWViewType::kLegoPFECALBit );
00154 REGISTER_FWPROXYBUILDER( FWPFBlockEcalProxyBuilder, reco::PFBlock, "PF Block", FWViewType::kLegoPFECALBit | FWViewType::kRhoPhiPFBit |
00155                                                                                FWViewType::kRhoZBit );
00156 REGISTER_FWPROXYBUILDER( FWPFBlockHcalProxyBuilder, reco::PFBlock, "PF Block", FWViewType::kLegoBit | FWViewType::kRhoPhiPFBit |
00157                                                                                FWViewType::kRhoZBit );