CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/Fireworks/Muons/plugins/FWDTRecHitProxyBuilder.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Muons
00004 // Class  :     FWDTRecHitProxyBuilder
00005 //
00006 // $Id: FWDTRecHitProxyBuilder.cc,v 1.13 2010/11/11 20:25:28 amraktad Exp $
00007 //
00008 
00009 #include "TEvePointSet.h"
00010 #include "TEveStraightLineSet.h"
00011 
00012 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
00013 #include "Fireworks/Core/interface/FWEventItem.h"
00014 #include "Fireworks/Core/interface/FWGeometry.h"
00015 #include "Fireworks/Core/interface/fwLog.h"
00016 
00017 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
00018 #include "DataFormats/DTRecHit/interface/DTRecHitCollection.h"
00019 
00020 using namespace DTEnums;
00021 
00022 class FWDTRecHitProxyBuilder : public FWSimpleProxyBuilderTemplate<DTRecHit1DPair>
00023 {
00024 public:
00025   FWDTRecHitProxyBuilder( void ) {}
00026   virtual ~FWDTRecHitProxyBuilder( void ) {}
00027         
00028   virtual bool haveSingleProduct() const { return false; }
00029    
00030   REGISTER_PROXYBUILDER_METHODS();
00031 
00032 private:
00033   // Disable default copy constructor
00034   FWDTRecHitProxyBuilder( const FWDTRecHitProxyBuilder& );
00035   // Disable default assignment operator
00036   const FWDTRecHitProxyBuilder& operator=( const FWDTRecHitProxyBuilder& );
00037 
00038   virtual void buildViewType( const DTRecHit1DPair& iData, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type , const FWViewContext* );
00039 };
00040 
00041 void
00042 FWDTRecHitProxyBuilder::buildViewType( const DTRecHit1DPair& iData, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType type, const FWViewContext* )
00043 {
00044   const DTLayerId& layerId = iData.wireId().layerId();
00045   int superLayer = layerId.superlayerId().superLayer();
00046 
00047   const FWGeometry *geom = item()->getGeom();
00048 
00049   if( ! geom->contains( layerId ))
00050   {
00051     fwLog( fwlog::kError ) << "failed get geometry of DT layer with detid: " 
00052                            << layerId << std::endl;
00053     return;
00054   }
00055 
00056   TEveStraightLineSet* recHitSet = new TEveStraightLineSet;
00057   setupAddElement( recHitSet, &oItemHolder );
00058 
00059   TEvePointSet* pointSet = new TEvePointSet;
00060   setupAddElement( pointSet, &oItemHolder );
00061          
00062   const DTRecHit1D* leftRecHit = iData.componentRecHit( Left );
00063   const DTRecHit1D* rightRecHit = iData.componentRecHit( Right );
00064   float lLocalPos[3] = { leftRecHit->localPosition().x(), 0.0, 0.0 };
00065   float rLocalPos[3] = { rightRecHit->localPosition().x(), 0.0, 0.0 };
00066 
00067   if(( (type == FWViewType::kRhoPhi || type == FWViewType::kRhoPhiPF) && superLayer != 2 ) ||
00068     ( type == FWViewType::kRhoZ && superLayer == 2 ) ||
00069      type == FWViewType::k3D ||
00070      type == FWViewType::kISpy )
00071   {
00072     float leftGlobalPoint[3];
00073     float rightGlobalPoint[3];
00074                 
00075     geom->localToGlobal( layerId, lLocalPos, leftGlobalPoint, rLocalPos, rightGlobalPoint );
00076                 
00077     pointSet->SetNextPoint( leftGlobalPoint[0],  leftGlobalPoint[1],  leftGlobalPoint[2] ); 
00078     pointSet->SetNextPoint( rightGlobalPoint[0], rightGlobalPoint[1], rightGlobalPoint[2] );
00079                 
00080     recHitSet->AddLine( leftGlobalPoint[0],  leftGlobalPoint[1],  leftGlobalPoint[2], 
00081                         rightGlobalPoint[0], rightGlobalPoint[1], rightGlobalPoint[2] );                
00082   }
00083 }
00084 
00085 REGISTER_FWPROXYBUILDER( FWDTRecHitProxyBuilder, DTRecHit1DPair, "DT RecHits",  FWViewType::kAll3DBits | FWViewType::kAllRPZBits );
00086 
00087