CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/Fireworks/SimData/plugins/FWPCaloHitProxyBuilder.cc

Go to the documentation of this file.
00001 /*
00002  *  FWPCaloHitProxyBuilder.cc
00003  *  FWorks
00004  *
00005  *  Created by Ianna Osborne on 9/9/10.
00006  *
00007  */
00008 
00009 #include "Fireworks/Core/interface/FWDigitSetProxyBuilder.h"
00010 #include "Fireworks/Core/interface/FWGeometry.h"
00011 #include "Fireworks/Core/interface/FWEventItem.h"
00012 #include "Fireworks/Core/interface/BuilderUtils.h"
00013 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00014 #include "SimDataFormats/CaloHit/interface/PCaloHit.h"
00015 #include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
00016 
00017 class FWPCaloHitProxyBuilder : public FWDigitSetProxyBuilder
00018 {
00019 public:
00020    FWPCaloHitProxyBuilder( void ) {} 
00021    virtual ~FWPCaloHitProxyBuilder( void ) {}
00022 
00023    REGISTER_PROXYBUILDER_METHODS();
00024 
00025 private:
00026    FWPCaloHitProxyBuilder( const FWPCaloHitProxyBuilder& );
00027    const FWPCaloHitProxyBuilder& operator=( const FWPCaloHitProxyBuilder& );
00028 
00029    virtual void build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext* );
00030 };
00031 
00032 void FWPCaloHitProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*)
00033 {
00034    const edm::PCaloHitContainer *collection = 0;
00035    iItem->get( collection );
00036    if (! collection)
00037       return;
00038 
00039 
00040    TEveBoxSet* boxSet = addBoxSetToProduct(product);
00041    int index = 0;
00042    for (std::vector<PCaloHit>::const_iterator it = collection->begin() ; it != collection->end(); ++it)
00043    {  
00044       const float* corners = item()->getGeom()->getCorners((*it).id());
00045 
00046       std::vector<float> scaledCorners(24);
00047       if (corners)
00048          fireworks::energyTower3DCorners(corners, (*it).energy() * 10, scaledCorners);
00049 
00050       addBox(boxSet, &scaledCorners[0], iItem->modelInfo(index++).displayProperties());
00051    }
00052 }
00053 
00054 // !AMT TEveBoxSet is not projectable. Can't be added to RPZ views empty.
00055 REGISTER_FWPROXYBUILDER( FWPCaloHitProxyBuilder, edm::PCaloHitContainer, "PCaloHits", FWViewType::kAll3DBits | FWViewType::kAllRPZBits );