CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/Fireworks/Calo/plugins/FWCaloClusterProxyBuilder.cc

Go to the documentation of this file.
00001 #include "TEveBoxSet.h"
00002 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
00003 #include "Fireworks/Core/interface/FWEventItem.h"
00004 #include "Fireworks/Core/interface/FWGeometry.h"
00005 #include "Fireworks/Core/interface/BuilderUtils.h"
00006 #include "DataFormats/CaloRecHit/interface/CaloCluster.h"
00007 
00008 class FWCaloClusterProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::CaloCluster>
00009 {
00010 public:
00011    FWCaloClusterProxyBuilder( void ) {}  
00012    virtual ~FWCaloClusterProxyBuilder( void ) {}
00013 
00014    REGISTER_PROXYBUILDER_METHODS();
00015 
00016 private:
00017    FWCaloClusterProxyBuilder( const FWCaloClusterProxyBuilder& );                       // stop default
00018    const FWCaloClusterProxyBuilder& operator=( const FWCaloClusterProxyBuilder& );      // stop default
00019 
00020    void build( const reco::CaloCluster& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* );
00021 };
00022 
00023 void
00024 FWCaloClusterProxyBuilder::build( const reco::CaloCluster& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* ) 
00025 {
00026    std::vector<std::pair<DetId, float> > clusterDetIds = iData.hitsAndFractions();
00027    
00028    TEveBoxSet* boxset = new TEveBoxSet();
00029    boxset->Reset(TEveBoxSet::kBT_FreeBox, true, 64);
00030    boxset->UseSingleColor();
00031    boxset->SetPickable(1);
00032 
00033    for( std::vector<std::pair<DetId, float> >::iterator it = clusterDetIds.begin(), itEnd = clusterDetIds.end();
00034         it != itEnd; ++it )
00035    {
00036       const float* corners = item()->getGeom()->getCorners( (*it).first );
00037       if( corners == 0 ) {
00038          continue;
00039       }
00040       std::vector<float> pnts(24);    
00041       fireworks::energyTower3DCorners(corners, (*it).second, pnts);
00042       boxset->AddBox( &pnts[0]);
00043    }
00044 
00045    boxset->RefitPlex();
00046    setupAddElement(boxset, &oItemHolder);
00047 }
00048 
00049 REGISTER_FWPROXYBUILDER( FWCaloClusterProxyBuilder, reco::CaloCluster, "Calo Cluster", FWViewType::kISpyBit );