CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/Fireworks/Electrons/plugins/FWElectronLegoProxyBuilder.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Muons
00004 // Class  :     FWElectronLegoProxyBuilder
00005 //
00006 // $Id: FWElectronLegoProxyBuilder.cc,v 1.5 2010/12/01 11:41:36 amraktad Exp $
00007 //
00008 
00009 #include "TEveStraightLineSet.h"
00010 #include "TEveTrack.h"
00011 
00012 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
00013 #include "Fireworks/Core/interface/FWEventItem.h"
00014 
00015 #include "Fireworks/Candidates/interface/CandidateUtils.h"
00016 #include "Fireworks/Tracks/interface/TrackUtils.h"
00017 
00018 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
00019 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
00020 
00021 class FWElectronLegoProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::GsfElectron>  
00022 {
00023 public:
00024   FWElectronLegoProxyBuilder() {}
00025   virtual ~FWElectronLegoProxyBuilder() {}
00026 
00027    REGISTER_PROXYBUILDER_METHODS();
00028 
00029 private:
00030    FWElectronLegoProxyBuilder(const FWElectronLegoProxyBuilder&);
00031    const FWElectronLegoProxyBuilder& operator=(const FWElectronLegoProxyBuilder&);
00032 
00033    virtual void build(const reco::GsfElectron& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*);
00034 };
00035 
00036 void FWElectronLegoProxyBuilder::build(const reco::GsfElectron& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) 
00037 {
00038    TEveStraightLineSet *marker = new TEveStraightLineSet("marker");
00039    setupAddElement(marker, &oItemHolder);
00040  
00041    TEveTrack* track(0);
00042    
00043    if( iData.gsfTrack().isAvailable() )
00044      track = fireworks::prepareTrack(*iData.gsfTrack(), context().getTrackPropagator());     
00045    else
00046      track = fireworks::prepareCandidate(iData, context().getTrackPropagator());
00047          
00048    track->MakeTrack();
00049    const double delta = 0.1;
00050    marker->AddLine(track->GetEndMomentum().Eta()-delta, track->GetEndMomentum().Phi()-delta, 0.1,
00051                    track->GetEndMomentum().Eta()+delta, track->GetEndMomentum().Phi()+delta, 0.1);
00052    marker->AddLine(track->GetEndMomentum().Eta()-delta, track->GetEndMomentum().Phi()+delta, 0.1,
00053                    track->GetEndMomentum().Eta()+delta, track->GetEndMomentum().Phi()-delta, 0.1);
00054    marker->AddLine(track->GetEndMomentum().Eta(), track->GetEndMomentum().Phi()-delta, 0.1,
00055                    track->GetEndMomentum().Eta(), track->GetEndMomentum().Phi()+delta, 0.1);
00056    marker->AddLine(track->GetEndMomentum().Eta()-delta, track->GetEndMomentum().Phi(), 0.1,
00057                    track->GetEndMomentum().Eta()+delta, track->GetEndMomentum().Phi(), 0.1);
00058 }
00059 
00060 REGISTER_FWPROXYBUILDER(FWElectronLegoProxyBuilder, reco::GsfElectron, "Electrons", FWViewType::kAllLegoBits);