CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/Fireworks/Muons/plugins/FWRPCRecHitProxyBuilder.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Muons
00004 // Class  :     FWRPCRecHitProxyBuilder
00005 //
00006 //
00007 // Original Author:
00008 //         Created:  Sun Jan  6 23:42:33 EST 2008
00009 // $Id: FWRPCRecHitProxyBuilder.cc,v 1.16 2010/11/11 20:25:28 amraktad Exp $
00010 //
00011 
00012 #include "TEveGeoNode.h"
00013 #include "TEveStraightLineSet.h"
00014 
00015 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
00016 #include "Fireworks/Core/interface/FWEventItem.h"
00017 #include "Fireworks/Core/interface/FWGeometry.h"
00018 #include "Fireworks/Core/interface/fwLog.h"
00019 
00020 #include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h"
00021 
00022 class FWRPCRecHitProxyBuilder : public FWSimpleProxyBuilderTemplate<RPCRecHit>
00023 {
00024 public:
00025    FWRPCRecHitProxyBuilder() {}
00026    virtual ~FWRPCRecHitProxyBuilder() {}
00027   
00028    virtual bool haveSingleProduct() const 
00029     { 
00030       return false; 
00031     }
00032 
00033    REGISTER_PROXYBUILDER_METHODS();
00034 
00035 private:
00036   FWRPCRecHitProxyBuilder(const FWRPCRecHitProxyBuilder&);
00037   const FWRPCRecHitProxyBuilder& operator=(const FWRPCRecHitProxyBuilder&); 
00038  
00039   virtual void buildViewType(const RPCRecHit& iData, 
00040                              unsigned int iIndex, 
00041                              TEveElement& oItemHolder, 
00042                              FWViewType::EType type, 
00043                              const FWViewContext*);
00044 };
00045 
00046 
00047 void
00048 FWRPCRecHitProxyBuilder::buildViewType(const RPCRecHit& iData,
00049                                        unsigned int iIndex, 
00050                                        TEveElement& oItemHolder, 
00051                                        FWViewType::EType type,
00052                                        const FWViewContext*)
00053 {
00054   RPCDetId rpcId = iData.rpcId();
00055   unsigned int rawid = rpcId.rawId();
00056   
00057   const FWGeometry *geom = item()->getGeom();
00058 
00059   if( ! geom->contains( rawid ))
00060   {
00061     fwLog( fwlog::kError ) << "failed to get geometry of RPC roll with detid: " 
00062                            << rawid <<std::endl;
00063     return;
00064   }
00065 
00066   TEveStraightLineSet* recHitSet = new TEveStraightLineSet;
00067   recHitSet->SetLineWidth(3);
00068 
00069   if( type == FWViewType::k3D || type == FWViewType::kISpy ) 
00070   {
00071     TEveGeoShape* shape = geom->getEveShape( rawid );
00072     shape->SetMainTransparency( 75 );
00073     shape->SetMainColor( item()->defaultDisplayProperties().color());
00074     recHitSet->AddElement( shape );
00075   }
00076 
00077   float localX = iData.localPosition().x();
00078   float localY = iData.localPosition().y();
00079   float localZ = iData.localPosition().z();
00080   
00081   float localXerr = sqrt(iData.localPositionError().xx());
00082   float localYerr = sqrt(iData.localPositionError().yy());
00083 
00084   float localU1[3] = 
00085     {
00086       localX - localXerr, localY, localZ 
00087     };
00088   
00089   float localU2[3] = 
00090     {
00091       localX + localXerr, localY, localZ 
00092     };
00093   
00094   float localV1[3] = 
00095     {
00096       localX, localY - localYerr, localZ
00097     };
00098   
00099   float localV2[3] = 
00100     {
00101       localX, localY + localYerr, localZ
00102     };
00103 
00104   float globalU1[3];
00105   float globalU2[3];
00106   float globalV1[3];
00107   float globalV2[3];
00108 
00109   FWGeometry::IdToInfoItr det = geom->find( rawid );
00110  
00111   geom->localToGlobal( *det, localU1, globalU1 );
00112   geom->localToGlobal( *det, localU2, globalU2 );
00113   geom->localToGlobal( *det, localV1, globalV1 );
00114   geom->localToGlobal( *det, localV2, globalV2 );
00115  
00116   recHitSet->AddLine( globalU1[0], globalU1[1], globalU1[2],
00117                       globalU2[0], globalU2[1], globalU2[2] );
00118 
00119   recHitSet->AddLine( globalV1[0], globalV1[1], globalV1[2],
00120                       globalV2[0], globalV2[1], globalV2[2] );
00121 
00122   setupAddElement( recHitSet, &oItemHolder );
00123 }
00124 
00125 REGISTER_FWPROXYBUILDER( FWRPCRecHitProxyBuilder, RPCRecHit, "RPC RecHits", 
00126                          FWViewType::kAll3DBits | FWViewType::kAllRPZBits);