CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/Fireworks/Tracks/plugins/FWSiPixelDigiProxyBuilder.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Tracks
00004 // Class  :     FWSiPixelDigiProxyBuilder
00005 //
00006 //
00007 // Original Author:
00008 //         Created:  Thu Dec  6 18:01:21 PST 2007
00009 // $Id: FWSiPixelDigiProxyBuilder.cc,v 1.17 2010/09/07 15:46:48 yana Exp $
00010 //
00011 
00012 #include "TEveCompound.h"
00013 #include "TEvePointSet.h"
00014 
00015 #include "Fireworks/Core/interface/FWProxyBuilderBase.h"
00016 #include "Fireworks/Core/interface/FWEventItem.h"
00017 #include "Fireworks/Core/interface/FWGeometry.h"
00018 #include "Fireworks/Core/interface/fwLog.h"
00019 #include "Fireworks/Tracks/interface/TrackUtils.h"
00020 
00021 #include "DataFormats/SiPixelDigi/interface/PixelDigi.h"
00022 #include "DataFormats/Common/interface/DetSetVector.h"
00023 
00024 class FWSiPixelDigiProxyBuilder : public FWProxyBuilderBase
00025 {
00026 public:
00027   FWSiPixelDigiProxyBuilder( void ) {}
00028   virtual ~FWSiPixelDigiProxyBuilder( void ) {}
00029 
00030   REGISTER_PROXYBUILDER_METHODS();
00031 
00032 private:
00033   // Disable default copy constructor
00034   FWSiPixelDigiProxyBuilder( const FWSiPixelDigiProxyBuilder& );    
00035   // Disable default assignment operator
00036   const FWSiPixelDigiProxyBuilder& operator=( const FWSiPixelDigiProxyBuilder& );
00037 
00038   virtual void build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext* );
00039 };
00040 
00041 void FWSiPixelDigiProxyBuilder::build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext* )
00042 {
00043   const edm::DetSetVector<PixelDigi>* digis = 0;
00044   iItem->get( digis );
00045 
00046   if( ! digis )
00047   {
00048     return;
00049   }
00050   const FWGeometry *geom = iItem->getGeom();
00051   
00052   for( edm::DetSetVector<PixelDigi>::const_iterator it = digis->begin(), end = digis->end();
00053         it != end; ++it )
00054   {
00055     edm::DetSet<PixelDigi> ds = *it;
00056     unsigned int id = ds.id;
00057 
00058     const float* pars = geom->getParameters( id );
00059          
00060     for( edm::DetSet<PixelDigi>::const_iterator idigi = ds.data.begin(), idigiEnd = ds.data.end();
00061          idigi != idigiEnd; ++idigi )
00062     {
00063       TEvePointSet* pointSet = new TEvePointSet;
00064       pointSet->SetMarkerSize( 2 );
00065       pointSet->SetMarkerStyle( 2 );
00066       setupAddElement( pointSet, product );
00067 
00068       if( ! geom->contains( id ))
00069       {
00070         fwLog( fwlog::kWarning ) 
00071           << "failed get geometry of SiPixelDigi with detid: "
00072           << id << std::endl;
00073       }
00074       else
00075       { 
00076         float localPoint[3] = {     
00077           fireworks::pixelLocalX(( *idigi ).row(), pars[0] ),
00078           fireworks::pixelLocalY(( *idigi ).column(), pars[1] ),
00079           0.0 };
00080         
00081         float globalPoint[3];
00082         geom->localToGlobal( id, localPoint, globalPoint );
00083       
00084         pointSet->SetNextPoint( globalPoint[0], globalPoint[1], globalPoint[2] );
00085       }
00086     } // end of iteration over digis in range   
00087   } // end of iteration over the DetSetVector
00088 }
00089 
00090 
00091 REGISTER_FWPROXYBUILDER( FWSiPixelDigiProxyBuilder, edm::DetSetVector<PixelDigi>, "SiPixelDigi", FWViewType::kAll3DBits | FWViewType::kAllRPZBits );