Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-03 04:09:56

0001 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
0002 #include "DataFormats/HGCalReco/interface/Trackster.h"
0003 
0004 #include "TEveTrans.h"
0005 #include "TGeoSphere.h"
0006 #include "TEveGeoShape.h"
0007 
0008 class FWTracksterProxyBuilder : public FWSimpleProxyBuilderTemplate<ticl::Trackster> {
0009 public:
0010   FWTracksterProxyBuilder(void) {}
0011   ~FWTracksterProxyBuilder(void) override {}
0012 
0013   REGISTER_PROXYBUILDER_METHODS();
0014 
0015   FWTracksterProxyBuilder(const FWTracksterProxyBuilder &) = delete;                   // stop default
0016   const FWTracksterProxyBuilder &operator=(const FWTracksterProxyBuilder &) = delete;  // stop default
0017 
0018 private:
0019   void build(const ticl::Trackster &iData,
0020              unsigned int iIndex,
0021              TEveElement &oItemHolder,
0022              const FWViewContext *) override;
0023 };
0024 
0025 void FWTracksterProxyBuilder::build(const ticl::Trackster &iData,
0026                                     unsigned int iIndex,
0027                                     TEveElement &oItemHolder,
0028                                     const FWViewContext *) {
0029   const ticl::Trackster &trackster = iData;
0030   const ticl::Trackster::Vector &barycenter = trackster.barycenter();
0031   const std::array<float, 3> &eigenvalues = trackster.eigenvalues();
0032   const double theta = barycenter.Theta();
0033   const double phi = barycenter.Phi();
0034 
0035   auto eveEllipsoid = new TEveGeoShape("Ellipsoid");
0036   auto sphere = new TGeoSphere(0., 1.);
0037   eveEllipsoid->SetShape(sphere);
0038   eveEllipsoid->InitMainTrans();
0039   eveEllipsoid->RefMainTrans().Move3PF(barycenter.x(), barycenter.y(), barycenter.z());
0040   eveEllipsoid->RefMainTrans().SetRotByAnyAngles(theta, phi, 0., "xzy");
0041   eveEllipsoid->RefMainTrans().SetScale(sqrt(eigenvalues[2]), sqrt(eigenvalues[1]), sqrt(eigenvalues[0]));
0042   setupAddElement(eveEllipsoid, &oItemHolder);
0043 }
0044 
0045 REGISTER_FWPROXYBUILDER(FWTracksterProxyBuilder,
0046                         ticl::Trackster,
0047                         "Trackster",
0048                         FWViewType::k3DBit | FWViewType::kAllRPZBits);