CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/Fireworks/Calo/plugins/FWHFRecHitProxyBuilder.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 "Fireworks/Core/interface/fwLog.h"
00006 #include "DataFormats/HcalRecHit/interface/HFRecHit.h"
00007 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00008 #include "TEveCompound.h"
00009 
00010 class FWHFRecHitProxyBuilder : public FWDigitSetProxyBuilder
00011 {
00012 public:
00013    FWHFRecHitProxyBuilder( void ) 
00014      : m_maxEnergy( 5.0 )
00015     {}
00016   
00017    virtual ~FWHFRecHitProxyBuilder( void ) 
00018     {}
00019 
00020    REGISTER_PROXYBUILDER_METHODS();
00021 
00022 private:
00023    virtual void build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext* );
00024 
00025    Float_t m_maxEnergy;
00026 
00027    FWHFRecHitProxyBuilder( const FWHFRecHitProxyBuilder& );
00028    const FWHFRecHitProxyBuilder& operator=( const FWHFRecHitProxyBuilder& );
00029 };
00030 
00031 void
00032 FWHFRecHitProxyBuilder::build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext* )
00033 {
00034    const HFRecHitCollection* collection = 0;
00035    iItem->get( collection );
00036 
00037    if( 0 == collection )
00038    {
00039       return;
00040    }
00041 
00042    std::vector<HFRecHit>::const_iterator it = collection->begin();
00043    std::vector<HFRecHit>::const_iterator itEnd = collection->end();
00044    for( ; it != itEnd; ++it )
00045    {
00046       if(( *it ).energy() > m_maxEnergy )
00047          m_maxEnergy = ( *it ).energy();
00048    }
00049 
00050    TEveBoxSet* boxSet = addBoxSetToProduct(product);
00051    int index = 0;
00052    for (std::vector<HFRecHit>::const_iterator it = collection->begin() ; it != collection->end(); ++it)
00053    {  
00054       unsigned int rawid = ( *it ).detid().rawId();
00055       if( ! context().getGeom()->contains( rawid ))
00056       {
00057          fwLog( fwlog::kInfo ) << "FWHFRecHitProxyBuilder cannot get geometry for DetId: "
00058                                << rawid << ". Ignored.\n";
00059       }
00060       const float* corners = context().getGeom()->getCorners( rawid );
00061 
00062       std::vector<float> scaledCorners(24);
00063       if (corners)
00064          fireworks::energyScaledBox3DCorners(corners, (*it).energy() / m_maxEnergy, scaledCorners, true);
00065 
00066       addBox(boxSet, &scaledCorners[0], iItem->modelInfo(index++).displayProperties());
00067    }
00068 }
00069 
00070 REGISTER_FWPROXYBUILDER( FWHFRecHitProxyBuilder, HFRecHitCollection, "HF RecHit", FWViewType::kISpyBit );