CMS 3D CMS Logo

Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions

FWPFBlockProxyBuilder Class Reference

#include <FWPFBlockProxyBuilder.h>

Inheritance diagram for FWPFBlockProxyBuilder:
FWSimpleProxyBuilderTemplate< reco::PFBlock > FWSimpleProxyBuilder FWProxyBuilderBase FWPFBlockEcalProxyBuilder FWPFBlockHcalProxyBuilder

List of all members.

Public Types

enum  BuilderType { BASE = 0, ECAL = 1, HCAL = 2 }

Public Member Functions

 FWPFBlockProxyBuilder ()
 REGISTER_PROXYBUILDER_METHODS ()
virtual ~FWPFBlockProxyBuilder ()

Protected Member Functions

virtual void buildViewType (const reco::PFBlock &, unsigned int, TEveElement &, FWViewType::EType, const FWViewContext *)
virtual void cleanLocal ()
void clusterSharedBuild (const reco::PFCluster &, TEveElement &, const FWViewContext *)
virtual bool havePerViewProduct (FWViewType::EType) const
virtual bool haveSingleProduct () const
virtual void scaleProduct (TEveElementList *parent, FWViewType::EType, const FWViewContext *vc)
void setupClusterElement (const reco::PFBlockElement &, TEveElement &, const FWViewContext *, FWViewType::EType, float r)
void setupTrackElement (const reco::PFBlockElement &, TEveElement &, const FWViewContext *, FWViewType::EType)

Protected Attributes

BuilderType e_builderType
std::vector< ScalableLinesm_clusters

Private Member Functions

 FWPFBlockProxyBuilder (const FWPFBlockProxyBuilder &)
const FWPFBlockProxyBuilderoperator= (const FWPFBlockProxyBuilder &)

Detailed Description

Definition at line 37 of file FWPFBlockProxyBuilder.h.


Member Enumeration Documentation

Enumerator:
BASE 
ECAL 
HCAL 

Definition at line 40 of file FWPFBlockProxyBuilder.h.

{ BASE=0, ECAL=1, HCAL=2 };

Constructor & Destructor Documentation

FWPFBlockProxyBuilder::FWPFBlockProxyBuilder ( ) [inline]

Definition at line 43 of file FWPFBlockProxyBuilder.h.

virtual FWPFBlockProxyBuilder::~FWPFBlockProxyBuilder ( ) [inline, virtual]

Definition at line 44 of file FWPFBlockProxyBuilder.h.

{}
FWPFBlockProxyBuilder::FWPFBlockProxyBuilder ( const FWPFBlockProxyBuilder ) [private]

Member Function Documentation

void FWPFBlockProxyBuilder::buildViewType ( const reco::PFBlock iData,
unsigned int  iIndex,
TEveElement &  oItemHolder,
FWViewType::EType  viewType,
const FWViewContext vc 
) [protected, virtual]

Reimplemented from FWSimpleProxyBuilderTemplate< reco::PFBlock >.

Definition at line 157 of file FWPFBlockProxyBuilder.cc.

References BASE, FWPFUtils::caloR1(), FWPFUtils::caloR2(), FWProxyBuilderBase::context(), e_builderType, ECAL, reco::PFBlock::elements(), asciidump::elements, HCAL, i, FWViewType::kRhoPhiPF, setupClusterElement(), setupTrackElement(), and edm::OwnVector< T, P >::size().

{
   const edm::OwnVector<reco::PFBlockElement> &elements = iData.elements();
   
   for( unsigned int i = 0; i < elements.size(); ++i )
   {
      reco::PFBlockElement::Type type = elements[i].type();
      switch( type )
      {
         case 1:  // TRACK
            if( e_builderType == BASE )
               setupTrackElement( elements[i], oItemHolder, vc, viewType );
         break;

         case 4:  // ECAL
            if( e_builderType == ECAL )
               setupClusterElement( elements[i], oItemHolder, vc, viewType, FWPFUtils::caloR1() );
         break;

         case 5:  // HCAL
            if( e_builderType == HCAL )
            {
               if( viewType == FWViewType::kRhoPhiPF )
                  setupClusterElement( elements[i], oItemHolder, vc, viewType, FWPFUtils::caloR2() );
               else  // RhoZ
                  setupClusterElement( elements[i], oItemHolder, vc, viewType, context().caloR1() );
            }
         break;

         default: // Ignore anything that isn't wanted
         break;
      }
   }
}
virtual void FWPFBlockProxyBuilder::cleanLocal ( ) [inline, protected, virtual]

Reimplemented from FWProxyBuilderBase.

Definition at line 59 of file FWPFBlockProxyBuilder.h.

References m_clusters.

{ m_clusters.clear(); }
void FWPFBlockProxyBuilder::clusterSharedBuild ( const reco::PFCluster ,
TEveElement &  ,
const FWViewContext  
) [protected]
virtual bool FWPFBlockProxyBuilder::havePerViewProduct ( FWViewType::EType  ) const [inline, protected, virtual]

Reimplemented from FWProxyBuilderBase.

Definition at line 55 of file FWPFBlockProxyBuilder.h.

{ return true; }
virtual bool FWPFBlockProxyBuilder::haveSingleProduct ( void  ) const [inline, protected, virtual]

Reimplemented from FWProxyBuilderBase.

Definition at line 56 of file FWPFBlockProxyBuilder.h.

{ return false; } // different view types
const FWPFBlockProxyBuilder& FWPFBlockProxyBuilder::operator= ( const FWPFBlockProxyBuilder ) [private]
FWPFBlockProxyBuilder::REGISTER_PROXYBUILDER_METHODS ( )
void FWPFBlockProxyBuilder::scaleProduct ( TEveElementList *  parent,
FWViewType::EType  viewType,
const FWViewContext vc 
) [protected, virtual]

Reimplemented from FWProxyBuilderBase.

Definition at line 5 of file FWPFBlockProxyBuilder.cc.

References FWProxyBuilderBase::context(), FWViewContext::getEnergyScale(), FWViewEnergyScale::getPlotEt(), FWViewEnergyScale::getScaleFactor3D(), i, j, FWViewType::kLego, FWViewType::kLegoPFECAL, FWViewType::kRhoPhiPF, FWViewType::kRhoZ, m_clusters, FWPFLegoCandidate::updateScale(), and relativeConstraints::value.

{
   typedef std::vector<ScalableLines> Lines_t;
   FWViewEnergyScale *caloScale = vc->getEnergyScale();

   if( viewType == FWViewType::kRhoPhiPF || viewType == FWViewType::kRhoZ )
   {  /* Handle the rhophi and rhoz cluster scaling */
      for( Lines_t::iterator i = m_clusters.begin(); i != m_clusters.end(); ++i )
      {
         if( vc == (*i).m_vc )
         {
            float value = caloScale->getPlotEt() ? (*i).m_et : (*i).m_energy;
            (*i).m_ls->SetScale( caloScale->getScaleFactor3D() * value );
            TEveProjected *proj = *(*i).m_ls->BeginProjecteds();
            proj->UpdateProjection();
         }
      }
   } /* Handle cluster scaling in lego view(s) */
   else if( viewType == FWViewType::kLego || viewType == FWViewType::kLegoPFECAL )
   {  // Loop products
      for( TEveElement::List_i i = parent->BeginChildren(); i != parent->EndChildren(); ++i )
      {
         if( (*i)->HasChildren() )
         {  // Loop elements of block
            for( TEveElement::List_i j = (*i)->BeginChildren(); j != (*i)->EndChildren(); ++j )
            {
               if( strcmp( (*j)->GetElementName(), "BlockCluster" ) == 0 )
               {
                  FWPFLegoCandidate *cluster = dynamic_cast<FWPFLegoCandidate*>( *j );
                  cluster->updateScale( vc, context() );
               }
            }
         }
      }
   }
}
void FWPFBlockProxyBuilder::setupClusterElement ( const reco::PFBlockElement blockElement,
TEveElement &  oItemHolder,
const FWViewContext vc,
FWViewType::EType  viewType,
float  r 
) [protected]

Definition at line 111 of file FWPFBlockProxyBuilder.cc.

References FWPFClusterRPZUtils::buildRhoPhiClusterLineSet(), FWPFClusterRPZUtils::buildRhoZClusterLineSet(), FWPFMaths::calculateEt(), FWPFUtils::caloZ1(), reco::PFBlockElement::clusterRef(), FWDisplayProperties::color(), FWProxyBuilderBase::context(), FWEventItem::defaultDisplayProperties(), reco::PFCluster::energy(), relval_parameters_module::energy, eta(), reco::CaloCluster::eta(), FWProxyBuilderBase::item(), FWViewType::kLego, FWViewType::kLegoPFECAL, FWViewType::kRhoPhiPF, FWViewType::kRhoZ, m_clusters, phi, reco::CaloCluster::phi(), FWProxyBuilderBase::setupAddElement(), fireworks::Context::voteMaxEtAndEnergy(), reco::CaloCluster::x(), reco::CaloCluster::y(), and reco::CaloCluster::z().

Referenced by buildViewType().

{
   // Get reference to PFCluster
   reco::PFCluster cluster = *blockElement.clusterRef();
   TEveVector centre = TEveVector( cluster.x(), cluster.y(), cluster.z() );
   float energy = cluster.energy();
   float et = FWPFMaths::calculateEt( centre, energy );
   float pt = et;
   float eta = cluster.eta();
   float phi = cluster.phi();

   FWProxyBuilderBase::context().voteMaxEtAndEnergy( et, energy );

   if( viewType == FWViewType::kLego || viewType == FWViewType::kLegoPFECAL )
   {
      FWPFLegoCandidate *legoCluster = new FWPFLegoCandidate( vc, FWProxyBuilderBase::context(), energy, et, pt, eta, phi );
      legoCluster->SetMarkerColor( FWProxyBuilderBase::item()->defaultDisplayProperties().color() );
      legoCluster->SetElementName( "BlockCluster" );
      setupAddElement( legoCluster, &oItemHolder );
   }
   if( viewType == FWViewType::kRhoPhiPF )
   {
      const FWDisplayProperties &dp = item()->defaultDisplayProperties();
      FWPFClusterRPZUtils *clusterUtils = new FWPFClusterRPZUtils();
      TEveScalableStraightLineSet *rpCluster = clusterUtils->buildRhoPhiClusterLineSet( cluster, vc, energy, et, r );
      rpCluster->SetLineColor( dp.color() );
      m_clusters.push_back( ScalableLines( rpCluster, et, energy, vc ) );
      setupAddElement( rpCluster, &oItemHolder );
      delete clusterUtils;
   }
   else if( viewType == FWViewType::kRhoZ )
   {
      const FWDisplayProperties &dp = item()->defaultDisplayProperties();
      FWPFClusterRPZUtils *clusterUtils = new FWPFClusterRPZUtils();
      TEveScalableStraightLineSet *rzCluster = clusterUtils->buildRhoZClusterLineSet( cluster, vc, context().caloTransAngle(),
                                                                                      energy, et, r, context().caloZ1() );
      rzCluster->SetLineColor( dp.color() );
      m_clusters.push_back( ScalableLines( rzCluster, et, energy, vc ) );
      setupAddElement( rzCluster, &oItemHolder );
      delete clusterUtils;
   }
}
void FWPFBlockProxyBuilder::setupTrackElement ( const reco::PFBlockElement blockElement,
TEveElement &  oItemHolder,
const FWViewContext vc,
FWViewType::EType  viewType 
) [protected]

Definition at line 44 of file FWPFBlockProxyBuilder.cc.

References a, b, trackerHits::c, reco::PFBlockElement::DEFAULT, FWPFTrackUtils::getCollisionMarkers(), i, FWViewType::kLego, FWViewType::kLegoPFECAL, FWViewType::kRhoPhiPF, FWViewType::kRhoZ, prof2calltree::last, FWProxyBuilderBase::setupAddElement(), FWPFTrackUtils::setupLegoTrack(), FWPFTrackUtils::setupTrack(), reco::PFBlockElement::trackRef(), reco::PFBlockElement::trackType(), detailsBasic3DVector::y, and z.

Referenced by buildViewType().

{
   if( blockElement.trackType( reco::PFBlockElement::DEFAULT ) )
   {
      reco::Track track = *blockElement.trackRef();
      FWPFTrackUtils *trackUtils = new FWPFTrackUtils();

      if( viewType == FWViewType::kLego || viewType == FWViewType::kLegoPFECAL )       // Lego views
      {
         TEveStraightLineSet *legoTrack = trackUtils->setupLegoTrack( track );
         setupAddElement( legoTrack, &oItemHolder );
      }
      else if( viewType == FWViewType::kRhoPhiPF )   // RhoPhi view
      {
         TEveTrack *trk = trackUtils->setupTrack( track );
         TEvePointSet *ps = trackUtils->getCollisionMarkers( trk );
         setupAddElement( trk, &oItemHolder );
         if( ps->GetN() != 0 )
            setupAddElement( ps, &oItemHolder );
         else
            delete ps;
      }
      else if ( viewType == FWViewType::kRhoZ )       // RhoZ view
      {
         TEveTrack *trk = trackUtils->setupTrack( track );
         TEvePointSet *markers = trackUtils->getCollisionMarkers( trk );
         TEvePointSet *ps = new TEvePointSet();
         setupAddElement( trk, &oItemHolder );

         Float_t *trackPoints = trk->GetP();
         unsigned int last = ( trk->GetN() - 1 ) * 3;
         float y = trackPoints[last+1];
         float z = trackPoints[last+2];

         // Reposition any points that have been translated in RhoZ
         for( signed int i = 0; i < markers->GetN(); ++i )
         {
            Float_t a,b,c;
            markers->GetPoint( i, a, b, c );
            
            if( y < 0 && b > 0 )
               b *= -1;
            else if( y > 0 && b < 0 )
               b *= -1;

            if( z < 0 && c > 0 )
               c *= -1;
            else if( z > 0 && c < 0 )
               c *= -1;

            ps->SetNextPoint( a, b, c );
         }

         if( ps->GetN() != 0 )
            setupAddElement( ps, &oItemHolder );
         else
            delete ps;
         delete markers;
      }
      
      delete trackUtils;
   }
}

Member Data Documentation

Definition at line 63 of file FWPFBlockProxyBuilder.h.

Referenced by cleanLocal(), scaleProduct(), and setupClusterElement().