Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-03 04:10:01

0001 #include "TEvePointSet.h"
0002 
0003 #include "Fireworks/Core/interface/FWEventItem.h"
0004 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
0005 #include "Fireworks/Core/interface/FWProxyBuilderConfiguration.h"
0006 #include "Fireworks/Candidates/interface/CandidateUtils.h"
0007 
0008 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
0009 #include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
0010 
0011 class FWGenParticleLegoProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::GenParticle> {
0012 public:
0013   FWGenParticleLegoProxyBuilder() {}
0014   ~FWGenParticleLegoProxyBuilder() override {}
0015 
0016   void setItem(const FWEventItem* iItem) override {
0017     FWProxyBuilderBase::setItem(iItem);
0018     if (iItem) {
0019       iItem->getConfig()->assertParam("MarkerStyle", 0l, -1l, 3l);
0020       iItem->getConfig()->assertParam("MarkerSize", 2., 0.1, 10.);
0021     }
0022   }
0023 
0024   // ---------- member functions ---------------------------
0025   REGISTER_PROXYBUILDER_METHODS();
0026 
0027   FWGenParticleLegoProxyBuilder(const FWGenParticleLegoProxyBuilder&) = delete;  // stop default
0028 
0029   const FWGenParticleLegoProxyBuilder& operator=(const FWGenParticleLegoProxyBuilder&) = delete;  // stop default
0030 
0031 private:
0032   using FWSimpleProxyBuilderTemplate<reco::GenParticle>::build;
0033   void build(const reco::GenParticle& iData,
0034              unsigned int iIndex,
0035              TEveElement& oItemHolder,
0036              const FWViewContext*) override;
0037 };
0038 
0039 //______________________________________________________________________________
0040 
0041 void FWGenParticleLegoProxyBuilder::build(const reco::GenParticle& iData,
0042                                           unsigned int iIndex,
0043                                           TEveElement& oItemHolder,
0044                                           const FWViewContext*) {
0045   long markerStyle = item()->getConfig()->value<long>("MarkerStyle");
0046   double markerSize = item()->getConfig()->value<double>("MarkerSize");
0047 
0048   // workaround around for TEvePointSet marker styles indices
0049   if (markerStyle == 0)
0050     markerStyle = 3;
0051   else if (markerStyle == 1)
0052     markerStyle = 4;
0053   else if (markerStyle == 2)
0054     markerStyle = 8;
0055   std::cerr << std::endl;
0056 
0057   // scale non-pixel size marker
0058   if (markerStyle == 3)
0059     markerSize /= 20;
0060 
0061   TEvePointSet* ps = new TEvePointSet();
0062   ps->SetMarkerStyle(markerStyle);
0063   ps->SetMarkerSize(markerSize);
0064   ps->SetNextPoint(iData.eta(), iData.phi(), 0.001);
0065   setupAddElement(ps, &oItemHolder);
0066 }
0067 
0068 REGISTER_FWPROXYBUILDER(FWGenParticleLegoProxyBuilder, reco::GenParticle, "GenParticles", FWViewType::kLegoBit);