CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/Fireworks/Tracks/plugins/FWTrackProxyBuilder.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Tracks
00004 // Class  :     FWTrackProxyBuilder
00005 //
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Chris Jones
00010 //         Created:  Tue Nov 25 14:42:13 EST 2008
00011 // $Id: FWTrackProxyBuilder.cc,v 1.13 2010/11/11 20:25:29 amraktad Exp $
00012 //
00013 
00014 // system include files
00015 #include "TEveTrack.h"
00016 
00017 // user include files
00018 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
00019 #include "Fireworks/Core/interface/FWEventItem.h"
00020 #include "Fireworks/Core/interface/FWMagField.h"
00021 #include "Fireworks/Tracks/interface/TrackUtils.h"
00022 #include "Fireworks/Tracks/interface/estimate_field.h"
00023 
00024 #include "DataFormats/TrackReco/interface/Track.h"
00025 
00026 class FWTrackProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::Track> {
00027 
00028 public:
00029    FWTrackProxyBuilder();
00030    virtual ~FWTrackProxyBuilder();
00031 
00032    REGISTER_PROXYBUILDER_METHODS();
00033 
00034 private:
00035    FWTrackProxyBuilder(const FWTrackProxyBuilder&); // stop default
00036 
00037    const FWTrackProxyBuilder& operator=(const FWTrackProxyBuilder&); // stop default
00038 
00039    void build(const reco::Track& iData, unsigned int iIndex,TEveElement& oItemHolder, const FWViewContext*);
00040 };
00041 
00042 FWTrackProxyBuilder::FWTrackProxyBuilder()
00043 {
00044 }
00045 
00046 FWTrackProxyBuilder::~FWTrackProxyBuilder()
00047 {
00048 }
00049 
00050 void
00051 FWTrackProxyBuilder::build( const reco::Track& iData, unsigned int iIndex,TEveElement& oItemHolder , const FWViewContext*) 
00052 {
00053    if( context().getField()->getSource() == FWMagField::kNone ) {
00054       if( fabs( iData.eta() ) < 2.0 && iData.pt() > 0.5 && iData.pt() < 30 ) {
00055          double estimate = fw::estimate_field( iData, true );
00056          if( estimate >= 0 ) context().getField()->guessField( estimate );
00057       }
00058    }
00059 
00060    TEveTrackPropagator* propagator = ( !iData.extra().isAvailable() ) ?  context().getTrackerTrackPropagator() : context().getTrackPropagator();
00061 
00062    TEveTrack* trk = fireworks::prepareTrack( iData, propagator );
00063    trk->MakeTrack();
00064    setupAddElement(trk, &oItemHolder);
00065 }
00066 
00067 //
00068 // static member functions
00069 //
00070 REGISTER_FWPROXYBUILDER(FWTrackProxyBuilder, reco::Track, "Tracks", FWViewType::kAll3DBits | FWViewType::kAllRPZBits);