CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/Fireworks/SimData/plugins/FWPSimHitProxyBuilder.cc

Go to the documentation of this file.
00001 /*
00002  *  FWPSimHitProxyBuilder.cc
00003  *  FWorks
00004  *
00005  *  Created by Ianna Osborne on 9/9/10.
00006  *
00007  */
00008 
00009 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
00010 #include "Fireworks/Core/interface/FWEventItem.h"
00011 #include "Fireworks/Core/interface/FWGeometry.h"
00012 #include "Fireworks/Core/interface/fwLog.h"
00013 #include "SimDataFormats/TrackingHit/interface/PSimHit.h"
00014 
00015 #include "TEvePointSet.h"
00016 
00017 class FWPSimHitProxyBuilder : public FWSimpleProxyBuilderTemplate<PSimHit>
00018 {
00019 public:
00020    FWPSimHitProxyBuilder( void ) {} 
00021    virtual ~FWPSimHitProxyBuilder( void ) {}
00022 
00023    REGISTER_PROXYBUILDER_METHODS();
00024 
00025 private:
00026    // Disable default copy constructor
00027    FWPSimHitProxyBuilder( const FWPSimHitProxyBuilder& );
00028    // Disable default assignment operator
00029    const FWPSimHitProxyBuilder& operator=( const FWPSimHitProxyBuilder& );
00030 
00031    void build( const PSimHit& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* );
00032 };
00033 
00034 void
00035 FWPSimHitProxyBuilder::build( const PSimHit& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* )
00036 {
00037    TEvePointSet* pointSet = new TEvePointSet;
00038    setupAddElement( pointSet, &oItemHolder );
00039    const FWGeometry *geom = item()->getGeom();
00040    unsigned int rawid = iData.detUnitId();
00041    if( ! geom->contains( rawid ))
00042    {
00043       fwLog( fwlog::kError )
00044         << "failed to get geometry of detid: " 
00045         << rawid << std::endl;
00046       return;
00047    }
00048    
00049    float local[3] = { iData.localPosition().x(), iData.localPosition().y(), iData.localPosition().z() };
00050    float global[3];
00051    geom->localToGlobal( rawid, local, global );
00052    pointSet->SetNextPoint( global[0], global[1], global[2] );
00053 }
00054 
00055 REGISTER_FWPROXYBUILDER( FWPSimHitProxyBuilder, PSimHit, "PSimHits", FWViewType::kAll3DBits | FWViewType::kAllRPZBits );