CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/Fireworks/Tracks/plugins/FWSiStripDigiProxyBuilder.cc

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