CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/Fireworks/Calo/plugins/FWHORecHitProxyBuilder.cc

Go to the documentation of this file.
00001 #include "Fireworks/Core/interface/FWDigitSetProxyBuilder.h"
00002 #include "Fireworks/Core/interface/FWEventItem.h"
00003 #include "Fireworks/Core/interface/FWGeometry.h"
00004 #include "Fireworks/Core/interface/BuilderUtils.h"
00005 #include "DataFormats/HcalRecHit/interface/HORecHit.h"
00006 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00007 #include "TEveCompound.h"
00008 
00009 class FWHORecHitProxyBuilder : public FWDigitSetProxyBuilder
00010 {
00011 public:
00012    FWHORecHitProxyBuilder( void ) 
00013      : m_maxEnergy( 1.0 )
00014     {}
00015   
00016    virtual ~FWHORecHitProxyBuilder( void ) 
00017     {}
00018 
00019    REGISTER_PROXYBUILDER_METHODS();
00020 
00021 private:
00022    virtual void build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext* );
00023 
00024    Float_t m_maxEnergy;
00025 
00026    FWHORecHitProxyBuilder( const FWHORecHitProxyBuilder& );
00027    const FWHORecHitProxyBuilder& operator=( const FWHORecHitProxyBuilder& );
00028 };
00029 
00030 void
00031 FWHORecHitProxyBuilder::build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext* )
00032 {
00033    const HORecHitCollection* collection = 0;
00034    iItem->get( collection );
00035 
00036    if( 0 == collection )
00037    {
00038       return;
00039    }
00040    std::vector<HORecHit>::const_iterator it = collection->begin();
00041    std::vector<HORecHit>::const_iterator itEnd = collection->end();
00042    for( ; it != itEnd; ++it )
00043    {
00044       if(( *it ).energy() > m_maxEnergy)
00045          m_maxEnergy = ( *it ).energy();
00046    }
00047 
00048    TEveBoxSet* boxSet = addBoxSetToProduct(product);
00049    int index = 0;
00050    for (std::vector<HORecHit>::const_iterator it = collection->begin() ; it != collection->end(); ++it)
00051    {  
00052       const float* corners = item()->getGeom()->getCorners((*it).detid());
00053       std::vector<float> scaledCorners(24);
00054       if (corners)
00055          fireworks::energyScaledBox3DCorners(corners, (*it).energy() / m_maxEnergy, scaledCorners, true);
00056 
00057       addBox(boxSet, &scaledCorners[0], iItem->modelInfo(index++).displayProperties());
00058    }
00059 }
00060 
00061 REGISTER_FWPROXYBUILDER( FWHORecHitProxyBuilder, HORecHitCollection, "HO RecHit", FWViewType::kISpyBit );