CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/Fireworks/GenParticle/plugins/FWGenParticleProxyBuilder.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Core
00004 // Class  :     FWGenParticleProxyBuilder
00005 //
00014 //
00015 // Original Author:
00016 //         Created:  Thu Dec  6 18:01:21 PST 2007
00017 // $Id: FWGenParticleProxyBuilder.cc,v 1.7 2010/11/11 20:25:28 amraktad Exp $
00018 // 
00019 
00020 #include "TDatabasePDG.h"
00021 #include "TEveTrack.h"
00022 
00023 #include "Fireworks/Core/interface/FWEventItem.h"
00024 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
00025 #include "Fireworks/Candidates/interface/CandidateUtils.h"
00026 
00027 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
00028 #include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
00029 
00030 class FWGenParticleProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::GenParticle> {
00031 
00032 public:
00033    FWGenParticleProxyBuilder() {}
00034    virtual ~FWGenParticleProxyBuilder() {}
00035 
00036    // ---------- member functions ---------------------------
00037    REGISTER_PROXYBUILDER_METHODS();
00038 
00039 private:
00040    FWGenParticleProxyBuilder(const FWGenParticleProxyBuilder&); // stop default
00041 
00042    const FWGenParticleProxyBuilder& operator=(const FWGenParticleProxyBuilder&); // stop default
00043    
00044    void build(const reco::GenParticle& iData, unsigned int iIndex,TEveElement& oItemHolder, const FWViewContext*);
00045 
00046    // ---------- member data --------------------------------
00047    static TDatabasePDG* s_pdg;
00048 };
00049 
00050 //______________________________________________________________________________
00051 
00052 TDatabasePDG* FWGenParticleProxyBuilder::s_pdg = 0;
00053 
00054 void
00055 FWGenParticleProxyBuilder::build(const reco::GenParticle& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) 
00056 {
00057    if (!s_pdg)
00058       s_pdg = new TDatabasePDG();
00059  
00060  
00061    TEveTrack* trk = fireworks::prepareCandidate( iData, context().getTrackPropagator() );    
00062    trk->MakeTrack();
00063    /*
00064      trk->SetTitle(s);
00065      char s[1024];
00066      TParticlePDG* pID = s_pdg->GetParticle(iData.pdgId());
00067      if ( pID )
00068      sprintf(s,"gen %s, Pt: %0.1f GeV", pID->GetName(), iData.pt());
00069      else
00070      sprintf(s,"gen pdg %d, Pt: %0.1f GeV", iData.pdgId(), iData.pt());
00071    */
00072    setupAddElement(trk, &oItemHolder);
00073 }
00074 
00075 REGISTER_FWPROXYBUILDER(FWGenParticleProxyBuilder, reco::GenParticle, "GenParticles", FWViewType::kAll3DBits | FWViewType::kAllRPZBits);
00076