CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/Fireworks/Tracks/plugins/FWTracksModulesProxyBuilder.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // $Id: FWTracksModulesProxyBuilder.cc,v 1.1 2009/01/16 10:37:00 Tom Danielson
00003 //
00004 
00005 // user include files
00006 #include "TEveGeoShape.h"
00007 
00008 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
00009 #include "Fireworks/Core/interface/FWGeometry.h"
00010 #include "Fireworks/Core/interface/FWEventItem.h"
00011 #include "Fireworks/Tracks/interface/TrackUtils.h"
00012 
00013 #include "DataFormats/TrackReco/interface/Track.h"
00014 #include "DataFormats/MuonDetId/interface/MuonSubdetId.h"
00015 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
00016 
00017 #include "Fireworks/Core/interface/fwLog.h"
00018 
00019 class FWTracksModulesProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::Track>
00020 {
00021 public:
00022    FWTracksModulesProxyBuilder( void ) {}
00023    virtual ~FWTracksModulesProxyBuilder( void ) {}
00024 
00025    REGISTER_PROXYBUILDER_METHODS();
00026   
00027    static bool representsSubPart( void );
00028 private:
00029    void build( const reco::Track& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* );
00030 
00031    FWTracksModulesProxyBuilder( const FWTracksModulesProxyBuilder& );    // stop default
00032    const FWTracksModulesProxyBuilder& operator=( const FWTracksModulesProxyBuilder& );    // stop default
00033 };
00034 
00035 void
00036 FWTracksModulesProxyBuilder::build( const reco::Track& track, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* ) 
00037 {
00038    if( track.extra().isAvailable() )
00039    {
00040      const FWGeometry *geom = item()->getGeom();
00041 
00042       for( trackingRecHit_iterator recIt = track.recHitsBegin(), recItEnd = track.recHitsEnd();
00043            recIt != recItEnd; ++recIt )
00044       {
00045          DetId detid = ( *recIt )->geographicalId();
00046          if(( *recIt )->isValid())
00047          {
00048             if( detid.det() ==  DetId::Muon )
00049             {
00050                if( detid.subdetId() == MuonSubdetId::DT )
00051                   detid = DetId( DTChamberId( detid )); // get rid of layer bits
00052             }
00053 
00054             TEveGeoShape* shape = geom->getEveShape( detid );
00055             if( shape )
00056             {
00057                setupAddElement( shape, &oItemHolder );
00058             }
00059             else
00060             {
00061                fwLog( fwlog::kDebug )
00062                  << "Failed to get shape extract for track-id " << iIndex << ", tracking rec hit: "
00063                  << "\n" << fireworks::info( detid ) << std::endl;
00064             }
00065          }
00066       }
00067    }
00068 }
00069 
00070 bool
00071 FWTracksModulesProxyBuilder::representsSubPart( void )
00072 {
00073    return true;
00074 }
00075 
00076 REGISTER_FWPROXYBUILDER( FWTracksModulesProxyBuilder, reco::Track, "TrackDets", FWViewType::kAll3DBits | FWViewType::kAllRPZBits );