CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_8_patch3/src/Fireworks/Tracks/plugins/FWSiPixelClusterProxyBuilder.cc

Go to the documentation of this file.
00001 
00002 // -*- C++ -*-
00003 //
00004 // Package:     Tracks
00005 // Class  :     FWSiPixelClusterProxyBuilder
00006 //
00007 //
00008 // Original Author:
00009 //         Created:  Thu Dec  6 18:01:21 PST 2007
00010 // $Id: FWSiPixelClusterProxyBuilder.cc,v 1.17 2010/09/07 15:46:48 yana Exp $
00011 //
00012 
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/SiPixelCluster/interface/SiPixelCluster.h"
00022 
00023 class FWSiPixelClusterProxyBuilder : public FWProxyBuilderBase
00024 {
00025 public:
00026   FWSiPixelClusterProxyBuilder( void ) {}
00027   virtual ~FWSiPixelClusterProxyBuilder( void ) {}
00028 
00029   REGISTER_PROXYBUILDER_METHODS();
00030 
00031 private:
00032   // Disable default copy constructor
00033   FWSiPixelClusterProxyBuilder( const FWSiPixelClusterProxyBuilder& );
00034   // Disable default assignment operator
00035   const FWSiPixelClusterProxyBuilder& operator=( const FWSiPixelClusterProxyBuilder& );
00036 
00037   virtual void build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext* );
00038 };
00039 
00040 void
00041 FWSiPixelClusterProxyBuilder::build( const FWEventItem* iItem, TEveElementList* product , const FWViewContext* )
00042 {
00043   const SiPixelClusterCollectionNew* pixels = 0;
00044   
00045   iItem->get( pixels );
00046   
00047   if( ! pixels ) 
00048   {    
00049     fwLog( fwlog::kWarning ) << "failed get SiPixelDigis" << std::endl;
00050     return;
00051   }
00052 
00053   for( SiPixelClusterCollectionNew::const_iterator set = pixels->begin(), setEnd = pixels->end();
00054        set != setEnd; ++set ) 
00055   {    
00056     unsigned int id = set->detId();
00057 
00058     const FWGeometry *geom = iItem->getGeom();
00059     const float* pars = geom->getParameters( id );
00060 
00061     const edmNew::DetSet<SiPixelCluster> & clusters = *set;
00062       
00063     for( edmNew::DetSet<SiPixelCluster>::const_iterator itc = clusters.begin(), edc = clusters.end(); 
00064          itc != edc; ++itc ) 
00065     {
00066       TEvePointSet* pointSet = new TEvePointSet;
00067       setupAddElement( pointSet, product );
00068       
00069       if( ! geom->contains( id ))
00070       {
00071         fwLog( fwlog::kWarning ) 
00072           << "failed get geometry of SiPixelCluster with detid: "
00073           << id << std::endl;
00074         continue;
00075       }
00076 
00077       float localPoint[3] = 
00078         {     
00079           fireworks::pixelLocalX(( *itc ).minPixelRow(), ( int )pars[0] ),
00080           fireworks::pixelLocalY(( *itc ).minPixelCol(), ( int )pars[1] ),
00081           0.0
00082         };
00083 
00084       float globalPoint[3];
00085       geom->localToGlobal( id, localPoint, globalPoint );
00086 
00087       pointSet->SetNextPoint( globalPoint[0], globalPoint[1], globalPoint[2] );
00088     }
00089   }    
00090 }
00091 
00092 REGISTER_FWPROXYBUILDER( FWSiPixelClusterProxyBuilder, SiPixelClusterCollectionNew, "SiPixelCluster", FWViewType::kAll3DBits | FWViewType::kAllRPZBits );