CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/Fireworks/GenParticle/plugins/FWGenParticleLegoProxyBuilder.cc

Go to the documentation of this file.
00001 #include "TEvePointSet.h"
00002 
00003 #include "Fireworks/Core/interface/FWEventItem.h"
00004 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
00005 #include "Fireworks/Core/interface/FWProxyBuilderConfiguration.h"
00006 #include "Fireworks/Candidates/interface/CandidateUtils.h"
00007 
00008 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
00009 #include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
00010 
00011 class FWGenParticleLegoProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::GenParticle> {
00012 
00013 public:
00014    FWGenParticleLegoProxyBuilder() {}
00015    virtual ~FWGenParticleLegoProxyBuilder() {}
00016 
00017   virtual void setItem(const FWEventItem* iItem)
00018   {
00019     FWProxyBuilderBase::setItem(iItem);
00020     if (iItem)
00021       {
00022         iItem->getConfig()->assertParam("MarkerStyle",  0l, -1l,  3l);
00023         iItem->getConfig()->assertParam("MarkerSize",2., 0.1, 10.);
00024       }
00025   }
00026    
00027    // ---------- member functions ---------------------------
00028    REGISTER_PROXYBUILDER_METHODS();
00029 
00030 private:
00031    FWGenParticleLegoProxyBuilder(const FWGenParticleLegoProxyBuilder&); // stop default
00032 
00033    const FWGenParticleLegoProxyBuilder& operator=(const FWGenParticleLegoProxyBuilder&); // stop default
00034    
00035    void build(const reco::GenParticle& iData, unsigned int iIndex,TEveElement& oItemHolder, const FWViewContext*);
00036 };
00037 
00038 //______________________________________________________________________________
00039 
00040 
00041 void
00042 FWGenParticleLegoProxyBuilder::build(const reco::GenParticle& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) 
00043   {
00044      long markerStyle = item()->getConfig()->value<long>("MarkerStyle");
00045      double markerSize = item()->getConfig()->value<double>("MarkerSize");
00046 
00047     
00048     // workaround around for TEvePointSet marker styles indices
00049     if (markerStyle == 0 )
00050       markerStyle = 3;
00051     else if (markerStyle == 1)
00052       markerStyle = 4;
00053     else if (markerStyle == 2)
00054       markerStyle = 8;
00055     std::cerr << std::endl;
00056 
00057     // scale non-pixel size marker
00058     if (markerStyle == 3 )
00059       markerSize /= 20;
00060 
00061     TEvePointSet* ps = new TEvePointSet();
00062     ps->SetMarkerStyle(markerStyle);
00063     ps->SetMarkerSize(markerSize);
00064     ps->SetNextPoint(iData.eta(), iData.phi(), 0.001);
00065     setupAddElement( ps, &oItemHolder );
00066 
00067   }
00068 
00069 REGISTER_FWPROXYBUILDER(FWGenParticleLegoProxyBuilder, reco::GenParticle, "GenParticles", FWViewType::kLegoBit);
00070